From 21e63bbf54679ec236d1f09ed435959ff6a04db2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 17:29:30 +0300 Subject: remove use internal guichan flag. From now manaplus can use only own forked guichan version. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 7 ------- src/being/being.cpp | 2 -- src/gui/widgets/container.h | 4 ---- src/gui/widgets/window.cpp | 5 ----- src/localconsts.h | 7 ------- 6 files changed, 1 insertion(+), 26 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29e5afcb0..fafeeaf5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,7 +47,7 @@ ELSEIF (CMAKE_SYSTEM_NAME STREQUAL Linux) SET(EXTRA_LIBRARIES rt) ENDIF() -SET(FLAGS "${FLAGS} -DUSE_MUMBLE -DUSE_INTERNALGUICHAN") +SET(FLAGS "${FLAGS} -DUSE_MUMBLE") IF (WITH_OPENGL) FIND_PACKAGE(OpenGL REQUIRED) diff --git a/src/Makefile.am b/src/Makefile.am index 7fb4541a1..0c50b6da5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,7 +25,6 @@ else manaplus_SOURCES = endif -if USE_INTERNALGUICHAN dyecmd_CXXFLAGS = -I$(srcdir)/guichan/include -DUSE_INTERNALGUICHAN dyecmd_SOURCES = guichan/actionevent.cpp \ guichan/cliprectangle.cpp \ @@ -45,10 +44,6 @@ dyecmd_SOURCES = guichan/actionevent.cpp \ guichan/include/guichan/graphics.hpp \ guichan/include/guichan/rectangle.hpp \ guichan/include/guichan/widget.hpp -else -dyecmd_CXXFLAGS = -dyecmd_SOURCES = -endif dyecmd_SOURCES += dyetool/dyemain.cpp \ animatedsprite.cpp \ @@ -163,7 +158,6 @@ manaplus_CXXFLAGS += -DUSE_SDL2 endif endif -if USE_INTERNALGUICHAN manaplus_CXXFLAGS += -I$(srcdir)/guichan/include -DUSE_INTERNALGUICHAN manaplus_SOURCES += guichan/include/guichan/actionevent.hpp \ guichan/include/guichan/actionlistener.hpp \ @@ -238,7 +232,6 @@ manaplus_SOURCES += guichan/actionevent.cpp \ guichan/widgets/textbox.cpp \ guichan/widgets/textfield.cpp \ guichan/widgets/window.cpp -endif manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/avatarlistbox.h \ diff --git a/src/being/being.cpp b/src/being/being.cpp index fef3ca53a..dfb335f9b 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1847,9 +1847,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY) mSpeechBubble->setPosition(px - (mSpeechBubble->getWidth() / 2), py - getHeight() - (mSpeechBubble->getHeight())); mSpeechBubble->setVisible(true); -#ifdef USE_INTERNALGUICHAN mSpeechBubble->requestMoveToBackground(); -#endif } else if (mSpeechTime > 0 && speech == TEXT_OVERHEAD) { diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 2983a7433..8f3933357 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -27,10 +27,6 @@ #include -#if !defined USE_INTERNALGUICHAN -typedef std::list::const_iterator WidgetListConstIterator; -#endif - /** * A widget container. * diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 36372dcaa..c716445f3 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -92,11 +92,6 @@ Window::Window(const std::string &caption, const bool modal, { logger->log("Window::Window(\"%s\")", caption.c_str()); -#ifndef USE_INTERNALGUICHAN - mDragOffsetX = 0; - mDragOffsetY = 0; -#endif - if (!windowContainer) throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); diff --git a/src/localconsts.h b/src/localconsts.h index 58b469f01..92c36d92a 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -33,13 +33,6 @@ #endif #endif -#ifndef DEBUGBUILD -#ifndef USE_INTERNALGUICHAN -#warning using depricated way for linking with guichan. \ - Please removed configure flag --without-internalguichan -#endif -#endif - #if !defined(__GXX_EXPERIMENTAL_CXX0X__) #undef nullptr #define nullptr 0 -- cgit v1.2.3-70-g09d2 From cde42202d69e178da73c698065deca54b24054fd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 18:07:17 +0300 Subject: move exguichan files into gui/base/ --- src/CMakeLists.txt | 152 ++- src/Makefile.am | 184 ++- src/being/being.h | 2 +- src/being/localplayer.h | 2 +- src/client.h | 2 +- src/gui/base/actionevent.cpp | 88 ++ src/gui/base/actionevent.hpp | 133 +++ src/gui/base/actionlistener.hpp | 112 ++ src/gui/base/basiccontainer.cpp | 394 +++++++ src/gui/base/basiccontainer.hpp | 216 ++++ src/gui/base/cliprectangle.cpp | 107 ++ src/gui/base/cliprectangle.hpp | 129 ++ src/gui/base/color.cpp | 165 +++ src/gui/base/color.hpp | 192 +++ src/gui/base/deathlistener.hpp | 109 ++ src/gui/base/event.cpp | 87 ++ src/gui/base/event.hpp | 113 ++ src/gui/base/exception.cpp | 120 ++ src/gui/base/exception.hpp | 196 ++++ src/gui/base/focushandler.cpp | 571 +++++++++ src/gui/base/focushandler.hpp | 417 +++++++ src/gui/base/focuslistener.hpp | 119 ++ src/gui/base/font.cpp | 87 ++ src/gui/base/font.hpp | 133 +++ src/gui/base/graphics.cpp | 179 +++ src/gui/base/graphics.hpp | 294 +++++ src/gui/base/gui.cpp | 765 ++++++++++++ src/gui/base/gui.hpp | 514 ++++++++ src/gui/base/image.cpp | 83 ++ src/gui/base/image.hpp | 162 +++ src/gui/base/input.hpp | 134 +++ src/gui/base/inputevent.cpp | 117 ++ src/gui/base/inputevent.hpp | 177 +++ src/gui/base/key.cpp | 113 ++ src/gui/base/key.hpp | 201 ++++ src/gui/base/keyevent.cpp | 111 ++ src/gui/base/keyevent.hpp | 157 +++ src/gui/base/keyinput.cpp | 154 +++ src/gui/base/keyinput.hpp | 289 +++++ src/gui/base/keylistener.hpp | 119 ++ src/gui/base/listmodel.hpp | 106 ++ src/gui/base/mouseevent.cpp | 121 ++ src/gui/base/mouseevent.hpp | 217 ++++ src/gui/base/mouseinput.cpp | 136 +++ src/gui/base/mouseinput.hpp | 260 +++++ src/gui/base/mouselistener.hpp | 196 ++++ src/gui/base/rectangle.cpp | 156 +++ src/gui/base/rectangle.hpp | 159 +++ src/gui/base/sdl/sdlpixel.hpp | 306 +++++ src/gui/base/selectionevent.cpp | 82 ++ src/gui/base/selectionevent.hpp | 98 ++ src/gui/base/selectionlistener.hpp | 117 ++ src/gui/base/widget.cpp | 695 +++++++++++ src/gui/base/widget.hpp | 1232 ++++++++++++++++++++ src/gui/base/widgetlistener.hpp | 143 +++ src/gui/base/widgets/button.cpp | 194 +++ src/gui/base/widgets/button.hpp | 220 ++++ src/gui/base/widgets/checkbox.cpp | 154 +++ src/gui/base/widgets/checkbox.hpp | 180 +++ src/gui/base/widgets/container.cpp | 136 +++ src/gui/base/widgets/container.hpp | 180 +++ src/gui/base/widgets/label.cpp | 121 ++ src/gui/base/widgets/label.hpp | 154 +++ src/gui/base/widgets/listbox.cpp | 241 ++++ src/gui/base/widgets/listbox.hpp | 275 +++++ src/gui/base/widgets/radiobutton.cpp | 207 ++++ src/gui/base/widgets/radiobutton.hpp | 226 ++++ src/gui/base/widgets/scrollarea.cpp | 600 ++++++++++ src/gui/base/widgets/scrollarea.hpp | 549 +++++++++ src/gui/base/widgets/slider.cpp | 231 ++++ src/gui/base/widgets/slider.hpp | 293 +++++ src/gui/base/widgets/textbox.cpp | 345 ++++++ src/gui/base/widgets/textbox.hpp | 310 +++++ src/gui/base/widgets/textfield.cpp | 165 +++ src/gui/base/widgets/textfield.hpp | 190 +++ src/gui/base/widgets/window.cpp | 233 ++++ src/gui/base/widgets/window.hpp | 269 +++++ src/gui/focushandler.h | 2 +- src/gui/gui.cpp | 2 +- src/gui/gui.h | 6 +- src/gui/palette.h | 2 +- src/gui/popups/beingpopup.cpp | 2 +- src/gui/popups/itempopup.cpp | 2 +- src/gui/popups/popupmenu.cpp | 2 +- src/gui/popups/popupmenu.h | 4 +- src/gui/popups/speechbubble.cpp | 2 +- src/gui/popups/statuspopup.cpp | 2 +- src/gui/popups/textpopup.cpp | 2 +- src/gui/sdlfont.cpp | 2 +- src/gui/sdlfont.h | 4 +- src/gui/sdlinput.cpp | 2 +- src/gui/sdlinput.h | 6 +- src/gui/userpalette.h | 2 +- src/gui/viewport.cpp | 2 +- src/gui/viewport.h | 2 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/browserbox.cpp | 6 +- src/gui/widgets/browserbox.h | 4 +- src/gui/widgets/button.cpp | 2 +- src/gui/widgets/button.h | 4 +- src/gui/widgets/characterdisplay.h | 2 +- src/gui/widgets/characterviewbase.h | 2 +- src/gui/widgets/checkbox.cpp | 2 +- src/gui/widgets/checkbox.h | 2 +- src/gui/widgets/colormodel.h | 4 +- src/gui/widgets/colorpage.cpp | 2 +- src/gui/widgets/container.h | 2 +- src/gui/widgets/desktop.h | 2 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 14 +- src/gui/widgets/dropshortcutcontainer.cpp | 2 +- src/gui/widgets/emotepage.h | 6 +- src/gui/widgets/emoteshortcutcontainer.cpp | 2 +- src/gui/widgets/extendedlistbox.cpp | 6 +- src/gui/widgets/extendedlistmodel.h | 2 +- src/gui/widgets/flowcontainer.h | 2 +- src/gui/widgets/guitable.cpp | 6 +- src/gui/widgets/guitable.h | 6 +- src/gui/widgets/horizontcontainer.h | 2 +- src/gui/widgets/icon.h | 2 +- src/gui/widgets/itemcontainer.cpp | 4 +- src/gui/widgets/itemcontainer.h | 8 +- src/gui/widgets/itemlinkhandler.cpp | 4 +- src/gui/widgets/itemshortcutcontainer.cpp | 2 +- src/gui/widgets/label.cpp | 2 +- src/gui/widgets/label.h | 2 +- src/gui/widgets/layout.h | 2 +- src/gui/widgets/layouthelper.h | 2 +- src/gui/widgets/linkhandler.h | 2 +- src/gui/widgets/listbox.cpp | 8 +- src/gui/widgets/listbox.h | 2 +- src/gui/widgets/mouseevent.h | 4 +- src/gui/widgets/namesmodel.h | 2 +- src/gui/widgets/playerbox.h | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 4 +- src/gui/widgets/popuplist.h | 4 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/progressindicator.h | 2 +- src/gui/widgets/radiobutton.cpp | 2 +- src/gui/widgets/radiobutton.h | 2 +- src/gui/widgets/radiogroup.h | 2 +- src/gui/widgets/scrollarea.h | 4 +- src/gui/widgets/setupitem.cpp | 2 +- src/gui/widgets/setupitem.h | 2 +- src/gui/widgets/shopitems.h | 2 +- src/gui/widgets/shoplistbox.cpp | 4 +- src/gui/widgets/shortcutcontainer.h | 6 +- src/gui/widgets/skillinfo.h | 2 +- src/gui/widgets/skillmodel.h | 2 +- src/gui/widgets/slider.h | 2 +- src/gui/widgets/sliderlist.cpp | 2 +- src/gui/widgets/sliderlist.h | 6 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 10 +- src/gui/widgets/tablemodel.cpp | 2 +- src/gui/widgets/tabs/setup_colors.h | 2 +- src/gui/widgets/tabs/setup_input.cpp | 2 +- src/gui/widgets/tabs/setup_video.cpp | 2 +- src/gui/widgets/tabs/setup_video.h | 2 +- src/gui/widgets/tabs/setuptab.h | 4 +- src/gui/widgets/tabs/tab.h | 6 +- src/gui/widgets/tabstrip.h | 2 +- src/gui/widgets/textbox.cpp | 2 +- src/gui/widgets/textbox.h | 2 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textfield.h | 4 +- src/gui/widgets/textpreview.h | 2 +- src/gui/widgets/vertcontainer.h | 2 +- src/gui/widgets/widgetgroup.h | 4 +- src/gui/widgets/window.cpp | 6 +- src/gui/widgets/window.h | 4 +- src/gui/windowmenu.h | 4 +- src/gui/windows/botcheckerwindow.h | 2 +- src/gui/windows/buydialog.h | 4 +- src/gui/windows/buyselldialog.h | 2 +- src/gui/windows/changeemaildialog.h | 2 +- src/gui/windows/changepassworddialog.h | 2 +- src/gui/windows/charcreatedialog.h | 4 +- src/gui/windows/charselectdialog.h | 4 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/chatwindow.h | 4 +- src/gui/windows/confirmdialog.cpp | 2 +- src/gui/windows/confirmdialog.h | 2 +- src/gui/windows/connectiondialog.h | 2 +- src/gui/windows/didyouknowwindow.h | 2 +- src/gui/windows/editdialog.h | 2 +- src/gui/windows/editserverdialog.h | 6 +- src/gui/windows/equipmentwindow.cpp | 2 +- src/gui/windows/equipmentwindow.h | 2 +- src/gui/windows/helpwindow.h | 2 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 6 +- src/gui/windows/itemamountwindow.h | 4 +- src/gui/windows/killstats.h | 2 +- src/gui/windows/logindialog.h | 4 +- src/gui/windows/npcdialog.cpp | 2 +- src/gui/windows/npcdialog.h | 2 +- src/gui/windows/npcpostdialog.h | 2 +- src/gui/windows/okdialog.cpp | 2 +- src/gui/windows/okdialog.h | 2 +- src/gui/windows/outfitwindow.h | 2 +- src/gui/windows/questswindow.h | 2 +- src/gui/windows/quitdialog.h | 4 +- src/gui/windows/registerdialog.h | 4 +- src/gui/windows/selldialog.h | 4 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 8 +- src/gui/windows/setupwindow.h | 2 +- src/gui/windows/shopwindow.h | 4 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/skilldialog.h | 2 +- src/gui/windows/socialwindow.h | 2 +- src/gui/windows/statuswindow.h | 2 +- src/gui/windows/textcommandeditor.h | 2 +- src/gui/windows/textdialog.cpp | 2 +- src/gui/windows/textdialog.h | 2 +- src/gui/windows/tradewindow.cpp | 2 +- src/gui/windows/tradewindow.h | 4 +- src/gui/windows/unregisterdialog.h | 2 +- src/gui/windows/updaterwindow.h | 4 +- src/gui/windows/whoisonline.h | 2 +- src/gui/windows/worldselectdialog.h | 4 +- src/guichan/actionevent.cpp | 88 -- src/guichan/basiccontainer.cpp | 394 ------- src/guichan/cliprectangle.cpp | 107 -- src/guichan/color.cpp | 165 --- src/guichan/event.cpp | 87 -- src/guichan/exception.cpp | 120 -- src/guichan/focushandler.cpp | 571 --------- src/guichan/font.cpp | 87 -- src/guichan/graphics.cpp | 179 --- src/guichan/gui.cpp | 765 ------------ src/guichan/image.cpp | 83 -- src/guichan/include/guichan/actionevent.hpp | 133 --- src/guichan/include/guichan/actionlistener.hpp | 112 -- src/guichan/include/guichan/basiccontainer.hpp | 216 ---- src/guichan/include/guichan/cliprectangle.hpp | 129 -- src/guichan/include/guichan/color.hpp | 192 --- src/guichan/include/guichan/deathlistener.hpp | 109 -- src/guichan/include/guichan/event.hpp | 113 -- src/guichan/include/guichan/exception.hpp | 196 ---- src/guichan/include/guichan/focushandler.hpp | 417 ------- src/guichan/include/guichan/focuslistener.hpp | 119 -- src/guichan/include/guichan/font.hpp | 133 --- src/guichan/include/guichan/graphics.hpp | 294 ----- src/guichan/include/guichan/gui.hpp | 514 -------- src/guichan/include/guichan/image.hpp | 162 --- src/guichan/include/guichan/input.hpp | 134 --- src/guichan/include/guichan/inputevent.hpp | 177 --- src/guichan/include/guichan/key.hpp | 201 ---- src/guichan/include/guichan/keyevent.hpp | 157 --- src/guichan/include/guichan/keyinput.hpp | 289 ----- src/guichan/include/guichan/keylistener.hpp | 119 -- src/guichan/include/guichan/listmodel.hpp | 106 -- src/guichan/include/guichan/mouseevent.hpp | 217 ---- src/guichan/include/guichan/mouseinput.hpp | 260 ----- src/guichan/include/guichan/mouselistener.hpp | 196 ---- src/guichan/include/guichan/rectangle.hpp | 159 --- src/guichan/include/guichan/sdl/sdlpixel.hpp | 306 ----- src/guichan/include/guichan/selectionevent.hpp | 98 -- src/guichan/include/guichan/selectionlistener.hpp | 117 -- src/guichan/include/guichan/widget.hpp | 1232 -------------------- src/guichan/include/guichan/widgetlistener.hpp | 143 --- src/guichan/include/guichan/widgets/button.hpp | 220 ---- src/guichan/include/guichan/widgets/checkbox.hpp | 180 --- src/guichan/include/guichan/widgets/container.hpp | 180 --- src/guichan/include/guichan/widgets/label.hpp | 154 --- src/guichan/include/guichan/widgets/listbox.hpp | 275 ----- .../include/guichan/widgets/radiobutton.hpp | 226 ---- src/guichan/include/guichan/widgets/scrollarea.hpp | 549 --------- src/guichan/include/guichan/widgets/slider.hpp | 293 ----- src/guichan/include/guichan/widgets/textbox.hpp | 310 ----- src/guichan/include/guichan/widgets/textfield.hpp | 190 --- src/guichan/include/guichan/widgets/window.hpp | 269 ----- src/guichan/inputevent.cpp | 117 -- src/guichan/key.cpp | 113 -- src/guichan/keyevent.cpp | 111 -- src/guichan/keyinput.cpp | 154 --- src/guichan/mouseevent.cpp | 121 -- src/guichan/mouseinput.cpp | 136 --- src/guichan/rectangle.cpp | 156 --- src/guichan/selectionevent.cpp | 82 -- src/guichan/widget.cpp | 695 ----------- src/guichan/widgets/button.cpp | 194 --- src/guichan/widgets/checkbox.cpp | 154 --- src/guichan/widgets/container.cpp | 136 --- src/guichan/widgets/label.cpp | 121 -- src/guichan/widgets/listbox.cpp | 241 ---- src/guichan/widgets/radiobutton.cpp | 207 ---- src/guichan/widgets/scrollarea.cpp | 600 ---------- src/guichan/widgets/slider.cpp | 231 ---- src/guichan/widgets/textbox.cpp | 345 ------ src/guichan/widgets/textfield.cpp | 165 --- src/guichan/widgets/window.cpp | 233 ---- src/input/inputmanager.cpp | 4 +- src/input/keyevent.h | 4 +- src/input/keyinput.h | 2 +- src/mouseinput.h | 2 +- src/particle/textparticle.cpp | 4 +- src/render/graphics.h | 4 +- src/render/sdl2graphics.cpp | 2 +- src/render/sdl2softwaregraphics.cpp | 2 +- src/render/sdlgraphics.cpp | 2 +- src/text.cpp | 2 +- src/text.h | 2 +- src/touchmanager.h | 2 +- 309 files changed, 16962 insertions(+), 16968 deletions(-) create mode 100644 src/gui/base/actionevent.cpp create mode 100644 src/gui/base/actionevent.hpp create mode 100644 src/gui/base/actionlistener.hpp create mode 100644 src/gui/base/basiccontainer.cpp create mode 100644 src/gui/base/basiccontainer.hpp create mode 100644 src/gui/base/cliprectangle.cpp create mode 100644 src/gui/base/cliprectangle.hpp create mode 100644 src/gui/base/color.cpp create mode 100644 src/gui/base/color.hpp create mode 100644 src/gui/base/deathlistener.hpp create mode 100644 src/gui/base/event.cpp create mode 100644 src/gui/base/event.hpp create mode 100644 src/gui/base/exception.cpp create mode 100644 src/gui/base/exception.hpp create mode 100644 src/gui/base/focushandler.cpp create mode 100644 src/gui/base/focushandler.hpp create mode 100644 src/gui/base/focuslistener.hpp create mode 100644 src/gui/base/font.cpp create mode 100644 src/gui/base/font.hpp create mode 100644 src/gui/base/graphics.cpp create mode 100644 src/gui/base/graphics.hpp create mode 100644 src/gui/base/gui.cpp create mode 100644 src/gui/base/gui.hpp create mode 100644 src/gui/base/image.cpp create mode 100644 src/gui/base/image.hpp create mode 100644 src/gui/base/input.hpp create mode 100644 src/gui/base/inputevent.cpp create mode 100644 src/gui/base/inputevent.hpp create mode 100644 src/gui/base/key.cpp create mode 100644 src/gui/base/key.hpp create mode 100644 src/gui/base/keyevent.cpp create mode 100644 src/gui/base/keyevent.hpp create mode 100644 src/gui/base/keyinput.cpp create mode 100644 src/gui/base/keyinput.hpp create mode 100644 src/gui/base/keylistener.hpp create mode 100644 src/gui/base/listmodel.hpp create mode 100644 src/gui/base/mouseevent.cpp create mode 100644 src/gui/base/mouseevent.hpp create mode 100644 src/gui/base/mouseinput.cpp create mode 100644 src/gui/base/mouseinput.hpp create mode 100644 src/gui/base/mouselistener.hpp create mode 100644 src/gui/base/rectangle.cpp create mode 100644 src/gui/base/rectangle.hpp create mode 100644 src/gui/base/sdl/sdlpixel.hpp create mode 100644 src/gui/base/selectionevent.cpp create mode 100644 src/gui/base/selectionevent.hpp create mode 100644 src/gui/base/selectionlistener.hpp create mode 100644 src/gui/base/widget.cpp create mode 100644 src/gui/base/widget.hpp create mode 100644 src/gui/base/widgetlistener.hpp create mode 100644 src/gui/base/widgets/button.cpp create mode 100644 src/gui/base/widgets/button.hpp create mode 100644 src/gui/base/widgets/checkbox.cpp create mode 100644 src/gui/base/widgets/checkbox.hpp create mode 100644 src/gui/base/widgets/container.cpp create mode 100644 src/gui/base/widgets/container.hpp create mode 100644 src/gui/base/widgets/label.cpp create mode 100644 src/gui/base/widgets/label.hpp create mode 100644 src/gui/base/widgets/listbox.cpp create mode 100644 src/gui/base/widgets/listbox.hpp create mode 100644 src/gui/base/widgets/radiobutton.cpp create mode 100644 src/gui/base/widgets/radiobutton.hpp create mode 100644 src/gui/base/widgets/scrollarea.cpp create mode 100644 src/gui/base/widgets/scrollarea.hpp create mode 100644 src/gui/base/widgets/slider.cpp create mode 100644 src/gui/base/widgets/slider.hpp create mode 100644 src/gui/base/widgets/textbox.cpp create mode 100644 src/gui/base/widgets/textbox.hpp create mode 100644 src/gui/base/widgets/textfield.cpp create mode 100644 src/gui/base/widgets/textfield.hpp create mode 100644 src/gui/base/widgets/window.cpp create mode 100644 src/gui/base/widgets/window.hpp delete mode 100644 src/guichan/actionevent.cpp delete mode 100644 src/guichan/basiccontainer.cpp delete mode 100644 src/guichan/cliprectangle.cpp delete mode 100644 src/guichan/color.cpp delete mode 100644 src/guichan/event.cpp delete mode 100644 src/guichan/exception.cpp delete mode 100644 src/guichan/focushandler.cpp delete mode 100644 src/guichan/font.cpp delete mode 100644 src/guichan/graphics.cpp delete mode 100644 src/guichan/gui.cpp delete mode 100644 src/guichan/image.cpp delete mode 100644 src/guichan/include/guichan/actionevent.hpp delete mode 100644 src/guichan/include/guichan/actionlistener.hpp delete mode 100644 src/guichan/include/guichan/basiccontainer.hpp delete mode 100644 src/guichan/include/guichan/cliprectangle.hpp delete mode 100644 src/guichan/include/guichan/color.hpp delete mode 100644 src/guichan/include/guichan/deathlistener.hpp delete mode 100644 src/guichan/include/guichan/event.hpp delete mode 100644 src/guichan/include/guichan/exception.hpp delete mode 100644 src/guichan/include/guichan/focushandler.hpp delete mode 100644 src/guichan/include/guichan/focuslistener.hpp delete mode 100644 src/guichan/include/guichan/font.hpp delete mode 100644 src/guichan/include/guichan/graphics.hpp delete mode 100644 src/guichan/include/guichan/gui.hpp delete mode 100644 src/guichan/include/guichan/image.hpp delete mode 100644 src/guichan/include/guichan/input.hpp delete mode 100644 src/guichan/include/guichan/inputevent.hpp delete mode 100644 src/guichan/include/guichan/key.hpp delete mode 100644 src/guichan/include/guichan/keyevent.hpp delete mode 100644 src/guichan/include/guichan/keyinput.hpp delete mode 100644 src/guichan/include/guichan/keylistener.hpp delete mode 100644 src/guichan/include/guichan/listmodel.hpp delete mode 100644 src/guichan/include/guichan/mouseevent.hpp delete mode 100644 src/guichan/include/guichan/mouseinput.hpp delete mode 100644 src/guichan/include/guichan/mouselistener.hpp delete mode 100644 src/guichan/include/guichan/rectangle.hpp delete mode 100644 src/guichan/include/guichan/sdl/sdlpixel.hpp delete mode 100644 src/guichan/include/guichan/selectionevent.hpp delete mode 100644 src/guichan/include/guichan/selectionlistener.hpp delete mode 100644 src/guichan/include/guichan/widget.hpp delete mode 100644 src/guichan/include/guichan/widgetlistener.hpp delete mode 100644 src/guichan/include/guichan/widgets/button.hpp delete mode 100644 src/guichan/include/guichan/widgets/checkbox.hpp delete mode 100644 src/guichan/include/guichan/widgets/container.hpp delete mode 100644 src/guichan/include/guichan/widgets/label.hpp delete mode 100644 src/guichan/include/guichan/widgets/listbox.hpp delete mode 100644 src/guichan/include/guichan/widgets/radiobutton.hpp delete mode 100644 src/guichan/include/guichan/widgets/scrollarea.hpp delete mode 100644 src/guichan/include/guichan/widgets/slider.hpp delete mode 100644 src/guichan/include/guichan/widgets/textbox.hpp delete mode 100644 src/guichan/include/guichan/widgets/textfield.hpp delete mode 100644 src/guichan/include/guichan/widgets/window.hpp delete mode 100644 src/guichan/inputevent.cpp delete mode 100644 src/guichan/key.cpp delete mode 100644 src/guichan/keyevent.cpp delete mode 100644 src/guichan/keyinput.cpp delete mode 100644 src/guichan/mouseevent.cpp delete mode 100644 src/guichan/mouseinput.cpp delete mode 100644 src/guichan/rectangle.cpp delete mode 100644 src/guichan/selectionevent.cpp delete mode 100644 src/guichan/widget.cpp delete mode 100644 src/guichan/widgets/button.cpp delete mode 100644 src/guichan/widgets/checkbox.cpp delete mode 100644 src/guichan/widgets/container.cpp delete mode 100644 src/guichan/widgets/label.cpp delete mode 100644 src/guichan/widgets/listbox.cpp delete mode 100644 src/guichan/widgets/radiobutton.cpp delete mode 100644 src/guichan/widgets/scrollarea.cpp delete mode 100644 src/guichan/widgets/slider.cpp delete mode 100644 src/guichan/widgets/textbox.cpp delete mode 100644 src/guichan/widgets/textfield.cpp delete mode 100644 src/guichan/widgets/window.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fafeeaf5d..f540d2552 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,7 +62,6 @@ IF (USE_X11) ENDIF (USE_X11) INCLUDE_DIRECTORIES( - "guichan/include" ${CMAKE_CURRENT_SOURCE_DIR} ${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} @@ -770,81 +769,78 @@ SET(SRCS vector.h walklayer.cpp walklayer.h - ) - -SET(SRCS_GUICHAN - guichan/include/guichan/actionevent.hpp - guichan/include/guichan/actionlistener.hpp - guichan/include/guichan/basiccontainer.hpp - guichan/include/guichan/cliprectangle.hpp - guichan/include/guichan/color.hpp - guichan/include/guichan/deathlistener.hpp - guichan/include/guichan/event.hpp - guichan/include/guichan/exception.hpp - guichan/include/guichan/focushandler.hpp - guichan/include/guichan/focuslistener.hpp - guichan/include/guichan/font.hpp - guichan/include/guichan/graphics.hpp - guichan/include/guichan/gui.hpp - guichan/include/guichan/image.hpp - guichan/include/guichan/input.hpp - guichan/include/guichan/inputevent.hpp - guichan/include/guichan/key.hpp - guichan/include/guichan/keyevent.hpp - guichan/include/guichan/keyinput.hpp - guichan/include/guichan/keylistener.hpp - guichan/include/guichan/listmodel.hpp - guichan/include/guichan/mouseevent.hpp - guichan/include/guichan/mouseinput.hpp - guichan/include/guichan/mouselistener.hpp - guichan/include/guichan/rectangle.hpp - guichan/include/guichan/selectionevent.hpp - guichan/include/guichan/selectionlistener.hpp - guichan/include/guichan/sdl/sdlpixel.hpp - guichan/include/guichan/widget.hpp - guichan/include/guichan/widgetlistener.hpp - guichan/include/guichan/widgets/button.hpp - guichan/include/guichan/widgets/checkbox.hpp - guichan/include/guichan/widgets/container.hpp - guichan/include/guichan/widgets/label.hpp - guichan/include/guichan/widgets/listbox.hpp - guichan/include/guichan/widgets/radiobutton.hpp - guichan/include/guichan/widgets/scrollarea.hpp - guichan/include/guichan/widgets/slider.hpp - guichan/include/guichan/widgets/textbox.hpp - guichan/include/guichan/widgets/textfield.hpp - guichan/include/guichan/widgets/window.hpp - guichan/actionevent.cpp - guichan/basiccontainer.cpp - guichan/cliprectangle.cpp - guichan/color.cpp - guichan/event.cpp - guichan/exception.cpp - guichan/focushandler.cpp - guichan/font.cpp - guichan/graphics.cpp - guichan/gui.cpp - guichan/image.cpp - guichan/inputevent.cpp - guichan/key.cpp - guichan/keyevent.cpp - guichan/keyinput.cpp - guichan/mouseevent.cpp - guichan/mouseinput.cpp - guichan/rectangle.cpp - guichan/selectionevent.cpp - guichan/widget.cpp - guichan/widgets/button.cpp - guichan/widgets/checkbox.cpp - guichan/widgets/container.cpp - guichan/widgets/label.cpp - guichan/widgets/listbox.cpp - guichan/widgets/radiobutton.cpp - guichan/widgets/scrollarea.cpp - guichan/widgets/slider.cpp - guichan/widgets/textbox.cpp - guichan/widgets/textfield.cpp - guichan/widgets/window.cpp + gui/base/actionevent.hpp + gui/base/actionlistener.hpp + gui/base/basiccontainer.hpp + gui/base/cliprectangle.hpp + gui/base/color.hpp + gui/base/deathlistener.hpp + gui/base/event.hpp + gui/base/exception.hpp + gui/base/focushandler.hpp + gui/base/focuslistener.hpp + gui/base/font.hpp + gui/base/graphics.hpp + gui/base/gui.hpp + gui/base/image.hpp + gui/base/input.hpp + gui/base/inputevent.hpp + gui/base/key.hpp + gui/base/keyevent.hpp + gui/base/keyinput.hpp + gui/base/keylistener.hpp + gui/base/listmodel.hpp + gui/base/mouseevent.hpp + gui/base/mouseinput.hpp + gui/base/mouselistener.hpp + gui/base/rectangle.hpp + gui/base/selectionevent.hpp + gui/base/selectionlistener.hpp + gui/base/sdl/sdlpixel.hpp + gui/base/widget.hpp + gui/base/widgetlistener.hpp + gui/base/widgets/button.hpp + gui/base/widgets/checkbox.hpp + gui/base/widgets/container.hpp + gui/base/widgets/label.hpp + gui/base/widgets/listbox.hpp + gui/base/widgets/radiobutton.hpp + gui/base/widgets/scrollarea.hpp + gui/base/widgets/slider.hpp + gui/base/widgets/textbox.hpp + gui/base/widgets/textfield.hpp + gui/base/widgets/window.hpp + gui/base/actionevent.cpp + gui/base/basiccontainer.cpp + gui/base/cliprectangle.cpp + gui/base/color.cpp + gui/base/event.cpp + gui/base/exception.cpp + gui/base/focushandler.cpp + gui/base/font.cpp + gui/base/graphics.cpp + gui/base/gui.cpp + gui/base/image.cpp + gui/base/inputevent.cpp + gui/base/key.cpp + gui/base/keyevent.cpp + gui/base/keyinput.cpp + gui/base/mouseevent.cpp + gui/base/mouseinput.cpp + gui/base/rectangle.cpp + gui/base/selectionevent.cpp + gui/base/widget.cpp + gui/base/widgets/button.cpp + gui/base/widgets/checkbox.cpp + gui/base/widgets/container.cpp + gui/base/widgets/label.cpp + gui/base/widgets/listbox.cpp + gui/base/widgets/radiobutton.cpp + gui/base/widgets/scrollarea.cpp + gui/base/widgets/slider.cpp + gui/base/widgets/textbox.cpp + gui/base/widgets/textfield.cpp + gui/base/widgets/window.cpp ) SET(SRCS_EVOL @@ -1000,9 +996,9 @@ ENDIF () SET (PROGRAMS manaplus) IF (ENABLE_EATHENA) - ADD_EXECUTABLE(manaplus WIN32 ${SRCS_GUICHAN} ${SRCS} ${SRCS_EATHENA} ${SRCS_TMWA} ${SRCS_EVOL}) + ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_EATHENA} ${SRCS_TMWA} ${SRCS_EVOL}) ELSE(ENABLE_EATHENA) - ADD_EXECUTABLE(manaplus WIN32 ${SRCS_GUICHAN} ${SRCS} ${SRCS_TMWA} ${SRCS_EVOL}) + ADD_EXECUTABLE(manaplus WIN32 ${SRCS} ${SRCS_TMWA} ${SRCS_EVOL}) ENDIF(ENABLE_EATHENA) TARGET_LINK_LIBRARIES(manaplus diff --git a/src/Makefile.am b/src/Makefile.am index 0c50b6da5..f53c0f432 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,25 +25,25 @@ else manaplus_SOURCES = endif -dyecmd_CXXFLAGS = -I$(srcdir)/guichan/include -DUSE_INTERNALGUICHAN -dyecmd_SOURCES = guichan/actionevent.cpp \ - guichan/cliprectangle.cpp \ - guichan/color.cpp \ - guichan/event.cpp \ - guichan/exception.cpp \ - guichan/font.cpp \ - guichan/graphics.cpp \ - guichan/rectangle.cpp \ - guichan/widget.cpp \ - guichan/include/guichan/actionevent.hpp \ - guichan/include/guichan/cliprectangle.hpp \ - guichan/include/guichan/color.hpp \ - guichan/include/guichan/event.hpp \ - guichan/include/guichan/exception.hpp \ - guichan/include/guichan/font.hpp \ - guichan/include/guichan/graphics.hpp \ - guichan/include/guichan/rectangle.hpp \ - guichan/include/guichan/widget.hpp +dyecmd_CXXFLAGS = +dyecmd_SOURCES = gui/base/actionevent.cpp \ + gui/base/cliprectangle.cpp \ + gui/base/color.cpp \ + gui/base/event.cpp \ + gui/base/exception.cpp \ + gui/base/font.cpp \ + gui/base/graphics.cpp \ + gui/base/rectangle.cpp \ + gui/base/widget.cpp \ + gui/base/actionevent.hpp \ + gui/base/cliprectangle.hpp \ + gui/base/color.hpp \ + gui/base/event.hpp \ + gui/base/exception.hpp \ + gui/base/font.hpp \ + gui/base/graphics.hpp \ + gui/base/rectangle.hpp \ + gui/base/widget.hpp dyecmd_SOURCES += dyetool/dyemain.cpp \ animatedsprite.cpp \ @@ -158,80 +158,78 @@ manaplus_CXXFLAGS += -DUSE_SDL2 endif endif -manaplus_CXXFLAGS += -I$(srcdir)/guichan/include -DUSE_INTERNALGUICHAN -manaplus_SOURCES += guichan/include/guichan/actionevent.hpp \ - guichan/include/guichan/actionlistener.hpp \ - guichan/include/guichan/basiccontainer.hpp \ - guichan/include/guichan/cliprectangle.hpp \ - guichan/include/guichan/color.hpp \ - guichan/include/guichan/deathlistener.hpp \ - guichan/include/guichan/event.hpp \ - guichan/include/guichan/exception.hpp \ - guichan/include/guichan/focushandler.hpp \ - guichan/include/guichan/focuslistener.hpp \ - guichan/include/guichan/font.hpp \ - guichan/include/guichan/graphics.hpp \ - guichan/include/guichan/gui.hpp \ - guichan/include/guichan/image.hpp \ - guichan/include/guichan/input.hpp \ - guichan/include/guichan/inputevent.hpp \ - guichan/include/guichan/key.hpp \ - guichan/include/guichan/keyevent.hpp \ - guichan/include/guichan/keyinput.hpp \ - guichan/include/guichan/keylistener.hpp \ - guichan/include/guichan/listmodel.hpp \ - guichan/include/guichan/mouseevent.hpp \ - guichan/include/guichan/mouseinput.hpp \ - guichan/include/guichan/mouselistener.hpp \ - guichan/include/guichan/rectangle.hpp \ - guichan/include/guichan/selectionevent.hpp \ - guichan/include/guichan/selectionlistener.hpp \ - guichan/include/guichan/sdl/sdlpixel.hpp \ - guichan/include/guichan/widget.hpp \ - guichan/include/guichan/widgetlistener.hpp \ - guichan/include/guichan/widgets/button.hpp \ - guichan/include/guichan/widgets/checkbox.hpp \ - guichan/include/guichan/widgets/container.hpp \ - guichan/include/guichan/widgets/label.hpp \ - guichan/include/guichan/widgets/listbox.hpp \ - guichan/include/guichan/widgets/radiobutton.hpp \ - guichan/include/guichan/widgets/scrollarea.hpp \ - guichan/include/guichan/widgets/slider.hpp \ - guichan/include/guichan/widgets/textbox.hpp \ - guichan/include/guichan/widgets/textfield.hpp \ - guichan/include/guichan/widgets/window.hpp - -manaplus_SOURCES += guichan/actionevent.cpp \ - guichan/basiccontainer.cpp \ - guichan/cliprectangle.cpp \ - guichan/color.cpp \ - guichan/event.cpp \ - guichan/exception.cpp \ - guichan/focushandler.cpp \ - guichan/font.cpp \ - guichan/graphics.cpp \ - guichan/gui.cpp \ - guichan/image.cpp \ - guichan/inputevent.cpp \ - guichan/key.cpp \ - guichan/keyevent.cpp \ - guichan/keyinput.cpp \ - guichan/mouseevent.cpp \ - guichan/mouseinput.cpp \ - guichan/rectangle.cpp \ - guichan/selectionevent.cpp \ - guichan/widget.cpp \ - guichan/widgets/button.cpp \ - guichan/widgets/checkbox.cpp \ - guichan/widgets/container.cpp \ - guichan/widgets/label.cpp \ - guichan/widgets/listbox.cpp \ - guichan/widgets/radiobutton.cpp \ - guichan/widgets/scrollarea.cpp \ - guichan/widgets/slider.cpp \ - guichan/widgets/textbox.cpp \ - guichan/widgets/textfield.cpp \ - guichan/widgets/window.cpp +manaplus_SOURCES += gui/base/actionevent.hpp \ + gui/base/actionlistener.hpp \ + gui/base/basiccontainer.hpp \ + gui/base/cliprectangle.hpp \ + gui/base/color.hpp \ + gui/base/deathlistener.hpp \ + gui/base/event.hpp \ + gui/base/exception.hpp \ + gui/base/focushandler.hpp \ + gui/base/focuslistener.hpp \ + gui/base/font.hpp \ + gui/base/graphics.hpp \ + gui/base/gui.hpp \ + gui/base/image.hpp \ + gui/base/input.hpp \ + gui/base/inputevent.hpp \ + gui/base/key.hpp \ + gui/base/keyevent.hpp \ + gui/base/keyinput.hpp \ + gui/base/keylistener.hpp \ + gui/base/listmodel.hpp \ + gui/base/mouseevent.hpp \ + gui/base/mouseinput.hpp \ + gui/base/mouselistener.hpp \ + gui/base/rectangle.hpp \ + gui/base/selectionevent.hpp \ + gui/base/selectionlistener.hpp \ + gui/base/sdl/sdlpixel.hpp \ + gui/base/widget.hpp \ + gui/base/widgetlistener.hpp \ + gui/base/widgets/button.hpp \ + gui/base/widgets/checkbox.hpp \ + gui/base/widgets/container.hpp \ + gui/base/widgets/label.hpp \ + gui/base/widgets/listbox.hpp \ + gui/base/widgets/radiobutton.hpp \ + gui/base/widgets/scrollarea.hpp \ + gui/base/widgets/slider.hpp \ + gui/base/widgets/textbox.hpp \ + gui/base/widgets/textfield.hpp \ + gui/base/widgets/window.hpp \ + gui/base/actionevent.cpp \ + gui/base/basiccontainer.cpp \ + gui/base/cliprectangle.cpp \ + gui/base/color.cpp \ + gui/base/event.cpp \ + gui/base/exception.cpp \ + gui/base/focushandler.cpp \ + gui/base/font.cpp \ + gui/base/graphics.cpp \ + gui/base/gui.cpp \ + gui/base/image.cpp \ + gui/base/inputevent.cpp \ + gui/base/key.cpp \ + gui/base/keyevent.cpp \ + gui/base/keyinput.cpp \ + gui/base/mouseevent.cpp \ + gui/base/mouseinput.cpp \ + gui/base/rectangle.cpp \ + gui/base/selectionevent.cpp \ + gui/base/widget.cpp \ + gui/base/widgets/button.cpp \ + gui/base/widgets/checkbox.cpp \ + gui/base/widgets/container.cpp \ + gui/base/widgets/label.cpp \ + gui/base/widgets/listbox.cpp \ + gui/base/widgets/radiobutton.cpp \ + gui/base/widgets/scrollarea.cpp \ + gui/base/widgets/slider.cpp \ + gui/base/widgets/textbox.cpp \ + gui/base/widgets/textfield.cpp \ + gui/base/widgets/window.cpp manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/avatarlistbox.h \ diff --git a/src/being/being.h b/src/being/being.h index b9039bce3..c8da2d97c 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -27,7 +27,7 @@ #include "resources/beinginfo.h" -#include +#include "gui/base/color.hpp" #include diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 6ba12bd56..1bbf7dcc8 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -30,7 +30,7 @@ #include "gui/userpalette.h" -#include +#include "gui/base/actionlistener.hpp" #include diff --git a/src/client.h b/src/client.h index 22567ae94..c26e91eae 100644 --- a/src/client.h +++ b/src/client.h @@ -27,7 +27,7 @@ #include "net/serverinfo.h" -#include +#include "gui/base/actionlistener.hpp" #include diff --git a/src/gui/base/actionevent.cpp b/src/gui/base/actionevent.cpp new file mode 100644 index 000000000..7fcc1ee84 --- /dev/null +++ b/src/gui/base/actionevent.cpp @@ -0,0 +1,88 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/actionevent.hpp" + +#include "debug.h" + +namespace gcn +{ + ActionEvent::ActionEvent(Widget *const source, const std::string &id) + :Event(source), + mId(id) + { + } + + ActionEvent::~ActionEvent() + { + } + + const std::string& ActionEvent::getId() const + { + return mId; + } +} // namespace gcn diff --git a/src/gui/base/actionevent.hpp b/src/gui/base/actionevent.hpp new file mode 100644 index 000000000..621499864 --- /dev/null +++ b/src/gui/base/actionevent.hpp @@ -0,0 +1,133 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_ACTIONEVENT_HPP +#define GCN_ACTIONEVENT_HPP + +#include "gui/base/event.hpp" + +#include + +#include "localconsts.h" + +namespace gcn +{ + class Widget; + + /** + * Represents an action event. An action event is an event + * that can be fired by a widget whenever an action has occured. + * What exactly an action is is up to the widget that fires + * the action event. An example is a Button which fires an action + * event as soon as the Button is clicked, another example is + * TextField which fires an action event as soon as the enter + * key is pressed. + * + * Any object can listen for actions from widgets by implementing + * the ActionListener interface. + * + * If you have implement a widget of your own it's a good idea to + * let the widget fire action events whenever you feel an action + * has occured so action listeners of the widget can be informed + * of the state of the widget. + * + * @see Widget::addActionListener, Widget::removeActionListener, + * Widget::distributeActionEvent + * @author Olof Naessén + * @since 0.6.0 + */ + class ActionEvent final : public Event + { + public: + /** + * Constructor. + * + * @param source The source widget of the event. + * @param id An identifier of the event. + */ + ActionEvent(Widget *const source, const std::string &id); + + /** + * Destructor. + */ + virtual ~ActionEvent(); + + /** + * Gets the identifier of the event. An identifier can + * be used to distinguish from two actions from the same + * widget or to let many widgets fire the same widgets + * that should be treated equally. + * + * @return The identifier of the event. + */ + const std::string& getId() const A_WARN_UNUSED; + + protected: + /** + * Holds the identifier of the event. + */ + std::string mId; + }; +} // namespace gcn + +#endif // GCN_ACTIONEVENT_HPP diff --git a/src/gui/base/actionlistener.hpp b/src/gui/base/actionlistener.hpp new file mode 100644 index 000000000..8a40fbb8c --- /dev/null +++ b/src/gui/base/actionlistener.hpp @@ -0,0 +1,112 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_ACTIONLISTENER_HPP +#define GCN_ACTIONLISTENER_HPP + +#include + +#include "gui/base/actionevent.hpp" + +namespace gcn +{ + /** + * Interface for listening for action events from widgets. + * + * @see Widget::addActionListener, Widget::removeActionListener, + * ActionEvent + * @author Olof Naessén + * @author Per Larsson + */ + class ActionListener + { + public: + /** + * Destructor. + */ + virtual ~ActionListener() + { } + + /** + * Called when an action is recieved from a widget. It is used + * to be able to recieve a notification that an action has + * occured. + * + * @param actionEvent The event of the action. + * @since 0.6.0 + */ + virtual void action(const ActionEvent& actionEvent) = 0; + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of ActionListener, + * therefore its constructor is protected. + */ + ActionListener() + { } + }; +} // namespace gcn + +#endif // end GCN_ACTIONLISTENER_HPP diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp new file mode 100644 index 000000000..45bb1e231 --- /dev/null +++ b/src/gui/base/basiccontainer.cpp @@ -0,0 +1,394 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/basiccontainer.hpp" + +#include + +#include "gui/base/exception.hpp" +#include "gui/base/focushandler.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + BasicContainer::~BasicContainer() + { + clear(); + } + + void BasicContainer::moveToTop(Widget* widget) + { + for (WidgetListIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + if (*iter == widget) + { + mWidgets.erase(iter); + mWidgets.push_back(widget); + return; + } + } + + throw GCN_EXCEPTION("There is no such widget in this container."); + } + + void BasicContainer::moveToBottom(Widget* widget) + { + WidgetListIterator iter; + iter = std::find(mWidgets.begin(), mWidgets.end(), widget); + + if (iter == mWidgets.end()) + throw GCN_EXCEPTION("There is no such widget in this container."); + + mWidgets.erase(iter); + mWidgets.insert(mWidgets.begin(), widget); +// mWidgets.push_front(widget); + } + + void BasicContainer::death(const Event& event) + { + WidgetListIterator iter; + iter = std::find(mWidgets.begin(), mWidgets.end(), event.getSource()); + + if (iter == mWidgets.end()) + throw GCN_EXCEPTION("There is no such widget in this container."); + + mWidgets.erase(iter); + } + + Rectangle BasicContainer::getChildrenArea() + { + return Rectangle(0, 0, getWidth(), getHeight()); + } + + void BasicContainer::focusNext() + { + WidgetListConstIterator it; + + for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) + { + if ((*it)->isFocused()) + break; + } + + WidgetListConstIterator end = it; + + if (it == mWidgets.end()) + it = mWidgets.begin(); + + ++ it; + + for ( ; it != end; ++ it) + { + if (it == mWidgets.end()) + it = mWidgets.begin(); + + if ((*it)->isFocusable()) + { + (*it)->requestFocus(); + return; + } + } + } + + void BasicContainer::focusPrevious() + { + WidgetListReverseIterator it; + + for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it) + { + if ((*it)->isFocused()) + break; + } + + const WidgetListReverseIterator end = it; + + ++ it; + + if (it == mWidgets.rend()) + it = mWidgets.rbegin(); + + for ( ; it != end; ++ it) + { + if (it == mWidgets.rend()) + it = mWidgets.rbegin(); + + if ((*it)->isFocusable()) + { + (*it)->requestFocus(); + return; + } + } + } + + Widget *BasicContainer::getWidgetAt(int x, int y) + { + const Rectangle r = getChildrenArea(); + + if (!r.isPointInRect(x, y)) + return nullptr; + + x -= r.x; + y -= r.y; + + for (WidgetListReverseIterator it = mWidgets.rbegin(); + it != mWidgets.rend(); ++ it) + { + if ((*it)->isVisible() && (*it)->getDimension() + .isPointInRect(x, y)) + { + return (*it); + } + } + + return nullptr; + } + + void BasicContainer::logic() + { + BLOCK_START("BasicContainer::logic") + logicChildren(); + BLOCK_END("BasicContainer::logic") + } + + void BasicContainer::_setFocusHandler(FocusHandler* focusHandler) + { + Widget::_setFocusHandler(focusHandler); + + if (mInternalFocusHandler) + return; + + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + (*iter)->_setFocusHandler(focusHandler); + } + } + + void BasicContainer::add(Widget* widget) + { + mWidgets.push_back(widget); + + if (!mInternalFocusHandler) + widget->_setFocusHandler(_getFocusHandler()); + else + widget->_setFocusHandler(mInternalFocusHandler); + + widget->_setParent(this); + widget->addDeathListener(this); + } + + void BasicContainer::remove(Widget* widget) + { + for (WidgetListIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + if (*iter == widget) + { + mWidgets.erase(iter); + widget->_setFocusHandler(nullptr); + widget->_setParent(nullptr); + widget->removeDeathListener(this); + return; + } + } + + throw GCN_EXCEPTION("There is no such widget in this container."); + } + + void BasicContainer::clear() + { + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + (*iter)->_setFocusHandler(nullptr); + (*iter)->_setParent(nullptr); + (*iter)->removeDeathListener(this); + } + + mWidgets.clear(); + } + + void BasicContainer::drawChildren(Graphics* graphics) + { + BLOCK_START("BasicContainer::drawChildren") + + graphics->pushClipArea(getChildrenArea()); + + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + Widget *const widget = *iter; + if (widget->isVisible()) + { + // If the widget has a frame, + // draw it before drawing the widget + if (widget->getFrameSize() > 0) + { + Rectangle rec = widget->getDimension(); + const int frame = widget->getFrameSize(); + const int frame2 = frame * 2; + rec.x -= frame; + rec.y -= frame; + rec.width += frame2; + rec.height += frame2; + graphics->pushClipArea(rec); + BLOCK_START("BasicContainer::drawChildren 1") + widget->drawFrame(graphics); + BLOCK_END("BasicContainer::drawChildren 1") + graphics->popClipArea(); + } + + graphics->pushClipArea(widget->getDimension()); + BLOCK_START("BasicContainer::drawChildren 2") + widget->draw(graphics); + BLOCK_END("BasicContainer::drawChildren 2") + graphics->popClipArea(); + } + } + + graphics->popClipArea(); + BLOCK_END("BasicContainer::drawChildren") + } + + void BasicContainer::logicChildren() + { + BLOCK_START("BasicContainer::logicChildren") + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + (*iter)->logic(); + } + BLOCK_END("BasicContainer::logicChildren") + } + + void BasicContainer::showWidgetPart(Widget* widget, Rectangle area) + { + const Rectangle widgetArea = getChildrenArea(); + + area.x += widget->getX(); + area.y += widget->getY(); + + if (area.x + area.width > widgetArea.width) + { + widget->setX(widget->getX() - area.x + - area.width + widgetArea.width); + } + + if (area.y + area.height > widgetArea.height) + { + widget->setY(widget->getY() - area.y + - area.height + widgetArea.height); + } + + if (area.x < 0) + widget->setX(widget->getX() - area.x); + + if (area.y < 0) + widget->setY(widget->getY() - area.y); + } + + void BasicContainer::setInternalFocusHandler(FocusHandler* focusHandler) + { + Widget::setInternalFocusHandler(focusHandler); + + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + if (!mInternalFocusHandler) + (*iter)->_setFocusHandler(_getFocusHandler()); + else + (*iter)->_setFocusHandler(mInternalFocusHandler); + } + } + + Widget* BasicContainer::findWidgetById(const std::string& id) + { + for (WidgetListConstIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++ iter) + { + if ((*iter)->getId() == id) + return (*iter); + + BasicContainer *const basicContainer + = dynamic_cast(*iter); + + if (basicContainer) + { + Widget *const widget = basicContainer->findWidgetById(id); + + if (widget) + return widget; + } + } + + return nullptr; + } +} // namespace gcn diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp new file mode 100644 index 000000000..d6dd38b63 --- /dev/null +++ b/src/gui/base/basiccontainer.hpp @@ -0,0 +1,216 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_BASICCONTAINER_HPP +#define GCN_BASICCONTAINER_HPP + +#include +#include + +#include "gui/base/deathlistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * A base class for containers. The class implements the most + * common things for a container. If you are implementing a + * container, consider inheriting from this class. + * + * @see Container + * @since 0.6.0 + */ + class BasicContainer : public Widget, + public DeathListener + { + public: + BasicContainer() : + mWidgets() + { } + + A_DELETE_COPY(BasicContainer) + + /** + * Destructor + */ + virtual ~BasicContainer(); + + /** + * Shows a certain part of a widget in the basic container. + * Used when widgets want a specific part to be visible in + * its parent. An example is a TextArea that wants a specific + * part of its text to be visible when a TextArea is a child + * of a ScrollArea. + * + * @param widget The widget whom wants a specific part of + * itself to be visible. + * @param rectangle The rectangle to be visible. + */ + virtual void showWidgetPart(Widget* widget, Rectangle area); + + // Inherited from Widget + + virtual void moveToTop(Widget* widget); + + virtual void moveToBottom(Widget* widget); + + virtual Rectangle getChildrenArea() A_WARN_UNUSED; + + virtual void focusNext(); + + virtual void focusPrevious(); + + virtual void logic(); + + virtual void _setFocusHandler(FocusHandler* focusHandler); + + void setInternalFocusHandler(FocusHandler* focusHandler); + + virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED; + + + // Inherited from DeathListener + + virtual void death(const Event& event); + + protected: + /** + * Adds a widget to the basic container. + * + * @param widget The widget to add. + * @see remove, clear + */ + void add(Widget* widget); + + /** + * Removes a widget from the basic container. + * + * @param widget The widget to remove. + * @see add, clear + */ + virtual void remove(Widget* widget); + + /** + * Clears the basic container from all widgets. + * + * @see remove, clear + */ + virtual void clear(); + + /** + * Draws the children widgets of the basic container. + * + * @param graphics A graphics object to draw with. + */ + virtual void drawChildren(Graphics* graphics); + + /** + * Calls logic for the children widgets of the basic + * container. + */ + virtual void logicChildren(); + + /** + * Finds a widget given an id. This function can be useful + * when implementing a GUI generator for Guichan, such as + * the ability to create a Guichan GUI from an XML file. + * + * @param id The id to find a widget by. + * @return The widget with the corrosponding id, + NULL of no widget is found. + */ + virtual Widget* findWidgetById(const std::string& id) A_WARN_UNUSED; + + /** + * Typedef. + */ + typedef std::vector WidgetList; + + /** + * Typedef. + */ + typedef WidgetList::iterator WidgetListIterator; + + /** + * Typedef. + */ + typedef WidgetList::const_iterator WidgetListConstIterator; + + /** + * Typedef. + */ + typedef WidgetList::reverse_iterator WidgetListReverseIterator; + + /** + * Typedef. + */ + typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator; + + /** + * Holds all widgets of the basic container. + */ + WidgetList mWidgets; + }; +} // namespace gcn + +#endif // end GCN_BASICCONTAINER_HPP diff --git a/src/gui/base/cliprectangle.cpp b/src/gui/base/cliprectangle.cpp new file mode 100644 index 000000000..f52bc384a --- /dev/null +++ b/src/gui/base/cliprectangle.cpp @@ -0,0 +1,107 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/cliprectangle.hpp" + +#include "debug.h" + +namespace gcn +{ + ClipRectangle::ClipRectangle() : + Rectangle(), + xOffset(0), + yOffset(0) + { + x = 0; + y = 0; + width = 0; + height = 0; + } + + ClipRectangle::ClipRectangle(const int x0, const int y0, + const int width0, const int height0, + const int xOffset0, const int yOffset0) : + Rectangle(), + xOffset(xOffset0), + yOffset(yOffset0) + { + x = x0; + y = y0; + width = width0; + height = height0; + } + + const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) + { + x = other.x; + y = other.y; + width = other.width; + height = other.height; + + return *this; + } +} // namespace gcn diff --git a/src/gui/base/cliprectangle.hpp b/src/gui/base/cliprectangle.hpp new file mode 100644 index 000000000..1fdbfbe8d --- /dev/null +++ b/src/gui/base/cliprectangle.hpp @@ -0,0 +1,129 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_CLIPRECTANGLE_HPP +#define GCN_CLIPRECTANGLE_HPP + +#include "gui/base/rectangle.hpp" + +#include "localconsts.h" + +namespace gcn +{ + /** + * A rectangle used when dealing with clipping. A clip rectangle is + * a regular rectangle extended with variables for x offsets and y + * offsets. The offsets are used for calculations from relative + * screen coordinates to actual screen coordinates. + */ + class ClipRectangle final : public Rectangle + { + public: + /** + * Constructor. + */ + ClipRectangle(); + + /** + * Constructor. + * + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + */ + ClipRectangle(const int x0, + const int y0, + const int width0, + const int height0, + const int xOffset0, + const int yOffset0); + + /** + * Copy constructor. Copies x, y, width and height + * field from a rectangle to a clip rectangle. + * + * @param other The rectangle to copy data from. + * @returns A clip rectangle with data copyied from a rectangle. + */ + const ClipRectangle& operator=(const Rectangle& other); + + /** + * Holds the x offset of the x coordinate. + */ + int xOffset; + + /** + * Holds the y offset of the y coordinate. + */ + int yOffset; + }; +} // namespace gcn + +#endif // end GCN_CLIPRECTANGLE_HPP diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp new file mode 100644 index 000000000..764259efc --- /dev/null +++ b/src/gui/base/color.cpp @@ -0,0 +1,165 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/color.hpp" + +#include "debug.h" + +namespace gcn +{ + Color::Color() : + r(0), + g(0), + b(0), + a(255) + { + } + + Color::Color(const int color) : + r((color >> 16) & 0xFF), + g((color >> 8) & 0xFF), + b(color & 0xFF), + a(255) + { + } + + Color::Color(const int ar, const int ag, const int ab, const int aa) : + r(ar), + g(ag), + b(ab), + a(aa) + { + } + + Color Color::operator+(const Color& color) const + { + Color result(r + color.r, + g + color.g, + b + color.b, + 255); + + result.r = (result.r>255?255:(result.r<0?0:result.r)); + result.g = (result.g>255?255:(result.g<0?0:result.g)); + result.b = (result.b>255?255:(result.b<0?0:result.b)); + + return result; + } + + Color Color::operator-(const Color& color) const + { + Color result(r - color.r, + g - color.g, + b - color.b, + 255); + + result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); + result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); + result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); + + return result; + } + + Color Color::operator*(const float value) const + { + Color result(static_cast(static_cast(r) * value), + static_cast(static_cast(g) * value), + static_cast(static_cast(b) * value), + a); + + result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); + result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); + result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); + + return result; + } + + bool Color::operator==(const Color& color) const + { + return r == color.r && g == color.g && b == color.b && a == color.a; + } + + bool Color::operator!=(const Color& color) const + { + return !(r == color.r && g == color.g && b == color.b && a == color.a); + } + + std::ostream& operator<<(std::ostream& out, + const Color& color) + { + out << "Color [r = " + << color.r + << ", g = " + << color.g + << ", b = " + << color.b + << ", a = " + << color.a + << "]"; + + return out; + } +} // namespace gcn diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp new file mode 100644 index 000000000..c32adb2e9 --- /dev/null +++ b/src/gui/base/color.hpp @@ -0,0 +1,192 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_COLOR_HPP +#define GCN_COLOR_HPP + +#include + +#include "localconsts.h" + +namespace gcn +{ + /** + * Represents a color with red, green, blue and alpha components. + */ + class Color final + { + public: + /** + * Constructor. Initializes the color to black. + */ + Color(); + + /** + * Constructor. Constructs a color from the bytes in an integer. + * Call it with a hexadecimal constant for HTML-style color representation. + * The alpha component is 255 by default. + * + * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. + * + * NOTE: Because of this constructor, integers will be automatically + * casted to a color by your compiler. + * + * @param color The color to initialise the object with. + */ + explicit Color(const int color); + + /** + * Constructor. The default alpha value is 255. + * + * @param r Red color component (range 0-255). + * @param g Green color component (range 0-255). + * @param b Blue color component (range 0-255). + * @param a Alpha, used for transparency. A value of 0 means + * totaly transparent, 255 is totaly opaque. + */ + Color(const int r, const int g, const int b, const int a = 255); + + /** + * Adds the RGB values of two colors together. The values will be + * clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to add to this color. + * @return The added colors with an alpha value set to 255. + */ + Color operator+(const Color& color) const; + + /** + * Subtracts the RGB values of one color from another. + * The values will be clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to subtract from this color. + * @return The subtracted colors with an alpha value set to 255. + */ + Color operator-(const Color& color) const; + + /** + * Multiplies the RGB values of a color with a float value. + * The values will be clamped if they go out of range. + * + * @param value The value to multiply the color with. + * @return The multiplied colors. The alpha value will, unlike + * the add and subtract operations, be multiplied as + * well. + */ + Color operator*(const float value) const; + + /** + * Compares two colors. + * + * @return True if the two colors have the same RGBA components + * false otherwise. + */ + bool operator==(const Color& color) const; + + /** + * Compares two colors. + * + * @return True if the two colors have different RGBA components, + * false otherwise. + */ + bool operator!=(const Color& color) const; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param color The color to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Color& Color); + + /** + * Holds the red color component (range 0-255). + */ + int r; + + /** + * Holds the green color component (range 0-255). + */ + int g; + + /** + * Holds the blue color component (range 0-255). + */ + int b; + + /** + * Holds the alpha color component. A value of 0 means totally + * transparent while a value of 255 is considered opaque. + */ + int a; + }; +} // namespace gcn + +#endif // end GCN_COLOR_HPP diff --git a/src/gui/base/deathlistener.hpp b/src/gui/base/deathlistener.hpp new file mode 100644 index 000000000..b325166c2 --- /dev/null +++ b/src/gui/base/deathlistener.hpp @@ -0,0 +1,109 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_DEATHLISTENER_HPP +#define GCN_DEATHLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +namespace gcn +{ + /** + * Interface for listening for death events from widgets. + * + * @see Widget::addDeathListener, Widget::removeDeathListener + * @author Olof Naessén + * @since 0.6.0 + */ + class DeathListener + { + public: + /** + * Destructor. + */ + virtual ~DeathListener() + { } + + /** + * Called when a widget dies. It is used to be able to recieve + * a notification when a death of a widget occurs. + * + * @param event The event of the death. + */ + virtual void death(const Event& event) = 0; + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of DeathListener, + * therefore its constructor is protected. + */ + DeathListener() + { } + }; +} // namespace gcn + +#endif // end GCN_DEATHLISTENER_HPP diff --git a/src/gui/base/event.cpp b/src/gui/base/event.cpp new file mode 100644 index 000000000..359b780bf --- /dev/null +++ b/src/gui/base/event.cpp @@ -0,0 +1,87 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/event.hpp" + +#include "debug.h" + +namespace gcn +{ + Event::Event(Widget *const source) : + mSource(source) + { + } + + Event::~Event() + { + } + + Widget* Event::getSource() const + { + return mSource; + } +} // namespace gcn diff --git a/src/gui/base/event.hpp b/src/gui/base/event.hpp new file mode 100644 index 000000000..2a1f4ca4b --- /dev/null +++ b/src/gui/base/event.hpp @@ -0,0 +1,113 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_EVENT_HPP +#define GCN_EVENT_HPP + +#include "localconsts.h" + +namespace gcn +{ + class Widget; + + /** + * Base class for all events. All events in Guichan should + * inherit from this class. + * + * @author Olof Naessén + * @since 0.6.0 + */ + class Event + { + public: + /** + * Constructor. + * + * @param source The source widget of the event. + */ + explicit Event(Widget *const source); + + A_DELETE_COPY(Event) + + /** + * Destructor. + */ + virtual ~Event(); + + /** + * Gets the source widget of the event. The function + * is used to tell which widget fired an event. + * + * @return The source widget of the event. + */ + Widget* getSource() const A_WARN_UNUSED; + + protected: + /** + * Holds the source widget of the event. + */ + Widget* mSource; + }; +} // namespace gcn + +#endif // end GCN_EVENT_HPP diff --git a/src/gui/base/exception.cpp b/src/gui/base/exception.cpp new file mode 100644 index 000000000..998db928d --- /dev/null +++ b/src/gui/base/exception.cpp @@ -0,0 +1,120 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/exception.hpp" + +#include "debug.h" + +namespace gcn +{ + Exception::Exception() + : mFunction("?"), + mMessage(""), + mFilename("?"), + mLine(0) + { + } + + Exception::Exception(const std::string& message) + : mFunction("?"), + mMessage(message), + mFilename("?"), + mLine(0) + { + } + + Exception::Exception(const std::string& message, + const std::string& function, + const std::string& filename, + const unsigned int line) + : mFunction(function), + mMessage(message), + mFilename(filename), + mLine(line) + { + } + + const std::string& Exception::getFunction() const + { + return mFunction; + } + + const std::string& Exception::getMessage() const + { + return mMessage; + } + + const std::string& Exception::getFilename() const + { + return mFilename; + } + + unsigned int Exception::getLine() const + { + return mLine; + } +} // namespace gcn diff --git a/src/gui/base/exception.hpp b/src/gui/base/exception.hpp new file mode 100644 index 000000000..a60152c96 --- /dev/null +++ b/src/gui/base/exception.hpp @@ -0,0 +1,196 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_EXCEPTION_HPP +#define GCN_EXCEPTION_HPP + +#include + +#include "localconsts.h" + +#ifndef __FUNCTION__ +#define __FUNCTION__ "?" +#endif + +/* + * A macro used to create a standard exception object. + * What it basicly does is that it creates a new exception + * and automatically sets the filename and line number where + * the exception occured by using other compiler macros. + */ +#define GCN_EXCEPTION(mess) gcn::Exception(mess, \ + __FUNCTION__, \ + __FILE__, \ + __LINE__) + +namespace gcn +{ + + /** + * An exception containing a message, a file and a line number + * where the exception occured. Guichan will only throw exceptions + * of this class. + * + * You can use this class for your own exceptions that has + * something to do with a GUI exception. A nifty feature of the + * excpetion class is that it can tell you from which line and + * file it was thrown. To make things easier when throwing + * exceptions there exists a macro for creating exceptions + * which automatically sets the filename and line number. + * + * EXAMPLE: @code + * throw GCN_EXCEPTION("my error message"); + * @endcode + */ + class Exception final + { + public: + /** + * Constructor. + */ + Exception(); + + /** + * Constructor. + * + * @param message The error message of the exception. + */ + explicit Exception(const std::string& message); + + /** + * Constructor. + * + * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead. + * This constructor merely exists for the GCN_EXCEPTION macro to + * use. + * + * @param message The error message of the exception. + * @param function The function name where the exception occured. + * @param filename The name of the file where the exception occured. + * @param line The line number in the source code where the exception + * occured. + */ + Exception(const std::string& message, + const std::string& function, + const std::string& filename, + const unsigned int line); + + /** + * Gets the function name where the exception occured. + * + * @return The function name where the exception occured. + */ + const std::string& getFunction() const A_WARN_UNUSED; + + /** + * Gets the error message of the exception. + * + * @return The error message of the exception. + */ + const std::string& getMessage() const A_WARN_UNUSED; + + /** + * Gets the filename where the exception occured. + * + * @return The filename where the exception occured. + */ + const std::string& getFilename() const A_WARN_UNUSED; + + /** + * Gets the line number where the exception occured. + * + * @return The line number where the exception occured. + */ + unsigned int getLine() const A_WARN_UNUSED; + + protected: + /** + * Holds the name of the function name where the + * exception occured. + */ + std::string mFunction; + + /** + * Holds the error message of the exception. + */ + std::string mMessage; + + /** + * Holds the filename where the exception occured. + */ + std::string mFilename; + + /** + * Holds the line number where the exception occured. + */ + unsigned int mLine; + }; +} // namespace gcn + +#endif // end GCN_EXCEPTION_HPP + +/* + * "Final Fantasy XI is the BEST!... It's even better then water!" + * - Astrolite + * I believe it's WoW now days. + */ diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp new file mode 100644 index 000000000..6984d1fcd --- /dev/null +++ b/src/gui/base/focushandler.cpp @@ -0,0 +1,571 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/focushandler.hpp" + +#include "gui/base/focuslistener.hpp" +#include "gui/base/exception.hpp" +#include "gui/base/widget.hpp" + +#include "debug.h" + +namespace gcn +{ + FocusHandler::FocusHandler() : + mWidgets(), + mFocusedWidget(nullptr), + mModalFocusedWidget(nullptr), + mModalMouseInputFocusedWidget(nullptr), + mDraggedWidget(nullptr), + mLastWidgetWithMouse(nullptr), + mLastWidgetWithModalFocus(nullptr), + mLastWidgetWithModalMouseInputFocus(nullptr), + mLastWidgetPressed(nullptr) + { + } + + void FocusHandler::requestFocus(Widget* widget) + { + if (!widget || widget == mFocusedWidget) + return; + + int toBeFocusedIndex = -1; + for (unsigned int i = 0, sz = static_cast( + mWidgets.size()); i < sz; ++i) + { + if (mWidgets[i] == widget) + { + toBeFocusedIndex = i; + break; + } + } + + if (toBeFocusedIndex < 0) + throw GCN_EXCEPTION("Trying to focus a none existing widget."); + + Widget *const oldFocused = mFocusedWidget; + + if (oldFocused != widget) + { + mFocusedWidget = mWidgets.at(toBeFocusedIndex); + + if (oldFocused) + { + Event focusEvent(oldFocused); + distributeFocusLostEvent(focusEvent); + } + + Event focusEvent(mWidgets.at(toBeFocusedIndex)); + distributeFocusGainedEvent(focusEvent); + } + } + + void FocusHandler::requestModalFocus(Widget* widget) + { + if (mModalFocusedWidget && mModalFocusedWidget != widget) + throw GCN_EXCEPTION("Another widget already has modal focus."); + + mModalFocusedWidget = widget; + + if (mFocusedWidget && !mFocusedWidget->isModalFocused()) + focusNone(); + } + + void FocusHandler::requestModalMouseInputFocus(Widget* widget) + { + if (mModalMouseInputFocusedWidget + && mModalMouseInputFocusedWidget != widget) + { + throw GCN_EXCEPTION("Another widget already has " + "modal input focus."); + } + + mModalMouseInputFocusedWidget = widget; + } + + void FocusHandler::releaseModalFocus(Widget* widget) + { + if (mModalFocusedWidget == widget) + mModalFocusedWidget = nullptr; + } + + void FocusHandler::releaseModalMouseInputFocus(Widget* widget) + { + if (mModalMouseInputFocusedWidget == widget) + mModalMouseInputFocusedWidget = nullptr; + } + + Widget* FocusHandler::getFocused() const + { + return mFocusedWidget; + } + + Widget* FocusHandler::getModalFocused() const + { + return mModalFocusedWidget; + } + + Widget* FocusHandler::getModalMouseInputFocused() const + { + return mModalMouseInputFocusedWidget; + } + + void FocusHandler::focusNext() + { + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + ++ focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget >= sz) + focusedWidget = 0; + + if (focusedWidget == focused) + return; + } + while (!mWidgets.at(focusedWidget)->isFocusable()); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } + } + + void FocusHandler::focusPrevious() + { + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + -- focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget <= 0) + focusedWidget = sz - 1; + + if (focusedWidget == focused) + return; + } + while (!mWidgets.at(focusedWidget)->isFocusable()); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } + } + + bool FocusHandler::isFocused(const Widget* widget) const + { + return mFocusedWidget == widget; + } + + void FocusHandler::add(Widget* widget) + { + mWidgets.push_back(widget); + } + + void FocusHandler::remove(Widget* widget) + { + if (isFocused(widget)) + mFocusedWidget = nullptr; + + for (WidgetIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++iter) + { + if ((*iter) == widget) + { + mWidgets.erase(iter); + break; + } + } + + if (mDraggedWidget == widget) + { + mDraggedWidget = nullptr; + return; + } + + if (mLastWidgetWithMouse == widget) + { + mLastWidgetWithMouse = nullptr; + return; + } + + if (mLastWidgetWithModalFocus == widget) + { + mLastWidgetWithModalFocus = nullptr; + return; + } + + if (mLastWidgetWithModalMouseInputFocus == widget) + { + mLastWidgetWithModalMouseInputFocus = nullptr; + return; + } + + if (mLastWidgetPressed == widget) + { + mLastWidgetPressed = nullptr; + return; + } + } + + void FocusHandler::focusNone() + { + if (mFocusedWidget) + { + Widget *const focused = mFocusedWidget; + mFocusedWidget = nullptr; + + Event focusEvent(focused); + distributeFocusLostEvent(focusEvent); + } + } + + void FocusHandler::tabNext() + { + if (mFocusedWidget) + { + if (!mFocusedWidget->isTabOutEnabled()) + return; + } + + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + bool done = false; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + ++ focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget >= sz) + focusedWidget = 0; + + if (focusedWidget == focused) + return; + + const Widget *const widget = mWidgets.at(focusedWidget); + if (widget->isFocusable() && widget->isTabInEnabled() && + (!mModalFocusedWidget || widget->isModalFocused())) + { + done = true; + } + } + while (!done); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } + } + + void FocusHandler::tabPrevious() + { + if (mFocusedWidget) + { + if (!mFocusedWidget->isTabOutEnabled()) + return; + } + + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + bool done = false; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + -- focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget <= 0) + focusedWidget = sz - 1; + + if (focusedWidget == focused) + return; + + const Widget *const widget = mWidgets.at(focusedWidget); + if (widget->isFocusable() && widget->isTabInEnabled() && + (!mModalFocusedWidget || widget->isModalFocused())) + { + done = true; + } + } + while (!done); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } + } + + void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) + { + Widget *const sourceWidget = focusEvent.getSource(); + + std::list focusListeners + = sourceWidget->_getFocusListeners(); + + // Send the event to all focus listeners of the widget. + for (std::list::const_iterator + it = focusListeners.begin(); + it != focusListeners.end(); + ++ it) + { + (*it)->focusLost(focusEvent); + } + } + + void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent) + { + Widget *const sourceWidget = focusEvent.getSource(); + + std::list focusListeners + = sourceWidget->_getFocusListeners(); + + // Send the event to all focus listeners of the widget. + for (std::list::const_iterator + it = focusListeners.begin(); + it != focusListeners.end(); + ++ it) + { + (*it)->focusGained(focusEvent); + } + } + + Widget* FocusHandler::getDraggedWidget() + { + return mDraggedWidget; + } + + void FocusHandler::setDraggedWidget(Widget* draggedWidget) + { + mDraggedWidget = draggedWidget; + } + + Widget* FocusHandler::getLastWidgetWithMouse() + { + return mLastWidgetWithMouse; + } + + void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse) + { + mLastWidgetWithMouse = lastWidgetWithMouse; + } + + Widget* FocusHandler::getLastWidgetWithModalFocus() + { + return mLastWidgetWithModalFocus; + } + + void FocusHandler::setLastWidgetWithModalFocus(Widget* widget) + { + mLastWidgetWithModalFocus = widget; + } + + Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() + { + return mLastWidgetWithModalMouseInputFocus; + } + + void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget) + { + mLastWidgetWithModalMouseInputFocus = widget; + } + + Widget* FocusHandler::getLastWidgetPressed() + { + return mLastWidgetPressed; + } + + void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed) + { + mLastWidgetPressed = lastWidgetPressed; + } +} // namespace gcn diff --git a/src/gui/base/focushandler.hpp b/src/gui/base/focushandler.hpp new file mode 100644 index 000000000..aab3f2464 --- /dev/null +++ b/src/gui/base/focushandler.hpp @@ -0,0 +1,417 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_FOCUSHANDLER_HPP +#define GCN_FOCUSHANDLER_HPP + +#include + +#include "gui/base/event.hpp" + +namespace gcn +{ + class Widget; + + /** + * Handles focus for widgets in a Gui. Each Gui has at least one + * focus handler. + * You will probably not use the focus handler directly as Widget + * has functions that automatically uses the active focus handler. + * + * @see Widget::isFocus, Widget::isModalFocused, + * Widget::isModalMouseInputFocused, Widget::requestFocus, + * Widget::requestModalFocus, Widget::requestModalMouseInputFocus, + * Widget::releaseModalFocus, Widget::relaseModalMouseInputFocus, + * Widget::setFocusable, Widget::isFocusable, FocusListener + * + * @since 0.1.0 + */ + class FocusHandler + { + public: + /** + * Constructor. + */ + FocusHandler(); + + A_DELETE_COPY(FocusHandler) + + /** + * Destructor. + */ + virtual ~FocusHandler() + { } + + /** + * Requests focus for a widget. Focus will only be granted to a widget + * if it's focusable and if no other widget has modal focus. + * If a widget receives focus a focus event will be sent to the + * focus listeners of the widget. + * + * @param widget The widget to request focus for. + * @see isFocused, Widget::requestFocus + */ + virtual void requestFocus(Widget* widget); + + /** + * Requests modal focus for a widget. Focus will only be granted + * to a widget if it's focusable and if no other widget has modal + * focus. + * + * @param widget The widget to request modal focus for. + * @throws Exception when another widget already has modal focus. + * @see releaseModalFocus, Widget::requestModalFocus + */ + virtual void requestModalFocus(Widget* widget); + + /** + * Requests modal mouse input focus for a widget. Focus will only + * be granted to a widget if it's focusable and if no other widget + * has modal mouse input focus. + * + * Modal mouse input focus means no other widget then the widget with + * modal mouse input focus will receive mouse input. The widget with + * modal mouse input focus will also receive mouse input no matter what + * the mouse input is or where the mouse input occurs. + * + * @param widget The widget to focus for modal mouse input focus. + * @throws Exception when another widget already has modal mouse input + * focus. + * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus + */ + virtual void requestModalMouseInputFocus(Widget* widget); + + /** + * Releases modal focus if the widget has modal focus. + * If the widget doesn't have modal focus no relase will occur. + * + * @param widget The widget to release modal focus for. + * @see reuqestModalFocus, Widget::releaseModalFocus + */ + virtual void releaseModalFocus(Widget* widget); + + /** + * Releases modal mouse input focus if the widget has modal mouse input + * focus. If the widget doesn't have modal mouse input focus no relase + * will occur. + * + * @param widget the widget to release modal mouse input focus for. + * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus + */ + virtual void releaseModalMouseInputFocus(Widget* widget); + + /** + * Checks if a widget is focused. + * + * @param widget The widget to check. + * @return True if the widget is focused, false otherwise. + * @see Widget::isFocused + */ + virtual bool isFocused(const Widget* widget) const; + + /** + * Gets the widget with focus. + * + * @return The widget with focus. NULL if no widget has focus. + */ + virtual Widget* getFocused() const A_WARN_UNUSED; + + /** + * Gets the widget with modal focus. + * + * @return The widget with modal focus. NULL if no widget has + * modal focus. + */ + virtual Widget* getModalFocused() const A_WARN_UNUSED; + + /** + * Gets the widget with modal mouse input focus. + * + * @return The widget with modal mouse input focus. NULL if + * no widget has modal mouse input focus. + */ + virtual Widget* getModalMouseInputFocused() const A_WARN_UNUSED; + + /** + * Focuses the next widget added to a conainer. + * If no widget has focus the first widget gets focus. The order + * in which the widgets are focused is determined by the order + * they were added to a container. + * + * @see focusPrevious + */ + virtual void focusNext(); + + /** + * Focuses the previous widget added to a contaienr. + * If no widget has focus the first widget gets focus. The order + * in which the widgets are focused is determined by the order + * they were added to a container. + * + * @see focusNext + */ + virtual void focusPrevious(); + + /** + * Adds a widget to by handles by the focus handler. + * + * @param widget The widget to add. + * @see remove + */ + virtual void add(Widget* widget); + + /** + * Removes a widget from the focus handler. + * + * @param widget The widget to remove. + * @see add + */ + virtual void remove(Widget* widget); + + /** + * Focuses nothing. A focus event will also be sent to the + * focused widget's focus listeners if a widget has focus. + */ + virtual void focusNone(); + + /** + * Focuses the next widget which allows tabbing in unless + * the current focused Widget disallows tabbing out. + * + * @see tabPrevious + */ + virtual void tabNext(); + + /** + * Focuses the previous widget which allows tabbing in unless + * current focused widget disallows tabbing out. + * + * @see tabNext + */ + virtual void tabPrevious(); + + /** + * Gets the widget being dragged. Used by the Gui class to + * keep track of the dragged widget. + * + * @return the widget being dragged. + * @see setDraggedWidget + */ + virtual Widget* getDraggedWidget() A_WARN_UNUSED; + + /** + * Sets the widget being dragged. Used by the Gui class to + * keep track of the dragged widget. + * + * @param draggedWidget The widget being dragged. + * @see getDraggedWidget + */ + virtual void setDraggedWidget(Widget* draggedWidget); + + /** + * Gets the last widget with the mouse. Used by the Gui class + * to keep track the last widget with the mouse. + * + * @return The last widget with the mouse. + * @see setLastWidgetWithMouse + */ + virtual Widget* getLastWidgetWithMouse() A_WARN_UNUSED; + + /** + * Sets the last widget with the mouse. Used by the Gui class + * to keep track the last widget with the mouse. + * + * @param lastWidgetWithMouse The last widget with the mouse. + * @see getLastWidgetWithMouse + */ + virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); + + /** + * Gets the last widget with modal focus. + * + * @return The last widget with modal focus. + * @see setLastWidgetWithModalFocus + */ + virtual Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; + + /** + * Sets the last widget with modal focus. + * + * @param widget The last widget with modal focus. + * @see getLastWidgetWithModalFocus + */ + virtual void setLastWidgetWithModalFocus(Widget* widget); + + /** + * Gets the last widget with modal mouse input focus. + * + * @return The last widget with modal mouse input focus. + * @see setLastWidgetWithModalMouseInputFocus + */ + virtual Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; + + /** + * Sets the last widget with modal mouse input focus. + * + * @param widget The last widget with modal mouse input focus. + * @see getLastWidgetWithModalMouseInputFocus + */ + virtual void setLastWidgetWithModalMouseInputFocus(Widget* widget); + + /** + * Gets the last widget pressed. Used by the Gui class to keep track + * of pressed widgets. + * + * @return The last widget pressed. + * @see setLastWidgetPressed + */ + virtual Widget* getLastWidgetPressed() A_WARN_UNUSED; + + /** + * Sets the last widget pressed. Used by the Gui class to keep track + * of pressed widgets. + * + * @param lastWidgetPressed The last widget pressed. + * @see getLastWidgetPressed + */ + virtual void setLastWidgetPressed(Widget* lastWidgetPressed); + + protected: + /** + * Distributes a focus lost event. + * + * @param focusEvent the event to distribute. + * @since 0.7.0 + */ + virtual void distributeFocusLostEvent(const Event& focusEvent); + + /** + * Distributes a focus gained event. + * + * @param focusEvent the event to distribute. + * @since 0.7.0 + */ + virtual void distributeFocusGainedEvent(const Event& focusEvent); + + /** + * Typedef. + */ + typedef std::vector WidgetVector; + + /** + * Typedef. + */ + typedef WidgetVector::iterator WidgetIterator; + + /** + * Holds the widgets currently being handled by the + * focus handler. + */ + WidgetVector mWidgets; + + /** + * Holds the focused widget. NULL if no widget has focus. + */ + Widget* mFocusedWidget; + + /** + * Holds the modal focused widget. NULL if no widget has + * modal focused. + */ + Widget* mModalFocusedWidget; + + /** + * Holds the modal mouse input focused widget. NULL if no widget + * is being dragged. + */ + Widget* mModalMouseInputFocusedWidget; + + /** + * Holds the dragged widget. NULL if no widget is + * being dragged. + */ + Widget* mDraggedWidget; + + /** + * Holds the last widget with the mouse. + */ + Widget* mLastWidgetWithMouse; + + /** + * Holds the last widget with modal focus. + */ + Widget* mLastWidgetWithModalFocus; + + /** + * Holds the last widget with modal mouse input focus. + */ + Widget* mLastWidgetWithModalMouseInputFocus; + + /** + * Holds the last widget pressed. + */ + Widget* mLastWidgetPressed; + }; +} // namespace gcn + +#endif // end GCN_FOCUSHANDLER_HPP diff --git a/src/gui/base/focuslistener.hpp b/src/gui/base/focuslistener.hpp new file mode 100644 index 000000000..f6a7da5ea --- /dev/null +++ b/src/gui/base/focuslistener.hpp @@ -0,0 +1,119 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_FOCUSLISTENER_HPP +#define GCN_FOCUSLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +#include "localconsts.h" + +namespace gcn +{ + /** + * Interface for listening for focus events from widgets. + * + * @see Widget::addFocusListener, Widget::removeFocusListener + * @author Olof Naessén + * @since 0.7.0 + */ + class FocusListener + { + public: + /** + * Destructor. + */ + virtual ~FocusListener() + { } + + /** + * Called when a widget gains focus. + * + * @param event Discribes the event. + */ + virtual void focusGained(const Event& event A_UNUSED) + { } + + /** + * Called when a widget loses focus. + * + * @param event Discribes the event. + */ + virtual void focusLost(const Event& event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of FocusListener, + * therefore its constructor is protected. + */ + FocusListener() + { } + }; +} // namespace gcn + +#endif // end GCN_FOCUSLISTENER_HPP diff --git a/src/gui/base/font.cpp b/src/gui/base/font.cpp new file mode 100644 index 000000000..ccb2f7022 --- /dev/null +++ b/src/gui/base/font.cpp @@ -0,0 +1,87 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/font.hpp" + +#include + +#include "debug.h" + +namespace gcn +{ + int Font::getStringIndexAt(const std::string& text, const int x) const + { + const size_t sz = text.size(); + for (size_t i = 0; i < sz; ++i) + { + if (getWidth(text.substr(0, i)) > x) + return i; + } + + return static_cast(sz); + } +} // namespace gcn diff --git a/src/gui/base/font.hpp b/src/gui/base/font.hpp new file mode 100644 index 000000000..8e8ad18c9 --- /dev/null +++ b/src/gui/base/font.hpp @@ -0,0 +1,133 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_FONT_HPP +#define GCN_FONT_HPP + +#include + +#include "localconsts.h" + +namespace gcn +{ + class Graphics; + + /** + * Interface for a font. + * + * @see ImageFont + */ + class Font + { + public: + /** + * Destructor. + */ + virtual ~Font() + { } + + /** + * Gets the width of a string. The width of a string is not necesserily + * the sum of all the widths of it's glyphs. + * + * @param text The string to return the width of. + * @return The width of a string. + */ + virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0; + + /** + * Gets the height of the glyphs in the font. + * + * @return The height of the glyphs int the font. + */ + virtual int getHeight() const A_WARN_UNUSED = 0; + + /** + * Gets a string index in a string providing an x coordinate. + * Used to retrive a string index (for a character in a + * string) at a certain x position. It is especially useful + * when a mouse clicks in a TextField and you want to know which + * character was clicked. + * + * @return A string index in a string providing an x coordinate. + */ + virtual int getStringIndexAt(const std::string& text, + const int x) const A_WARN_UNUSED; + + /** + * Draws a string. + * + * NOTE: You normally won't use this function to draw text since + * Graphics contains better functions for drawing text. + * + * @param graphics A Graphics object to use for drawing. + * @param text The string to draw. + * @param x The x coordinate where to draw the string. + * @param y The y coordinate where to draw the string. + */ + virtual void drawString(Graphics* graphics, const std::string& text, + int x, int y) = 0; + }; +} // namespace gcn + +#endif // end GCN_FONT_HPP diff --git a/src/gui/base/graphics.cpp b/src/gui/base/graphics.cpp new file mode 100644 index 000000000..229543bc9 --- /dev/null +++ b/src/gui/base/graphics.cpp @@ -0,0 +1,179 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/graphics.hpp" + +#include "gui/base/exception.hpp" +#include "gui/base/font.hpp" +#include "gui/base/image.hpp" + +#include "debug.h" + +namespace gcn +{ + + Graphics::Graphics() : + mClipStack(), + mFont(nullptr) + { + } + + bool Graphics::pushClipArea(Rectangle area) + { + // Ignore area with a negate width or height + // by simple pushing an empty clip area + // to the stack. + if (area.width < 0 || area.height < 0) + { + ClipRectangle carea; + mClipStack.push(carea); + return true; + } + + if (mClipStack.empty()) + { + ClipRectangle carea; + carea.x = area.x; + carea.y = area.y; + carea.width = area.width; + carea.height = area.height; + carea.xOffset = area.x; + carea.yOffset = area.y; + mClipStack.push(carea); + return true; + } + + const ClipRectangle &top = mClipStack.top(); + ClipRectangle carea; + carea = area; + carea.xOffset = top.xOffset + carea.x; + carea.yOffset = top.yOffset + carea.y; + carea.x += top.xOffset; + carea.y += top.yOffset; + + // Clamp the pushed clip rectangle. + if (carea.x < top.x) + carea.x = top.x; + + if (carea.y < top.y) + carea.y = top.y; + + if (carea.x + carea.width > top.x + top.width) + { + carea.width = top.x + top.width - carea.x; + + if (carea.width < 0) + carea.width = 0; + } + + if (carea.y + carea.height > top.y + top.height) + { + carea.height = top.y + top.height - carea.y; + + if (carea.height < 0) + carea.height = 0; + } + + const bool result = carea.isIntersecting(top); + + mClipStack.push(carea); + + return result; + } + + void Graphics::popClipArea() + { + if (mClipStack.empty()) + throw GCN_EXCEPTION("Tried to pop clip area from empty stack."); + + mClipStack.pop(); + } + + const ClipRectangle& Graphics::getCurrentClipArea() + { + if (mClipStack.empty()) + throw GCN_EXCEPTION("The clip area stack is empty."); + + return mClipStack.top(); + } + + void Graphics::drawImage(const Image* image A_UNUSED, + int dstX A_UNUSED, int dstY A_UNUSED) + { + } + +/* + void Graphics::setFont(Font* font) + { + } + + void Graphics::drawText(const std::string& text, int x, int y, + Alignment alignment) + { + } +*/ +} // namespace gcn diff --git a/src/gui/base/graphics.hpp b/src/gui/base/graphics.hpp new file mode 100644 index 000000000..d3128c8ae --- /dev/null +++ b/src/gui/base/graphics.hpp @@ -0,0 +1,294 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_GRAPHICS_HPP +#define GCN_GRAPHICS_HPP + +#include +#include + +#include "gui/base/cliprectangle.hpp" + +namespace gcn +{ + class Color; + class Font; + class Image; + + /** + * Abstract class for providing drawing primitve functions. + * It contains all vital functions for drawing. + * + * Guichan contains implementations of Graphics for common + * libraries like the Allegro library, the HGE library, + * the OpenGL library, the OpenLayer library, and the SDL library. + * To make Guichan usable with other libraries, a Graphics class + * must be implemented. + * + * In Graphics you can set clip areas to limit drawing to certain + * areas of the screen. Clip areas are put on a stack, which + * means that you can push smaller and smaller clip areas onto the + * stack. All coordinates will be relative to the top most clip area. + * In most cases you won't have to worry about the clip areas, + * unless you want to implement some really complex widget. + * Pushing and poping of clip areas are handled automatically by + * container widgets when their child widgets are drawn. + * + * IMPORTANT: Remember to pop each clip area that you pushed on the stack + * after you are done with it. + * + * If you feel that Graphics is to restrictive for your needs, + * there is no one stopping you from using your own code for drawing + * in widgets. You could for instance use pure SDL in the drawing of + * widgets bypassing Graphics. This might however hurt portability of + * your application. + * + * If you implement a Graphics class not present in Guichan we would + * be very happy to add it to Guichan. + * + * @see AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics, + * SDLGraphics, Image + * @since 0.1.0 + */ + class Graphics + { + public: + /** + * Alignments for text drawing. + */ + enum Alignment + { + LEFT = 0, + CENTER, + RIGHT + }; + + /** + * Constructor. + */ + Graphics(); + + A_DELETE_COPY(Graphics) + + /** + * Destructor. + */ + virtual ~Graphics() + { } + + /** + * Initializes drawing. Called by the Gui when Gui::draw() is called. + * It is needed by some implementations of Graphics to perform + * preparations before drawing. An example of such an implementation + * is the OpenGLGraphics. + * + * NOTE: You will never need to call this function yourself, unless + * you use a Graphics object outside of Guichan. + * + * @see _endDraw, Gui::draw + */ + virtual void _beginDraw() + { } + + /** + * Deinitializes drawing. Called by the Gui when a Gui::draw() is done. + * done. It should reset any state changes made by _beginDraw(). + * + * NOTE: You will never need to call this function yourself, unless + * you use a Graphics object outside of Guichan. + * + * @see _beginDraw, Gui::draw + */ + virtual void _endDraw() + { } + + /** + * Pushes a clip area onto the stack. The x and y coordinates in the + * rectangle is relative to the last pushed clip area. + * If the new area falls outside the current clip area, it will be + * clipped as necessary. + * + * If a clip area is outside of the top clip area a clip area with + * zero width and height will be pushed. + * + * @param area The clip area to be pushed onto the stack. + * @return False if the the new area lays outside the current clip + * area. + */ + virtual bool pushClipArea(Rectangle area); + + /** + * Removes the top most clip area from the stack. + * + * @throws Exception if the stack is empty. + */ + virtual void popClipArea(); + + /** + * Gets the current clip area. Usefull if you want to do drawing + * bypassing Graphics. + * + * @return The current clip area. + */ + virtual const ClipRectangle& getCurrentClipArea(); + + /** + * Draws a part of an image. + * + * NOTE: Width and height arguments will not scale the image but + * specifies the size of the part to be drawn. If you want + * to draw the whole image there is a simplified version of + * this function. + * + * EXAMPLE: @code drawImage(myImage, 10, 10, 20, 20, 40, 40); @endcode + * Will draw a rectangular piece of myImage starting at + * coordinate (10, 10) in myImage, with width and height 40. + * The piece will be drawn with it's top left corner at + * coordinate (20, 20). + * + * @param image The image to draw. + * @param srcX The source image x coordinate. + * @param srcY The source image y coordinate. + * @param dstX The destination x coordinate. + * @param dstY The destination y coordinate. + * @param width The width of the piece. + * @param height The height of the piece. + */ + virtual void drawImage(const Image* image, + int srcX, + int srcY, + int dstX, + int dstY, + int width, + int height) = 0; + /** + * Draws an image. A simplified version of the other drawImage. + * It will draw a whole image at the coordinate you specify. + * It is equivalent to calling: + * @code drawImage(myImage, 0, 0, dstX, dstY, image->getWidth(), \ + image->getHeight()); @endcode + */ + virtual void drawImage(const Image* image, int dstX, int dstY); + + /** + * Draws a single point/pixel. + * + * @param x The x coordinate. + * @param y The y coordinate. + */ + virtual void drawPoint(int x, int y) = 0; + + /** + * Ddraws a line. + * + * @param x1 The first x coordinate. + * @param y1 The first y coordinate. + * @param x2 The second x coordinate. + * @param y2 The second y coordinate. + */ + virtual void drawLine(int x1, int y1, int x2, int y2) = 0; + + /** + * Draws a simple, non-filled, rectangle with a one pixel width. + * + * @param rectangle The rectangle to draw. + */ + virtual void drawRectangle(const Rectangle& rectangle) = 0; + + /** + * Draws a filled rectangle. + * + * @param rectangle The filled rectangle to draw. + */ + virtual void fillRectangle(const Rectangle& rectangle) = 0; + + /** + * Sets the color to use when drawing. + * + * @param color A color. + * @see getColor + */ + virtual void setColor(const Color& color) = 0; + + /** + * Gets the color to use when drawing. + * + * @return The color used when drawing. + * @see setColor + */ + virtual const Color& getColor() const = 0; + + protected: + /** + * Holds the clip area stack. + */ + std::stack mClipStack; + + /** + * Holds the current font. + */ + Font* mFont; + }; +} // namespace gcn + +#endif // end GCN_GRAPHICS_HPP diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp new file mode 100644 index 000000000..e4827f716 --- /dev/null +++ b/src/gui/base/gui.cpp @@ -0,0 +1,765 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/gui.hpp" + +#include "gui/base/basiccontainer.hpp" +#include "gui/base/exception.hpp" +#include "gui/base/focushandler.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/input.hpp" +#include "gui/base/keyinput.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/mouseinput.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +#include "debug.h" + +namespace gcn +{ + Gui::Gui() : + mTop(nullptr), + mGraphics(nullptr), + mInput(nullptr), + mFocusHandler(new FocusHandler), + mTabbing(true), + mKeyListeners(), + mShiftPressed(false), + mMetaPressed(false), + mControlPressed(false), + mAltPressed(false), + mLastMousePressButton(0), + mLastMousePressTimeStamp(0), + mLastMouseX(0), + mLastMouseY(0), + mClickCount(1), + mLastMouseDragButton(0), + mWidgetWithMouseQueue() + { + } + + Gui::~Gui() + { + if (Widget::widgetExists(mTop)) + setTop(nullptr); + + delete mFocusHandler; + mFocusHandler = nullptr; + } + + void Gui::setTop(Widget* top) + { + if (mTop) + mTop->_setFocusHandler(nullptr); + if (top) + top->_setFocusHandler(mFocusHandler); + + mTop = top; + } + + Widget* Gui::getTop() const + { + return mTop; + } + + void Gui::setGraphics(Graphics* graphics) + { + mGraphics = graphics; + } + + Graphics* Gui::getGraphics() const + { + return mGraphics; + } + + void Gui::setInput(Input* input) + { + mInput = input; + } + + Input* Gui::getInput() const + { + return mInput; + } + + void Gui::logic() + { + } + + void Gui::draw() + { + } + + void Gui::focusNone() + { + mFocusHandler->focusNone(); + } + + void Gui::setTabbingEnabled(bool tabbing) + { + mTabbing = tabbing; + } + + bool Gui::isTabbingEnabled() + { + return mTabbing; + } + + void Gui::addGlobalKeyListener(KeyListener* keyListener) + { + mKeyListeners.push_back(keyListener); + } + + void Gui::removeGlobalKeyListener(KeyListener* keyListener) + { + mKeyListeners.remove(keyListener); + } + + void Gui::handleMouseInput() + { + } + + void Gui::handleKeyInput() + { + } + + void Gui::handleMouseMoved(const MouseInput& mouseInput) + { + // Check if the mouse leaves the application window. + if (!mWidgetWithMouseQueue.empty() && (mouseInput.getX() < 0 + || mouseInput.getY() < 0 || !mTop->getDimension().isPointInRect( + mouseInput.getX(), mouseInput.getY()))) + { + // Distribute an event to all widgets in the + // "widget with mouse" queue. + while (!mWidgetWithMouseQueue.empty()) + { + Widget *const widget = mWidgetWithMouseQueue.front(); + + if (Widget::widgetExists(widget)) + { + distributeMouseEvent(widget, + MouseEvent::EXITED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY(), + true, + true); + } + + mWidgetWithMouseQueue.pop_front(); + } + + return; + } + + // Check if there is a need to send mouse exited events by + // traversing the "widget with mouse" queue. + bool widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty(); + while (!widgetWithMouseQueueCheckDone) + { + unsigned int iterations = 0; + for (std::deque::iterator + iter = mWidgetWithMouseQueue.begin(); + iter != mWidgetWithMouseQueue.end(); + ++ iter) + { + Widget *const widget = *iter; + + // If a widget in the "widget with mouse queue" doesn't + // exists anymore it should be removed from the queue. + if (!Widget::widgetExists(widget)) + { + mWidgetWithMouseQueue.erase(iter); + break; + } + else + { + int x, y; + widget->getAbsolutePosition(x, y); + + if (x > mouseInput.getX() + || y > mouseInput.getY() + || x + widget->getWidth() <= mouseInput.getX() + || y + widget->getHeight() <= mouseInput.getY() + || !widget->isVisible()) + { + distributeMouseEvent(widget, + MouseEvent::EXITED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY(), + true, + true); + mClickCount = 1; + mLastMousePressTimeStamp = 0; + mWidgetWithMouseQueue.erase(iter); + break; + } + } + + iterations++; + } + + widgetWithMouseQueueCheckDone = + (iterations == mWidgetWithMouseQueue.size()); + } + + // Check all widgets below the mouse to see if they are + // present in the "widget with mouse" queue. If a widget + // is not then it should be added and an entered event should + // be sent to it. + Widget* parent = getMouseEventSource( + mouseInput.getX(), mouseInput.getY()); + Widget* widget = parent; + + // If a widget has modal mouse input focus then it will + // always be returned from getMouseEventSource, but we only wan't to + // send mouse entered events if the mouse has actually entered the + // widget with modal mouse input focus, hence we need to check if + // that's the case. If it's not we should simply ignore to send any + // mouse entered events. + if (mFocusHandler->getModalMouseInputFocused() + && widget == mFocusHandler->getModalMouseInputFocused() + && Widget::widgetExists(widget)) + { + int x, y; + widget->getAbsolutePosition(x, y); + + if (x > mouseInput.getX() || y > mouseInput.getY() + || x + widget->getWidth() <= mouseInput.getX() + || y + widget->getHeight() <= mouseInput.getY()) + { + parent = nullptr; + } + } + + while (parent) + { + parent = widget->getParent(); + + // Check if the widget is present in the "widget with mouse" queue. + bool widgetIsPresentInQueue = false; + FOR_EACH (std::deque::const_iterator, + iter, mWidgetWithMouseQueue) + { + if (*iter == widget) + { + widgetIsPresentInQueue = true; + break; + } + } + + // Widget is not present, send an entered event and add + // it to the "widget with mouse" queue. + if (!widgetIsPresentInQueue + && Widget::widgetExists(widget)) + { + distributeMouseEvent(widget, + MouseEvent::ENTERED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY(), + true, + true); + mWidgetWithMouseQueue.push_front(widget); + } + + const Widget *const swap = widget; + widget = parent; + parent = swap->getParent(); + } + + if (mFocusHandler->getDraggedWidget()) + { + distributeMouseEvent(mFocusHandler->getDraggedWidget(), + MouseEvent::DRAGGED, + mLastMouseDragButton, + mouseInput.getX(), + mouseInput.getY()); + } + else + { + Widget *const sourceWidget = getMouseEventSource( + mouseInput.getX(), mouseInput.getY()); + + distributeMouseEvent(sourceWidget, + MouseEvent::MOVED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + } + } + + void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput) + { + Widget* sourceWidget = getMouseEventSource( + mouseInput.getX(), mouseInput.getY()); + + if (mFocusHandler->getDraggedWidget()) + sourceWidget = mFocusHandler->getDraggedWidget(); + + int sourceWidgetX, sourceWidgetY; + sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); + + distributeMouseEvent(sourceWidget, + MouseEvent::WHEEL_MOVED_DOWN, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + } + + void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput) + { + Widget* sourceWidget = getMouseEventSource( + mouseInput.getX(), mouseInput.getY()); + + if (mFocusHandler->getDraggedWidget()) + sourceWidget = mFocusHandler->getDraggedWidget(); + + int sourceWidgetX, sourceWidgetY; + sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); + + distributeMouseEvent(sourceWidget, + MouseEvent::WHEEL_MOVED_UP, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + } + + Widget* Gui::getWidgetAt(int x, int y) + { + // If the widget's parent has no child then we have found the widget.. + Widget* parent = mTop; + Widget* child = mTop; + + while (child) + { + Widget *const swap = child; + int parentX, parentY; + parent->getAbsolutePosition(parentX, parentY); + child = parent->getWidgetAt(x - parentX, y - parentY); + parent = swap; + } + + return parent; + } + + Widget* Gui::getMouseEventSource(int x, int y) + { + Widget *const widget = getWidgetAt(x, y); + + // +++ possible nullpointer + if (mFocusHandler->getModalMouseInputFocused() + && !widget->isModalMouseInputFocused()) + { + return mFocusHandler->getModalMouseInputFocused(); + } + + return widget; + } + + Widget* Gui::getKeyEventSource() + { + Widget* widget = mFocusHandler->getFocused(); + + // +++ possible nullpointer + while (widget->_getInternalFocusHandler() + && widget->_getInternalFocusHandler()->getFocused()) + { + widget = widget->_getInternalFocusHandler()->getFocused(); + } + + return widget; + } + + void Gui::distributeMouseEvent(Widget* source, + int type, + int button, + int x, + int y, + bool force, + bool toSourceOnly) + { + Widget* parent = source; + Widget* widget = source; + + if (mFocusHandler->getModalFocused() + && !widget->isModalFocused() + && !force) + { + return; + } + + if (mFocusHandler->getModalMouseInputFocused() + && !widget->isModalMouseInputFocused() + && !force) + { + return; + } + + MouseEvent mouseEvent(source, + mShiftPressed, + mControlPressed, + mAltPressed, + mMetaPressed, + type, + button, + x, + y, + mClickCount); + + while (parent) + { + // If the widget has been removed due to input + // cancel the distribution. + if (!Widget::widgetExists(widget)) + break; + + parent = widget->getParent(); + + if (widget->isEnabled() || force) + { + int widgetX, widgetY; + widget->getAbsolutePosition(widgetX, widgetY); + + mouseEvent.mX = x - widgetX; + mouseEvent.mY = y - widgetY; + + std::list mouseListeners + = widget->_getMouseListeners(); + + // Send the event to all mouse listeners of the widget. + for (std::list::const_iterator + it = mouseListeners.begin(); + it != mouseListeners.end(); + ++it) + { + switch (mouseEvent.getType()) + { + case MouseEvent::ENTERED: + (*it)->mouseEntered(mouseEvent); + break; + case MouseEvent::EXITED: + (*it)->mouseExited(mouseEvent); + break; + case MouseEvent::MOVED: + (*it)->mouseMoved(mouseEvent); + break; + case MouseEvent::PRESSED: + (*it)->mousePressed(mouseEvent); + break; + case MouseEvent::RELEASED: + (*it)->mouseReleased(mouseEvent); + break; + case MouseEvent::WHEEL_MOVED_UP: + (*it)->mouseWheelMovedUp(mouseEvent); + break; + case MouseEvent::WHEEL_MOVED_DOWN: + (*it)->mouseWheelMovedDown(mouseEvent); + break; + case MouseEvent::DRAGGED: + (*it)->mouseDragged(mouseEvent); + break; + case MouseEvent::CLICKED: + (*it)->mouseClicked(mouseEvent); + break; + default: + throw GCN_EXCEPTION("Unknown mouse event type."); + } + } + + if (toSourceOnly) + break; + } + + const Widget *const swap = widget; + widget = parent; + parent = swap->getParent(); + + // If a non modal focused widget has been reach + // and we have modal focus cancel the distribution. + if (mFocusHandler->getModalFocused() + && !widget->isModalFocused()) + { + break; + } + + // If a non modal mouse input focused widget has been reach + // and we have modal mouse input focus cancel the distribution. + if (mFocusHandler->getModalMouseInputFocused() + && !widget->isModalMouseInputFocused()) + { + break; + } + } + } + + void Gui::distributeKeyEvent(KeyEvent& keyEvent) + { + Widget* parent = keyEvent.getSource(); + Widget* widget = keyEvent.getSource(); + + if (mFocusHandler->getModalFocused() + && !widget->isModalFocused()) + { + return; + } + + if (mFocusHandler->getModalMouseInputFocused() + && !widget->isModalMouseInputFocused()) + { + return; + } + + while (parent) + { + // If the widget has been removed due to input + // cancel the distribution. + if (!Widget::widgetExists(widget)) + break; + + parent = widget->getParent(); + + if (widget->isEnabled()) + { + std::list keyListeners + = widget->_getKeyListeners(); + + // Send the event to all key listeners of the source widget. + for (std::list::const_iterator + it = keyListeners.begin(); + it != keyListeners.end(); + ++it) + { + switch (keyEvent.getType()) + { + case KeyEvent::PRESSED: + (*it)->keyPressed(keyEvent); + break; + case KeyEvent::RELEASED: + (*it)->keyReleased(keyEvent); + break; + default: + throw GCN_EXCEPTION("Unknown key event type."); + } + } + } + + const Widget *const swap = widget; + widget = parent; + parent = swap->getParent(); + + // If a non modal focused widget has been reach + // and we have modal focus cancel the distribution. + if (mFocusHandler->getModalFocused() + && !widget->isModalFocused()) + { + break; + } + } + } + + void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& keyEvent) + { + for (KeyListenerListIterator it = mKeyListeners.begin(); + it != mKeyListeners.end(); ++ it) + { + switch (keyEvent.getType()) + { + case KeyEvent::PRESSED: + (*it)->keyPressed(keyEvent); + break; + case KeyEvent::RELEASED: + (*it)->keyReleased(keyEvent); + break; + default: + throw GCN_EXCEPTION("Unknown key event type."); + } + + if (keyEvent.isConsumed()) + break; + } + } + + void Gui::handleModalMouseInputFocus() + { + BLOCK_START("Gui::handleModalMouseInputFocus") + // Check if modal mouse input focus has been gained by a widget. + if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() + != mFocusHandler->getModalMouseInputFocused()) + && (!mFocusHandler->getLastWidgetWithModalMouseInputFocus())) + { + handleModalFocusGained(); + mFocusHandler->setLastWidgetWithModalMouseInputFocus( + mFocusHandler->getModalMouseInputFocused()); + } + // Check if modal mouse input focus has been released. + else if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() + != mFocusHandler->getModalMouseInputFocused()) + && (mFocusHandler->getLastWidgetWithModalMouseInputFocus())) + { + handleModalFocusReleased(); + mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr); + } + BLOCK_END("Gui::handleModalMouseInputFocus") + } + + void Gui::handleModalFocus() + { + BLOCK_START("Gui::handleModalFocus") + // Check if modal focus has been gained by a widget. + if ((mFocusHandler->getLastWidgetWithModalFocus() + != mFocusHandler->getModalFocused()) + && (!mFocusHandler->getLastWidgetWithModalFocus())) + { + handleModalFocusGained(); + mFocusHandler->setLastWidgetWithModalFocus( + mFocusHandler->getModalFocused()); + } + // Check if modal focus has been released. + else if ((mFocusHandler->getLastWidgetWithModalFocus() + != mFocusHandler->getModalFocused()) + && (mFocusHandler->getLastWidgetWithModalFocus())) + { + handleModalFocusReleased(); + mFocusHandler->setLastWidgetWithModalFocus(nullptr); + } + BLOCK_END("Gui::handleModalFocus") + } + + void Gui::handleModalFocusGained() + { + // Distribute an event to all widgets in the "widget with mouse" queue. + while (!mWidgetWithMouseQueue.empty()) + { + Widget *const widget = mWidgetWithMouseQueue.front(); + + if (Widget::widgetExists(widget)) + { + distributeMouseEvent(widget, + MouseEvent::EXITED, + mLastMousePressButton, + mLastMouseX, + mLastMouseY, + true, + true); + } + + mWidgetWithMouseQueue.pop_front(); + } + + mFocusHandler->setLastWidgetWithModalMouseInputFocus( + mFocusHandler->getModalMouseInputFocused()); + } + + void Gui::handleModalFocusReleased() + { + // Check all widgets below the mouse to see if they are + // present in the "widget with mouse" queue. If a widget + // is not then it should be added and an entered event should + // be sent to it. + Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY); + Widget* parent = widget; + + while (parent) + { + parent = widget->getParent(); + + // Check if the widget is present in the "widget with mouse" queue. + bool widgetIsPresentInQueue = false; + FOR_EACH (std::deque::const_iterator, + iter, mWidgetWithMouseQueue) + { + if (*iter == widget) + { + widgetIsPresentInQueue = true; + break; + } + } + + // Widget is not present, send an entered event and add + // it to the "widget with mouse" queue. + if (!widgetIsPresentInQueue && Widget::widgetExists(widget)) + { + distributeMouseEvent(widget, + MouseEvent::ENTERED, + mLastMousePressButton, + mLastMouseX, + mLastMouseY, + false, + true); + mWidgetWithMouseQueue.push_front(widget); + } + + const Widget *const swap = widget; + widget = parent; + parent = swap->getParent(); + } + } +} // namespace gcn diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp new file mode 100644 index 000000000..b1daba0fc --- /dev/null +++ b/src/gui/base/gui.hpp @@ -0,0 +1,514 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_GUI_HPP +#define GCN_GUI_HPP + +#include +#include + +#include "gui/base/keyevent.hpp" +#include "gui/base/mouseevent.hpp" +#include "gui/base/mouseinput.hpp" + +namespace gcn +{ + class FocusHandler; + class Graphics; + class Input; + class KeyListener; + class Widget; + + // The following comment will appear in the doxygen main page. + /** + * @mainpage + * @section Introduction + * This documentation is mostly intended as a reference to the API. + * If you want to get started with Guichan, we suggest you check out + * the programs in the examples directory of the Guichan release. + * @n + * @n + * This documentation is, and will always be, work in progress. + * If you find any errors, typos or inconsistencies, or if you feel + * something needs to be explained in more detail - don't hesitate to + * tell us. + */ + + /** + * Contains a Guichan GUI. This is the core class of Guichan to which + * implementations of back ends are passed, to make Guichan work with + * a specific library, and to where the top widget (root widget of GUI) + * is added. If you want to be able to have more then one widget in your + * GUI, the top widget should be a container. + * + * A Gui object cannot work properly without passing back end + * implementations to it. A Gui object must have an implementation of a + * Graphics and an implementation of Input. + * + * NOTE: A complete GUI also must have the ability to load images. + * Images are loaded with the Image class, so to make Guichan + * able to load images an implementation of ImageLoader must be + * passed to Image. + * + * @see Graphics, Input, Image + */ + class Gui + { + public: + /** + * Constructor. + */ + Gui(); + + A_DELETE_COPY(Gui) + + /** + * Destructor. + */ + virtual ~Gui(); + + /** + * Sets the top widget. The top widget is the root widget + * of the GUI. If you want a GUI to be able to contain more + * than one widget the top widget should be a container. + * + * @param top The top widget. + * @see Container + * @since 0.1.0 + */ + virtual void setTop(Widget* top); + + /** + * Gets the top widget. The top widget is the root widget + * of the GUI. + * + * @return The top widget. NULL if no top widget has been set. + * @since 0.1.0 + */ + virtual Widget* getTop() const A_WARN_UNUSED; + + /** + * Sets the graphics object to use for drawing. + * + * @param graphics The graphics object to use for drawing. + * @see getGraphics, AllegroGraphics, HGEGraphics, + * OpenLayerGraphics, OpenGLGraphics, SDLGraphics + * @since 0.1.0 + */ + virtual void setGraphics(Graphics* graphics); + + /** + * Gets the graphics object used for drawing. + * + * @return The graphics object used for drawing. NULL if no + * graphics object has been set. + * @see setGraphics, AllegroGraphics, HGEGraphics, + * OpenLayerGraphics, OpenGLGraphics, SDLGraphics + * @since 0.1.0 + */ + virtual Graphics* getGraphics() const A_WARN_UNUSED; + + /** + * Sets the input object to use for input handling. + * + * @param input The input object to use for input handling. + * @see getInput, AllegroInput, HGEInput, OpenLayerInput, + * SDLInput + * @since 0.1.0 + */ + virtual void setInput(Input* input); + + /** + * Gets the input object being used for input handling. + * + * @return The input object used for handling input. NULL if no + * input object has been set. + * @see setInput, AllegroInput, HGEInput, OpenLayerInput, + * SDLInput + * @since 0.1.0 + */ + virtual Input* getInput() const A_WARN_UNUSED; + + /** + * Performs logic of the GUI. By calling this function all logic + * functions down in the GUI heirarchy will be called. When logic + * is called for Gui, user input will be handled. + * + * @see Widget::logic + * @since 0.1.0 + */ + virtual void logic(); + + /** + * Draws the GUI. By calling this funcion all draw functions + * down in the GUI hierarchy will be called. When draw is called + * the used Graphics object will be initialised and drawing of + * the top widget will commence. + * + * @see Widget::draw + * @since 0.1.0 + */ + virtual void draw(); + + /** + * Focuses none of the widgets in the Gui. + * + * @since 0.1.0 + */ + virtual void focusNone(); + + /** + * Sets tabbing enabled, or not. Tabbing is the usage of + * changing focus by utilising the tab key. + * + * @param tabbing True if tabbing should be enabled, false + * otherwise. + * @see isTabbingEnabled + * @since 0.1.0 + */ + virtual void setTabbingEnabled(bool tabbing); + + /** + * Checks if tabbing is enabled. + * + * @return True if tabbing is enabled, false otherwise. + * @see setTabbingEnabled + * @since 0.1.0 + */ + virtual bool isTabbingEnabled(); + + /** + * Adds a global key listener to the Gui. A global key listener + * will receive all key events generated from the GUI and global + * key listeners will receive the events before key listeners + * of widgets. + * + * @param keyListener The key listener to add. + * @see removeGlobalKeyListener + * @since 0.5.0 + */ + virtual void addGlobalKeyListener(KeyListener* keyListener); + + /** + * Removes global key listener from the Gui. + * + * @param keyListener The key listener to remove. + * @throws Exception if the key listener hasn't been added. + * @see addGlobalKeyListener + * @since 0.5.0 + */ + virtual void removeGlobalKeyListener(KeyListener* keyListener); + + protected: + /** + * Handles all mouse input. + * + * @since 0.6.0 + */ + virtual void handleMouseInput(); + + /** + * Handles key input. + * + * @since 0.6.0 + */ + virtual void handleKeyInput(); + + /** + * Handles mouse moved input. + * + * @param mouseInput The mouse input to handle. + * @since 0.6.0 + */ + virtual void handleMouseMoved(const MouseInput& mouseInput); + + /** + * + * Handles mouse wheel moved down input. + * + * @param mouseInput The mouse input to handle. + * @since 0.6.0 + */ + virtual void handleMouseWheelMovedDown(const MouseInput& mouseInput); + + /** + * Handles mouse wheel moved up input. + * + * @param mouseInput The mouse input to handle. + * @since 0.6.0 + */ + virtual void handleMouseWheelMovedUp(const MouseInput& mouseInput); + + /** + * Handles modal focus. Modal focus needs to be checked at + * each logic iteration as it might be necessary to distribute + * mouse entered or mouse exited events. + * + * @since 0.8.0 + */ + virtual void handleModalFocus(); + + /** + * Handles modal mouse input focus. Modal mouse input focus needs + * to be checked at each logic iteration as it might be necessary to + * distribute mouse entered or mouse exited events. + * + * @since 0.8.0 + */ + virtual void handleModalMouseInputFocus(); + + /** + * Handles modal focus gained. If modal focus has been gained it might + * be necessary to distribute mouse entered or mouse exited events. + * + * @since 0.8.0 + */ + virtual void handleModalFocusGained(); + + /** + * Handles modal mouse input focus gained. If modal focus has been + * gained it might be necessary to distribute mouse entered or mouse + * exited events. + * + * @since 0.8.0 + */ + virtual void handleModalFocusReleased(); + + /** + * Distributes a mouse event. + * + * @param type The type of the event to distribute, + * @param button The button of the event (if any used) to distribute. + * @param x The x coordinate of the event. + * @param y The y coordinate of the event. + * @param fource indicates whether the distribution should be forced or not. + * A forced distribution distributes the event even if a widget + * is not enabled, not visible, another widget has modal + * focus or another widget has modal mouse input focus. + * Default value is false. + * @param toSourceOnly indicates whether the distribution should be to the + * source widget only or to it's parent's mouse listeners + * as well. + * + * @since 0.6.0 + */ + virtual void distributeMouseEvent(Widget* source, + int type, + int button, + int x, + int y, + bool force = false, + bool toSourceOnly = false); + + /** + * Distributes a key event. + * + * @param keyEvent The key event to distribute. + + * @since 0.6.0 + */ + virtual void distributeKeyEvent(KeyEvent& keyEvent); + + /** + * Distributes a key event to the global key listeners. + * + * @param keyEvent The key event to distribute. + * + * @since 0.6.0 + */ + virtual void distributeKeyEventToGlobalKeyListeners(KeyEvent& + keyEvent); + + /** + * Gets the widget at a certain position. + * + * @return The widget at a certain position. + * @since 0.6.0 + */ + virtual Widget* getWidgetAt(int x, int y) A_WARN_UNUSED; + + /** + * Gets the source of the mouse event. + * + * @return The source widget of the mouse event. + * @since 0.6.0 + */ + virtual Widget* getMouseEventSource(int x, int y) A_WARN_UNUSED; + + /** + * Gets the source of the key event. + * + * @return The source widget of the key event. + * @since 0.6.0 + */ + virtual Widget* getKeyEventSource() A_WARN_UNUSED; + + /** + * Holds the top widget. + */ + Widget* mTop; + + /** + * Holds the graphics implementation used. + */ + Graphics* mGraphics; + + /** + * Holds the input implementation used. + */ + Input* mInput; + + /** + * Holds the focus handler for the Gui. + */ + FocusHandler* mFocusHandler; + + /** + * True if tabbing is enabled, false otherwise. + */ + bool mTabbing; + + /** + * Typedef. + */ + typedef std::list KeyListenerList; + + /** + * Typedef. + */ + typedef KeyListenerList::iterator KeyListenerListIterator; + + /** + * Holds the global key listeners of the Gui. + */ + KeyListenerList mKeyListeners; + + /** + * True if shift is pressed, false otherwise. + */ + bool mShiftPressed; + + /** + * True if meta is pressed, false otherwise. + */ + bool mMetaPressed; + + /** + * True if control is pressed, false otherwise. + */ + bool mControlPressed; + + /** + * True if alt is pressed, false otherwise. + */ + bool mAltPressed; + + /** + * Holds the last mouse button pressed. + */ + unsigned int mLastMousePressButton; + + /** + * Holds the last mouse press time stamp. + */ + int mLastMousePressTimeStamp; + + /** + * Holds the last mouse x coordinate. + */ + int mLastMouseX; + + /** + * Holds the last mouse y coordinate. + */ + int mLastMouseY; + + /** + * Holds the current click count. Used to keep track + * of clicks for a the last pressed button. + */ + int mClickCount; + + /** + * Holds the last button used when a drag of a widget + * was initiated. Used to be able to release a drag + * when the same button is released. + */ + int mLastMouseDragButton; + + /** + * Holds a stack with all the widgets with the mouse. + * Used to properly distribute mouse events. + */ + std::deque mWidgetWithMouseQueue; + }; +} // namespace gcn + +#endif // end GCN_GUI_HPP + +/* yakslem - "Women, it's a constant struggle." + * finalman - "Yes, but sometimes they succeed with their guesses." + * yaklsem - "...eh...I was talking about love." + * finalman - "Oh...ok..." + * An awkward silence followed. + */ diff --git a/src/gui/base/image.cpp b/src/gui/base/image.cpp new file mode 100644 index 000000000..01e30dc20 --- /dev/null +++ b/src/gui/base/image.cpp @@ -0,0 +1,83 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/image.hpp" + +#include "gui/base/exception.hpp" + +#include "debug.h" + +namespace gcn +{ + Image::Image() + { + } + + Image::~Image() + { + } +} diff --git a/src/gui/base/image.hpp b/src/gui/base/image.hpp new file mode 100644 index 000000000..c39fe21ab --- /dev/null +++ b/src/gui/base/image.hpp @@ -0,0 +1,162 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_IMAGE_HPP +#define GCN_IMAGE_HPP + +#include + +#include "localconsts.h" + +namespace gcn +{ + class Color; + + /** + * Holds an image. To be able to use this class you must first set an + * ImageLoader in Image by calling + * @code Image::setImageLoader(myImageLoader) @endcode + * The function is static. If this is not done, the constructor taking a + * filename will throw an exception. The ImageLoader you use must be + * compatible with the Graphics object you use. + * + * EXAMPLE: If you use SDLGraphics you should use SDLImageLoader. + * Otherwise your program might crash in a most bizarre way. + * @see AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, + * OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader + * @since 0.1.0 + */ + class Image + { + public: + /** + * Constructor. + */ + Image(); + + /** + * Destructor. + */ + virtual ~Image(); + + /** + * Frees an image. + * + * @since 0.5.0 + */ + virtual void free() = 0; + + /** + * Gets the width of the image. + * + * @return The width of the image. + * + * @since 0.1.0 + */ + virtual int getWidth() const A_WARN_UNUSED = 0; + + /** + * Gets the height of the image. + * + * @return The height of the image. + * + * @since 0.1.0 + */ + virtual int getHeight() const A_WARN_UNUSED = 0; + + /** + * Gets the color of a pixel at coordinate (x, y) in the image. + * + * IMPORTANT: Only guaranteed to work before the image has been + * converted to display format. + * + * @param x The x coordinate. + * @param y The y coordinate. + * @return The color of the pixel. + * + * @since 0.5.0 + */ + virtual Color getPixel(int x, int y) A_WARN_UNUSED = 0; + + /** + * Puts a pixel with a certain color at coordinate (x, y). + * + * @param x The x coordinate. + * @param y The y coordinate. + * @param color The color of the pixel to put. + * @since 0.5.0 + */ + virtual void putPixel(int x, int y, const Color& color) = 0; + + /** + * Converts the image, if possible, to display format. + * + * IMPORTANT: Only guaranteed to work before the image has been + * converted to display format. + * @since 0.5.0 + */ + virtual void convertToDisplayFormat() = 0; + }; +} // namespace gcn + +#endif // end GCN_IMAGE_HPP diff --git a/src/gui/base/input.hpp b/src/gui/base/input.hpp new file mode 100644 index 000000000..71a15ce85 --- /dev/null +++ b/src/gui/base/input.hpp @@ -0,0 +1,134 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_INPUT_HPP +#define GCN_INPUT_HPP + +#include "localconsts.h" + +namespace gcn +{ + class KeyInput; + class MouseInput; + + /** + * Abstract class for providing functions for user input. + * + * Guichan contains implementations of Input for common + * libraries like the Allegro library, the HGE library, + * and the SDL library. + * To make Guichan usable with other libraries, an Input + * class must be implemented. + * + * @see AllegroInput, HGEInput, OpenLayerInput, + * SDLInput + */ + class Input + { + public: + /** + * Destructor. + */ + virtual ~Input(){ } + + /** + * Checks if the key queue is empty, or not. + * + * @return True if the key queue is empty, + * false otherwise. + */ + virtual bool isKeyQueueEmpty() A_WARN_UNUSED = 0; + + /** + * Dequeues the key input queue. + * + * @return The first key input in the key input queue. + */ + virtual KeyInput dequeueKeyInput() = 0; + + /** + * Checks if the mouse queue is empyt, or not. + * + * @return True if the mouse queue is empty, + * false otherwise. + */ + virtual bool isMouseQueueEmpty() A_WARN_UNUSED = 0; + + /** + * Dequeues the mouse input queue. + * + * @return The first mouse input in the mouse input queue. + */ + virtual MouseInput dequeueMouseInput() = 0; + + /** + * Polls all exsisting input. Called when input should + * be polled. The function exists for compatibility reason + * where some libraries need to poll input at a certain + * logic rate. + */ + virtual void _pollInput() = 0; + }; +} // namespace gcn + +#endif // end GCN_INPUT_HPP diff --git a/src/gui/base/inputevent.cpp b/src/gui/base/inputevent.cpp new file mode 100644 index 000000000..3251a102f --- /dev/null +++ b/src/gui/base/inputevent.cpp @@ -0,0 +1,117 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/inputevent.hpp" + +#include "debug.h" + +namespace gcn +{ + InputEvent::InputEvent(Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed) + :Event(source), + mShiftPressed(shiftPressed), + mControlPressed(controlPressed), + mAltPressed(altPressed), + mMetaPressed(metaPressed), + mIsConsumed(false) + { + } + + bool InputEvent::isShiftPressed() const + { + return mShiftPressed; + } + + bool InputEvent::isControlPressed() const + { + return mControlPressed; + } + + bool InputEvent::isAltPressed() const + { + return mAltPressed; + } + + bool InputEvent::isMetaPressed() const + { + return mMetaPressed; + } + + void InputEvent::consume() + { + mIsConsumed = true; + } + + bool InputEvent::isConsumed() const + { + return mIsConsumed; + } +} // namespace gcn diff --git a/src/gui/base/inputevent.hpp b/src/gui/base/inputevent.hpp new file mode 100644 index 000000000..166edf038 --- /dev/null +++ b/src/gui/base/inputevent.hpp @@ -0,0 +1,177 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_INPUTEVENT_HPP +#define GCN_INPUTEVENT_HPP + +#include "gui/base/event.hpp" + +namespace gcn +{ + /** + * Base class for all events concerning input. + * + * @author Olof Naessén + * @since 0.6.0 + */ + class InputEvent: public Event + { + public: + /** + * Constructor. + * + * @param source The source widget of the event. + * @param isShiftPressed True if shift is pressed, false otherwise. + * @param isControlPressed True if control is pressed, false otherwise. + * @param isAltPressed True if alt is pressed, false otherwise. + * @param isMetaPressed True if meta is pressed, false otherwise. + */ + InputEvent(Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed); + + /** + * Checks if shift is pressed. + * + * @return True if shift was pressed at the same time as the key, + * false otherwise. + */ + bool isShiftPressed() const A_WARN_UNUSED; + + /** + * Checks if control is pressed. + * + * @return True if control was pressed at the same time as the key, + * false otherwise. + */ + bool isControlPressed() const A_WARN_UNUSED; + + /** + * Checks if alt is pressed. + * + * @return True if alt was pressed at the same time as the key, + * false otherwise. + */ + bool isAltPressed() const A_WARN_UNUSED; + + /** + * Checks whether meta is pressed. + * + * @return True if meta was pressed at the same time as the key, + * false otherwise. + */ + bool isMetaPressed() const A_WARN_UNUSED; + + /** + * Marks the event as consumed. Input event listeners may discard + * consumed input or act on consumed input. An example of a widget + * that discards consumed input is the ScrollArea widget that + * discards consumed mouse wheel events so the ScrollArea will not + * scroll if for instance a Slider's value inside the ScrollArea was + * changed with the mouse wheel. + * + * @see isConsumed + */ + void consume(); + + /** + * Checks if the input event is consumed. + * + * @return True if the input event is consumed, + * false otherwise. + * @see consume + */ + bool isConsumed() const A_WARN_UNUSED; + + protected: + /** + * True if shift is pressed, false otherwise. + */ + bool mShiftPressed; + + /** + * True if control is pressed, false otherwise. + */ + bool mControlPressed; + + /** + * True if alt is pressed, false otherwise. + */ + bool mAltPressed; + + /** + * True if meta is pressed, false otherwise. + */ + bool mMetaPressed; + + /** + * True if the input event is consumed, + * false otherwise. + */ + bool mIsConsumed; + }; +} // namespace gcn + +#endif // end GCN_INPUTEVENT_HPP diff --git a/src/gui/base/key.cpp b/src/gui/base/key.cpp new file mode 100644 index 000000000..8cf21bdfe --- /dev/null +++ b/src/gui/base/key.cpp @@ -0,0 +1,113 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/key.hpp" + +#include "debug.h" + +namespace gcn +{ + Key::Key(const int value) : + mValue(value) + { + } + + bool Key::isCharacter() const + { + return (mValue >= 32 && mValue <= 126) + || (mValue >= 162 && mValue <= 255) + || (mValue == 9); + } + + bool Key::isNumber() const + { + return mValue >= 48 && mValue <= 57; + } + + bool Key::isLetter() const + { + return (((mValue >= 65 && mValue <= 90) + || (mValue >= 97 && mValue <= 122) + || (mValue >= 192 && mValue <= 255)) + && (mValue != 215) && (mValue != 247)); + } + + int Key::getValue() const + { + return mValue; + } + + bool Key::operator==(const Key& key) const + { + return mValue == key.mValue; + } + + bool Key::operator!=(const Key& key) const + { + return (mValue != key.mValue); + } +} // namespace gcn diff --git a/src/gui/base/key.hpp b/src/gui/base/key.hpp new file mode 100644 index 000000000..46b36a179 --- /dev/null +++ b/src/gui/base/key.hpp @@ -0,0 +1,201 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_KEY_HPP +#define GCN_KEY_HPP + +#include "localconsts.h" + +// windows.h defines DELETE which breaks this file as we have a constant named +// DELETE, hence we undefine DELETE if it is defined and hope people don't use +// that windows define with Guichan. +#if defined (_WIN32) && defined(DELETE) +#undef DELETE +#endif + +namespace gcn +{ + /** + * Represents a key or a character. + */ + class Key final + { + public: + /** + * Constructor. + * + * @param value The ascii or enum value for the key. + */ + explicit Key(const int value = 0); + + /** + * Checks if a key is a character. + * + * @return True if the key is a letter, number or whitespace, + * false otherwise. + */ + bool isCharacter() const A_WARN_UNUSED; + + /** + * Checks if a key is a number. + * + * @return True if the key is a number (0-9), + * false otherwise. + */ + bool isNumber() const A_WARN_UNUSED; + + /** + * Checks if a key is a letter. + * + * @return True if the key is a letter (a-z,A-Z), + * false otherwise. + */ + bool isLetter() const A_WARN_UNUSED; + + /** + * Gets the value of the key. If an ascii value exists it + * will be returned. Otherwise an enum value will be returned. + * + * @return the value of the key. + */ + int getValue() const A_WARN_UNUSED; + + /** + * Compares two keys. + * + * @param key The key to compare this key with. + * @return True if the keys are equal, false otherwise. + */ + bool operator==(const Key& key) const; + + /** + * Compares two keys. + * + * @param key The key to compare this key with. + * @return True if the keys are not equal, false otherwise. + */ + bool operator!=(const Key& key) const; + + /** + * An enum with key values. + */ + enum + { + SPACE = ' ', + TAB = '\t', + ENTER = '\n', + LEFT_ALT = 1000, + RIGHT_ALT, + LEFT_SHIFT, + RIGHT_SHIFT, + LEFT_CONTROL, + RIGHT_CONTROL, + LEFT_META, + RIGHT_META, + LEFT_SUPER, + RIGHT_SUPER, + INSERT, + HOME, + PAGE_UP, + DELETE, + END, + PAGE_DOWN, + ESCAPE, + CAPS_LOCK, + BACKSPACE, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + PRINT_SCREEN, + SCROLL_LOCK, + PAUSE, + NUM_LOCK, + ALT_GR, + LEFT, + RIGHT, + UP, + DOWN + }; + + protected: + /** + * Holds the value of the key. It may be an ascii value + * or an enum value. + */ + int mValue; + }; +} // namespace gcn + +#endif // end GCN_KEY_HPP diff --git a/src/gui/base/keyevent.cpp b/src/gui/base/keyevent.cpp new file mode 100644 index 000000000..35c4f06a5 --- /dev/null +++ b/src/gui/base/keyevent.cpp @@ -0,0 +1,111 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/keyevent.hpp" + +#include "debug.h" + +namespace gcn +{ + KeyEvent::KeyEvent(Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const Key& key) : + InputEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), + mType(type), + mIsNumericPad(numericPad), + mKey(key) + { + } + + KeyEvent::~KeyEvent() + { + } + + unsigned int KeyEvent::getType() const + { + return mType; + } + + bool KeyEvent::isNumericPad() const + { + return mIsNumericPad; + } + + const Key& KeyEvent::getKey() const + { + return mKey; + } +} // namespace gcn diff --git a/src/gui/base/keyevent.hpp b/src/gui/base/keyevent.hpp new file mode 100644 index 000000000..4f2fa05a3 --- /dev/null +++ b/src/gui/base/keyevent.hpp @@ -0,0 +1,157 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_KEYEVENT_HPP +#define GCN_KEYEVENT_HPP + +#include "gui/base/inputevent.hpp" +#include "gui/base/key.hpp" + +namespace gcn +{ + class Widget; + + /** + * Represents a key event. + */ + class KeyEvent: public InputEvent + { + public: + /** + * Key event types. + */ + enum + { + PRESSED = 0, + RELEASED + }; + + /** + * Constructor. + * + * @param source The source widget of the event. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. + * @param type The type of the event. A value from KeyEventType. + * @param numericPad True if the event occured on the numeric pad, + * false otherwise. + * @param key The key of the event. + */ + KeyEvent(Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const Key& key); + + /** + * Destructor. + */ + virtual ~KeyEvent(); + + /** + * Gets the type of the event. + * + * @return The type of the event. + */ + unsigned int getType() const A_WARN_UNUSED; + + /** + * Checks if the key event occured on the numeric pad. + * + * @return True if key event occured on the numeric pad, + * false otherwise. + * + */ + bool isNumericPad() const A_WARN_UNUSED; + + /** + * Gets the key of the event. + * + * @return The key of the event. + */ + const Key& getKey() const A_WARN_UNUSED; + + protected: + /** + * Holds the type of the key event. + */ + unsigned int mType; + + /** + * True if the numeric pad was used, false otherwise. + */ + bool mIsNumericPad; + + /** + * Holds the key of the key event. + */ + Key mKey; + }; +} // namespace gcn + +#endif // end GCN_KEYEVENT_HPP diff --git a/src/gui/base/keyinput.cpp b/src/gui/base/keyinput.cpp new file mode 100644 index 000000000..8b7ff3c8a --- /dev/null +++ b/src/gui/base/keyinput.cpp @@ -0,0 +1,154 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/keyinput.hpp" + +#include "debug.h" + +namespace gcn +{ + KeyInput::KeyInput(const Key& key, unsigned int type) : + mKey(key), + mType(type), + mShiftPressed(false), + mControlPressed(false), + mAltPressed(false), + mMetaPressed(false), + mNumericPad(false) + { + } + + void KeyInput::setType(unsigned int type) + { + mType = type; + } + + int KeyInput::getType() const + { + return mType; + } + + void KeyInput::setKey(const Key& key) + { + mKey = key; + } + + const Key& KeyInput::getKey() const + { + return mKey; + } + + bool KeyInput::isShiftPressed() const + { + return mShiftPressed; + } + + void KeyInput::setShiftPressed(bool pressed) + { + mShiftPressed = pressed; + } + + bool KeyInput::isControlPressed() const + { + return mControlPressed; + } + + void KeyInput::setControlPressed(bool pressed) + { + mControlPressed = pressed; + } + + bool KeyInput::isAltPressed() const + { + return mAltPressed; + } + + void KeyInput::setAltPressed(bool pressed) + { + mAltPressed = pressed; + } + + bool KeyInput::isMetaPressed() const + { + return mMetaPressed; + } + + void KeyInput::setMetaPressed(bool pressed) + { + mMetaPressed = pressed; + } + + bool KeyInput::isNumericPad() const + { + return mNumericPad; + } + + void KeyInput::setNumericPad(bool numpad) + { + mNumericPad = numpad; + } +} // namespace gcn diff --git a/src/gui/base/keyinput.hpp b/src/gui/base/keyinput.hpp new file mode 100644 index 000000000..422d9046c --- /dev/null +++ b/src/gui/base/keyinput.hpp @@ -0,0 +1,289 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_KEYINPUT_HPP +#define GCN_KEYINPUT_HPP + +#include "gui/base/key.hpp" + +namespace gcn +{ + /** + * Internal class that represents key input. Generally you won't have to + * bother using this class unless you implement an Input class for + * a back end. + * + * @since 0.1.0 + */ + class KeyInput + { + public: + /** + * Constructor. + */ + KeyInput() : + mKey(0), + mType(0), + mShiftPressed(false), + mControlPressed(false), + mAltPressed(false), + mMetaPressed(false), + mNumericPad(false) + { } + + /** + * Constructor. + * + * @param key The key of the key input. + * @param type The type of key input. + */ + KeyInput(const Key& key, unsigned int type); + + /** + * Sets the type of the key input. + * + * @param type The type of key input. + * @see getType + */ + void setType(unsigned int type); + + /** + * Gets the type of the key input. + * + * @return the input type. + * @see setType + */ + int getType() const A_WARN_UNUSED; + + /** + * Sets the key of the key input. + * + * @param key The key of the key input. + * @see getKey + */ + void setKey(const Key& key); + + /** + * Gets the key of the key input. + * + * @return The key of the key input. + * @see setKey + */ + const Key& getKey() const A_WARN_UNUSED; + + /** + * Checks if shift is pressed. + * + * @return True if shift was pressed at the same + * time as the key, false otherwise. + * @see setShiftPressed + * @since 0.6.0 + */ + bool isShiftPressed() const A_WARN_UNUSED; + + /** + * Sets shift to be pressed at the same time as the key, + * or not. + * + * @param pressed True if shift is pressed, false otherwise. + * @see isShiftPressed + * @since 0.6.0 + */ + void setShiftPressed(bool pressed); + + /** + * Checks if control is pressed. + * + * @return True if control was pressed at the same + * time as the key, false otherwise. + * @see setControlPressed + * @since 0.6.0 + */ + bool isControlPressed() const A_WARN_UNUSED; + + /** + * Sets control to be pressed at the same time as the key, + * or not. + * + * @param pressed True if control is pressed, false otherwise. + * @see isControlPressed + * @since 0.6.0 + */ + void setControlPressed(bool pressed); + + /** + * Checks if alt is pressed. + * + * @return True if alt was pressed at the same + * time as the key, false otherwise. + * @see setAltPressed + * @since 0.6.0 + */ + bool isAltPressed() const; + + /** + * Sets the alt to be pressed at the same time as the key, + * or not. + * + * @param pressed True if alt is pressed at the same + * time as the key, , false otherwise. + * @see isAltPressed + * @since 0.6.0 + */ + void setAltPressed(bool pressed); + + /** + * Checks if meta is pressed. + * + * @return True if meta was pressed at the same + * time as the key, false otherwise. + * @see setMetaPressed + * @since 0.6.0 + */ + bool isMetaPressed() const A_WARN_UNUSED; + + /** + * Sets meta to be pressed at the same time as the key, + * or not. + * + * @param pressed True if meta is pressed at the same + * time as the key, false otherwise. + * @see isMetaPressed + * @since 0.6.0 + */ + void setMetaPressed(bool pressed); + + /** + * Checks if the key was pressed at the numeric pad. + * + * @return True if key pressed at the numeric pad, + * false otherwise. + * @setNumericPad + * @since 0.6.0 + */ + bool isNumericPad() const A_WARN_UNUSED; + + /** + * Sets the key to be pressed at the numeric pad. + * + * @param numpad True if the key was pressed at the numeric + * pad, false otherwise. + * @see isNumericPad + * @since 0.6.0 + */ + void setNumericPad(bool numpad); + + /** + * Key input types. This enum corresponds to the enum with event + * types on KeyEvent for easy mapping. + */ + enum + { + PRESSED = 0, + RELEASED + }; + + protected: + /** + * Holds the key of the key input. + */ + Key mKey; + + /** + * Holds the type of the key input. + */ + unsigned int mType; + + /** + * True if shift was pressed at the same time as the key, + * false otherwise. + */ + bool mShiftPressed; + + /** + * True if control was pressed at the same time as the key, + * false otherwise. + */ + bool mControlPressed; + + /** + * True if alt was pressed at the same time as the key, + * false otherwise. + */ + bool mAltPressed; + + /** + * True if meta was pressed at the same time as the key, + * false otherwise. + */ + bool mMetaPressed; + + /** + * True if the numeric pad was used when the key was pressed, + * false otherwise. + */ + bool mNumericPad; + }; +} // namespace gcn + +#endif // end GCN_KEYINPUT_HPP diff --git a/src/gui/base/keylistener.hpp b/src/gui/base/keylistener.hpp new file mode 100644 index 000000000..088a937a6 --- /dev/null +++ b/src/gui/base/keylistener.hpp @@ -0,0 +1,119 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_KEYLISTENER_HPP +#define GCN_KEYLISTENER_HPP + +#include "gui/base/keyevent.hpp" + +#include "localconsts.h" + +namespace gcn +{ + class Key; + + /** + * Interface for listening for key events from widgets. + * + * @see Widget::addKeyListener, Widget::removeKeyListener + */ + class KeyListener + { + public: + /** + * Destructor. + */ + virtual ~KeyListener() + { } + + /** + * Called if a key is pressed when the widget has keyboard focus. + * If a key is held down the widget will generate multiple key + * presses. + * + * @param keyEvent Discribes the event. + */ + virtual void keyPressed(KeyEvent& keyEvent A_UNUSED) + { } + + /** + * Called if a key is released when the widget has keyboard focus. + * + * @param keyEvent Discribes the event. + */ + virtual void keyReleased(KeyEvent& keyEvent A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of KeyListener, + * therefore its constructor is protected. + */ + KeyListener() + { } + }; +} // namespace gcn + +#endif // end GCN_KEYLISTENER_HPP diff --git a/src/gui/base/listmodel.hpp b/src/gui/base/listmodel.hpp new file mode 100644 index 000000000..4b98f46fe --- /dev/null +++ b/src/gui/base/listmodel.hpp @@ -0,0 +1,106 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_LISTMODEL_HPP +#define GCN_LISTMODEL_HPP + +#include + +#include "localconsts.h" + +namespace gcn +{ + /** + * An interface for a model that represents a list. It is + * used in certain widgets, like the ListBox, to handle a + * lists with string elements. If you want to use widgets + * like ListBox, make a derived class from this class that + * represents your list. + */ + class ListModel + { + public: + /** + * Destructor. + */ + virtual ~ListModel() + { } + + /** + * Gets the number of elements in the list. + * + * @return The number of elements in the list + */ + virtual int getNumberOfElements() A_WARN_UNUSED = 0; + + /** + * Gets an element at a certain index in the list. + * + * @param i An index in the list. + * @return An element as a string at the a certain index. + */ + virtual std::string getElementAt(int i) A_WARN_UNUSED = 0; + }; +} // namespace gcn + +#endif // end GCN_LISTMODEL_HPP diff --git a/src/gui/base/mouseevent.cpp b/src/gui/base/mouseevent.cpp new file mode 100644 index 000000000..653974a83 --- /dev/null +++ b/src/gui/base/mouseevent.cpp @@ -0,0 +1,121 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/mouseevent.hpp" + +#include "debug.h" + +namespace gcn +{ + MouseEvent::MouseEvent(Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const unsigned int button, + const int x, + const int y, + const int clickCount) : + InputEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), + mType(type), + mButton(button), + mX(x), + mY(y), + mClickCount(clickCount) + { + } + + unsigned int MouseEvent::getButton() const + { + return mButton; + } + + int MouseEvent::getX() const + { + return mX; + } + + int MouseEvent::getY() const + { + return mY; + } + + int MouseEvent::getClickCount() const + { + return mClickCount; + } + + unsigned int MouseEvent::getType() const + { + return mType; + } +} // namespace gcn diff --git a/src/gui/base/mouseevent.hpp b/src/gui/base/mouseevent.hpp new file mode 100644 index 000000000..93c1fc0a7 --- /dev/null +++ b/src/gui/base/mouseevent.hpp @@ -0,0 +1,217 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_MOUSEEVENT_HPP +#define GCN_MOUSEEVENT_HPP + +#include "gui/base/inputevent.hpp" + +namespace gcn +{ + class Gui; + class Widget; + + /** + * Represents a mouse event. + * + * @author Olof Naessén + * @since 0.6.0 + */ + class MouseEvent: public InputEvent + { + public: + /** + * Constructor. + * + * @param source The source widget of the mouse event. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. + * @param type The type of the mouse event. + * @param button The button of the mouse event. + * @param x The x coordinate of the event relative to the source widget. + * @param y The y coordinate of the event relative the source widget. + * @param clickCount The number of clicks generated with the same button. + * It's set to zero if another button is used. + */ + MouseEvent(Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const unsigned int button, + const int x, + const int y, + const int clickCount); + + /** + * Gets the button of the mouse event. + * + * @return The button of the mouse event. + */ + unsigned int getButton() const A_WARN_UNUSED; + + /** + * Gets the x coordinate of the mouse event. + * The coordinate relative to widget the mouse listener + * receiving the events have registered to. + * + * @return The x coordinate of the mouse event. + * @see Widget::addMouseListener, Widget::removeMouseListener + */ + int getX() const A_WARN_UNUSED; + + /** + * Gets the y coordinate of the mouse event. + * The coordinate relative to widget the mouse listener + * receiving the events have registered to. + * + * @return The y coordinate of the mouse event. + * @see Widget::addMouseListener, Widget::removeMouseListener + */ + int getY() const A_WARN_UNUSED; + + /** + * Gets the number of clicks generated with the same button. + * It's set to zero if another button is used. + * + * @return The number of clicks generated with the same button. + */ + int getClickCount() const A_WARN_UNUSED; + + /** + * Gets the type of the event. + * + * @return The type of the event. + */ + unsigned int getType() const A_WARN_UNUSED; + + /** + * Mouse event types. + */ + enum + { + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP, + CLICKED, + ENTERED, + EXITED, + DRAGGED + }; + + /** + * Mouse button types. + */ + enum + { + EMPTY = 0, + LEFT, + RIGHT, + MIDDLE + }; + + protected: + /** + * Holds the type of the mouse event. + */ + unsigned int mType; + + /** + * Holds the button of the mouse event. + */ + unsigned int mButton; + + /** + * Holds the x-coordinate of the mouse event. + */ + int mX; + + /** + * Holds the y-coordinate of the mouse event. + */ + int mY; + + /** + * The number of clicks generated with the same button. + * It's set to zero if another button is used. + */ + int mClickCount; + + /** + * Gui is a friend of this class in order to be able to manipulate + * the protected member variables of this class and at the same time + * keep the MouseEvent class as const as possible. Gui needs to + * update the x och y coordinates for the coordinates to be relative + * to widget the mouse listener receiving the events have registered + * to. + */ + friend class Gui; + }; +} // namespace gcn + +#endif // GCN_MOUSEEVENT_HPP diff --git a/src/gui/base/mouseinput.cpp b/src/gui/base/mouseinput.cpp new file mode 100644 index 000000000..bc5d6c8e0 --- /dev/null +++ b/src/gui/base/mouseinput.cpp @@ -0,0 +1,136 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + MouseInput::MouseInput(const unsigned int button, + const unsigned int type, + const int x, + const int y, + const int timeStamp) : + mType(type), + mButton(button), + mTimeStamp(timeStamp), + mX(x), + mY(y) + { + } + + void MouseInput::setType(unsigned int type) + { + mType = type; + } + + unsigned int MouseInput::getType() const + { + return mType; + } + + void MouseInput::setButton(unsigned int button) + { + mButton = button; + } + + unsigned int MouseInput::getButton() const + { + return mButton; + } + + int MouseInput::getTimeStamp() const + { + return mTimeStamp; + } + + void MouseInput::setTimeStamp(int timeStamp) + { + mTimeStamp = timeStamp; + } + + void MouseInput::setX(int x) + { + mX = x; + } + + int MouseInput::getX() const + { + return mX; + } + + void MouseInput::setY(int y) + { + mY = y; + } + + int MouseInput::getY() const + { + return mY; + } +} // namespace gcn diff --git a/src/gui/base/mouseinput.hpp b/src/gui/base/mouseinput.hpp new file mode 100644 index 000000000..018205740 --- /dev/null +++ b/src/gui/base/mouseinput.hpp @@ -0,0 +1,260 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_MOUSEINPUT_HPP +#define GCN_MOUSEINPUT_HPP + +#include "localconsts.h" + +namespace gcn +{ + + /** + * Internal class that represents mouse input. Generally you won't have to + * bother using this class unless you implement an Input class for + * a back end. + * + * @author Olof Naessén + * @author Per Larsson + * @since 0.1.0 + */ + class MouseInput + { + public: + /** + * Constructor. + */ + MouseInput() : + mType(0), + mButton(0), + mTimeStamp(0), + mX(0), + mY(0) + { } + + /** + * Constructor. + * + * @param button The button pressed. + * @param type The type of mouse input. + * @param x The mouse x coordinate. + * @param y The mouse y coordinate. + * @param timeStamp The timestamp of the mouse input. Used to + * check for double clicks. + */ + MouseInput(const unsigned int button, + const unsigned int type, + const int x, + const int y, + const int timeStamp); + + /** + * Sets the type of the mouse input. + * + * @param type The type of the mouse input. Should be a value from the + * mouse event type enum + * @see getType + * @since 0.1.0 + */ + void setType(unsigned int type); + + /** + * Gets the type of the mouse input. + * + * @return The type of the mouse input. A value from the mouse event + * type enum. + * @see setType + * @since 0.1.0 + */ + unsigned int getType() const A_WARN_UNUSED; + + /** + * Sets the button pressed. + * + * @param button The button pressed. Should be one of the values + * in the mouse event button enum. + * @see getButton. + * @since 0.1.0 + */ + void setButton(unsigned int button); + + /** + * Gets the button pressed. + * + * @return The button pressed. A value from the mouse event + * button enum. + * @see setButton + * @since 0.1.0 + */ + unsigned int getButton() const A_WARN_UNUSED; + + /** + * Sets the timestamp for the mouse input. + * Used to check for double clicks. + * + * @param timeStamp The timestamp of the mouse input. + * @see getTimeStamp + * @since 0.1.0 + */ + void setTimeStamp(int timeStamp); + + /** + * Gets the time stamp of the input. + * Used to check for double clicks. + * + * @return The time stamp of the mouse input. + * @see setTimeStamp + * @since 0.1.0 + */ + int getTimeStamp() const A_WARN_UNUSED; + + /** + * Sets the x coordinate of the mouse input. + * + * @param x The x coordinate of the mouse input. + * @see getX + * @since 0.6.0 + */ + void setX(int x); + + /** + * Gets the x coordinate of the mouse input. + * + * @return The x coordinate of the mouse input. + * @see setX + * @since 0.6.0 + */ + int getX() const A_WARN_UNUSED; + + /** + * Sets the y coordinate of the mouse input. + * + * @param y The y coordinate of the mouse input. + * @see getY + * @since 0.6.0 + */ + void setY(int y); + + /** + * Gets the y coordinate of the mouse input. + * + * @return The y coordinate of the mouse input. + * @see setY + * @since 0.6.0 + */ + int getY() const A_WARN_UNUSED; + + /** + * Mouse input event types. This enum partially corresponds + * to the enum with event types in MouseEvent for easy mapping. + */ + enum + { + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP + }; + + /** + * Mouse button types. + */ + enum + { + EMPTY = 0, + LEFT, + RIGHT, + MIDDLE + }; + + protected: + /** + * Holds the type of the mouse input. + */ + unsigned int mType; + + /** + * Holds the button of the mouse input. + */ + unsigned int mButton; + + /** + * Holds the timestamp of the mouse input. Used to + * check for double clicks. + */ + int mTimeStamp; + + /** + * Holds the x coordinate of the mouse input. + */ + int mX; + + /** + * Holds the y coordinate of the mouse input. + */ + int mY; + }; +} // namespace gcn + +#endif // end GCN_MOUSEINPUT_HPP diff --git a/src/gui/base/mouselistener.hpp b/src/gui/base/mouselistener.hpp new file mode 100644 index 000000000..32486e56f --- /dev/null +++ b/src/gui/base/mouselistener.hpp @@ -0,0 +1,196 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_MOUSELISTENER_HPP +#define GCN_MOUSELISTENER_HPP + +#include "gui/base/mouseevent.hpp" + +#include "localconsts.h" + +namespace gcn +{ + /** + * Interface for listening for mouse events from widgets. + * + * @see Widget::addMouseListener, Widget::removeMouseListener + * @since 0.1.0 + */ + class MouseListener + { + public: + /** + * Destructor. + */ + virtual ~MouseListener() + { } + + /** + * Called when the mouse has entered into the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseEntered(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has exited the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseExited(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button has been pressed on the widget area. + * + * NOTE: A mouse press is NOT equal to a mouse click. + * Use mouseClickMessage to check for mouse clicks. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mousePressed(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button has been released on the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseReleased(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button is pressed and released (clicked) on + * the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseClicked(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse wheel has moved up on the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseWheelMovedUp(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse wheel has moved down on the widget area. + * + * @param mousEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseWheelMovedDown(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has moved in the widget area and no mouse button + * has been pressed (i.e no widget is being dragged). + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseMoved(MouseEvent& mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has moved and the mouse has previously been + * pressed on the widget. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseDragged(MouseEvent& mouseEvent A_UNUSED) + { + } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of MouseListener, + * therefore its constructor is protected. + */ + MouseListener() + { } + }; +} // namespace gcn + +#endif // end GCN_MOUSELISTENER_HPP diff --git a/src/gui/base/rectangle.cpp b/src/gui/base/rectangle.cpp new file mode 100644 index 000000000..a29069b18 --- /dev/null +++ b/src/gui/base/rectangle.cpp @@ -0,0 +1,156 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/rectangle.hpp" + +#include "debug.h" + +namespace gcn +{ + Rectangle::Rectangle() + : x(0), + y(0), + width(0), + height(0) + { + } + + Rectangle::Rectangle(const int x_, const int y_, + const int width_, const int height_) : + x(x_), + y(y_), + width(width_), + height(height_) + { + } + + void Rectangle::setAll(int x_, int y_, int width_, int height_) + { + x = x_; + y = y_; + width = width_; + height = height_; + } + + bool Rectangle::isIntersecting(const Rectangle& rectangle) const + { + int x_ = x; + int y_ = y; + int width_ = width; + int height_ = height; + + x_ -= rectangle.x; + y_ -= rectangle.y; + + if (x_ < 0) + { + width_ += x_; +// x_ = 0; + } + else if (x_ + width_ > rectangle.width) + { + width_ = rectangle.width - x_; + } + + if (y_ < 0) + { + height_ += y_; +// y_ = 0; + } + else if (y_ + height_ > rectangle.height) + { + height_ = rectangle.height - y_; + } + + if (width_ <= 0 || height_ <= 0) + { + return false; + } + + return true; + } + + bool Rectangle::isPointInRect(int x_, int y_) const + { + return x_ >= x + && y_ >= y + && x_ < x + width + && y_ < y + height; + } + + std::ostream& operator<<(std::ostream& out, + const Rectangle& rectangle) + { + out << "Rectangle [x = " << rectangle.x + << ", y = " << rectangle.y + << ", width = " << rectangle.width + << ", height = " << rectangle.height + << "]"; + + return out; + } +} // namespace gcn diff --git a/src/gui/base/rectangle.hpp b/src/gui/base/rectangle.hpp new file mode 100644 index 000000000..b8503db98 --- /dev/null +++ b/src/gui/base/rectangle.hpp @@ -0,0 +1,159 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_RECTANGLE_HPP +#define GCN_RECTANGLE_HPP + +#include + +#include "localconsts.h" + +namespace gcn +{ + /** + * Represents a rectangle. + * + * @since 0.1.0 + */ + class Rectangle + { + public: + /** + * Constructor. The default rectangle is an empty rectangle + * at the coordinates (0,0). + */ + Rectangle(); + + /** + * Constructor. + * + * @param x The x coordinate of the rectangle. + * @param y The y coordinate of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @since 0.1.0 + */ + Rectangle(const int x, const int y, const int width, const int height); + + /** + * Sets the dimension of a rectangle. + * + * @param x The x coordinate of the rectangle. + * @param y The y coordinate of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @since 0.1.0 + */ + void setAll(int x, int y, int width, int height); + + /** + * Checks if another rectangle intersects with the rectangle. + * + * @param rectangle Another rectangle to check for intersection. + * @return True if the rectangles intersect, false otherwise. + * @since 0.1.0 + */ + bool isIntersecting(const Rectangle& rectangle) const A_WARN_UNUSED; + + /** + * Checks if a point is inside the rectangle + * + * @param x The x coordinate of the point. + * @param y The y coordinate of the point. + * @return True if the point is inside the rectangle. + * @since 0.1.0 + */ + bool isPointInRect(int x, int y) const A_WARN_UNUSED; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param rectangle The rectangle to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Rectangle& rectangle); + + /** + * Holds the x coordinate of the rectangle. + */ + int x; + + /** + * Holds the x coordinate of the rectangle. + */ + int y; + + /** + * Holds the width of the rectangle. + */ + int width; + + /** + * Holds the height of the rectangle. + */ + int height; + }; +} // namespace gcn + +#endif // end GCN_RECTANGEL_HPP diff --git a/src/gui/base/sdl/sdlpixel.hpp b/src/gui/base/sdl/sdlpixel.hpp new file mode 100644 index 000000000..06a22f65f --- /dev/null +++ b/src/gui/base/sdl/sdlpixel.hpp @@ -0,0 +1,306 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_SDLPIXEL_HPP +#define GCN_SDLPIXEL_HPP + +#include "SDL.h" +#include "gui/base/color.hpp" + +namespace gcn +{ + + /** + * Checks a pixels color of an SDL_Surface. + * + * @param surface an SDL_Surface where to check for a pixel color. + * @param x the x coordinate on the surface. + * @param y the y coordinate on the surface. + * @return a color of a pixel. + */ + inline const Color SDLgetPixel(SDL_Surface* surface, int x, int y) + { + if (!surface) + return Color(0, 0, 0, 0); + + int bpp = surface->format->BytesPerPixel; + + SDL_LockSurface(surface); + + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; + + unsigned int color = 0; + + switch (bpp) + { + case 1: + color = *p; + break; + + case 2: + color = *reinterpret_cast(p); + break; + + case 3: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + color = p[0] << 16 | p[1] << 8 | p[2]; +#else + color = p[0] | p[1] << 8 | p[2] << 16; +#endif + break; + + case 4: + color = *reinterpret_cast(p); + break; + + default: + color = *p; + break; + } + + unsigned char r, g, b, a; + + SDL_GetRGBA(color, surface->format, &r, &g, &b, &a); + SDL_UnlockSurface(surface); + + return Color(r, g, b, a); + } + + /** + * Puts a pixel on an SDL_Surface. + * + * @param x the x coordinate on the surface. + * @param y the y coordinate on the surface. + * @param color the color the pixel should be in. + */ + inline void SDLputPixel(SDL_Surface* surface, int x, int y, + const Color& color) + { + if (!surface) + return; + + int bpp = surface->format->BytesPerPixel; + + SDL_LockSurface(surface); + + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; + + Uint32 pixel = SDL_MapRGB(surface->format, + static_cast(color.r), static_cast(color.g), + static_cast(color.b)); + + switch (bpp) + { + case 1: + *p = static_cast(pixel); + break; + + case 2: + *reinterpret_cast(p) = static_cast(pixel); + break; + + case 3: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + p[0] = static_cast((pixel >> 16) & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast((pixel) & 0xff); +#else + p[0] = static_cast((pixel) & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast((pixel >> 16) & 0xff); +#endif + break; + + case 4: + *reinterpret_cast(p) = pixel; + break; + + default: + break; + } + + SDL_UnlockSurface(surface); + } + + /** + * Blends two 32 bit colors together. + * + * @param src the source color. + * @param dst the destination color. + * @param a alpha. + */ + inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, + unsigned char a) + { + unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8; + unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) + * (255 - a)) >> 8; + unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) + * (255 - a)) >> 8; + + return (b & 0xff) | (g & 0xff00) | (r & 0xff0000); + } + + /** + * Blends two 16 bit colors together. + * + * @param src the source color. + * @param dst the destination color. + * @param a alpha. + */ + inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, + unsigned char a, const SDL_PixelFormat *f) + { + unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask) + * (255 - a)) >> 8; + unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask) + * (255 - a)) >> 8; + unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) + * (255 - a)) >> 8; + + return static_cast((b & f->Rmask) + | (g & f->Gmask) | (r & f->Bmask)); + } + + /* + typedef struct{ + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint32 Rmask, Gmask, Bmask, Amask; + Uint8 Rshift, Gshift, Bshift, Ashift; + Uint8 Rloss, Gloss, Bloss, Aloss; + Uint32 colorkey; + Uint8 alpha; + } SDL_PixelFormat; + */ + + /** + * Puts a pixel on an SDL_Surface with alpha + * + * @param x the x coordinate on the surface. + * @param y the y coordinate on the surface. + * @param color the color the pixel should be in. + */ + inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, + const Color& color) + { + int bpp = surface->format->BytesPerPixel; + + SDL_LockSurface(surface); + + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; + + Uint32 pixel = SDL_MapRGB(surface->format, + static_cast(color.r), + static_cast(color.g), + static_cast(color.b)); + + switch (bpp) + { + case 1: + *p = static_cast(pixel); + break; + + case 2: + *reinterpret_cast(p) = SDLAlpha16( + static_cast(pixel), + *reinterpret_cast(p), + static_cast(color.a), surface->format); + break; + + case 3: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + p[2] = static_cast((p[2] * (255 - color.a) + + color.b * color.a) >> 8); + p[1] = static_cast((p[1] * (255 - color.a) + + color.g * color.a) >> 8); + p[0] = static_cast((p[0] * (255 - color.a) + + color.r * color.a) >> 8); +#else + p[0] = static_cast((p[0] * (255 - color.a) + + color.b * color.a) >> 8); + p[1] = static_cast((p[1] * (255 - color.a) + + color.g * color.a) >> 8); + p[2] = static_cast((p[2] * (255 - color.a) + + color.r * color.a) >> 8); +#endif + break; + + case 4: + *reinterpret_cast(p) = SDLAlpha32(pixel, + *reinterpret_cast(p), + static_cast(color.a)); + break; + default: + break; + } + + SDL_UnlockSurface(surface); + } +} // namespace gcn + +#endif // end GCN_SDLPIXEL_HPP diff --git a/src/gui/base/selectionevent.cpp b/src/gui/base/selectionevent.cpp new file mode 100644 index 000000000..04318be06 --- /dev/null +++ b/src/gui/base/selectionevent.cpp @@ -0,0 +1,82 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/selectionevent.hpp" + +#include "debug.h" + +namespace gcn +{ + SelectionEvent::SelectionEvent(Widget *const source) : + Event(source) + { + } + + SelectionEvent::~SelectionEvent() + { + } +} // namespace gcn diff --git a/src/gui/base/selectionevent.hpp b/src/gui/base/selectionevent.hpp new file mode 100644 index 000000000..543b3a9ad --- /dev/null +++ b/src/gui/base/selectionevent.hpp @@ -0,0 +1,98 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_SELECTIONEVENT_HPP +#define GCN_SELECTIONEVENT_HPP + +#include "gui/base/event.hpp" + +#include "localconsts.h" + +namespace gcn +{ + class Widget; + + /** + * Represents a selection event. + * + * @author Olof Naessén + * @since 0.8.0 + */ + class SelectionEvent final: public Event + { + public: + /** + * Constructor. + * + * @param source source The widget of the selection event. + */ + explicit SelectionEvent(Widget *const source); + + /** + * Destructor. + */ + virtual ~SelectionEvent(); + }; +} // namespace gcn + +#endif // end GCN_SELECTIONEVENT_HPP diff --git a/src/gui/base/selectionlistener.hpp b/src/gui/base/selectionlistener.hpp new file mode 100644 index 000000000..b1a4d73ba --- /dev/null +++ b/src/gui/base/selectionlistener.hpp @@ -0,0 +1,117 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_SELECTIONLISTENER_HPP +#define GCN_SELECTIONLISTENER_HPP + +#include + +#include "gui/base/selectionevent.hpp" + +#include "localconsts.h" + +namespace gcn +{ + /** + * Interface for listening for selection events from widgets. + * + * @see ListBox::addSelectionListener, + * ListBox::removeSelectionListener, + * DropDown::addSelectionListener, + * DropDown::removeSelectionListener + * @author Olof Naessén + * @since 0.8.0 + */ + class SelectionListener + { + public: + /** + * Destructor. + */ + virtual ~SelectionListener() + { } + + /** + * Called when the value of a selection has been changed in a Widget. + * It is used to be able to recieve a notification that a value has + * been changed. + * + * @param event The event of the value change. + * @since 0.8.0 + */ + virtual void valueChanged(const SelectionEvent& event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of SelectionListener, + * therefore its constructor is protected. + */ + SelectionListener() + { } + }; +} // namespace gcn + +#endif // end GCN_SELECTIONLISTENER_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp new file mode 100644 index 000000000..2e8719446 --- /dev/null +++ b/src/gui/base/widget.cpp @@ -0,0 +1,695 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widget.hpp" + +#include "gui/base/actionevent.hpp" +#include "gui/base/actionlistener.hpp" +#include "gui/base/basiccontainer.hpp" +#include "gui/base/deathlistener.hpp" +#include "gui/base/event.hpp" +#include "gui/base/exception.hpp" +#include "gui/base/focushandler.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/keyinput.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/mouseinput.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widgetlistener.hpp" + +#include "debug.h" + +namespace gcn +{ + Font* Widget::mGlobalFont = nullptr; + std::list Widget::mWidgets; + std::set Widget::mWidgetsSet; + + Widget::Widget() : + mMouseListeners(), + mKeyListeners(), + mActionListeners(), + mDeathListeners(), + mFocusListeners(), + mWidgetListeners(), + mForegroundColor(0x000000), + mBackgroundColor(0xffffff), + mBaseColor(0x808090), + mSelectionColor(0xc3d9ff), + mFocusHandler(nullptr), + mInternalFocusHandler(nullptr), + mParent(nullptr), + mDimension(), + mFrameSize(0), + mActionEventId(), + mFocusable(false), + mVisible(true), + mTabIn(true), + mTabOut(true), + mEnabled(true), + mId(), + mCurrentFont(nullptr) + { + mWidgets.push_back(this); + mWidgetsSet.insert(this); + } + + Widget::~Widget() + { + for (DeathListenerIterator iter = mDeathListeners.begin(); + iter != mDeathListeners.end(); + ++iter) + { + Event event(this); + (*iter)->death(event); + } + + _setFocusHandler(nullptr); + + mWidgets.remove(this); + mWidgetsSet.erase(this); + } + + void Widget::drawFrame(Graphics* graphics) + { + BLOCK_START("Widget::drawFrame") + const Color &faceColor = getBaseColor(); + Color highlightColor = faceColor + Color(0x303030); + Color shadowColor = faceColor - Color(0x303030); + const int alpha = getBaseColor().a; + const int width = getWidth() + getFrameSize() * 2 - 1; + const int height = getHeight() + getFrameSize() * 2 - 1; + highlightColor.a = alpha; + shadowColor.a = alpha; + + for (unsigned int i = 0; i < getFrameSize(); ++i) + { + graphics->setColor(shadowColor); + graphics->drawLine(i, i, width - i, i); + graphics->drawLine(i, i + 1, i, height - i - 1); + graphics->setColor(highlightColor); + graphics->drawLine(width - i, i + 1, width - i, height - i); + graphics->drawLine(i, height - i, width - i - 1, height - i); + } + BLOCK_END("Widget::drawFrame") + } + + void Widget::_setParent(Widget* parent) + { + mParent = parent; + } + + void Widget::setWidth(int width) + { + Rectangle newDimension = mDimension; + newDimension.width = width; + + setDimension(newDimension); + } + + void Widget::setHeight(int height) + { + Rectangle newDimension = mDimension; + newDimension.height = height; + + setDimension(newDimension); + } + + void Widget::setX(int x) + { + Rectangle newDimension = mDimension; + newDimension.x = x; + + setDimension(newDimension); + } + + void Widget::setY(int y) + { + Rectangle newDimension = mDimension; + newDimension.y = y; + + setDimension(newDimension); + } + + void Widget::setPosition(int x, int y) + { + Rectangle newDimension = mDimension; + newDimension.x = x; + newDimension.y = y; + + setDimension(newDimension); + } + + void Widget::setDimension(const Rectangle& dimension) + { + const Rectangle oldDimension = mDimension; + mDimension = dimension; + + if (mDimension.width != oldDimension.width + || mDimension.height != oldDimension.height) + { + distributeResizedEvent(); + } + + if (mDimension.x != oldDimension.x + || mDimension.y != oldDimension.y) + { + distributeMovedEvent(); + } + } + + void Widget::setFrameSize(unsigned int frameSize) + { + mFrameSize = frameSize; + } + + unsigned int Widget::getFrameSize() const + { + return mFrameSize; + } + + const Rectangle& Widget::getDimension() const + { + return mDimension; + } + + const std::string& Widget::getActionEventId() const + { + return mActionEventId; + } + + void Widget::setActionEventId(const std::string& actionEventId) + { + mActionEventId = actionEventId; + } + + bool Widget::isFocused() const + { + if (!mFocusHandler) + return false; + + return (mFocusHandler->isFocused(this)); + } + + void Widget::setFocusable(bool focusable) + { + if (!focusable && isFocused()) + { + mFocusHandler->focusNone(); + } + + mFocusable = focusable; + } + + bool Widget::isFocusable() const + { + return mFocusable && isVisible() && isEnabled(); + } + + void Widget::requestFocus() + { + if (!mFocusHandler) + { + throw GCN_EXCEPTION("No focushandler set (did you add " + "the widget to the gui?)."); + } + + if (isFocusable()) + mFocusHandler->requestFocus(this); + } + + void Widget::requestMoveToTop() + { + if (mParent) + mParent->moveToTop(this); + } + + void Widget::requestMoveToBottom() + { + if (mParent) + mParent->moveToBottom(this); + } + + void Widget::setVisible(bool visible) + { + if (!visible && isFocused()) + mFocusHandler->focusNone(); + + if (visible) + distributeShownEvent(); + else + distributeHiddenEvent(); + + mVisible = visible; + } + + void Widget::setBaseColor(const Color& color) + { + mBaseColor = color; + } + + const Color& Widget::getBaseColor() const + { + return mBaseColor; + } + + void Widget::setForegroundColor(const Color& color) + { + mForegroundColor = color; + } + + const Color& Widget::getForegroundColor() const + { + return mForegroundColor; + } + + void Widget::setBackgroundColor(const Color& color) + { + mBackgroundColor = color; + } + + const Color& Widget::getBackgroundColor() const + { + return mBackgroundColor; + } + + void Widget::setSelectionColor(const Color& color) + { + mSelectionColor = color; + } + + const Color& Widget::getSelectionColor() const + { + return mSelectionColor; + } + + void Widget::_setFocusHandler(FocusHandler* focusHandler) + { + if (mFocusHandler) + { + releaseModalFocus(); + mFocusHandler->remove(this); + } + + if (focusHandler) + focusHandler->add(this); + + mFocusHandler = focusHandler; + } + + FocusHandler* Widget::_getFocusHandler() + { + return mFocusHandler; + } + + void Widget::addActionListener(ActionListener* actionListener) + { + mActionListeners.push_back(actionListener); + } + + void Widget::removeActionListener(ActionListener* actionListener) + { + mActionListeners.remove(actionListener); + } + + void Widget::addDeathListener(DeathListener* deathListener) + { + mDeathListeners.push_back(deathListener); + } + + void Widget::removeDeathListener(DeathListener* deathListener) + { + mDeathListeners.remove(deathListener); + } + + void Widget::addKeyListener(KeyListener* keyListener) + { + mKeyListeners.push_back(keyListener); + } + + void Widget::removeKeyListener(KeyListener* keyListener) + { + mKeyListeners.remove(keyListener); + } + + void Widget::addFocusListener(FocusListener* focusListener) + { + mFocusListeners.push_back(focusListener); + } + + void Widget::removeFocusListener(FocusListener* focusListener) + { + mFocusListeners.remove(focusListener); + } + + void Widget::addMouseListener(MouseListener* mouseListener) + { + mMouseListeners.push_back(mouseListener); + } + + void Widget::removeMouseListener(MouseListener* mouseListener) + { + mMouseListeners.remove(mouseListener); + } + + void Widget::addWidgetListener(WidgetListener* widgetListener) + { + mWidgetListeners.push_back(widgetListener); + } + + void Widget::removeWidgetListener(WidgetListener* widgetListener) + { + mWidgetListeners.remove(widgetListener); + } + + void Widget::getAbsolutePosition(int& x, int& y) const + { + if (!mParent) + { + x = mDimension.x; + y = mDimension.y; + return; + } + + int parentX; + int parentY; + + mParent->getAbsolutePosition(parentX, parentY); + + const Rectangle &rect = mParent->getChildrenArea(); + x = parentX + mDimension.x + rect.x; + y = parentY + mDimension.y + rect.y; + } + + Font* Widget::getFont() const + { + if (!mCurrentFont) + return mGlobalFont; + return mCurrentFont; + } + + void Widget::setGlobalFont(Font* font) + { + mGlobalFont = font; + + for (std::list::const_iterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++iter) + { + if (!(*iter)->mCurrentFont) + (*iter)->fontChanged(); + } + } + + void Widget::setFont(Font* font) + { + mCurrentFont = font; + fontChanged(); + } + + bool Widget::widgetExists(const Widget* widget) + { + return mWidgetsSet.find(const_cast(widget)) + != mWidgetsSet.end(); + } + + bool Widget::isTabInEnabled() const + { + return mTabIn; + } + + void Widget::setTabInEnabled(bool enabled) + { + mTabIn = enabled; + } + + bool Widget::isTabOutEnabled() const + { + return mTabOut; + } + + void Widget::setTabOutEnabled(bool enabled) + { + mTabOut = enabled; + } + + void Widget::setSize(int width, int height) + { + Rectangle newDimension = mDimension; + newDimension.width = width; + newDimension.height = height; + + setDimension(newDimension); + } + + void Widget::setEnabled(bool enabled) + { + mEnabled = enabled; + } + + bool Widget::isEnabled() const + { + return mEnabled && isVisible(); + } + + void Widget::requestModalFocus() + { + if (!mFocusHandler) + { + throw GCN_EXCEPTION("No focushandler set (did you add " + "the widget to the gui?)."); + } + + mFocusHandler->requestModalFocus(this); + } + + void Widget::requestModalMouseInputFocus() + { + if (!mFocusHandler) + { + throw GCN_EXCEPTION("No focushandler set (did you add " + "the widget to the gui?)."); + } + + mFocusHandler->requestModalMouseInputFocus(this); + } + + void Widget::releaseModalFocus() + { + if (!mFocusHandler) + return; + + mFocusHandler->releaseModalFocus(this); + } + + void Widget::releaseModalMouseInputFocus() + { + if (!mFocusHandler) + return; + + mFocusHandler->releaseModalMouseInputFocus(this); + } + + bool Widget::isModalFocused() const + { + if (!mFocusHandler) + { + throw GCN_EXCEPTION("No focushandler set (did you add " + "the widget to the gui?)."); + } + + if (mParent) + { + return (mFocusHandler->getModalFocused() == this) + || mParent->isModalFocused(); + } + + return mFocusHandler->getModalFocused() == this; + } + + bool Widget::isModalMouseInputFocused() const + { + if (!mFocusHandler) + { + throw GCN_EXCEPTION("No focushandler set (did you add " + "the widget to the gui?)."); + } + + if (mParent) + { + return (mFocusHandler->getModalMouseInputFocused() == this) + || mParent->isModalMouseInputFocused(); + } + + return mFocusHandler->getModalMouseInputFocused() == this; + } + + Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED) + { + return nullptr; + } + + const std::list& Widget::_getMouseListeners() + { + return mMouseListeners; + } + + const std::list& Widget::_getKeyListeners() + { + return mKeyListeners; + } + + const std::list& Widget::_getFocusListeners() + { + return mFocusListeners; + } + + Rectangle Widget::getChildrenArea() + { + return Rectangle(0, 0, 0, 0); + } + + FocusHandler* Widget::_getInternalFocusHandler() + { + return mInternalFocusHandler; + } + + void Widget::setInternalFocusHandler(FocusHandler* focusHandler) + { + mInternalFocusHandler = focusHandler; + } + + void Widget::setId(const std::string& id) + { + mId = id; + } + + const std::string& Widget::getId() + { + return mId; + } + + void Widget::distributeResizedEvent() + { + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++ iter) + { + Event event(this); + (*iter)->widgetResized(event); + } + } + + void Widget::distributeMovedEvent() + { + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++ iter) + { + Event event(this); + (*iter)->widgetMoved(event); + } + } + + void Widget::distributeHiddenEvent() + { + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++ iter) + { + Event event(this); + (*iter)->widgetHidden(event); + } + } + + void Widget::distributeActionEvent() + { + for (ActionListenerIterator iter = mActionListeners.begin(); + iter != mActionListeners.end(); + ++iter) + { + ActionEvent actionEvent(this, mActionEventId); + (*iter)->action(actionEvent); + } + } + + void Widget::distributeShownEvent() + { + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++iter) + { + Event event(this); + (*iter)->widgetShown(event); + } + } + + void Widget::showPart(Rectangle rectangle) + { + if (mParent) + mParent->showWidgetPart(this, rectangle); + } +} // namespace gcn diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp new file mode 100644 index 000000000..fe02d3b14 --- /dev/null +++ b/src/gui/base/widget.hpp @@ -0,0 +1,1232 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_WIDGET_HPP +#define GCN_WIDGET_HPP + +#include +#include +#include + +#include "guichan/color.hpp" +#include "guichan/rectangle.hpp" + +#include "localconsts.h" + +namespace gcn +{ + class ActionListener; + class BasicContainer; + class DeathListener; + class FocusHandler; + class FocusListener; + class Font; + class Graphics; + class KeyInput; + class KeyListener; + class MouseInput; + class MouseListener; + class WidgetListener; + + /** + * Abstract class for widgets of Guichan. It contains basic functions + * every widget should have. + * + * NOTE: Functions begining with underscore "_" should not + * be overloaded unless you know what you are doing + * + * @author Olof Naessén + * @author Per Larsson. + * @since 0.1.0 + */ + class Widget + { + public: + /** + * Constructor. Resets member variables. Noteable, a widget is not + * focusable as default, therefore, widgets that are supposed to be + * focusable should overide this default in their own constructor. + */ + Widget(); + + A_DELETE_COPY(Widget) + + /** + * Default destructor. + */ + virtual ~Widget(); + + /** + * Draws the widget. It is called by the parent widget when it is time + * for the widget to draw itself. The graphics object is set up so + * that all drawing is relative to the widget, i.e coordinate (0,0) is + * the top left corner of the widget. It is not possible to draw + * outside of a widget's dimension. + * + * @param graphics aA graphics object to draw with. + * @since 0.1.0 + */ + virtual void draw(Graphics* graphics) = 0; + + /** + * Called when a widget is given a chance to draw a frame around itself. + * The frame is not considered a part of the widget, it only allows a frame + * to be drawn around the widget, thus a frame will never be included when + * calculating if a widget should receive events from user input. Also + * a widget's frame will never be included when calculating a widget's + * position. + * + * The size of the frame is calculated using the widget's frame size. + * If a widget has a frame size of 10 pixels than the area the drawFrame + * function can draw to will be the size of the widget with an additional + * extension of 10 pixels in each direction. + * + * An example when drawFrame is a useful function is if a widget needs + * a glow around itself. + * + * @param graphics A graphics object to draw with. + * @see setFrameSize, getFrameSize + * @since 0.8.0 + */ + virtual void drawFrame(Graphics* graphics); + + /** + * Sets the size of the widget's frame. The frame is not considered a part of + * the widget, it only allows a frame to be drawn around the widget, thus a frame + * will never be included when calculating if a widget should receive events + * from user input. Also a widget's frame will never be included when calculating + * a widget's position. + * + * A frame size of 0 means that the widget has no frame. The default frame size + * is 0. + * + * @param frameSize The size of the widget's frame. + * @see getFrameSize, drawFrame + * @since 0.8.0 + */ + void setFrameSize(unsigned int frameSize); + + /** + * Gets the size of the widget's frame. The frame is not considered a part of + * the widget, it only allows a frame to be drawn around the widget, thus a frame + * will never be included when calculating if a widget should receive events + * from user input. Also a widget's frame will never be included when calculating + * a widget's position. + * + * A frame size of 0 means that the widget has no frame. The default frame size + * is 0. + * + * @return The size of the widget's frame. + * @see setFrameSize, drawFrame + * @since 0.8.0 + */ + unsigned int getFrameSize() const A_WARN_UNUSED; + + /** + * Called for all widgets in the gui each time Gui::logic is called. + * You can do logic stuff here like playing an animation. + * + * @see Gui::logic + * @since 0.1.0 + */ + virtual void logic() + { } + + /** + * Gets the widget's parent container. + * + * @return The widget's parent container. NULL if the widget + * has no parent. + * @since 0.1.0 + */ + virtual Widget* getParent() const A_WARN_UNUSED + { return mParent; } + + /** + * Sets the width of the widget. + * + * @param width The width of the widget. + * @see getWidth, setHeight, getHeight, setSize, + * setDimension, getDimensi + * @since 0.1.0 + */ + void setWidth(int width); + + /** + * Gets the width of the widget. + * + * @return The width of the widget. + * @see setWidth, setHeight, getHeight, setSize, + * setDimension, getDimension + * @since 0.1.0 + */ + int getWidth() const A_WARN_UNUSED + { return mDimension.width; } + + /** + * Sets the height of the widget. + * + * @param height The height of the widget. + * @see getHeight, setWidth, getWidth, setSize, + * setDimension, getDimension + * @since 0.1.0 + */ + void setHeight(int height); + + /** + * Gets the height of the widget. + * + * @return The height of the widget. + * @see setHeight, setWidth, getWidth, setSize, + * setDimension, getDimension + * @since 0.1.0 + */ + int getHeight() const A_WARN_UNUSED + { return mDimension.height; } + + /** + * Sets the size of the widget. + * + * @param width The width of the widget. + * @param height The height of the widget. + * @see setWidth, setHeight, getWidth, getHeight, + * setDimension, getDimension + * @since 0.1.0 + */ + void setSize(int width, int height); + + /** + * Sets the x coordinate of the widget. The coordinate is + * relateive to the widget's parent. + * + * @param x The x coordinate of the widget. + * @see getX, setY, getY, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + void setX(int x); + + /** + * Gets the x coordinate of the widget. The coordinate is + * relative to the widget's parent. + * + * @return The x coordinate of the widget. + * @see setX, setY, getY, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + int getX() const A_WARN_UNUSED + { return mDimension.x; } + + /** + * Sets the y coordinate of the widget. The coordinate is + * relative to the widget's parent. + * + * @param y The y coordinate of the widget. + * @see setY, setX, getX, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + void setY(int y); + + /** + * Gets the y coordinate of the widget. The coordinate is + * relative to the widget's parent. + * + * @return The y coordinate of the widget. + * @see setY, setX, getX, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + int getY() const A_WARN_UNUSED + { return mDimension.y; } + + /** + * Sets position of the widget. The position is relative + * to the widget's parent. + * + * @param x The x coordinate of the widget. + * @param y The y coordinate of the widget. + * @see setX, getX, setY, getY, setDimension, getDimension + * @since 0.1.0 + */ + void setPosition(int x, int y); + + /** + * Sets the dimension of the widget. The dimension is + * relative to the widget's parent. + * + * @param dimension The dimension of the widget. + * @see getDimension, setX, getX, setY, getY, setPosition + * @since 0.1.0 + */ + void setDimension(const Rectangle& dimension); + + /** + * Gets the dimension of the widget. The dimension is + * relative to the widget's parent. + * + * @return The dimension of the widget. + * @see getDimension, setX, getX, setY, getY, setPosition + * @since 0.1.0 + */ + const Rectangle& getDimension() const A_WARN_UNUSED; + + /** + * Sets the widget to be fosusable, or not. + * + * @param focusable True if the widget should be focusable, + * false otherwise. + * @see isFocusable + * @since 0.1.0 + */ + void setFocusable(bool focusable); + + /** + * Checks if a widget is focsable. + * + * @return True if the widget should be focusable, false otherwise. + * @see setFocusable + * @since 0.1.0 + */ + bool isFocusable() const A_WARN_UNUSED; + + /** + * Checks if the widget is focused. + * + * @return True if the widget is focused, false otherwise. + * @since 0.1.0 + */ + virtual bool isFocused() const A_WARN_UNUSED; + + /** + * Sets the widget to enabled, or not. A disabled + * widget will never recieve mouse or key events. + * + * @param enabled True if widget should be enabled, + * false otherwise. + * @see isEnabled + * @since 0.1.0 + */ + void setEnabled(bool enabled); + + /** + * Checks if the widget is enabled. A disabled + * widget will never recieve mouse or key events. + * + * @return True if widget is enabled, false otherwise. + * @see setEnabled + * @since 0.1.0 + */ + bool isEnabled() const A_WARN_UNUSED; + + /** + * Sets the widget to be visible, or not. + * + * @param visible True if widget should be visible, false otherwise. + * @see isVisible + * @since 0.1.0 + */ + void setVisible(bool visible); + + /** + * Checks if the widget is visible. + * + * @return True if widget is be visible, false otherwise. + * @see setVisible + * @since 0.1.0 + */ + bool isVisible() const A_WARN_UNUSED + { return mVisible && (!mParent || mParent->isVisible()); } + + /** + * Sets the base color of the widget. + * + * @param color The baseground color. + * @see getBaseColor + * @since 0.1.0 + */ + void setBaseColor(const Color& color); + + /** + * Gets the base color. + * + * @return The base color. + * @see setBaseColor + * @since 0.1.0 + */ + const Color& getBaseColor() const A_WARN_UNUSED; + + /** + * Sets the foreground color. + * + * @param color The foreground color. + * @see getForegroundColor + * @since 0.1.0 + */ + void setForegroundColor(const Color& color); + + /** + * Gets the foreground color. + * + * @see setForegroundColor + * @since 0.1.0 + */ + const Color& getForegroundColor() const A_WARN_UNUSED; + + /** + * Sets the background color. + * + * @param color The background Color. + * @see setBackgroundColor + * @since 0.1.0 + */ + void setBackgroundColor(const Color& color); + + /** + * Gets the background color. + * + * @see setBackgroundColor + * @since 0.1.0 + */ + const Color& getBackgroundColor() const A_WARN_UNUSED; + + /** + * Sets the selection color. + * + * @param color The selection color. + * @see getSelectionColor + * @since 0.6.0 + */ + void setSelectionColor(const Color& color); + + /** + * Gets the selection color. + * + * @return The selection color. + * @see setSelectionColor + * @since 0.6.0 + */ + const Color& getSelectionColor() const A_WARN_UNUSED; + + /** + * Requests focus for the widget. A widget will only recieve focus + * if it is focusable. + */ + virtual void requestFocus(); + + /** + * Requests a move to the top in the parent widget. + */ + virtual void requestMoveToTop(); + + /** + * Requests a move to the bottom in the parent widget. + */ + virtual void requestMoveToBottom(); + + /** + * Sets the focus handler to be used. + * + * WARNING: This function is used internally and should not + * be called or overloaded unless you know what you + * are doing. + * + * @param focusHandler The focus handler to use. + * @see _getFocusHandler + * @since 0.1.0 + */ + virtual void _setFocusHandler(FocusHandler* focusHandler); + + /** + * Gets the focus handler used. + * + * WARNING: This function is used internally and should not + * be called or overloaded unless you know what you + * are doing. + * + * @return The focus handler used. + * @see _setFocusHandler + * @since 0.1.0 + */ + virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED; + + /** + * Adds an action listener to the widget. When an action event + * is fired by the widget the action listeners of the widget + * will get notified. + * + * @param actionListener The action listener to add. + * @see removeActionListener + * @since 0.1.0 + */ + void addActionListener(ActionListener* actionListener); + + /** + * Removes an added action listener from the widget. + * + * @param actionListener The action listener to remove. + * @see addActionListener + * @since 0.1.0 + */ + void removeActionListener(ActionListener* actionListener); + + /** + * Adds a death listener to the widget. When a death event is + * fired by the widget the death listeners of the widget will + * get notified. + * + * @param deathListener The death listener to add. + * @see removeDeathListener + * @since 0.1.0 + */ + void addDeathListener(DeathListener* deathListener); + + /** + * Removes an added death listener from the widget. + * + * @param deathListener The death listener to remove. + * @see addDeathListener + * @since 0.1.0 + */ + void removeDeathListener(DeathListener* deathListener); + + /** + * Adds a mouse listener to the widget. When a mouse event is + * fired by the widget the mouse listeners of the widget will + * get notified. + * + * @param mouseListener The mouse listener to add. + * @see removeMouseListener + * @since 0.1.0 + */ + void addMouseListener(MouseListener* mouseListener); + + /** + * Removes an added mouse listener from the widget. + * + * @param mouseListener The mouse listener to remove. + * @see addMouseListener + * @since 0.1.0 + */ + void removeMouseListener(MouseListener* mouseListener); + + /** + * Adds a key listener to the widget. When a key event is + * fired by the widget the key listeners of the widget will + * get notified. + * + * @param keyListener The key listener to add. + * @see removeKeyListener + * @since 0.1.0 + */ + void addKeyListener(KeyListener* keyListener); + + /** + * Removes an added key listener from the widget. + * + * @param keyListener The key listener to remove. + * @see addKeyListener + * @since 0.1.0 + */ + void removeKeyListener(KeyListener* keyListener); + + /** + * Adds a focus listener to the widget. When a focus event is + * fired by the widget the key listeners of the widget will + * get notified. + * + * @param focusListener The focus listener to add. + * @see removeFocusListener + * @since 0.7.0 + */ + void addFocusListener(FocusListener* focusListener); + + /** + * Removes an added focus listener from the widget. + * + * @param focusListener The focus listener to remove. + * @see addFocusListener + * @since 0.7.0 + */ + void removeFocusListener(FocusListener* focusListener); + + /** + * Adds a widget listener to the widget. When a widget event is + * fired by the widget the key listeners of the widget will + * get notified. + * + * @param widgetListener The widget listener to add. + * @see removeWidgetListener + * @since 0.8.0 + */ + void addWidgetListener(WidgetListener* widgetListener); + + /** + * Removes an added widget listener from the widget. + * + * @param widgetListener The widget listener to remove. + * @see addWidgetListener + * @since 0.8.0 + */ + void removeWidgetListener(WidgetListener* widgetListener); + + /** + * Sets the action event identifier of the widget. The identifier is + * used to be able to identify which action has occured. + * + * NOTE: An action event identifier should not be used to identify a + * certain widget but rather a certain event in your application. + * Several widgets can have the same action event identifer. + * + * @param actionEventId The action event identifier. + * @see getActionEventId + * @since 0.6.0 + */ + void setActionEventId(const std::string& actionEventId); + + /** + * Gets the action event identifier of the widget. + * + * @return The action event identifier of the widget. + * @see setActionEventId + * @since 0.6.0 + */ + const std::string& getActionEventId() const; + + /** + * Gets the absolute position on the screen for the widget. + * + * @param x The absolute x coordinate will be stored in this parameter. + * @param y The absolute y coordinate will be stored in this parameter. + * @since 0.1.0 + */ + virtual void getAbsolutePosition(int& x, int& y) const; + + /** + * Sets the parent of the widget. A parent must be a BasicContainer. + * + * WARNING: This function is used internally and should not + * be called or overloaded unless you know what you + * are doing. + * + * @param parent The parent of the widget. + * @see getParent + * @since 0.1.0 + */ + virtual void _setParent(Widget* parent); + + /** + * Gets the font set for the widget. If no font has been set, + * the global font will be returned. If no global font has been set, + * the default font will be returend. + * + * @return The font set for the widget. + * @see setFont, setGlobalFont + * @since 0.1.0 + */ + Font *getFont() const A_WARN_UNUSED; + + /** + * Sets the global font to be used by default for all widgets. + * + * @param font The global font. + * @see getGlobalFont + * @since 0.1.0 + */ + static void setGlobalFont(Font* font); + + /** + * Sets the font for the widget. If NULL is passed, the global font + * will be used. + * + * @param font The font to set for the widget. + * @see getFont + * @since 0.1.0 + */ + void setFont(Font* font); + + /** + * Called when the font has changed. If the change is global, + * this function will only be called if the widget doesn't have a + * font already set. + * + * @since 0.1.0 + */ + virtual void fontChanged() + { } + + /** + * Checks if a widget exists or not, that is if it still exists + * an instance of the object. + * + * @param widget The widget to check. + * @return True if an instance of the widget exists, false otherwise. + * @since 0.1.0 + */ + static bool widgetExists(const Widget* widget) A_WARN_UNUSED; + + /** + * Checks if tab in is enabled. Tab in means that you can set focus + * to this widget by pressing the tab button. If tab in is disabled + * then the focus handler will skip this widget and focus the next + * in its focus order. + * + * @return True if tab in is enabled, false otherwise. + * @see setTabInEnabled + * @since 0.1.0 + */ + bool isTabInEnabled() const A_WARN_UNUSED; + + /** + * Sets tab in enabled, or not. Tab in means that you can set focus + * to this widget by pressing the tab button. If tab in is disabled + * then the FocusHandler will skip this widget and focus the next + * in its focus order. + * + * @param enabled True if tab in should be enabled, false otherwise. + * @see isTabInEnabled + * @since 0.1.0 + */ + void setTabInEnabled(bool enabled); + + /** + * Checks if tab out is enabled. Tab out means that you can lose + * focus to this widget by pressing the tab button. If tab out is + * disabled then the FocusHandler ignores tabbing and focus will + * stay with this widget. + * + * @return True if tab out is enabled, false otherwise. + * @see setTabOutEnabled + * @since 0.1.0 + */ + bool isTabOutEnabled() const A_WARN_UNUSED; + + /** + * Sets tab out enabled. Tab out means that you can lose + * focus to this widget by pressing the tab button. If tab out is + * disabled then the FocusHandler ignores tabbing and focus will + * stay with this widget. + * + * @param enabled True if tab out should be enabled, false otherwise. + * @see isTabOutEnabled + * @since 0.1.0 + */ + void setTabOutEnabled(bool enabled); + + /** + * Requests modal focus. When a widget has modal focus, only that + * widget and it's children may recieve input. + * + * @throws Exception if another widget already has modal focus. + * @see releaseModalFocus, isModalFocused + * @since 0.4.0 + */ + virtual void requestModalFocus(); + + /** + * Requests modal mouse input focus. When a widget has modal input focus + * that widget will be the only widget receiving input even if the input + * occurs outside of the widget and no matter what the input is. + * + * @throws Exception if another widget already has modal focus. + * @see releaseModalMouseInputFocus, isModalMouseInputFocused + * @since 0.6.0 + */ + virtual void requestModalMouseInputFocus(); + + /** + * Releases modal focus. Modal focus will only be released if the + * widget has modal focus. + * + * @see requestModalFocus, isModalFocused + * @since 0.4.0 + */ + virtual void releaseModalFocus(); + + /** + * Releases modal mouse input focus. Modal mouse input focus will only + * be released if the widget has modal mouse input focus. + * + * @see requestModalMouseInputFocus, isModalMouseInputFocused + * @since 0.6.0 + */ + virtual void releaseModalMouseInputFocus(); + + /** + * Checks if the widget or it's parent has modal focus. + * + * @return True if the widget has modal focus, false otherwise. + * @see requestModalFocus, releaseModalFocus + * @since 0.8.0 + */ + virtual bool isModalFocused() const A_WARN_UNUSED; + + /** + * Checks if the widget or it's parent has modal mouse input focus. + * + * @return True if the widget has modal mouse input focus, false + * otherwise. + * @see requestModalMouseInputFocus, releaseModalMouseInputFocus + * @since 0.8.0 + */ + virtual bool isModalMouseInputFocused() const A_WARN_UNUSED; + + /** + * Gets a widget from a certain position in the widget. + * This function is used to decide which gets mouse input, + * thus it can be overloaded to change that behaviour. + * + * NOTE: This always returns NULL if the widget is not + * a container. + * + * @param x The x coordinate of the widget to get. + * @param y The y coordinate of the widget to get. + * @return The widget at the specified coodinate, NULL + * if no widget is found. + * @since 0.6.0 + */ + virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED; + + /** + * Gets the mouse listeners of the widget. + * + * @return The mouse listeners of the widget. + * @since 0.6.0 + */ + virtual const std::list& _getMouseListeners() + A_WARN_UNUSED; + + /** + * Gets the key listeners of the widget. + * + * @return The key listeners of the widget. + * @since 0.6.0 + */ + virtual const std::list& _getKeyListeners() + A_WARN_UNUSED; + + /** + * Gets the focus listeners of the widget. + * + * @return The focus listeners of the widget. + * @since 0.7.0 + */ + virtual const std::list& _getFocusListeners() + A_WARN_UNUSED; + + /** + * Gets the area of the widget occupied by the widget's children. + * By default this method returns an empty rectangle as not all + * widgets are containers. If you want to make a container this + * method should return the area where the children resides. This + * method is used when drawing children of a widget when computing + * clip rectangles for the children. + * + * An example of a widget that overloads this method is ScrollArea. + * A ScrollArea has a view of its contant and that view is the + * children area. The size of a ScrollArea's children area might + * vary depending on if the scroll bars of the ScrollArea is shown + * or not. + * + * @return The area of the widget occupied by the widget's children. + * @see BasicContainer + * @see BasicContainer::getChildrenArea + * @see BasicContainer::drawChildren + * @since 0.1.0 + */ + virtual Rectangle getChildrenArea() A_WARN_UNUSED; + + /** + * Gets the internal focus handler used. + * + * @return the internalFocusHandler used. If no internal focus handler + * is used, NULL will be returned. + * @see setInternalFocusHandler + * @since 0.1.0 + */ + virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED; + + /** + * Sets the internal focus handler. An internal focus handler is + * needed if both a widget in the widget and the widget itself + * should be foucsed at the same time. + * + * @param focusHandler The internal focus handler to be used. + * @see getInternalFocusHandler + * @since 0.1.0 + */ + void setInternalFocusHandler(FocusHandler* internalFocusHandler); + + /** + * Moves a widget to the top of this widget. The moved widget will be + * drawn above all other widgets in this widget. + * + * @param widget The widget to move to the top. + * @see moveToBottom + * @since 0.1.0 + */ + virtual void moveToTop(Widget* widget A_UNUSED) + { } + + /** + * Moves a widget in this widget to the bottom of this widget. + * The moved widget will be drawn below all other widgets in this widget. + * + * @param widget The widget to move to the bottom. + * @see moveToTop + * @since 0.1.0 + */ + virtual void moveToBottom(Widget* widget A_UNUSED) + { } + + /** + * Focuses the next widget in the widget. + * + * @see moveToBottom + * @since 0.1.0 + */ + virtual void focusNext() + { } + + /** + * Focuses the previous widget in the widget. + * + * @see moveToBottom + * @since 0.1.0 + */ + virtual void focusPrevious() + { } + + /** + * Tries to show a specific part of a widget by moving it. Used if the + * widget should act as a container. + * + * @param widget The target widget. + * @param area The area to show. + * @since 0.1.0 + */ + virtual void showWidgetPart(Widget* widget A_UNUSED, + Rectangle area A_UNUSED) + { } + + /** + * Sets an id of a widget. An id can be useful if a widget needs to be + * identified in a container. For example, if widgets are created by an + * XML document, a certain widget can be retrieved given that the widget + * has an id. + * + * @param id The id to set to the widget. + * @see getId, BasicContainer::findWidgetById + * @since 0.8.0 + */ + void setId(const std::string& id); + + /** + * Gets the id of a widget. An id can be useful if a widget needs to be + * identified in a container. For example, if widgets are created by an + * XML document, a certain widget can be retrieved given that the widget + * has an id. + * + * @param id The id to set to the widget. + * @see setId, BasicContainer::findWidgetById + * @since 0.8.0 + */ + const std::string& getId() A_WARN_UNUSED; + + /** + * Shows a certain part of a widget in the widget's parent. + * Used when widgets want a specific part to be visible in + * its parent. An example is a TextArea that wants a specific + * part of its text to be visible when a TextArea is a child + * of a ScrollArea. + * + * @param rectangle The rectangle to be shown. + * @since 0.8.0 + */ + virtual void showPart(Rectangle rectangle); + + protected: + /** + * Distributes an action event to all action listeners + * of the widget. + * + * @since 0.8.0 + */ + void distributeActionEvent(); + + /** + * Distributes resized events to all of the widget's listeners. + * + * @since 0.8.0 + */ + void distributeResizedEvent(); + + /** + * Distributes moved events to all of the widget's listeners. + * + * @since 0.8.0 + */ + void distributeMovedEvent(); + + /** + * Distributes hidden events to all of the widget's listeners. + * + * @since 0.8.0 + * @author Olof Naessén + */ + void distributeHiddenEvent(); + + /** + * Distributes shown events to all of the widget's listeners. + * + * @since 0.8.0 + * @author Olof Naessén + */ + void distributeShownEvent(); + + /** + * Typdef. + */ + typedef std::list MouseListenerList; + + /** + * Typdef. + */ + typedef MouseListenerList::iterator MouseListenerIterator; + + /** + * Holds the mouse listeners of the widget. + */ + MouseListenerList mMouseListeners; + + /** + * Typdef. + */ + typedef std::list KeyListenerList; + + /** + * Holds the key listeners of the widget. + */ + KeyListenerList mKeyListeners; + + /** + * Typdef. + */ + typedef KeyListenerList::iterator KeyListenerIterator; + + /** + * Typdef. + */ + typedef std::list ActionListenerList; + + /** + * Holds the action listeners of the widget. + */ + ActionListenerList mActionListeners; + + /** + * Typdef. + */ + typedef ActionListenerList::iterator ActionListenerIterator; + + /** + * Typdef. + */ + typedef std::list DeathListenerList; + + /** + * Holds the death listeners of the widget. + */ + DeathListenerList mDeathListeners; + + /** + * Typdef. + */ + typedef DeathListenerList::iterator DeathListenerIterator; + + /** + * Typdef. + */ + typedef std::list FocusListenerList; + + /** + * Holds the focus listeners of the widget. + */ + FocusListenerList mFocusListeners; + + /** + * Typdef. + */ + typedef FocusListenerList::iterator FocusListenerIterator; + + typedef std::list WidgetListenerList; + + /** + * Holds the widget listeners of the widget. + */ + WidgetListenerList mWidgetListeners; + + /** + * Typdef. + */ + typedef WidgetListenerList::iterator WidgetListenerIterator; + + /** + * Holds the foreground color of the widget. + */ + Color mForegroundColor; + + /** + * Holds the background color of the widget. + */ + Color mBackgroundColor; + + /** + * Holds the base color of the widget. + */ + Color mBaseColor; + + /** + * Holds the selection color of the widget. + */ + Color mSelectionColor; + + /** + * Holds the focus handler used by the widget. + */ + FocusHandler* mFocusHandler; + + /** + * Holds the focus handler used by the widget. NULL + * if no internal focus handler is used. + */ + FocusHandler* mInternalFocusHandler; + + /** + * Holds the parent of the widget. NULL if the widget + * has no parent. + */ + Widget* mParent; + + /** + * Holds the dimension of the widget. + */ + Rectangle mDimension; + + /** + * Holds the frame size of the widget. + */ + unsigned int mFrameSize; + + /** + * Holds the action event of the widget. + */ + std::string mActionEventId; + + /** + * True if the widget focusable, false otherwise. + */ + bool mFocusable; + + /** + * True if the widget visible, false otherwise. + */ + bool mVisible; + + /** + * True if the widget has tab in enabled, false otherwise. + */ + bool mTabIn; + + /** + * True if the widget has tab in enabled, false otherwise. + */ + bool mTabOut; + + /** + * True if the widget is enabled, false otherwise. + */ + bool mEnabled; + + /** + * Holds the id of the widget. + */ + std::string mId; + + /** + * Holds the font used by the widget. + */ + Font* mCurrentFont; + + /** + * Holds the global font used by the widget. + */ + static Font* mGlobalFont; + + /** + * Holds a list of all instances of widgets. + */ + static std::list mWidgets; + + static std::set mWidgetsSet; + }; +} // namespace gcn + +#endif // end GCN_WIDGET_HPP diff --git a/src/gui/base/widgetlistener.hpp b/src/gui/base/widgetlistener.hpp new file mode 100644 index 000000000..3dd74bb4d --- /dev/null +++ b/src/gui/base/widgetlistener.hpp @@ -0,0 +1,143 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_WIDGETLISTENER_HPP +#define GCN_WIDGETLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +#include "localconsts.h" + +namespace gcn +{ + /** + * Interface for listening for events from widgets. When a widget's size, + * location or visibility changes, the relevant method of the listener is + * invoked. + * + * @see Widget::addWidgetListener, Widget::removeWidgetListener + * @author Olof Naessén + * @since 0.8.0 + */ + class WidgetListener + { + public: + /** + * Destructor. + */ + virtual ~WidgetListener() + { } + + /** + * Invoked when a widget changes its size. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetResized(const Event& event A_UNUSED) + { } + + /** + * Invoked when a widget is moved. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetMoved(const Event& event A_UNUSED) + { } + + /** + * Invoked when a widget is hidden, i.e it's set to be + * not visible. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetHidden(const Event& event A_UNUSED) + { } + + /** + * Invoked when a widget is shown, i.e it's set to be + * visible. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetShown(const Event& event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of WidgetListener, + * therefore its constructor is protected. + */ + WidgetListener() + { } + }; +} // namespace gcn + +#endif // end GCN_WIDGETLISTENER_HPP diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp new file mode 100644 index 000000000..a52bf2d78 --- /dev/null +++ b/src/gui/base/widgets/button.cpp @@ -0,0 +1,194 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/button.hpp" + +#include "gui/base/exception.hpp" +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/mouseevent.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + Button::Button() : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + gcn::FocusListener(), + mCaption(), + mHasMouse(false), + mKeyPressed(false), + mMousePressed(false), + mAlignment(Graphics::CENTER), + mSpacing(4) + { + setFocusable(true); + adjustSize(); + setFrameSize(1); + + addMouseListener(this); + addKeyListener(this); + addFocusListener(this); + } + + Button::Button(const std::string& caption) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + gcn::FocusListener(), + mCaption(caption), + mHasMouse(false), + mKeyPressed(false), + mMousePressed(false), + mAlignment(Graphics::CENTER), + mSpacing(4) + { + setFocusable(true); + adjustSize(); + setFrameSize(1); + + addMouseListener(this); + addKeyListener(this); + addFocusListener(this); + } + + void Button::setCaption(const std::string& caption) + { + mCaption = caption; + } + + const std::string& Button::getCaption() const + { + return mCaption; + } + + void Button::setAlignment(Graphics::Alignment alignment) + { + mAlignment = alignment; + } + + Graphics::Alignment Button::getAlignment() const + { + return mAlignment; + } + + void Button::setSpacing(unsigned int spacing) + { + mSpacing = spacing; + } + + unsigned int Button::getSpacing() const + { + return mSpacing; + } + + void Button::adjustSize() + { + } + + bool Button::isPressed() const + { + if (mMousePressed) + return mHasMouse; + else + return mKeyPressed; + } + + void Button::mousePressed(MouseEvent& mouseEvent) + { + if (mouseEvent.getButton() == MouseEvent::LEFT) + { + mMousePressed = true; + mouseEvent.consume(); + } + } + + void Button::mouseExited(MouseEvent& mouseEvent A_UNUSED) + { + mHasMouse = false; + } + + void Button::mouseEntered(MouseEvent& mouseEvent A_UNUSED) + { + mHasMouse = true; + } + + void Button::mouseDragged(MouseEvent& mouseEvent) + { + mouseEvent.consume(); + } + + void Button::focusLost(const Event& event A_UNUSED) + { + mMousePressed = false; + mKeyPressed = false; + } +} // namespace gcn diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp new file mode 100644 index 000000000..4ae08eb16 --- /dev/null +++ b/src/gui/base/widgets/button.hpp @@ -0,0 +1,220 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_BUTTON_HPP +#define GCN_BUTTON_HPP + +#include + +#include "gui/base/focuslistener.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/mouseevent.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * An implementation of a regular clickable button. A button is capable of + * displaying a caption. + * + * If a button is clicked an action event will be sent to all action listener's + * of the button. + * + * @see ImageButton + */ + class Button : public Widget, + public MouseListener, + public KeyListener, + public FocusListener + { + public: + /** + * Constructor. + */ + Button(); + + /** + * Constructor. The button will be automatically resized + * to fit the caption. + * + * @param caption The caption of the button. + */ + explicit Button(const std::string& caption); + + A_DELETE_COPY(Button) + + /** + * Sets the caption of the button. It's advisable to call + * adjustSize after setting of the caption to adjust the + * button's size to fit the caption. + * + * @param caption The caption of the button. + * @see getCaption, adjustSize + */ + void setCaption(const std::string& caption); + + /** + * Gets the caption of the button. + * + * @return The caption of the button. + */ + const std::string& getCaption() const; + + /** + * Sets the alignment of the caption. The alignment is relative + * to the center of the button. + * + * @param alignment The alignment of the caption. + * @see getAlignment, Graphics + */ + void setAlignment(Graphics::Alignment alignment); + + /** + * Gets the alignment of the caption. + * + * @return The alignment of the caption. + * @see setAlignment, Graphics + */ + Graphics::Alignment getAlignment() const; + + /** + * Sets the spacing between the border of the button and its caption. + * + * @param spacing The default value for spacing is 4 and can be changed + * using this method. + * @see getSpacing + */ + void setSpacing(unsigned int spacing); + + /** + * Gets the spacing between the border of the button and its caption. + * + * @return spacing. + * @see setSpacing + */ + unsigned int getSpacing() const; + + /** + * Adjusts the button's size to fit the caption. + */ + void adjustSize(); + + + // Inherited from FocusListener + + virtual void focusLost(const Event& event); + + // Inherited from MouseListener + + virtual void mousePressed(MouseEvent& mouseEvent) override; + + virtual void mouseEntered(MouseEvent& mouseEvent) override; + + virtual void mouseExited(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + protected: + /** + * Checks if the button is pressed. Convenient method to use + * when overloading the draw method of the button. + * + * @return True if the button is pressed, false otherwise. + */ + bool isPressed() const; + + /** + * Holds the caption of the button. + */ + std::string mCaption; + + /** + * True if the mouse is ontop of the button, false otherwise. + */ + bool mHasMouse; + + /** + * True if a key has been pressed, false otherwise. + */ + bool mKeyPressed; + + /** + * True if a mouse has been pressed, false otherwise. + */ + bool mMousePressed; + + /** + * Holds the alignment of the caption. + */ + Graphics::Alignment mAlignment; + + /** + * Holds the spacing between the border and the caption. + */ + unsigned int mSpacing; + }; +} // namespace gcn + +#endif // end GCN_BUTTON_HPP diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp new file mode 100644 index 000000000..908b4f509 --- /dev/null +++ b/src/gui/base/widgets/checkbox.cpp @@ -0,0 +1,154 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/checkbox.hpp" + +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + + CheckBox::CheckBox() : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mSelected(false), + mCaption() + { + setFocusable(true); + addMouseListener(this); + addKeyListener(this); + } + + CheckBox::CheckBox(const std::string &caption, bool selected) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mSelected(selected), + mCaption() + { + setCaption(caption); + + setFocusable(true); + addMouseListener(this); + addKeyListener(this); + + adjustSize(); + } + + bool CheckBox::isSelected() const + { + return mSelected; + } + + void CheckBox::setSelected(bool selected) + { + mSelected = selected; + } + + const std::string &CheckBox::getCaption() const + { + return mCaption; + } + + void CheckBox::setCaption(const std::string& caption) + { + mCaption = caption; + } + + void CheckBox::keyPressed(KeyEvent& keyEvent A_UNUSED) + { + } + + void CheckBox::mouseClicked(MouseEvent& mouseEvent) + { + if (mouseEvent.getButton() == MouseEvent::LEFT) + { + toggleSelected(); + } + } + + void CheckBox::mouseDragged(MouseEvent& mouseEvent) + { + mouseEvent.consume(); + } + + void CheckBox::adjustSize() + { + } + + void CheckBox::toggleSelected() + { + mSelected = !mSelected; + distributeActionEvent(); + } +} // namespace gcn diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp new file mode 100644 index 000000000..c9b723879 --- /dev/null +++ b/src/gui/base/widgets/checkbox.hpp @@ -0,0 +1,180 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_CHECKBOX_HPP +#define GCN_CHECKBOX_HPP + +#include + +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * An implementation of a check box where a user can select or deselect + * the check box and where the status of the check box is displayed to the user. + * A check box is capable of displaying a caption. + * + * If a check box's state changes an action event will be sent to all action + * listeners of the check box. + */ + class CheckBox : + public Widget, + public MouseListener, + public KeyListener + { + public: + /** + * Contructor. + */ + CheckBox(); + + /** + * Constructor. The check box will be automatically resized + * to fit the caption. + * + * @param caption The caption of the check box. + * @param marked True if the check box is selected, false otherwise. + */ + CheckBox(const std::string &caption, bool selected = false); + + A_DELETE_COPY(CheckBox) + + /** + * Destructor. + */ + virtual ~CheckBox() + { } + + /** + * Checks if the check box is selected. + * + * @return True if the check box is selected, false otherwise. + * @see setSelected + */ + bool isSelected() const; + + /** + * Sets the check box to be selected or not. + * + * @param selected True if the check box should be set as selected. + * @see isSelected + */ + void setSelected(bool selected); + + /** + * Gets the caption of the check box. + * + * @return The caption of the check box. + * @see setCaption + */ + const std::string &getCaption() const; + + /** + * Sets the caption of the check box. It's advisable to call + * adjustSize after setting of the caption to adjust the + * check box's size to fit the caption. + * + * @param caption The caption of the check box. + * @see getCaption, adjustSize + */ + void setCaption(const std::string& caption); + + /** + * Adjusts the check box's size to fit the caption. + */ + void adjustSize(); + + // Inherited from KeyListener + + virtual void keyPressed(KeyEvent& keyEvent) override; + + // Inherited from MouseListener + + virtual void mouseClicked(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + + protected: + /** + * Toggles the check box between being selected and + * not being selected. + */ + virtual void toggleSelected(); + + /** + * True if the check box is selected, false otherwise. + */ + bool mSelected; + + /** + * Holds the caption of the check box. + */ + std::string mCaption; + }; +} // namespace gcn + +#endif // end GCN_CHECKBOX_HPP diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp new file mode 100644 index 000000000..1e6de018b --- /dev/null +++ b/src/gui/base/widgets/container.cpp @@ -0,0 +1,136 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/container.hpp" + +#include "gui/base/exception.hpp" +#include "gui/base/graphics.hpp" + +#include "debug.h" + +namespace gcn +{ + + Container::Container() : + BasicContainer(), + mOpaque(true) + { + } + + Container::~Container() + { + } + + void Container::draw(Graphics* graphics) + { + BLOCK_START("Container::draw") + if (isOpaque()) + { + graphics->setColor(getBaseColor()); + graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); + } + + drawChildren(graphics); + BLOCK_END("Container::draw") + } + + void Container::setOpaque(bool opaque) + { + mOpaque = opaque; + } + + bool Container::isOpaque() const + { + return mOpaque; + } + + void Container::add(Widget* widget) + { + BasicContainer::add(widget); + } + + void Container::add(Widget* widget, int x, int y) + { + widget->setPosition(x, y); + BasicContainer::add(widget); + } + + void Container::remove(Widget* widget) + { + BasicContainer::remove(widget); + } + + void Container::clear() + { + BasicContainer::clear(); + } + + Widget* Container::findWidgetById(const std::string &id) + { + return BasicContainer::findWidgetById(id); + } +} // namespace gcn diff --git a/src/gui/base/widgets/container.hpp b/src/gui/base/widgets/container.hpp new file mode 100644 index 000000000..a5cbdb31b --- /dev/null +++ b/src/gui/base/widgets/container.hpp @@ -0,0 +1,180 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_CONTAINER_HPP +#define GCN_CONTAINER_HPP + +#include + +#include "gui/base/basiccontainer.hpp" +#include "gui/base/graphics.hpp" + +namespace gcn +{ + /** + * An implementation of a container able to contain other widgets. A widget's + * position in the container is relative to the container itself and not the screen. + * A container is the most common widget to use as the Gui's top widget as makes the Gui + * able to contain more than one widget. + * + * @see Gui::setTop + */ + class Container: public BasicContainer + { + public: + /** + * Constructor. A container is opauqe as default, if you want a + * none opaque container call setQpaque(false). + * + * @see setOpaque, isOpaque + */ + Container(); + + /** + * Destructor. + */ + virtual ~Container(); + + /** + * Sets the container to be opaque or not. If the container + * is opaque its background will be drawn, if it's not opaque + * its background will not be drawn, and thus making the container + * completely transparent. + * + * NOTE: This is not the same as to set visibility. A non visible + * container will not itself nor will it draw its content. + * + * @param opaque True if the container should be opaque, false otherwise. + * @see isOpaque + */ + void setOpaque(bool opaque); + + /** + * Checks if the container is opaque or not. + * + * @return True if the container is opaque, false otherwise. + * @see setOpaque + */ + bool isOpaque() const; + + /** + * Adds a widget to the container. + * + * @param widget The widget to add. + * @see remove, clear + */ + virtual void add(Widget* widget); + + /** + * Adds a widget to the container and also specifies the widget's + * position in the container. The position is relative to the container + * and not relative to the screen. + * + * @param widget The widget to add. + * @param x The x coordinate for the widget. + * @param y The y coordinate for the widget. + * @see remove, clear + */ + virtual void add(Widget* widget, int x, int y); + + /** + * Removes a widget from the Container. + * + * @param widget The widget to remove. + * @throws Exception when the widget has not been added to the + * container. + * @see add, clear + */ + virtual void remove(Widget* widget); + + /** + * Clears the container of all widgets. + * + * @see add, remove + */ + virtual void clear(); + + /** + * Finds a widget given an id. + * + * @param id The id to find a widget by. + * @return A widget with a corrosponding id, NULL if no widget + * is found. + * @see Widget::setId + */ + virtual Widget* findWidgetById(const std::string &id); + + + // Inherited from Widget + + virtual void draw(Graphics* graphics); + + protected: + /** + * True if the container is opaque, false otherwise. + */ + bool mOpaque; + }; +} // namespace gcn + +#endif // end GCN_CONTAINER_HPP diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp new file mode 100644 index 000000000..42fcd78f4 --- /dev/null +++ b/src/gui/base/widgets/label.cpp @@ -0,0 +1,121 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/label.hpp" + +#include "gui/base/exception.hpp" +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" + +#include "debug.h" + +namespace gcn +{ + Label::Label() : + gcn::Widget(), + mCaption(), + mAlignment(Graphics::LEFT) + { + } + + Label::Label(const std::string& caption) : + gcn::Widget(), + mCaption(caption), + mAlignment(Graphics::LEFT) + { + setWidth(getFont()->getWidth(caption)); + setHeight(getFont()->getHeight()); + } + + const std::string &Label::getCaption() const + { + return mCaption; + } + + void Label::setCaption(const std::string& caption) + { + mCaption = caption; + } + + void Label::setAlignment(Graphics::Alignment alignment) + { + mAlignment = alignment; + } + + Graphics::Alignment Label::getAlignment() const + { + return mAlignment; + } + + void Label::draw(Graphics* graphics A_UNUSED) + { + } + + void Label::adjustSize() + { + } +} // namespace gcn diff --git a/src/gui/base/widgets/label.hpp b/src/gui/base/widgets/label.hpp new file mode 100644 index 000000000..f1ef30b89 --- /dev/null +++ b/src/gui/base/widgets/label.hpp @@ -0,0 +1,154 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_LABEL_HPP +#define GCN_LABEL_HPP + +#include + +#include "gui/base/graphics.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * Implementation of a label capable of displaying a caption. + */ + class Label: public Widget + { + public: + /** + * Constructor. + */ + Label(); + + /** + * Constructor. The label will be automatically resized + * to fit the caption. + * + * @param caption The caption of the label. + */ + explicit Label(const std::string& caption); + + A_DELETE_COPY(Label) + + /** + * Gets the caption of the label. + * + * @return The caption of the label. + * @see setCaption + */ + const std::string &getCaption() const; + + /** + * Sets the caption of the label. It's advisable to call + * adjustSize after setting of the caption to adjust the + * label's size to fit the caption. + * + * @param caption The caption of the label. + * @see getCaption, adjustSize + */ + void setCaption(const std::string& caption); + + /** + * Sets the alignment of the caption. The alignment is relative + * to the center of the label. + * + * @param alignemnt The alignment of the caption of the label. + * @see getAlignment, Graphics + */ + void setAlignment(Graphics::Alignment alignment); + + /** + * Gets the alignment of the caption. The alignment is relative to + * the center of the label. + * + * @return The alignment of caption of the label. + * @see setAlignmentm Graphics + */ + Graphics::Alignment getAlignment() const; + + /** + * Adjusts the label's size to fit the caption. + */ + void adjustSize(); + + + // Inherited from Widget + + virtual void draw(Graphics* graphics); + + protected: + /** + * Holds the caption of the label. + */ + std::string mCaption; + + /** + * Holds the alignment of the caption. + */ + Graphics::Alignment mAlignment; + }; +} // namespace gcn + +#endif // end GCN_LABEL_HPP diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp new file mode 100644 index 000000000..b97bf47d4 --- /dev/null +++ b/src/gui/base/widgets/listbox.cpp @@ -0,0 +1,241 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/listbox.hpp" + +#include "gui/base/basiccontainer.hpp" +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/listmodel.hpp" +#include "gui/base/mouseinput.hpp" +#include "gui/base/selectionlistener.hpp" + +#include "debug.h" + +namespace gcn +{ + ListBox::ListBox() : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mSelected(-1), + mListModel(nullptr), + mWrappingEnabled(false), + mSelectionListeners() + { + setWidth(100); + setFocusable(true); + + addMouseListener(this); + addKeyListener(this); + } + + ListBox::ListBox(ListModel *listModel) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mSelected(-1), + mListModel(listModel), + mWrappingEnabled(false), + mSelectionListeners() + { + setWidth(100); + adjustSize(); + setFocusable(true); + addMouseListener(this); + addKeyListener(this); + } + + void ListBox::draw(Graphics* graphics A_UNUSED) + { + } + + void ListBox::logic() + { + } + + int ListBox::getSelected() const + { + return mSelected; + } + + void ListBox::setSelected(int selected) + { + if (!mListModel) + { + mSelected = -1; + } + else + { + if (selected < 0) + mSelected = -1; + else if (selected >= mListModel->getNumberOfElements()) + mSelected = mListModel->getNumberOfElements() - 1; + else + mSelected = selected; + } + + Rectangle scroll; + + if (mSelected < 0) + scroll.y = 0; + else + scroll.y = getRowHeight() * mSelected; + + scroll.height = getRowHeight(); + showPart(scroll); + + distributeValueChangedEvent(); + } + + void ListBox::keyPressed(KeyEvent &keyEvent A_UNUSED) + { + } + + void ListBox::mousePressed(MouseEvent &mouseEvent A_UNUSED) + { + } + + void ListBox::mouseWheelMovedUp(MouseEvent& mouseEvent) + { + if (isFocused()) + { + if (getSelected() > 0 ) + setSelected(getSelected() - 1); + + mouseEvent.consume(); + } + } + + void ListBox::mouseWheelMovedDown(MouseEvent& mouseEvent) + { + if (isFocused()) + { + setSelected(getSelected() + 1); + + mouseEvent.consume(); + } + } + + void ListBox::mouseDragged(MouseEvent& mouseEvent) + { + mouseEvent.consume(); + } + + void ListBox::setListModel(ListModel *listModel) + { + mSelected = -1; + mListModel = listModel; + adjustSize(); + } + + ListModel* ListBox::getListModel() + { + return mListModel; + } + + void ListBox::adjustSize() + { + } + + bool ListBox::isWrappingEnabled() const + { + return mWrappingEnabled; + } + + void ListBox::setWrappingEnabled(bool wrappingEnabled) + { + mWrappingEnabled = wrappingEnabled; + } + + void ListBox::addSelectionListener(SelectionListener* selectionListener) + { + mSelectionListeners.push_back(selectionListener); + } + + void ListBox::removeSelectionListener(SelectionListener* selectionListener) + { + mSelectionListeners.remove(selectionListener); + } + + void ListBox::distributeValueChangedEvent() + { + for (SelectionListenerIterator iter = mSelectionListeners.begin(); + iter != mSelectionListeners.end(); + ++ iter) + { + SelectionEvent event(this); + (*iter)->valueChanged(event); + } + } + + unsigned int ListBox::getRowHeight() const + { + return getFont()->getHeight(); + } +} // namespace gcn diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp new file mode 100644 index 000000000..f2780f130 --- /dev/null +++ b/src/gui/base/widgets/listbox.hpp @@ -0,0 +1,275 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_LISTBOX_HPP +#define GCN_LISTBOX_HPP + +#include + +#include "gui/base/keylistener.hpp" +#include "gui/base/listmodel.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + class SelectionListener; + + /** + * An implementation of a list box where an item can be selected. + * + * To be able display a list the list box uses a user provided list model. + * A list model can be any class that implements the ListModel interface. + * + * If an item is selected in the list box a select event will be sent to + * all selection listeners of the list box. If an item is selected by using + * a mouse click or by using the enter or space key an action event will be + * sent to all action listeners of the list box. + */ + class ListBox : + public Widget, + public MouseListener, + public KeyListener + { + public: + /** + * Constructor. + */ + ListBox(); + + /** + * Constructor. + * + * @param listModel the list model to use. + */ + explicit ListBox(ListModel *listModel); + + A_DELETE_COPY(ListBox) + + /** + * Destructor. + */ + virtual ~ListBox() + { } + + /** + * Gets the selected item as an index in the list model. + * + * @return the selected item as an index in the list model. + * @see setSelected + */ + int getSelected() const; + + /** + * Sets the selected item. The selected item is represented by + * an index from the list model. + * + * @param selected the selected item as an index from the list model. + * @see getSelected + */ + void setSelected(int selected); + + /** + * Sets the list model to use. + * + * @param listModel the list model to use. + * @see getListModel + */ + void setListModel(ListModel *listModel); + + /** + * Gets the list model used. + * + * @return the list model used. + * @see setListModel + */ + ListModel *getListModel(); + + /** + * Adjusts the size of the list box to fit it's list model. + */ + void adjustSize(); + + /** + * Checks whether the list box wraps when selecting items with a + * keyboard. + * + * Wrapping means that the selection of items will be wrapped. That is, + * if the first item is selected and up is pressed, the last item will + * get selected. If the last item is selected and down is pressed, the + * first item will get selected. + * + * @return true if wrapping is enabled, fasle otherwise. + * @see setWrappingEnabled + */ + bool isWrappingEnabled() const; + + /** + * Sets the list box to wrap or not when selecting items with a + * keyboard. + * + * Wrapping means that the selection of items will be wrapped. That is, + * if the first item is selected and up is pressed, the last item will + * get selected. If the last item is selected and down is pressed, the + * first item will get selected. + * + * @see isWrappingEnabled + */ + void setWrappingEnabled(bool wrappingEnabled); + + /** + * Adds a selection listener to the list box. When the selection + * changes an event will be sent to all selection listeners of the + * list box. + * + * If you delete your selection listener, be sure to also remove it + * using removeSelectionListener(). + * + * @param selectionListener The selection listener to add. + * @since 0.8.0 + */ + void addSelectionListener(SelectionListener* selectionListener); + + /** + * Removes a selection listener from the list box. + * + * @param selectionListener The selection listener to remove. + * @since 0.8.0 + */ + void removeSelectionListener(SelectionListener* selectionListener); + + /** + * Gets the height of a row. Should be overridden if another row + * height than the font height is preferred. + * + * @return The height of a row. + * @since 0.8.0 + */ + virtual unsigned int getRowHeight() const; + + + // Inherited from Widget + + virtual void draw(Graphics* graphics); + + virtual void logic(); + + + // Inherited from KeyListener + + virtual void keyPressed(KeyEvent& keyEvent) override; + + + // Inherited from MouseListener + + virtual void mousePressed(MouseEvent& mouseEvent) override; + + virtual void mouseWheelMovedUp(MouseEvent& mouseEvent) override; + + virtual void mouseWheelMovedDown(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + + protected: + /** + * Distributes a value changed event to all selection listeners + * of the list box. + * + * @since 0.8.0 + */ + void distributeValueChangedEvent(); + + /** + * The selected item as an index in the list model. + */ + int mSelected; + + /** + * The list model to use. + */ + ListModel *mListModel; + + /** + * True if wrapping is enabled, false otherwise. + */ + bool mWrappingEnabled; + + /** + * Typdef. + */ + typedef std::list SelectionListenerList; + + /** + * The selection listeners of the list box. + */ + SelectionListenerList mSelectionListeners; + + /** + * Typedef. + */ + typedef SelectionListenerList::iterator SelectionListenerIterator; + }; +} // namespace gcn + +#endif // end GCN_LISTBOX_HPP diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp new file mode 100644 index 000000000..bfd5b1ff8 --- /dev/null +++ b/src/gui/base/widgets/radiobutton.cpp @@ -0,0 +1,207 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/radiobutton.hpp" + +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + RadioButton::GroupMap RadioButton::mGroupMap; + + RadioButton::RadioButton() : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mSelected(false), + mCaption(), + mGroup() + { + setSelected(false); + + setFocusable(true); + addMouseListener(this); + addKeyListener(this); + } + + RadioButton::RadioButton(const std::string &caption, + const std::string &group, + bool selected) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mSelected(false), + mCaption(), + mGroup() + { + setCaption(caption); + setGroup(group); + setSelected(selected); + + setFocusable(true); + addMouseListener(this); + addKeyListener(this); + + adjustSize(); + } + + RadioButton::~RadioButton() + { + // Remove us from the group list + setGroup(""); + } + + bool RadioButton::isSelected() const + { + return mSelected; + } + + void RadioButton::setSelected(bool selected) + { + if (selected && mGroup != "") + { + for (GroupIterator iter = mGroupMap.lower_bound(mGroup), + iterEnd = mGroupMap.upper_bound(mGroup); + iter != iterEnd; + ++ iter) + { + if (iter->second->isSelected()) + iter->second->setSelected(false); + } + } + + mSelected = selected; + } + + const std::string &RadioButton::getCaption() const + { + return mCaption; + } + + void RadioButton::setCaption(const std::string &caption) + { + mCaption = caption; + } + + void RadioButton::keyPressed(KeyEvent& keyEvent A_UNUSED) + { + } + + void RadioButton::mouseClicked(MouseEvent& mouseEvent) + { + if (mouseEvent.getButton() == MouseEvent::LEFT) + { + setSelected(true); + distributeActionEvent(); + } + } + + void RadioButton::mouseDragged(MouseEvent& mouseEvent) + { + mouseEvent.consume(); + } + + void RadioButton::setGroup(const std::string &group) + { + if (mGroup != "") + { + for (GroupIterator iter = mGroupMap.lower_bound(mGroup), + iterEnd = mGroupMap.upper_bound(mGroup); + iter != iterEnd; + ++ iter) + { + if (iter->second == this) + { + mGroupMap.erase(iter); + break; + } + } + } + + if (group != "") + { + mGroupMap.insert( + std::pair(group, this)); + } + + mGroup = group; + } + + const std::string &RadioButton::getGroup() const + { + return mGroup; + } + + void RadioButton::adjustSize() + { + } +} // namespace gcn diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp new file mode 100644 index 000000000..07e3d656a --- /dev/null +++ b/src/gui/base/widgets/radiobutton.hpp @@ -0,0 +1,226 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_RADIOBUTTON_HPP +#define GCN_RADIOBUTTON_HPP + +#include +#include + +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * An implementation of a radio button where a user can select or deselect + * the radio button and where the status of the radio button is displayed to the user. + * A radio button can belong to a group and when a radio button belongs to a + * group only one radio button can be selected in the group. A radio button is + * capable of displaying a caption. + * + * If a radio button's state changes an action event will be sent to all action + * listeners of the check box. + */ + class RadioButton : + public Widget, + public MouseListener, + public KeyListener + { + public: + /** + * Constructor. + */ + RadioButton(); + + /** + * Constructor. The radio button will be automatically resized + * to fit the caption. + * + * @param caption The caption of the radio button. + * @param group The group the radio button should belong to. + * @param selected True if the radio button should be selected. + */ + RadioButton(const std::string &caption, + const std::string &group, + bool selected = false); + + A_DELETE_COPY(RadioButton) + + /** + * Destructor. + */ + virtual ~RadioButton(); + + /** + * Checks if the radio button is selected. + * + * @return True if the radio button is selecte, false otherwise. + * @see setSelected + */ + bool isSelected() const; + + /** + * Sets the radio button to selected or not. + * + * @param selected True if the radio button should be selected, + * false otherwise. + * @see isSelected + */ + void setSelected(bool selected); + + /** + * Gets the caption of the radio button. + * + * @return The caption of the radio button. + * @see setCaption + */ + const std::string &getCaption() const; + + /** + * Sets the caption of the radio button. It's advisable to call + * adjustSize after setting of the caption to adjust the + * radio button's size to fit the caption. + * + * @param caption The caption of the radio button. + * @see getCaption, adjustSize + */ + void setCaption(const std::string &caption); + + /** + * Sets the group the radio button should belong to. Note that + * a radio button group is unique per application, not per Gui object + * as the group is stored in a static map. + * + * @param group The name of the group. + * @see getGroup + */ + void setGroup(const std::string &group); + + /** + * Gets the group the radio button belongs to. + * + * @return The group the radio button belongs to. + * @see setGroup + */ + const std::string &getGroup() const; + + /** + * Adjusts the radio button's size to fit the caption. + */ + void adjustSize(); + + + // Inherited from KeyListener + + virtual void keyPressed(KeyEvent& keyEvent) override; + + + // Inherited from MouseListener + + virtual void mouseClicked(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + protected: + /** + * Draws the box. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawBox(Graphics *graphics) = 0; + + /** + * True if the radio button is selected, false otherwise. + */ + bool mSelected; + + /** + * Holds the caption of the radio button. + */ + std::string mCaption; + + /** + * Holds the group of the radio button. + */ + std::string mGroup; + + /** + * Typdef. + */ + typedef std::multimap GroupMap; + + /** + * Typdef. + */ + typedef GroupMap::iterator GroupIterator; + + /** + * Holds all available radio button groups. + */ + static GroupMap mGroupMap; + }; +} // namespace gcn + +#endif // end GCN_RADIOBUTTON_HPP diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp new file mode 100644 index 000000000..e3dcfc61c --- /dev/null +++ b/src/gui/base/widgets/scrollarea.cpp @@ -0,0 +1,600 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/scrollarea.hpp" + +#include "gui/base/exception.hpp" +#include "gui/base/graphics.hpp" + +#include "debug.h" + +namespace gcn +{ + ScrollArea::ScrollArea() : + gcn::BasicContainer(), + gcn::MouseListener(), + mVScroll(0), + mHScroll(0), + mScrollbarWidth(12), + mHPolicy(SHOW_AUTO), + mVPolicy(SHOW_AUTO), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mUpButtonScrollAmount(10), + mDownButtonScrollAmount(10), + mLeftButtonScrollAmount(10), + mRightButtonScrollAmount(10), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mHorizontalMarkerDragOffset(0), + mVerticalMarkerDragOffset(0), + mOpaque(true) + { + addMouseListener(this); + } + + ScrollArea::ScrollArea(Widget *const content) : + gcn::BasicContainer(), + gcn::MouseListener(), + mVScroll(0), + mHScroll(0), + mScrollbarWidth(12), + mHPolicy(SHOW_AUTO), + mVPolicy(SHOW_AUTO), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mUpButtonScrollAmount(10), + mDownButtonScrollAmount(10), + mLeftButtonScrollAmount(10), + mRightButtonScrollAmount(10), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mHorizontalMarkerDragOffset(0), + mVerticalMarkerDragOffset(0), + mOpaque(true) + { + setContent(content); + addMouseListener(this); + } + + ScrollArea::ScrollArea(Widget *content, + ScrollPolicy hPolicy, + ScrollPolicy vPolicy) : + gcn::BasicContainer(), + gcn::MouseListener(), + mVScroll(0), + mHScroll(0), + mScrollbarWidth(12), + mHPolicy(hPolicy), + mVPolicy(vPolicy), + mVBarVisible(false), + mHBarVisible(false), + mUpButtonPressed(false), + mDownButtonPressed(false), + mLeftButtonPressed(false), + mRightButtonPressed(false), + mUpButtonScrollAmount(10), + mDownButtonScrollAmount(10), + mLeftButtonScrollAmount(10), + mRightButtonScrollAmount(10), + mIsVerticalMarkerDragged(false), + mIsHorizontalMarkerDragged(false), + mHorizontalMarkerDragOffset(0), + mVerticalMarkerDragOffset(0), + mOpaque(true) + { + setContent(content); + addMouseListener(this); + } + + ScrollArea::~ScrollArea() + { + setContent(nullptr); + } + + void ScrollArea::setContent(Widget* widget) + { + if (widget) + { + clear(); + add(widget); + widget->setPosition(0, 0); + } + else + { + clear(); + } + + checkPolicies(); + } + + Widget* ScrollArea::getContent() + { + if (!mWidgets.empty()) + return *mWidgets.begin(); + + return nullptr; + } + + void ScrollArea::setHorizontalScrollPolicy(ScrollPolicy hPolicy) + { + mHPolicy = hPolicy; + checkPolicies(); + } + + ScrollArea::ScrollPolicy ScrollArea::getHorizontalScrollPolicy() const + { + return mHPolicy; + } + + void ScrollArea::setVerticalScrollPolicy(ScrollPolicy vPolicy) + { + mVPolicy = vPolicy; + checkPolicies(); + } + + ScrollArea::ScrollPolicy ScrollArea::getVerticalScrollPolicy() const + { + return mVPolicy; + } + + void ScrollArea::setScrollPolicy(ScrollPolicy hPolicy, + ScrollPolicy vPolicy) + { + mHPolicy = hPolicy; + mVPolicy = vPolicy; + checkPolicies(); + } + + void ScrollArea::setVerticalScrollAmount(int vScroll) + { + const int max = getVerticalMaxScroll(); + + mVScroll = vScroll; + + if (vScroll > max) + mVScroll = max; + + if (vScroll < 0) + mVScroll = 0; + } + + int ScrollArea::getVerticalScrollAmount() const + { + return mVScroll; + } + + void ScrollArea::setHorizontalScrollAmount(int hScroll) + { + const int max = getHorizontalMaxScroll(); + + mHScroll = hScroll; + + if (hScroll > max) + mHScroll = max; + else if (hScroll < 0) + mHScroll = 0; + } + + int ScrollArea::getHorizontalScrollAmount() const + { + return mHScroll; + } + + void ScrollArea::setScrollAmount(int hScroll, int vScroll) + { + setHorizontalScrollAmount(hScroll); + setVerticalScrollAmount(vScroll); + } + + int ScrollArea::getHorizontalMaxScroll() + { + checkPolicies(); + + const Widget *const content = getContent(); + if (!content) + return 0; + + const int value = content->getWidth() - getChildrenArea().width + + 2 * content->getFrameSize(); + + if (value < 0) + return 0; + + return value; + } + + int ScrollArea::getVerticalMaxScroll() + { + checkPolicies(); + + const Widget *const content = getContent(); + if (!content) + return 0; + + int value; + + value = content->getHeight() - getChildrenArea().height + + 2 * content->getFrameSize(); + + if (value < 0) + return 0; + + return value; + } + + void ScrollArea::setScrollbarWidth(int width) + { + if (width > 0) + mScrollbarWidth = width; + else + throw GCN_EXCEPTION("Width should be greater then 0."); + } + + int ScrollArea::getScrollbarWidth() const + { + return mScrollbarWidth; + } + + void ScrollArea::mouseReleased(MouseEvent& mouseEvent) + { + mUpButtonPressed = false; + mDownButtonPressed = false; + mLeftButtonPressed = false; + mRightButtonPressed = false; + mIsHorizontalMarkerDragged = false; + mIsVerticalMarkerDragged = false; + + mouseEvent.consume(); + } + + void ScrollArea::draw(Graphics *graphics A_UNUSED) + { + } + + void ScrollArea::drawHBar(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawVBar(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawBackground(Graphics *graphics A_UNUSED) + { + } + + void ScrollArea::drawUpButton(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawDownButton(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawLeftButton(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawRightButton(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawVMarker(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::drawHMarker(Graphics* graphics A_UNUSED) + { + } + + void ScrollArea::logic() + { + BLOCK_START("ScrollArea::logic") + checkPolicies(); + + setVerticalScrollAmount(getVerticalScrollAmount()); + setHorizontalScrollAmount(getHorizontalScrollAmount()); + + Widget *const content = getContent(); + if (content) + { + const int frameSize = content->getFrameSize(); + content->setPosition(-mHScroll + frameSize, -mVScroll + frameSize); + content->logic(); + } + BLOCK_END("ScrollArea::logic") + } + + void ScrollArea::checkPolicies() + { + const int w = getWidth(); + const int h = getHeight(); + + mHBarVisible = false; + mVBarVisible = false; + + const Widget *const content = getContent(); + if (!content) + { + mHBarVisible = (mHPolicy == SHOW_ALWAYS); + mVBarVisible = (mVPolicy == SHOW_ALWAYS); + return; + } + + if (mHPolicy == SHOW_AUTO && + mVPolicy == SHOW_AUTO) + { + if (content->getWidth() <= w + && content->getHeight() <= h) + { + mHBarVisible = false; + mVBarVisible = false; + } + + if (content->getWidth() > w) + { + mHBarVisible = true; + } + + if ((content->getHeight() > h) + || (mHBarVisible && content->getHeight() + > h - mScrollbarWidth)) + { + mVBarVisible = true; + } + + if (mVBarVisible && content->getWidth() > w - mScrollbarWidth) + mHBarVisible = true; + + return; + } + + switch (mHPolicy) + { + case SHOW_NEVER: + mHBarVisible = false; + break; + + case SHOW_ALWAYS: + mHBarVisible = true; + break; + + case SHOW_AUTO: + if (mVPolicy == SHOW_NEVER) + { + mHBarVisible = (content->getWidth() > w); + } + else // (mVPolicy == SHOW_ALWAYS) + { + mHBarVisible = (content->getWidth() + > w - mScrollbarWidth); + } + break; + + default: + throw GCN_EXCEPTION("Horizontal scroll policy invalid."); + } + + switch (mVPolicy) + { + case SHOW_NEVER: + mVBarVisible = false; + break; + + case SHOW_ALWAYS: + mVBarVisible = true; + break; + + case SHOW_AUTO: + if (mHPolicy == SHOW_NEVER) + { + mVBarVisible = (content->getHeight() > h); + } + else // (mHPolicy == SHOW_ALWAYS) + { + mVBarVisible = (content->getHeight() + > h - mScrollbarWidth); + } + break; + default: + throw GCN_EXCEPTION("Vertical scroll policy invalid."); + } + } + + Rectangle ScrollArea::getChildrenArea() + { + const Rectangle area = Rectangle(0, 0, + mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(), + mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight()); + + if (area.width < 0 || area.height < 0) + return Rectangle(); + + return area; + } + + void ScrollArea::showWidgetPart(Widget* widget, Rectangle area) + { + const Widget *const content = getContent(); + if (widget != content) + throw GCN_EXCEPTION("Widget not content widget"); + + BasicContainer::showWidgetPart(widget, area); + + setHorizontalScrollAmount(content->getFrameSize() + - content->getX()); + setVerticalScrollAmount(content->getFrameSize() + - content->getY()); + } + + Widget *ScrollArea::getWidgetAt(int x, int y) + { + if (getChildrenArea().isPointInRect(x, y)) + return getContent(); + + return nullptr; + } + + void ScrollArea::mouseWheelMovedUp(MouseEvent& mouseEvent) + { + if (mouseEvent.isConsumed()) + return; + + setVerticalScrollAmount(getVerticalScrollAmount() + - getChildrenArea().height / 8); + + mouseEvent.consume(); + } + + void ScrollArea::mouseWheelMovedDown(MouseEvent& mouseEvent) + { + if (mouseEvent.isConsumed()) + return; + + setVerticalScrollAmount(getVerticalScrollAmount() + + getChildrenArea().height / 8); + + mouseEvent.consume(); + } + + void ScrollArea::setWidth(int width) + { + Widget::setWidth(width); + checkPolicies(); + } + + void ScrollArea::setHeight(int height) + { + Widget::setHeight(height); + checkPolicies(); + } + + void ScrollArea::setDimension(const Rectangle& dimension) + { + Widget::setDimension(dimension); + checkPolicies(); + } + + void ScrollArea::setLeftButtonScrollAmount(int amount) + { + mLeftButtonScrollAmount = amount; + } + + void ScrollArea::setRightButtonScrollAmount(int amount) + { + mRightButtonScrollAmount = amount; + } + + void ScrollArea::setUpButtonScrollAmount(int amount) + { + mUpButtonScrollAmount = amount; + } + + void ScrollArea::setDownButtonScrollAmount(int amount) + { + mDownButtonScrollAmount = amount; + } + + int ScrollArea::getLeftButtonScrollAmount() const + { + return mLeftButtonScrollAmount; + } + + int ScrollArea::getRightButtonScrollAmount() const + { + return mRightButtonScrollAmount; + } + + int ScrollArea::getUpButtonScrollAmount() const + { + return mUpButtonScrollAmount; + } + + int ScrollArea::getDownButtonScrollAmount() const + { + return mDownButtonScrollAmount; + } + + void ScrollArea::setOpaque(bool opaque) + { + mOpaque = opaque; + } + + bool ScrollArea::isOpaque() const + { + return mOpaque; + } +} // namespace gcn diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp new file mode 100644 index 000000000..e75390ec0 --- /dev/null +++ b/src/gui/base/widgets/scrollarea.hpp @@ -0,0 +1,549 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_SCROLLAREA_HPP +#define GCN_SCROLLAREA_HPP + +#include + +#include "gui/base/basiccontainer.hpp" +#include "gui/base/mouselistener.hpp" + +namespace gcn +{ + /** + * Implementation if a scrollable area used to view widgets larger than the scroll area. + * A scroll area can be customized to always show scroll bars or to show them only when + * necessary. + */ + class ScrollArea: + public BasicContainer, + public MouseListener + { + public: + /** + * Scrollpolicies for the horizontal and vertical scrollbar. + * The policies are: + * + * SHOW_ALWAYS - Always show the scrollbars no matter what. + * SHOW_NEVER - Never show the scrollbars no matter waht. + * SHOW_AUTO - Show the scrollbars only when needed. That is if the + * content grows larger then the ScrollArea. + */ + enum ScrollPolicy + { + SHOW_ALWAYS = 0, + SHOW_NEVER, + SHOW_AUTO + }; + + /** + * Constructor. + */ + ScrollArea(); + + /** + * Constructor. + * + * @param content The content of the scroll area. + */ + explicit ScrollArea(Widget *const content); + + /** + * Constructor. + * + * @param content The content of the scroll area. + * @param hPolicy The policy for the horizontal scrollbar. See enum with + * policies. + * @param vPolicy The policy for the vertical scrollbar. See enum with + * policies. + */ + ScrollArea(Widget *content, + ScrollPolicy hPolicy, + ScrollPolicy vPolicy); + + A_DELETE_COPY(ScrollArea) + + /** + * Destructor. + */ + virtual ~ScrollArea(); + + /** + * Sets the content. + * + * @param widget The content of the scroll area. + */ + void setContent(Widget* widget); + + /** + * Gets the content. + * + * @return The content of the scroll area. + */ + Widget* getContent(); + + /** + * Sets the horizontal scrollbar policy. See enum with policies. + * + * @param hPolicy The policy for the horizontal scrollbar. + * @see getHorizontalScrollPolicy + */ + void setHorizontalScrollPolicy(ScrollPolicy hPolicy); + + /** + * Gets the horizontal scrollbar policy. See enum with policies. + * + * @return The policy for the horizontal scrollbar policy. + * @see setHorizontalScrollPolicy, setScrollPolicy + */ + ScrollPolicy getHorizontalScrollPolicy() const; + + /** + * Sets the vertical scrollbar policy. See enum with policies. + * + * @param vPolicy The policy for the vertical scrollbar. + * @see getVerticalScrollPolicy + */ + void setVerticalScrollPolicy(ScrollPolicy vPolicy); + + /** + * Gets the vertical scrollbar policy. See enum with policies. + * + * @return The policy for the vertical scrollbar. + * @see setVerticalScrollPolicy, setScrollPolicy + */ + ScrollPolicy getVerticalScrollPolicy() const; + + /** + * Sets the horizontal and vertical scrollbar policy. + * + * @param hPolicy The policy for the horizontal scrollbar. + * @param vPolicy The policy for the vertical scrollbar. + * @see getVerticalScrollPolicy, getHorizontalScrollPolicy + */ + void setScrollPolicy(ScrollPolicy hPolicy, ScrollPolicy vPolicy); + + /** + * Sets the amount to scroll vertically. + * + * @param vScroll The amount to scroll. + * @see getVerticalScrollAmount + */ + void setVerticalScrollAmount(int vScroll); + + /** + * Gets the amount that is scrolled vertically. + * + * @return The scroll amount on vertical scroll. + * @see setVerticalScrollAmount, setScrollAmount + */ + int getVerticalScrollAmount() const; + + /** + * Sets the amount to scroll horizontally. + * + * @param hScroll The amount to scroll. + * @see getHorizontalScrollAmount + */ + void setHorizontalScrollAmount(int hScroll); + + /** + * Gets the amount that is scrolled horizontally. + * + * @return The scroll amount on horizontal scroll. + * @see setHorizontalScrollAmount, setScrollAmount + */ + int getHorizontalScrollAmount() const; + + /** + * Sets the amount to scroll horizontally and vertically. + * + * @param hScroll The amount to scroll on horizontal scroll. + * @param vScroll The amount to scroll on vertical scroll. + * @see getHorizontalScrollAmount, getVerticalScrollAmount + */ + void setScrollAmount(int hScroll, int vScroll); + + /** + * Gets the maximum amount of horizontal scroll. + * + * @return The horizontal max scroll. + */ + int getHorizontalMaxScroll(); + + /** + * Gets the maximum amount of vertical scroll. + * + * @return The vertical max scroll. + */ + int getVerticalMaxScroll(); + + /** + * Sets the width of the scroll bars. + * + * @param width The width of the scroll bars. + * @see getScrollbarWidth + */ + void setScrollbarWidth(int width); + + /** + * Gets the width of the scroll bars. + * + * @return the width of the ScrollBar. + * @see setScrollbarWidth + */ + int getScrollbarWidth() const; + + /** + * Sets the amount to scroll in pixels when the left scroll button is + * pushed. + * + * @param amount The amount to scroll in pixels. + * @see getLeftButtonScrollAmount + */ + void setLeftButtonScrollAmount(int amount); + + /** + * Sets the amount to scroll in pixels when the right scroll button is + * pushed. + * + * @param amount The amount to scroll in pixels. + * @see getRightButtonScrollAmount + */ + void setRightButtonScrollAmount(int amount); + + /** + * Sets the amount to scroll in pixels when the up scroll button is + * pushed. + * + * @param amount The amount to scroll in pixels. + * @see getUpButtonScrollAmount + */ + void setUpButtonScrollAmount(int amount); + + /** + * Sets the amount to scroll in pixels when the down scroll button is + * pushed. + * + * @param amount The amount to scroll in pixels. + * @see getDownButtonScrollAmount + */ + void setDownButtonScrollAmount(int amount); + + /** + * Gets the amount to scroll in pixels when the left scroll button is + * pushed. + * + * @return The amount to scroll in pixels. + * @see setLeftButtonScrollAmount + */ + int getLeftButtonScrollAmount() const; + + /** + * Gets the amount to scroll in pixels when the right scroll button is + * pushed. + * + * @return The amount to scroll in pixels. + * @see setRightButtonScrollAmount + */ + int getRightButtonScrollAmount() const; + + /** + * Gets the amount to scroll in pixels when the up scroll button is + * pushed. + * + * @return The amount to scroll in pixels. + * @see setUpButtonScrollAmount + */ + int getUpButtonScrollAmount() const; + + /** + * Gets the amount to scroll in pixels when the down scroll button is + * pushed. + * + * @return The amount to scroll in pixels. + * @see setDownButtonScrollAmount + */ + int getDownButtonScrollAmount() const; + + /** + * Sets the scroll area to be opaque, that is sets the scoll area + * to display its background. + * + * @param opaque True if the scoll area should be opaque, false otherwise. + */ + void setOpaque(bool opaque); + + /** + * Checks if the scroll area is opaque, that is if the scroll area + * displays its background. + * + * @return True if the scroll area is opaque, false otherwise. + */ + bool isOpaque() const; + + // Inherited from BasicContainer + + virtual void showWidgetPart(Widget* widget, Rectangle area); + + virtual Rectangle getChildrenArea(); + + virtual Widget *getWidgetAt(int x, int y); + + + // Inherited from Widget + + virtual void draw(Graphics *graphics); + + virtual void logic(); + + void setWidth(int width); + + void setHeight(int height); + + void setDimension(const Rectangle& dimension); + + + // Inherited from MouseListener + + virtual void mouseReleased(MouseEvent& mouseEvent) override; + + virtual void mouseWheelMovedUp(MouseEvent& mouseEvent) override; + + virtual void mouseWheelMovedDown(MouseEvent& mouseEvent) override; + + protected: + /** + * Draws the background of the scroll area, that is + * the area behind the content. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawBackground(Graphics *graphics); + + /** + * Draws the up button. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawUpButton(Graphics *graphics); + + /** + * Draws the down button. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawDownButton(Graphics *graphics); + + /** + * Draws the left button. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawLeftButton(Graphics *graphics); + + /** + * Draws the right button. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawRightButton(Graphics *graphics); + + /** + * Draws the vertical scroll bar. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawVBar(Graphics* graphics); + + /** + * Draws the horizontal scroll bar. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawHBar(Graphics* graphics); + + /** + * Draws the vertical marker. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawVMarker(Graphics* graphics); + + /** + * Draws the horizontal marker. + * + * @param graphics a Graphics object to draw with. + */ + virtual void drawHMarker(Graphics* graphics); + + /** + * Checks the policies for the scroll bars. + */ + virtual void checkPolicies(); + + /** + * Holds the vertical scroll amount. + */ + int mVScroll; + + /** + * Holds the horizontal scroll amount. + */ + int mHScroll; + + /** + * Holds the width of the scroll bars. + */ + int mScrollbarWidth; + + /** + * Holds the horizontal scroll bar policy. + */ + ScrollPolicy mHPolicy; + + /** + * Holds the vertical scroll bar policy. + */ + ScrollPolicy mVPolicy; + + /** + * True if the vertical scroll bar is visible, false otherwise. + */ + bool mVBarVisible; + + /** + * True if the horizontal scroll bar is visible, false otherwise. + */ + bool mHBarVisible; + + /** + * True if the up button is pressed, false otherwise. + */ + bool mUpButtonPressed; + + /** + * True if the down button is pressed, false otherwise. + */ + bool mDownButtonPressed; + + /** + * True if the left button is pressed, false otherwise. + */ + bool mLeftButtonPressed; + + /** + * True if the right button is pressed, false otherwise. + */ + bool mRightButtonPressed; + + /** + * Holds the up button scroll amount. + */ + int mUpButtonScrollAmount; + + /** + * Holds the down button scroll amount. + */ + int mDownButtonScrollAmount; + + /** + * Holds the left button scroll amount. + */ + int mLeftButtonScrollAmount; + + /** + * Holds the right button scroll amount. + */ + int mRightButtonScrollAmount; + + /** + * True if the vertical marked is dragged. + */ + bool mIsVerticalMarkerDragged; + + /** + * True if the horizontal marked is dragged. + */ + bool mIsHorizontalMarkerDragged; + + /** + * Holds the horizontal markers drag offset. + */ + int mHorizontalMarkerDragOffset; + + /** + * Holds the vertical markers drag offset. + */ + int mVerticalMarkerDragOffset; + + /** + * True if the scroll area should be opaque (that is + * display its background), false otherwise. + */ + bool mOpaque; + }; +} // namespace gcn + +#endif // end GCN_SCROLLAREA_HPP diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp new file mode 100644 index 000000000..a1a106303 --- /dev/null +++ b/src/gui/base/widgets/slider.cpp @@ -0,0 +1,231 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/slider.hpp" + +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + Slider::Slider(const double scaleEnd) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mDragged(false), + mValue(0), + mStepLength(scaleEnd / 10), + mMarkerLength(10), + mScaleStart(0), + mScaleEnd(scaleEnd), + mOrientation(HORIZONTAL) + { + setFocusable(true); + setFrameSize(1); + + addMouseListener(this); + addKeyListener(this); + } + + Slider::Slider(const double scaleStart, const double scaleEnd) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mDragged(false), + mValue(scaleStart), + mStepLength((scaleEnd - scaleStart) / 10), + mMarkerLength(10), + mScaleStart(scaleStart), + mScaleEnd(scaleEnd), + mOrientation(HORIZONTAL) + { + setFocusable(true); + setFrameSize(1); + + addMouseListener(this); + addKeyListener(this); + } + + void Slider::setScale(double scaleStart, double scaleEnd) + { + mScaleStart = scaleStart; + mScaleEnd = scaleEnd; + } + + double Slider::getScaleStart() const + { + return mScaleStart; + } + + void Slider::setScaleStart(double scaleStart) + { + mScaleStart = scaleStart; + } + + double Slider::getScaleEnd() const + { + return mScaleEnd; + } + + void Slider::setScaleEnd(double scaleEnd) + { + mScaleEnd = scaleEnd; + } + + void Slider::setValue(double value) + { + if (value > getScaleEnd()) + { + mValue = getScaleEnd(); + return; + } + + if (value < getScaleStart()) + { + mValue = getScaleStart(); + return; + } + + mValue = value; + } + + double Slider::getValue() const + { + return mValue; + } + + int Slider::getMarkerLength() const + { + return mMarkerLength; + } + + void Slider::setMarkerLength(int length) + { + mMarkerLength = length; + } + + void Slider::setOrientation(Slider::Orientation orientation) + { + mOrientation = orientation; + } + + Slider::Orientation Slider::getOrientation() const + { + return mOrientation; + } + + double Slider::markerPositionToValue(int v) const + { + int w; + if (getOrientation() == HORIZONTAL) + w = getWidth(); + else + w = getHeight(); + + const double pos = v / (static_cast(w) - getMarkerLength()); + return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); + } + + int Slider::valueToMarkerPosition(double value) const + { + int v; + if (getOrientation() == HORIZONTAL) + v = getWidth(); + else + v = getHeight(); + + const int w = static_cast((v - getMarkerLength()) + * (value - getScaleStart()) + / (getScaleEnd() - getScaleStart())); + + if (w < 0) + return 0; + + if (w > v - getMarkerLength()) + return v - getMarkerLength(); + + return w; + } + + void Slider::setStepLength(double length) + { + mStepLength = length; + } + + double Slider::getStepLength() const + { + return mStepLength; + } + + int Slider::getMarkerPosition() const + { + return valueToMarkerPosition(getValue()); + } +} // namespace gcn diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp new file mode 100644 index 000000000..32cdfefb9 --- /dev/null +++ b/src/gui/base/widgets/slider.hpp @@ -0,0 +1,293 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_SLIDER_HPP +#define GCN_SLIDER_HPP + +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * An implementation of a slider where a user can select different values by + * sliding between a start value and an end value of a scale. + * + * If the selected value is changed an action event will be sent to all + * action listeners of the slider. + */ + class Slider : + public Widget, + public MouseListener, + public KeyListener + { + public: + /** + * Draw orientations for the slider. A slider can be drawn vertically or + * horizontally. + */ + enum Orientation + { + HORIZONTAL = 0, + VERTICAL + }; + + /** + * Constructor. The default start value of the slider scale is zero. + * + * @param scaleEnd The end value of the slider scale. + */ + explicit Slider(const double scaleEnd = 1.0); + + /** + * Constructor. + * + * @param scaleStart The start value of the slider scale. + * @param scaleEnd The end value of the slider scale. + */ + Slider(const double scaleStart, const double scaleEnd); + + A_DELETE_COPY(Slider) + + /** + * Destructor. + */ + virtual ~Slider() + { } + + /** + * Sets the scale of the slider. + * + * @param scaleStart The start value of the scale. + * @param scaleEnd tThe end of value the scale. + * @see getScaleStart, getScaleEnd + */ + void setScale(double scaleStart, double scaleEnd); + + /** + * Gets the start value of the scale. + * + * @return The start value of the scale. + * @see setScaleStart, setScale + */ + double getScaleStart() const; + + /** + * Sets the start value of the scale. + * + * @param scaleStart The start value of the scale. + * @see getScaleStart + */ + void setScaleStart(double scaleStart); + + /** + * Gets the end value of the scale. + * + * @return The end value of the scale. + * @see setScaleEnd, setScale + */ + double getScaleEnd() const; + + /** + * Sets the end value of the scale. + * + * @param scaleEnd The end value of the scale. + * @see getScaleEnd + */ + void setScaleEnd(double scaleEnd); + + /** + * Gets the current selected value. + * + * @return The current selected value. + * @see setValue + */ + double getValue() const; + + /** + * Sets the current selected value. + * + * @param value The current selected value. + * @see getValue + */ + void setValue(double value); + + /** + * Sets the length of the marker. + * + * @param length The length for the marker. + * @see getMarkerLength + */ + void setMarkerLength(int length); + + /** + * Gets the length of the marker. + * + * @return The length of the marker. + * @see setMarkerLength + */ + int getMarkerLength() const; + + /** + * Sets the orientation of the slider. A slider can be drawn vertically + * or horizontally. + * + * @param orientation The orientation of the slider. + * @see getOrientation + */ + void setOrientation(Orientation orientation); + + /** + * Gets the orientation of the slider. A slider can be drawn vertically + * or horizontally. + * + * @return The orientation of the slider. + * @see setOrientation + */ + Orientation getOrientation() const; + + /** + * Sets the step length. The step length is used when the keys LEFT + * and RIGHT are pressed to step in the scale. + * + * @param length The step length. + * @see getStepLength + */ + void setStepLength(double length); + + /** + * Gets the step length. The step length is used when the keys LEFT + * and RIGHT are pressed to step in the scale. + * + * @return the step length. + * @see setStepLength + */ + double getStepLength() const; + + protected: + /** + * Converts a marker position to a value in the scale. + * + * @param position The position to convert. + * @return A scale value corresponding to the position. + * @see valueToMarkerPosition + */ + virtual double markerPositionToValue(int position) const; + + /** + * Converts a value to a marker position. + * + * @param value The value to convert. + * @return A marker position corresponding to the value. + * @see markerPositionToValue + */ + virtual int valueToMarkerPosition(double value) const; + + /** + * Gets the marker position of the current selected value. + * + * @return The marker position of the current selected value. + */ + virtual int getMarkerPosition() const; + + /** + * True if the slider is dragged, false otherwise. + */ + bool mDragged; + + /** + * Holds the current selected value. + */ + double mValue; + + /** + * Holds the step length. The step length is used when the keys LEFT + * and RIGHT are pressed to step in the scale. + */ + double mStepLength; + + /** + * Holds the length of the marker. + */ + int mMarkerLength; + + /** + * Holds the start value of the scale. + */ + double mScaleStart; + + /** + * Holds the end value of the scale. + */ + double mScaleEnd; + + /** + * Holds the orientation of the slider. A slider can be drawn + * vertically or horizontally. + */ + Orientation mOrientation; + }; +} // namespace gcn + +#endif // end GCN_SLIDER_HPP diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp new file mode 100644 index 000000000..2e9ca0563 --- /dev/null +++ b/src/gui/base/widgets/textbox.cpp @@ -0,0 +1,345 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/textbox.hpp" + +#include "gui/base/basiccontainer.hpp" +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + TextBox::TextBox() : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mTextRows(), + mCaretColumn(0), + mCaretRow(0), + mEditable(true), + mOpaque(true) + { + setText(""); + setFocusable(true); + + addMouseListener(this); + addKeyListener(this); + adjustSize(); + } + + TextBox::TextBox(const std::string& text) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mTextRows(), + mCaretColumn(0), + mCaretRow(0), + mEditable(true), + mOpaque(true) + { + setText(text); + setFocusable(true); + + addMouseListener(this); + addKeyListener(this); + adjustSize(); + } + + void TextBox::setText(const std::string& text) + { + mCaretColumn = 0; + mCaretRow = 0; + + mTextRows.clear(); + + size_t pos, lastPos = 0; + int length; + do + { + pos = text.find("\n", lastPos); + + if (pos != std::string::npos) + length = static_cast(pos - lastPos); + else + length = static_cast(text.size() - lastPos); + std::string sub = text.substr(lastPos, length); + mTextRows.push_back(sub); + lastPos = pos + 1; + } while (pos != std::string::npos); + + adjustSize(); + } + +/* + void TextBox::draw(Graphics* graphics) + { + } +*/ + + void TextBox::drawCaret(Graphics* graphics, int x, int y) + { + graphics->setColor(mForegroundColor); + graphics->drawLine(x, getFont()->getHeight() + y, x, y); + } + + void TextBox::mousePressed(MouseEvent& mouseEvent) + { + if (mouseEvent.getButton() == MouseEvent::LEFT) + { + mCaretRow = mouseEvent.getY() / getFont()->getHeight(); + + const int sz = static_cast(mTextRows.size()); + if (mCaretRow >= sz) + mCaretRow = sz - 1; + + mCaretColumn = getFont()->getStringIndexAt( + mTextRows[mCaretRow], mouseEvent.getX()); + } + } + + void TextBox::mouseDragged(MouseEvent& mouseEvent) + { + mouseEvent.consume(); + } + + void TextBox::keyPressed(KeyEvent& keyEvent A_UNUSED) + { + } + + void TextBox::adjustSize() + { + int width = 0; + for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i) + { + const int w = getFont()->getWidth(mTextRows[i]); + if (width < w) + width = w; + } + + setWidth(width + 1); + setHeight(static_cast(getFont()->getHeight() * mTextRows.size())); + } + + void TextBox::setCaretPosition(unsigned int position) + { + for (int row = 0, sz = static_cast(mTextRows.size()); + row < sz; row ++) + { + if (position <= mTextRows[row].size()) + { + mCaretRow = row; + mCaretColumn = position; + return; // we are done + } + else + { + position--; + } + } + + // position beyond end of text + mCaretRow = static_cast(mTextRows.size() - 1); + mCaretColumn = static_cast(mTextRows[mCaretRow].size()); + } + + unsigned int TextBox::getCaretPosition() const + { + int pos = 0, row; + + for (row = 0; row < mCaretRow; row++) + pos += static_cast(mTextRows[row].size()); + + return pos + mCaretColumn; + } + + void TextBox::setCaretRowColumn(int row, int column) + { + setCaretRow(row); + setCaretColumn(column); + } + + void TextBox::setCaretRow(int row) + { + mCaretRow = row; + + const int sz = static_cast(mTextRows.size()); + if (mCaretRow >= sz) + mCaretRow = sz - 1; + + if (mCaretRow < 0) + mCaretRow = 0; + + setCaretColumn(mCaretColumn); + } + + unsigned int TextBox::getCaretRow() const + { + return mCaretRow; + } + + void TextBox::setCaretColumn(int column) + { + mCaretColumn = column; + + const int sz = static_cast(mTextRows[mCaretRow].size()); + if (mCaretColumn > sz) + mCaretColumn = sz; + + if (mCaretColumn < 0) + mCaretColumn = 0; + } + + unsigned int TextBox::getCaretColumn() const + { + return mCaretColumn; + } + + const std::string& TextBox::getTextRow(int row) const + { + return mTextRows[row]; + } + + void TextBox::setTextRow(int row, const std::string& text) + { + mTextRows[row] = text; + + if (mCaretRow == row) + setCaretColumn(mCaretColumn); + + adjustSize(); + } + + unsigned int TextBox::getNumberOfRows() const + { + return static_cast(mTextRows.size()); + } + + std::string TextBox::getText() const + { + if (mTextRows.empty()) + return std::string(""); + + int i; + std::string text; + + const int sz = static_cast(mTextRows.size()); + for (i = 0; i < sz - 1; ++ i) + text.append(mTextRows[i]).append("\n"); + text.append(mTextRows[i]); + + return text; + } + + void TextBox::fontChanged() + { + adjustSize(); + } + + void TextBox::scrollToCaret() + { + Rectangle scroll; + scroll.x = getFont()->getWidth( + mTextRows[mCaretRow].substr(0, mCaretColumn)); + scroll.y = getFont()->getHeight() * mCaretRow; + scroll.width = getFont()->getWidth(" "); + + // add 2 for some extra space + scroll.height = getFont()->getHeight() + 2; + + showPart(scroll); + } + + void TextBox::setEditable(bool editable) + { + mEditable = editable; + } + + bool TextBox::isEditable() const + { + return mEditable; + } + + void TextBox::addRow(const std::string &row) + { + mTextRows.push_back(row); + adjustSize(); + } + + bool TextBox::isOpaque() + { + return mOpaque; + } + + void TextBox::setOpaque(bool opaque) + { + mOpaque = opaque; + } +} // namespace gcn diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp new file mode 100644 index 000000000..0a540a2c1 --- /dev/null +++ b/src/gui/base/widgets/textbox.hpp @@ -0,0 +1,310 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_TEXTBOX_HPP +#define GCN_TEXTBOX_HPP + +#include +#include +#include + +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +namespace gcn +{ + /** + * An implementation of a text box where a user can enter text that contains of many lines. + */ + class TextBox: + public Widget, + public MouseListener, + public KeyListener + { + public: + /** + * Constructor. + */ + TextBox(); + + /** + * Constructor. + * + * @param text The default text of the text box. + */ + explicit TextBox(const std::string& text); + + A_DELETE_COPY(TextBox) + + /** + * Sets the text of the text box. + * + * @param text The text of the text box. + * @see getText + */ + void setText(const std::string& text); + + /** + * Gets the text of the text box. + * + * @return The text of the text box. + * @see setText + */ + std::string getText() const; + + /** + * Gets a certain row from the text. + * + * @param row The number of the row to get from the text. + * @return A row from the text of the text box. + * @see setTextRow + */ + const std::string& getTextRow(int row) const; + + /** + * Sets the text of a certain row of the text. + * + * @param row The number of the row to set in the text. + * @param text The text to set in the given row number. + * @see getTextRow + */ + void setTextRow(int row, const std::string& text); + + /** + * Gets the number of rows in the text. + * + * @return The number of rows in the text. + */ + unsigned int getNumberOfRows() const; + + /** + * Gets the caret position in the text. + * + * @return The caret position in the text. + * @see setCaretPosition + */ + unsigned int getCaretPosition() const; + + /** + * Sets the position of the caret in the text. + * + * @param position the positon of the caret. + * @see getCaretPosition + */ + void setCaretPosition(unsigned int position); + + /** + * Gets the row number where the caret is currently located. + * + * @return The row number where the caret is currently located. + * @see setCaretRow + */ + unsigned int getCaretRow() const; + + /** + * Sets the row where the caret should be currently located. + * + * @param The row where the caret should be currently located. + * @see getCaretRow + */ + void setCaretRow(int row); + + /** + * Gets the column where the caret is currently located. + * + * @return The column where the caret is currently located. + * @see setCaretColumn + */ + unsigned int getCaretColumn() const; + + /** + * Sets the column where the caret should be currently located. + * + * @param The column where the caret should be currently located. + * @see getCaretColumn + */ + void setCaretColumn(int column); + + /** + * Sets the row and the column where the caret should be curretly + * located. + * + * @param row The row where the caret should be currently located. + * @param column The column where the caret should be currently located. + * @see getCaretRow, getCaretColumn + */ + void setCaretRowColumn(int row, int column); + + /** + * Scrolls the text to the caret if the text box is in a scroll area. + * + * @see ScrollArea + */ + virtual void scrollToCaret(); + + /** + * Checks if the text box is editable. + * + * @return True it the text box is editable, false otherwise. + * @see setEditable + */ + bool isEditable() const; + + /** + * Sets the text box to be editable or not. + * + * @param editable True if the text box should be editable, false otherwise. + */ + void setEditable(bool editable); + + /** + * Adds a row of text to the end of the text. + * + * @param row The row to add. + */ + virtual void addRow(const std::string &row); + + /** + * Checks if the text box is opaque. An opaque text box will draw + * it's background and it's text. A non opaque text box only draw it's + * text making it transparent. + * + * @return True if the text box is opaque, false otherwise. + * @see setOpaque + */ + bool isOpaque(); + + /** + * Sets the text box to be opaque or not. An opaque text box will draw + * it's background and it's text. A non opaque text box only draw it's + * text making it transparent. + * + * @param opaque True if the text box should be opaque, false otherwise. + * @see isOpaque + */ + void setOpaque(bool opaque); + + + // Inherited from Widget + +// virtual void draw(Graphics* graphics); + + virtual void fontChanged(); + + + // Inherited from KeyListener + + virtual void keyPressed(KeyEvent& keyEvent) override; + + + // Inherited from MouseListener + + virtual void mousePressed(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + protected: + /** + * Draws the caret. Overloaded this method if you want to + * change the style of the caret. + * + * @param graphics a Graphics object to draw with. + * @param x the x position. + * @param y the y position. + */ + virtual void drawCaret(Graphics* graphics, int x, int y); + + /** + * Adjusts the text box's size to fit the text. + */ + virtual void adjustSize(); + + /** + * Holds all the rows of the text. + */ + std::vector mTextRows; + + /** + * Holds the current column of the caret. + */ + int mCaretColumn; + + /** + * Holds the current row of the caret. + */ + int mCaretRow; + + /** + * True if the text box is editable, false otherwise. + */ + bool mEditable; + + /** + * True if the text box is editable, false otherwise. + */ + bool mOpaque; + }; +} // namespace gcn + +#endif // end GCN_TEXTBOX_HPP diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp new file mode 100644 index 000000000..586e49663 --- /dev/null +++ b/src/gui/base/widgets/textfield.cpp @@ -0,0 +1,165 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/textfield.hpp" + +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + TextField::TextField() : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mText(), + mCaretPosition(0), + mXScroll(0) + { + setFocusable(true); + + addMouseListener(this); + addKeyListener(this); + } + + TextField::TextField(const std::string& text) : + gcn::Widget(), + gcn::MouseListener(), + gcn::KeyListener(), + mText(text), + mCaretPosition(0), + mXScroll(0) + { + adjustSize(); + + setFocusable(true); + + addMouseListener(this); + addKeyListener(this); + } + + void TextField::setText(const std::string& text) + { + const size_t sz = text.size(); + if (sz < mCaretPosition) + mCaretPosition = sz; + mText = text; + } + + void TextField::drawCaret(Graphics* graphics A_UNUSED, int x A_UNUSED) + { + } + + void TextField::mousePressed(MouseEvent& mouseEvent) + { + if (mouseEvent.getButton() == MouseEvent::LEFT) + { + mCaretPosition = getFont()->getStringIndexAt( + mText, mouseEvent.getX() + mXScroll); + fixScroll(); + } + } + + void TextField::mouseDragged(MouseEvent& mouseEvent) + { + mouseEvent.consume(); + } + + void TextField::adjustSize() + { + } + + void TextField::adjustHeight() + { + } + + void TextField::fixScroll() + { + } + + void TextField::setCaretPosition(unsigned int position A_UNUSED) + { + } + + unsigned int TextField::getCaretPosition() const + { + return mCaretPosition; + } + + const std::string& TextField::getText() const + { + return mText; + } + + void TextField::fontChanged() + { + } +} // namespace gcn diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp new file mode 100644 index 000000000..bc227eb55 --- /dev/null +++ b/src/gui/base/widgets/textfield.hpp @@ -0,0 +1,190 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_TEXTFIELD_HPP +#define GCN_TEXTFIELD_HPP + +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" + +#include + +namespace gcn +{ + /** + * An implementation of a text field where a user can enter a line of text. + */ + class TextField: + public Widget, + public MouseListener, + public KeyListener + { + public: + /** + * Constructor. + */ + TextField(); + + /** + * Constructor. The text field will be automatically resized + * to fit the text. + * + * @param text The default text of the text field. + */ + explicit TextField(const std::string& text); + + A_DELETE_COPY(TextField) + + /** + * Sets the text of the text field. + * + * @param text The text of the text field. + * @see getText + */ + void setText(const std::string& text); + + /** + * Gets the text of the text field. + * + * @return The text of the text field. + * @see setText + */ + const std::string& getText() const; + + /** + * Adjusts the size of the text field to fit the text. + */ + void adjustSize(); + + /** + * Adjusts the height of the text field to fit caption. + */ + void adjustHeight(); + + /** + * Sets the caret position. As there is only one line of text + * in a text field the position is the caret's x coordinate. + * + * @param position The caret position. + * @see getCaretPosition + */ + void setCaretPosition(unsigned int position); + + /** + * Gets the caret position. As there is only one line of text + * in a text field the position is the caret's x coordinate. + * + * @return The caret position. + * @see setCaretPosition + */ + unsigned int getCaretPosition() const; + + + // Inherited from Widget + + virtual void fontChanged(); + + // Inherited from MouseListener + + virtual void mousePressed(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + protected: + /** + * Draws the caret. Overloaded this method if you want to + * change the style of the caret. + * + * @param graphics the Graphics object to draw with. + * @param x the caret's x-position. + */ + virtual void drawCaret(Graphics* graphics, int x); + + /** + * Scrolls the text horizontally so that the caret shows if needed. + * The method is used any time a user types in the text field so the + * caret always will be shown. + */ + void fixScroll(); + + /** + * Holds the text of the text box. + */ + std::string mText; + + /** + * Holds the caret position. + */ + unsigned int mCaretPosition; + + /** + * Holds the amount scrolled in x. If a user types more characters than + * the text field can display, due to the text field being to small, the + * text needs to scroll in order to show the last type character. + */ + int mXScroll; + }; +} // namespace gcn + +#endif // end GCN_TEXTFIELD_HPP diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp new file mode 100644 index 000000000..c7a108ab8 --- /dev/null +++ b/src/gui/base/widgets/window.cpp @@ -0,0 +1,233 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/base/widgets/window.hpp" + +#include "gui/base/exception.hpp" +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/mouseinput.hpp" + +#include "debug.h" + +namespace gcn +{ + Window::Window() : + Container(), + gcn::MouseListener(), + mCaption(), + mAlignment(Graphics::CENTER), + mPadding(2), + mTitleBarHeight(16), + mMovable(true), + mOpaque(true), + mDragOffsetX(0), + mDragOffsetY(0), + mMoved(false) + { + mFrameSize = 1; + addMouseListener(this); + } + + Window::Window(const std::string& caption) : + Container(), + gcn::MouseListener(), + mCaption(caption), + mAlignment(Graphics::CENTER), + mPadding(2), + mTitleBarHeight(16), + mMovable(true), + mOpaque(true), + mDragOffsetX(0), + mDragOffsetY(0), + mMoved(false) + { + mFrameSize = 1; + addMouseListener(this); + } + + Window::~Window() + { + } + + void Window::setPadding(unsigned int padding) + { + mPadding = padding; + } + + unsigned int Window::getPadding() const + { + return mPadding; + } + + void Window::setTitleBarHeight(unsigned int height) + { + mTitleBarHeight = height; + } + + unsigned int Window::getTitleBarHeight() + { + return mTitleBarHeight; + } + + void Window::setCaption(const std::string& caption) + { + mCaption = caption; + } + + const std::string& Window::getCaption() const + { + return mCaption; + } + + void Window::setAlignment(Graphics::Alignment alignment) + { + mAlignment = alignment; + } + + Graphics::Alignment Window::getAlignment() const + { + return mAlignment; + } + + void Window::mousePressed(MouseEvent& mouseEvent) + { + if (mouseEvent.getSource() != this) + return; + + if (getParent()) + getParent()->moveToTop(this); + + mDragOffsetX = mouseEvent.getX(); + mDragOffsetY = mouseEvent.getY(); + + mMoved = mouseEvent.getY() <= static_cast(mTitleBarHeight); + } + + void Window::mouseReleased(MouseEvent& mouseEvent A_UNUSED) + { + mMoved = false; + } + + void Window::mouseDragged(MouseEvent& mouseEvent) + { + if (mouseEvent.isConsumed() || mouseEvent.getSource() != this) + return; + + if (isMovable() && mMoved) + { + setPosition(mouseEvent.getX() - mDragOffsetX + getX(), + mouseEvent.getY() - mDragOffsetY + getY()); + } + + mouseEvent.consume(); + } + + Rectangle Window::getChildrenArea() + { + return Rectangle(getPadding(), + getTitleBarHeight(), + getWidth() - getPadding() * 2, + getHeight() - getPadding() - getTitleBarHeight()); + } + + void Window::setMovable(bool movable) + { + mMovable = movable; + } + + bool Window::isMovable() const + { + return mMovable; + } + + void Window::setOpaque(bool opaque) + { + mOpaque = opaque; + } + + bool Window::isOpaque() + { + return mOpaque; + } + + void Window::resizeToContent() + { + int w = 0, h = 0; + for (WidgetListConstIterator it = mWidgets.begin(); + it != mWidgets.end(); ++ it) + { + if ((*it)->getX() + (*it)->getWidth() > w) + w = (*it)->getX() + (*it)->getWidth(); + + if ((*it)->getY() + (*it)->getHeight() > h) + h = (*it)->getY() + (*it)->getHeight(); + } + + setSize(w + 2* getPadding(), h + getPadding() + getTitleBarHeight()); + } +} // namespace gcn diff --git a/src/gui/base/widgets/window.hpp b/src/gui/base/widgets/window.hpp new file mode 100644 index 000000000..9c7e6bcbf --- /dev/null +++ b/src/gui/base/widgets/window.hpp @@ -0,0 +1,269 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_WINDOW_HPP +#define GCN_WINDOW_HPP + +#include + +#include "gui/base/mouselistener.hpp" +#include "gui/base/widgets/container.hpp" + +namespace gcn +{ + /** + * An implementation of a movable window that can contain other widgets. + */ + class Window : public Container, + public MouseListener + { + public: + /** + * Constructor. + */ + Window(); + + /** + * Constructor. The window will be automatically resized in height + * to fit the caption. + * + * @param caption the caption of the window. + */ + explicit Window(const std::string& caption); + + A_DELETE_COPY(Window) + + /** + * Destructor. + */ + virtual ~Window(); + + /** + * Sets the caption of the window. + * + * @param caption The caption of the window. + * @see getCaption + */ + void setCaption(const std::string& caption); + + /** + * Gets the caption of the window. + * + * @return the caption of the window. + * @see setCaption + */ + const std::string& getCaption() const; + + /** + * Sets the alignment of the caption. + * + * @param alignment The alignment of the caption. + * @see getAlignment, Graphics + */ + void setAlignment(Graphics::Alignment alignment); + + /** + * Gets the alignment of the caption. + * + * @return The alignment of caption. + * @see setAlignment, Graphics + */ + Graphics::Alignment getAlignment() const; + + /** + * Sets the padding of the window. The padding is the distance between the + * window border and the content. + * + * @param padding The padding of the window. + * @see getPadding + */ + void setPadding(unsigned int padding); + + /** + * Gets the padding of the window. The padding is the distance between the + * window border and the content. + * + * @return The padding of the window. + * @see setPadding + */ + unsigned int getPadding() const; + + /** + * Sets the title bar height. + * + * @param height The title height value. + * @see getTitleBarHeight + */ + void setTitleBarHeight(unsigned int height); + + /** + * Gets the title bar height. + * + * @return The title bar height. + * @see setTitleBarHeight + */ + unsigned int getTitleBarHeight(); + + /** + * Sets the window to be moveble or not. + * + * @param movable True if the window should be movable, false otherwise. + * @see isMovable + */ + void setMovable(bool movable); + + /** + * Checks if the window is movable. + * + * @return True if the window is movable, false otherwise. + * @see setMovable + */ + bool isMovable() const; + + /** + * Sets the window to be opaque or not. An opaque window will draw it's background + * and it's content. A non opaque window will only draw it's content. + * + * @param opaque True if the window should be opaque, false otherwise. + * @see isOpaque + */ + void setOpaque(bool opaque); + + /** + * Checks if the window is opaque. + * + * @return True if the window is opaque, false otherwise. + * @see setOpaque + */ + bool isOpaque(); + + /** + * Resizes the window to fit the content. + */ + virtual void resizeToContent(); + + // Inherited from BasicContainer + + virtual Rectangle getChildrenArea(); + + // Inherited from MouseListener + + virtual void mousePressed(MouseEvent& mouseEvent) override; + + virtual void mouseDragged(MouseEvent& mouseEvent) override; + + virtual void mouseReleased(MouseEvent& mouseEvent) override; + + protected: + /** + * Holds the caption of the window. + */ + std::string mCaption; + + /** + * Holds the alignment of the caption. + */ + Graphics::Alignment mAlignment; + + /** + * Holds the padding of the window. + */ + unsigned int mPadding; + + /** + * Holds the title bar height of the window. + */ + unsigned int mTitleBarHeight; + + /** + * True if the window is movable, false otherwise. + */ + bool mMovable; + + /** + * True if the window is opaque, false otherwise. + */ + bool mOpaque; + + /** + * Holds a drag offset as an x coordinate where the drag of the window + * started if the window is being dragged. It's used to move the window + * correctly when dragged. + */ + int mDragOffsetX; + + /** + * Holds a drag offset as an y coordinate where the drag of the window + * started if the window is being dragged. It's used to move the window + * correctly when dragged. + */ + int mDragOffsetY; + + /** + * True if the window is being moved, false otherwise. + */ + bool mMoved; + }; +} // namespace gcn + +#endif // end GCN_WINDOW_HPP diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index e32b9afa1..b051fe300 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -23,7 +23,7 @@ #ifndef GUI_FOCUSHANDLER_H #define GUI_FOCUSHANDLER_H -#include +#include "gui/base/focushandler.hpp" #include diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 126fc9a3b..00a3da25e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -51,7 +51,7 @@ #include "utils/langs.h" #include "utils/timer.h" -#include +#include "gui/base/exception.hpp" #include "debug.h" diff --git a/src/gui/gui.h b/src/gui/gui.h index 5fddc7df7..4737c62fb 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -23,9 +23,9 @@ #ifndef GUI_GUI_H #define GUI_GUI_H -#include -#include -#include +#include "gui/base/color.hpp" +#include "gui/base/focuslistener.hpp" +#include "gui/base/gui.hpp" #include "localconsts.h" diff --git a/src/gui/palette.h b/src/gui/palette.h index 26ea6817c..1377822ca 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -26,7 +26,7 @@ #include "logger.h" -#include +#include "gui/base/color.hpp" #if defined __native_client__ #include diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 6d3077130..623b19d00 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -31,7 +31,7 @@ #include "utils/gettext.h" #include "utils/stringutils.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index 1fd496dec..07c950706 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -38,7 +38,7 @@ #include "resources/image.h" #include "resources/resourcemanager.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 52cf1d5d6..4d12e835e 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -79,7 +79,7 @@ #include "utils/gettext.h" #include "utils/process.h" -#include +#include "gui/base/listmodel.hpp" #include "debug.h" diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 0970f34b6..498132ded 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -28,8 +28,8 @@ #include "being/actorsprite.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/listmodel.hpp" #include "localconsts.h" diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index e32a6bb4d..dd8f9ada9 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -30,7 +30,7 @@ #include "gui/widgets/label.h" #include "gui/widgets/textbox.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 1d696fe82..2332e20a9 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -33,7 +33,7 @@ #include "utils/stringutils.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 9a7f1d3e4..14f31f84f 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/label.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index f97970a26..8246cea94 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -39,7 +39,7 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include +#include "gui/base/exception.hpp" #include "debug.h" diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index b2638f835..79ee0fbfb 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -24,8 +24,8 @@ #ifndef GUI_SDLFONT_H #define GUI_SDLFONT_H -#include -#include +#include "gui/base/color.hpp" +#include "gui/base/font.hpp" #include diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 193a35dfe..c81f11802 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -90,7 +90,7 @@ #include #include -#include +#include "gui/base/exception.hpp" SDLInput::SDLInput() : mKeyInputQueue(), diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index b07a57a00..345e939c5 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -84,9 +84,9 @@ #include -#include -#include -#include +#include "gui/base/input.hpp" +#include "gui/base/keyinput.hpp" +#include "gui/base/mouseinput.hpp" #include diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index 18fe1cbe2..fbba415b8 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -26,7 +26,7 @@ #include "gui/palette.h" -#include +#include "gui/base/listmodel.hpp" /** * Class controlling the game's color palette. diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 341af1f0b..9982840de 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -42,7 +42,7 @@ #include "gui/windows/ministatuswindow.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/viewport.h b/src/gui/viewport.h index dcddc003c..848a1ae8c 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -28,7 +28,7 @@ #include "gui/widgets/windowcontainer.h" -#include +#include "gui/base/mouselistener.hpp" class ActorSprite; class Button; diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index b676a7e94..4a477b802 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -36,7 +36,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index b91c095b7..d7ce9ab12 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -37,9 +37,9 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include -#include -#include +#include "gui/base/graphics.hpp" +#include "gui/base/font.hpp" +#include "gui/base/cliprectangle.hpp" #include diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 09f06bc39..deefd886a 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -26,8 +26,8 @@ #include "gui/widgets/widget2.h" -#include -#include +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" #include #include diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 0042b07e3..faefd6f6c 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -30,7 +30,7 @@ #include "resources/imageset.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 3dd783e52..aeec63b82 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -25,8 +25,8 @@ #include "gui/widgets/widget2.h" -#include -#include +#include "gui/base/widgets/button.hpp" +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index eb5ec6dfc..ebb0d46da 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -29,7 +29,7 @@ #include "net/charserverhandler.h" #include "net/net.h" -#include +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/characterviewbase.h b/src/gui/widgets/characterviewbase.h index a7c9d2240..af3722e4b 100644 --- a/src/gui/widgets/characterviewbase.h +++ b/src/gui/widgets/characterviewbase.h @@ -25,7 +25,7 @@ #include "gui/widgets/container.h" -#include +#include "gui/base/actionlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 47d9f2b57..fa227f5ca 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -29,7 +29,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 2d4581327..d0864d0d5 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/checkbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h index 8b9226159..4d29e24d3 100644 --- a/src/gui/widgets/colormodel.h +++ b/src/gui/widgets/colormodel.h @@ -23,8 +23,8 @@ #include "utils/stringvector.h" -#include -#include +#include "gui/base/color.hpp" +#include "gui/base/listmodel.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 11dd1f07e..9730f7006 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -22,7 +22,7 @@ #include "gui/widgets/colormodel.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 8f3933357..a83ec8d48 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/container.hpp" /** * A widget container. diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index b62ae96ef..88034fbbc 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 59cdec6fb..3669d3eab 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -32,7 +32,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index ed93dc358..da2eb64f9 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -25,13 +25,13 @@ #include "gui/widgets/widget2.h" -#include -#include -#include -#include -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/basiccontainer.hpp" +#include "gui/base/focuslistener.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/listmodel.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/selectionlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 73547b770..857eed024 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -36,7 +36,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 132cfb8e9..1603bab5e 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -23,9 +23,9 @@ #include "gui/widgets/widget2.h" -#include -#include -#include +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index d080a6072..8d83ffeae 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -33,7 +33,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index bd3a35964..6aaf85bbe 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -22,9 +22,9 @@ #include "gui/widgets/extendedlistmodel.h" -#include -#include -#include +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/listmodel.hpp" #include "debug.h" diff --git a/src/gui/widgets/extendedlistmodel.h b/src/gui/widgets/extendedlistmodel.h index 0299ef7ed..0b9c4d819 100644 --- a/src/gui/widgets/extendedlistmodel.h +++ b/src/gui/widgets/extendedlistmodel.h @@ -23,7 +23,7 @@ #include "resources/image.h" -#include +#include "gui/base/listmodel.hpp" class ExtendedListModel : public gcn::ListModel { diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 81043b450..1967258dd 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index ae0dd14c5..9630f5c17 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -29,9 +29,9 @@ #include "utils/dtor.h" -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/key.hpp" #include "debug.h" diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 5529ce842..e91482078 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -28,9 +28,9 @@ #include "gui/widgets/tablemodel.h" #include "gui/widgets/widget2.h" -#include -#include -#include +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" #include diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index be30220e8..517cb6fd9 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 1cbd3158c..98cb83b61 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 2014d3ffe..0361c54e7 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -46,8 +46,8 @@ #include "resources/image.h" -#include -#include +#include "gui/base/font.hpp" +#include "gui/base/selectionlistener.hpp" #include diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index f4a73af9f..c7ca851d9 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -25,10 +25,10 @@ #include "gui/widgets/widget2.h" -#include -#include -#include -#include +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" +#include "gui/base/widgetlistener.hpp" #include diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index cb74a658b..c10979bef 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -37,8 +37,8 @@ #include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/mouseinput.hpp" #include "debug.h" diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index cdeb83af7..1334afae7 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -45,7 +45,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 7a16b800c..767830f5d 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/label.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 3546f17b4..2fc2393fb 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -24,7 +24,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/label.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index b03c10c1f..013963bfa 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -25,7 +25,7 @@ #include "localconsts.h" -#include +#include "gui/base/widgets/container.hpp" #include diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index 4f8ed8708..1a3a3a69f 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -25,7 +25,7 @@ #include "gui/widgets/layout.h" -#include +#include "gui/base/widgetlistener.hpp" /** * A helper class for adding a layout to a Guichan container widget. The layout diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h index 744ff0b29..f79f1bf50 100644 --- a/src/gui/widgets/linkhandler.h +++ b/src/gui/widgets/linkhandler.h @@ -25,7 +25,7 @@ #include -#include +#include "gui/base/mouselistener.hpp" /** * A simple interface to windows that need to handle links from BrowserBox diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 9a1a074b3..767067801 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -29,10 +29,10 @@ #include "gui/gui.h" -#include -#include -#include -#include +#include "gui/base/focushandler.hpp" +#include "gui/base/font.hpp" +#include "gui/base/graphics.hpp" +#include "gui/base/listmodel.hpp" #include "debug.h" diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index b1a2f0da5..784193fdf 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/listbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h index b7c0cc94c..d98a70130 100644 --- a/src/gui/widgets/mouseevent.h +++ b/src/gui/widgets/mouseevent.h @@ -22,8 +22,8 @@ #ifndef GUI_WIDGETS_MOUSEEVENT_H #define GUI_WIDGETS_MOUSEEVENT_H -#include -#include +#include "gui/base/mouseevent.hpp" +#include "gui/base/widget.hpp" class MouseEvent final : public gcn::MouseEvent { diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h index f70dd2571..5e8b47d23 100644 --- a/src/gui/widgets/namesmodel.h +++ b/src/gui/widgets/namesmodel.h @@ -23,7 +23,7 @@ #include "utils/stringvector.h" -#include +#include "gui/base/listmodel.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 3ebae9be4..b78c8c3f1 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/scrollarea.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 1ba4083cd..c0de328e7 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -27,7 +27,7 @@ #include "gui/viewport.h" -#include +#include "gui/base/exception.hpp" #include "debug.h" diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 711ac97b7..7e7001891 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -26,8 +26,8 @@ #include "gui/widgets/container.h" -#include -#include +#include "gui/base/mouselistener.hpp" +#include "gui/base/widgetlistener.hpp" class ImageCollection; class Skin; diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index f41b9f631..dfe93c0ae 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -23,8 +23,8 @@ #include "gui/widgets/popup.h" -#include -#include +#include "gui/base/focuslistener.hpp" +#include "gui/base/listmodel.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 38257e0a8..61ecc9080 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -28,7 +28,7 @@ #include "gui/gui.h" #include "gui/sdlfont.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index eefabe83a..ca32fc165 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -25,8 +25,8 @@ #include "gui/widgets/widget2.h" -#include -#include +#include "gui/base/widget.hpp" +#include "gui/base/widgetlistener.hpp" #include diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index 61a72dd67..fc9ab5b5f 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -24,7 +24,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index e0643a8ac..a81afa037 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -29,7 +29,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index f5ff43f4c..dca2d1167 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/radiobutton.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h index 1863a348c..0fd1f2605 100644 --- a/src/gui/widgets/radiogroup.h +++ b/src/gui/widgets/radiogroup.h @@ -23,7 +23,7 @@ #include "gui/widgets/widgetgroup.h" -#include +#include "gui/base/widget.hpp" class RadioGroup final : public WidgetGroup { diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 13e5e3665..58bd73107 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -25,8 +25,8 @@ #include "gui/widgets/widget2.h" -#include -#include +#include "gui/base/widgets/scrollarea.hpp" +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 2cb7f60d1..4f0ea025d 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -41,7 +41,7 @@ #include "utils/gettext.h" #include "utils/mathutils.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index c72bb39ef..027f91824 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -24,7 +24,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/tabs/setuptabscroll.h" -#include +#include "gui/base/actionlistener.hpp" #include #include diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index 4803d6fed..54de95cc0 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_SHOPITEMS_H #define GUI_WIDGETS_SHOPITEMS_H -#include +#include "gui/base/listmodel.hpp" #include #include diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 58f9ec8eb..4a7fda039 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -35,8 +35,8 @@ #include "resources/image.h" -#include -#include +#include "gui/base/font.hpp" +#include "gui/base/listmodel.hpp" #include "debug.h" diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 8bd84758d..88e27320a 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -25,9 +25,9 @@ #include "gui/widgets/widget2.h" -#include -#include -#include +#include "gui/base/mouselistener.hpp" +#include "gui/base/widget.hpp" +#include "gui/base/widgetlistener.hpp" class Image; class ImageCollection; diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h index d268b3438..a201f3274 100644 --- a/src/gui/widgets/skillinfo.h +++ b/src/gui/widgets/skillinfo.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_SKILLINFO_H #define GUI_WIDGETS_SKILLINFO_H -#include +#include "gui/base/color.hpp" #include #include diff --git a/src/gui/widgets/skillmodel.h b/src/gui/widgets/skillmodel.h index 0f77dccfe..b1a682fd9 100644 --- a/src/gui/widgets/skillmodel.h +++ b/src/gui/widgets/skillmodel.h @@ -24,7 +24,7 @@ #define GUI_WIDGETS_SKILLMODEL_H #include "gui/widgets/skillinfo.h" -#include +#include "gui/base/listmodel.hpp" #include diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index a0f7829ac..d5d4a30fe 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/slider.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 60d7926d1..4416a00b7 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/label.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 73f8c6f5c..016a60290 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -21,9 +21,9 @@ #ifndef GUI_WIDGETS_SLIDERLIST_H #define GUI_WIDGETS_SLIDERLIST_H -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/listmodel.hpp" +#include "gui/base/mouselistener.hpp" #include "gui/widgets/container.h" diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index bf14f21fe..e59b9fbdb 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -36,7 +36,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 3b0cf1db5..8cb8fd78a 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -29,7 +29,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabs/tab.h" -#include +#include "gui/base/widgets/container.hpp" #include "debug.h" diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index d0f97b688..7a023903f 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -25,11 +25,11 @@ #include "gui/widgets/widget2.h" -#include -#include -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widgetlistener.hpp" +#include "gui/base/widgets/container.hpp" class Button; class Image; diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index f244f51f4..7b6b8048e 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -24,7 +24,7 @@ #include "utils/dtor.h" -#include +#include "gui/base/widget.hpp" #include "debug.h" diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index b2f860415..38f0f2687 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -24,7 +24,7 @@ #include "gui/widgets/tabs/setuptab.h" -#include +#include "gui/base/selectionlistener.hpp" #include diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 9ce6fd616..b079974d5 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -38,7 +38,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabstrip.h" -#include +#include "gui/base/listmodel.hpp" #include "debug.h" diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index 45ada01df..f35f75413 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -46,7 +46,7 @@ #include "test/testmain.h" -#include +#include "gui/base/listmodel.hpp" #include diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h index 22d55c121..25ecfabd6 100644 --- a/src/gui/widgets/tabs/setup_video.h +++ b/src/gui/widgets/tabs/setup_video.h @@ -25,7 +25,7 @@ #include "gui/widgets/tabs/setuptab.h" -#include +#include "gui/base/keylistener.hpp" class Button; class CheckBox; diff --git a/src/gui/widgets/tabs/setuptab.h b/src/gui/widgets/tabs/setuptab.h index 388b0a988..d8e76f812 100644 --- a/src/gui/widgets/tabs/setuptab.h +++ b/src/gui/widgets/tabs/setuptab.h @@ -25,8 +25,8 @@ #include "gui/widgets/container.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/widgetlistener.hpp" #include diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 118b1f0e2..fa9846ab4 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -25,9 +25,9 @@ #include "gui/widgets/widget2.h" -#include -#include -#include +#include "gui/base/basiccontainer.hpp" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index 622ccba81..3e954aec5 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -23,7 +23,7 @@ #include "gui/widgets/widgetgroup.h" -#include +#include "gui/base/widget.hpp" class TabStrip final : public WidgetGroup { diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index f59bc0ceb..3f56ecfcf 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -25,7 +25,7 @@ #include "input/keydata.h" #include "input/keyevent.h" -#include +#include "gui/base/font.hpp" #include diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 501744515..797707716 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgets/textbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 269ace775..b655de830 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -39,7 +39,7 @@ #include "utils/copynpaste.h" #include "utils/timer.h" -#include +#include "gui/base/font.hpp" #undef DELETE // Win32 compatibility hack diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index abff9cf2a..d8ab2c830 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -25,8 +25,8 @@ #include "gui/widgets/widget2.h" -#include -#include +#include "gui/base/focuslistener.hpp" +#include "gui/base/widgets/textfield.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index eeb6805fb..bfb361a9b 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 76f6354dd..d194a00c3 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include +#include "gui/base/widgetlistener.hpp" #include diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 3d63b02f8..897183839 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -23,8 +23,8 @@ #include "gui/widgets/container.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/widgetlistener.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c716445f3..c78582a91 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -37,9 +37,9 @@ #include "resources/cursor.h" #include "resources/image.h" -#include -#include -#include +#include "gui/base/exception.hpp" +#include "gui/base/focushandler.hpp" +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index bb0f19bb3..29fd589a5 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -27,9 +27,9 @@ #include "gui/widgets/widget2.h" -#include +#include "gui/base/widgetlistener.hpp" -#include +#include "gui/base/widgets/window.hpp" #include "localconsts.h" diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 38ee090a7..a87f655d8 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -28,8 +28,8 @@ #include "gui/widgets/container.h" #include "gui/widgets/button.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/selectionlistener.hpp" #include "localconsts.h" diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h index d3615957d..e7c9ecbb0 100644 --- a/src/gui/windows/botcheckerwindow.h +++ b/src/gui/windows/botcheckerwindow.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" struct BOTCHK final { diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index e11317cde..594fd0a30 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/selectionlistener.hpp" class Button; class DropDown; diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h index 34a716ee1..107730b2d 100644 --- a/src/gui/windows/buyselldialog.h +++ b/src/gui/windows/buyselldialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h index 31ffa7b39..4a13d5e52 100644 --- a/src/gui/windows/changeemaildialog.h +++ b/src/gui/windows/changeemaildialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; class LoginData; diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h index ce45e6f47..011229d15 100644 --- a/src/gui/windows/changepassworddialog.h +++ b/src/gui/windows/changepassworddialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; class LoginData; diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index 0d73bf805..c59b631dc 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -27,8 +27,8 @@ #include "gui/windows/charselectdialog.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" class Label; class PlayerBox; diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 3ac5d664f..df08c9058 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -29,8 +29,8 @@ #include "net/charserverhandler.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" class Button; class CharacterDisplay; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 26f665052..a21efbe52 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -68,7 +68,7 @@ #include "resources/resourcemanager.h" -#include +#include "gui/base/focushandler.hpp" #include diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 3093c52e9..742c79876 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -29,8 +29,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" #include #include diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index e48427a5b..1ba3ebf65 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -29,7 +29,7 @@ #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h index 0b092e234..9d5c9f23b 100644 --- a/src/gui/windows/confirmdialog.h +++ b/src/gui/windows/confirmdialog.h @@ -29,7 +29,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class TextBox; diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h index 2f861bc52..dd3c84e5e 100644 --- a/src/gui/windows/connectiondialog.h +++ b/src/gui/windows/connectiondialog.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" /** * The connection dialog. diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h index 942bcf41c..85bbe8107 100644 --- a/src/gui/windows/didyouknowwindow.h +++ b/src/gui/windows/didyouknowwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; class BrowserBox; diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h index fa4a02bf7..9c84558a6 100644 --- a/src/gui/windows/editdialog.h +++ b/src/gui/windows/editdialog.h @@ -28,7 +28,7 @@ #include "gui/widgets/window.h" #include "gui/widgets/textfield.h" -#include +#include "gui/base/actionlistener.hpp" #define ACTION_EDIT_OK "edit ok" diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 525005429..cbb789fbb 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -31,9 +31,9 @@ class ServerDialog; #include "net/serverinfo.h" -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/listmodel.hpp" /** * Server Type List Model diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 3b97e12d7..c796c8433 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -46,7 +46,7 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index 7387fb249..4b6ae8b4c 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -30,7 +30,7 @@ #include "utils/xml.h" -#include +#include "gui/base/actionlistener.hpp" #include diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h index 72c0d4aba..a9d1a0279 100644 --- a/src/gui/windows/helpwindow.h +++ b/src/gui/windows/helpwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" #include "localconsts.h" diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 6fd2ab95b..23c1980be 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -57,7 +57,7 @@ #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 4e32f6fa2..da6e56a77 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -28,9 +28,9 @@ #include "gui/widgets/window.h" -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/selectionlistener.hpp" class Button; class DropDown; diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index 7625c4a71..dd3b498fb 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/keylistener.hpp" +#include "gui/base/actionlistener.hpp" class DropDown; class Icon; diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index 094147383..181e43a51 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -23,7 +23,7 @@ #ifndef GUI_WINDOWS_KILLSTATS_H #define GUI_WINDOWS_KILLSTATS_H -#include +#include "gui/base/actionlistener.hpp" #include "depricatedlistener.h" diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index c9d2ad61f..5099644ea 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" #include diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index b441b724c..093f17e29 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -59,7 +59,7 @@ #include "utils/copynpaste.h" #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index 5e679d7d1..21c3f93e5 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -30,7 +30,7 @@ #include "utils/stringvector.h" -#include +#include "gui/base/actionlistener.hpp" #include diff --git a/src/gui/windows/npcpostdialog.h b/src/gui/windows/npcpostdialog.h index e111f150e..b8237a694 100644 --- a/src/gui/windows/npcpostdialog.h +++ b/src/gui/windows/npcpostdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class TextBox; class TextField; diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index c16123abd..c1ce6f13f 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/okdialog.h b/src/gui/windows/okdialog.h index 7d2ff070b..7e63c9787 100644 --- a/src/gui/windows/okdialog.h +++ b/src/gui/windows/okdialog.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class TextBox; diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index eeedc2ec6..6d54889e6 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" const unsigned int OUTFITS_COUNT = 100; const unsigned int OUTFIT_ITEM_COUNT = 16; diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h index 7ecc86c84..edb9d845e 100644 --- a/src/gui/windows/questswindow.h +++ b/src/gui/windows/questswindow.h @@ -27,7 +27,7 @@ #include "utils/xml.h" -#include +#include "gui/base/actionlistener.hpp" #include #include diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h index ab395c7f4..d5d315074 100644 --- a/src/gui/windows/quitdialog.h +++ b/src/gui/windows/quitdialog.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" #include diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h index 66c3e40b7..1b53581b6 100644 --- a/src/gui/windows/registerdialog.h +++ b/src/gui/windows/registerdialog.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" class Button; class LoginData; diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h index 15db28f10..ca973ea03 100644 --- a/src/gui/windows/selldialog.h +++ b/src/gui/windows/selldialog.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/selectionlistener.hpp" class Button; class Item; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 3006922c3..dec80b50a 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -44,7 +44,7 @@ #include "utils/gettext.h" #include "utils/langs.h" -#include +#include "gui/base/font.hpp" #include diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index ad6f554c6..d17ebcf42 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -31,10 +31,10 @@ #include "utils/mutex.h" -#include -#include -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" +#include "gui/base/listmodel.hpp" +#include "gui/base/selectionlistener.hpp" #include #include diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index f5406e8ac..bd67fa860 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" #include diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 95eee1e05..2430073da 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/selectionlistener.hpp" class Button; class CheckBox; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 04baad26a..c4505b37c 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -53,7 +53,7 @@ #include "resources/beingcommon.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 4a6182d38..0fb6c1100 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" const int SKILL_MIN_ID = 200000; const unsigned int SKILL_VAR_MIN_ID = 1000000; diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index e8dc44043..283cfde69 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -26,7 +26,7 @@ #include "being/playerrelationslistener.h" -#include +#include "gui/base/actionlistener.hpp" #include #include diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h index 94f1aaa65..5e100b64e 100644 --- a/src/gui/windows/statuswindow.h +++ b/src/gui/windows/statuswindow.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" #include diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h index a31cdbaf2..4b63aaf29 100644 --- a/src/gui/windows/textcommandeditor.h +++ b/src/gui/windows/textcommandeditor.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; class DropDown; diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index 936f08c76..c31c099fb 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h index 9bfb4ae5f..58819de76 100644 --- a/src/gui/windows/textdialog.h +++ b/src/gui/windows/textdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; class PasswordField; diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index a379f0f28..c3a096161 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -51,7 +51,7 @@ #include "utils/gettext.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index ac49c1f52..da5c84df2 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/selectionlistener.hpp" #include diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h index fd40810ac..806822171 100644 --- a/src/gui/windows/unregisterdialog.h +++ b/src/gui/windows/unregisterdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include +#include "gui/base/actionlistener.hpp" class Button; class LoginData; diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index bddd3ef9e..5509168d4 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -30,8 +30,8 @@ #include "utils/mutex.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" #include #include diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 10a8be4b5..da5ab010d 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -30,7 +30,7 @@ #include -#include +#include "gui/base/actionlistener.hpp" class BrowserBox; class Button; diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h index f7491689b..0f3d857b2 100644 --- a/src/gui/windows/worldselectdialog.h +++ b/src/gui/windows/worldselectdialog.h @@ -27,8 +27,8 @@ #include "net/worldinfo.h" -#include -#include +#include "gui/base/actionlistener.hpp" +#include "gui/base/keylistener.hpp" class Button; class ListBox; diff --git a/src/guichan/actionevent.cpp b/src/guichan/actionevent.cpp deleted file mode 100644 index 2a31bfc8b..000000000 --- a/src/guichan/actionevent.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/actionevent.hpp" - -#include "debug.h" - -namespace gcn -{ - ActionEvent::ActionEvent(Widget *const source, const std::string &id) - :Event(source), - mId(id) - { - } - - ActionEvent::~ActionEvent() - { - } - - const std::string& ActionEvent::getId() const - { - return mId; - } -} // namespace gcn diff --git a/src/guichan/basiccontainer.cpp b/src/guichan/basiccontainer.cpp deleted file mode 100644 index 239a8544e..000000000 --- a/src/guichan/basiccontainer.cpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/basiccontainer.hpp" - -#include - -#include "guichan/exception.hpp" -#include "guichan/focushandler.hpp" -#include "guichan/graphics.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - BasicContainer::~BasicContainer() - { - clear(); - } - - void BasicContainer::moveToTop(Widget* widget) - { - for (WidgetListIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - if (*iter == widget) - { - mWidgets.erase(iter); - mWidgets.push_back(widget); - return; - } - } - - throw GCN_EXCEPTION("There is no such widget in this container."); - } - - void BasicContainer::moveToBottom(Widget* widget) - { - WidgetListIterator iter; - iter = std::find(mWidgets.begin(), mWidgets.end(), widget); - - if (iter == mWidgets.end()) - throw GCN_EXCEPTION("There is no such widget in this container."); - - mWidgets.erase(iter); - mWidgets.insert(mWidgets.begin(), widget); -// mWidgets.push_front(widget); - } - - void BasicContainer::death(const Event& event) - { - WidgetListIterator iter; - iter = std::find(mWidgets.begin(), mWidgets.end(), event.getSource()); - - if (iter == mWidgets.end()) - throw GCN_EXCEPTION("There is no such widget in this container."); - - mWidgets.erase(iter); - } - - Rectangle BasicContainer::getChildrenArea() - { - return Rectangle(0, 0, getWidth(), getHeight()); - } - - void BasicContainer::focusNext() - { - WidgetListConstIterator it; - - for (it = mWidgets.begin(); it != mWidgets.end(); ++ it) - { - if ((*it)->isFocused()) - break; - } - - WidgetListConstIterator end = it; - - if (it == mWidgets.end()) - it = mWidgets.begin(); - - ++ it; - - for ( ; it != end; ++ it) - { - if (it == mWidgets.end()) - it = mWidgets.begin(); - - if ((*it)->isFocusable()) - { - (*it)->requestFocus(); - return; - } - } - } - - void BasicContainer::focusPrevious() - { - WidgetListReverseIterator it; - - for (it = mWidgets.rbegin(); it != mWidgets.rend(); ++ it) - { - if ((*it)->isFocused()) - break; - } - - const WidgetListReverseIterator end = it; - - ++ it; - - if (it == mWidgets.rend()) - it = mWidgets.rbegin(); - - for ( ; it != end; ++ it) - { - if (it == mWidgets.rend()) - it = mWidgets.rbegin(); - - if ((*it)->isFocusable()) - { - (*it)->requestFocus(); - return; - } - } - } - - Widget *BasicContainer::getWidgetAt(int x, int y) - { - const Rectangle r = getChildrenArea(); - - if (!r.isPointInRect(x, y)) - return nullptr; - - x -= r.x; - y -= r.y; - - for (WidgetListReverseIterator it = mWidgets.rbegin(); - it != mWidgets.rend(); ++ it) - { - if ((*it)->isVisible() && (*it)->getDimension() - .isPointInRect(x, y)) - { - return (*it); - } - } - - return nullptr; - } - - void BasicContainer::logic() - { - BLOCK_START("BasicContainer::logic") - logicChildren(); - BLOCK_END("BasicContainer::logic") - } - - void BasicContainer::_setFocusHandler(FocusHandler* focusHandler) - { - Widget::_setFocusHandler(focusHandler); - - if (mInternalFocusHandler) - return; - - for (WidgetListConstIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - (*iter)->_setFocusHandler(focusHandler); - } - } - - void BasicContainer::add(Widget* widget) - { - mWidgets.push_back(widget); - - if (!mInternalFocusHandler) - widget->_setFocusHandler(_getFocusHandler()); - else - widget->_setFocusHandler(mInternalFocusHandler); - - widget->_setParent(this); - widget->addDeathListener(this); - } - - void BasicContainer::remove(Widget* widget) - { - for (WidgetListIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - if (*iter == widget) - { - mWidgets.erase(iter); - widget->_setFocusHandler(nullptr); - widget->_setParent(nullptr); - widget->removeDeathListener(this); - return; - } - } - - throw GCN_EXCEPTION("There is no such widget in this container."); - } - - void BasicContainer::clear() - { - for (WidgetListConstIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - (*iter)->_setFocusHandler(nullptr); - (*iter)->_setParent(nullptr); - (*iter)->removeDeathListener(this); - } - - mWidgets.clear(); - } - - void BasicContainer::drawChildren(Graphics* graphics) - { - BLOCK_START("BasicContainer::drawChildren") - - graphics->pushClipArea(getChildrenArea()); - - for (WidgetListConstIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - Widget *const widget = *iter; - if (widget->isVisible()) - { - // If the widget has a frame, - // draw it before drawing the widget - if (widget->getFrameSize() > 0) - { - Rectangle rec = widget->getDimension(); - const int frame = widget->getFrameSize(); - const int frame2 = frame * 2; - rec.x -= frame; - rec.y -= frame; - rec.width += frame2; - rec.height += frame2; - graphics->pushClipArea(rec); - BLOCK_START("BasicContainer::drawChildren 1") - widget->drawFrame(graphics); - BLOCK_END("BasicContainer::drawChildren 1") - graphics->popClipArea(); - } - - graphics->pushClipArea(widget->getDimension()); - BLOCK_START("BasicContainer::drawChildren 2") - widget->draw(graphics); - BLOCK_END("BasicContainer::drawChildren 2") - graphics->popClipArea(); - } - } - - graphics->popClipArea(); - BLOCK_END("BasicContainer::drawChildren") - } - - void BasicContainer::logicChildren() - { - BLOCK_START("BasicContainer::logicChildren") - for (WidgetListConstIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - (*iter)->logic(); - } - BLOCK_END("BasicContainer::logicChildren") - } - - void BasicContainer::showWidgetPart(Widget* widget, Rectangle area) - { - const Rectangle widgetArea = getChildrenArea(); - - area.x += widget->getX(); - area.y += widget->getY(); - - if (area.x + area.width > widgetArea.width) - { - widget->setX(widget->getX() - area.x - - area.width + widgetArea.width); - } - - if (area.y + area.height > widgetArea.height) - { - widget->setY(widget->getY() - area.y - - area.height + widgetArea.height); - } - - if (area.x < 0) - widget->setX(widget->getX() - area.x); - - if (area.y < 0) - widget->setY(widget->getY() - area.y); - } - - void BasicContainer::setInternalFocusHandler(FocusHandler* focusHandler) - { - Widget::setInternalFocusHandler(focusHandler); - - for (WidgetListConstIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - if (!mInternalFocusHandler) - (*iter)->_setFocusHandler(_getFocusHandler()); - else - (*iter)->_setFocusHandler(mInternalFocusHandler); - } - } - - Widget* BasicContainer::findWidgetById(const std::string& id) - { - for (WidgetListConstIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++ iter) - { - if ((*iter)->getId() == id) - return (*iter); - - BasicContainer *const basicContainer - = dynamic_cast(*iter); - - if (basicContainer) - { - Widget *const widget = basicContainer->findWidgetById(id); - - if (widget) - return widget; - } - } - - return nullptr; - } -} // namespace gcn diff --git a/src/guichan/cliprectangle.cpp b/src/guichan/cliprectangle.cpp deleted file mode 100644 index c09990087..000000000 --- a/src/guichan/cliprectangle.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/cliprectangle.hpp" - -#include "debug.h" - -namespace gcn -{ - ClipRectangle::ClipRectangle() : - Rectangle(), - xOffset(0), - yOffset(0) - { - x = 0; - y = 0; - width = 0; - height = 0; - } - - ClipRectangle::ClipRectangle(const int x0, const int y0, - const int width0, const int height0, - const int xOffset0, const int yOffset0) : - Rectangle(), - xOffset(xOffset0), - yOffset(yOffset0) - { - x = x0; - y = y0; - width = width0; - height = height0; - } - - const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) - { - x = other.x; - y = other.y; - width = other.width; - height = other.height; - - return *this; - } -} // namespace gcn diff --git a/src/guichan/color.cpp b/src/guichan/color.cpp deleted file mode 100644 index 27612876f..000000000 --- a/src/guichan/color.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/color.hpp" - -#include "debug.h" - -namespace gcn -{ - Color::Color() : - r(0), - g(0), - b(0), - a(255) - { - } - - Color::Color(const int color) : - r((color >> 16) & 0xFF), - g((color >> 8) & 0xFF), - b(color & 0xFF), - a(255) - { - } - - Color::Color(const int ar, const int ag, const int ab, const int aa) : - r(ar), - g(ag), - b(ab), - a(aa) - { - } - - Color Color::operator+(const Color& color) const - { - Color result(r + color.r, - g + color.g, - b + color.b, - 255); - - result.r = (result.r>255?255:(result.r<0?0:result.r)); - result.g = (result.g>255?255:(result.g<0?0:result.g)); - result.b = (result.b>255?255:(result.b<0?0:result.b)); - - return result; - } - - Color Color::operator-(const Color& color) const - { - Color result(r - color.r, - g - color.g, - b - color.b, - 255); - - result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); - result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); - result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); - - return result; - } - - Color Color::operator*(const float value) const - { - Color result(static_cast(static_cast(r) * value), - static_cast(static_cast(g) * value), - static_cast(static_cast(b) * value), - a); - - result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); - result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); - result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); - - return result; - } - - bool Color::operator==(const Color& color) const - { - return r == color.r && g == color.g && b == color.b && a == color.a; - } - - bool Color::operator!=(const Color& color) const - { - return !(r == color.r && g == color.g && b == color.b && a == color.a); - } - - std::ostream& operator<<(std::ostream& out, - const Color& color) - { - out << "Color [r = " - << color.r - << ", g = " - << color.g - << ", b = " - << color.b - << ", a = " - << color.a - << "]"; - - return out; - } -} // namespace gcn diff --git a/src/guichan/event.cpp b/src/guichan/event.cpp deleted file mode 100644 index f4a03bc19..000000000 --- a/src/guichan/event.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/event.hpp" - -#include "debug.h" - -namespace gcn -{ - Event::Event(Widget *const source) : - mSource(source) - { - } - - Event::~Event() - { - } - - Widget* Event::getSource() const - { - return mSource; - } -} // namespace gcn diff --git a/src/guichan/exception.cpp b/src/guichan/exception.cpp deleted file mode 100644 index b02df93eb..000000000 --- a/src/guichan/exception.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/exception.hpp" - -#include "debug.h" - -namespace gcn -{ - Exception::Exception() - : mFunction("?"), - mMessage(""), - mFilename("?"), - mLine(0) - { - } - - Exception::Exception(const std::string& message) - : mFunction("?"), - mMessage(message), - mFilename("?"), - mLine(0) - { - } - - Exception::Exception(const std::string& message, - const std::string& function, - const std::string& filename, - const unsigned int line) - : mFunction(function), - mMessage(message), - mFilename(filename), - mLine(line) - { - } - - const std::string& Exception::getFunction() const - { - return mFunction; - } - - const std::string& Exception::getMessage() const - { - return mMessage; - } - - const std::string& Exception::getFilename() const - { - return mFilename; - } - - unsigned int Exception::getLine() const - { - return mLine; - } -} // namespace gcn diff --git a/src/guichan/focushandler.cpp b/src/guichan/focushandler.cpp deleted file mode 100644 index 3249703a3..000000000 --- a/src/guichan/focushandler.cpp +++ /dev/null @@ -1,571 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/focushandler.hpp" - -#include "guichan/focuslistener.hpp" -#include "guichan/exception.hpp" -#include "guichan/widget.hpp" - -#include "debug.h" - -namespace gcn -{ - FocusHandler::FocusHandler() : - mWidgets(), - mFocusedWidget(nullptr), - mModalFocusedWidget(nullptr), - mModalMouseInputFocusedWidget(nullptr), - mDraggedWidget(nullptr), - mLastWidgetWithMouse(nullptr), - mLastWidgetWithModalFocus(nullptr), - mLastWidgetWithModalMouseInputFocus(nullptr), - mLastWidgetPressed(nullptr) - { - } - - void FocusHandler::requestFocus(Widget* widget) - { - if (!widget || widget == mFocusedWidget) - return; - - int toBeFocusedIndex = -1; - for (unsigned int i = 0, sz = static_cast( - mWidgets.size()); i < sz; ++i) - { - if (mWidgets[i] == widget) - { - toBeFocusedIndex = i; - break; - } - } - - if (toBeFocusedIndex < 0) - throw GCN_EXCEPTION("Trying to focus a none existing widget."); - - Widget *const oldFocused = mFocusedWidget; - - if (oldFocused != widget) - { - mFocusedWidget = mWidgets.at(toBeFocusedIndex); - - if (oldFocused) - { - Event focusEvent(oldFocused); - distributeFocusLostEvent(focusEvent); - } - - Event focusEvent(mWidgets.at(toBeFocusedIndex)); - distributeFocusGainedEvent(focusEvent); - } - } - - void FocusHandler::requestModalFocus(Widget* widget) - { - if (mModalFocusedWidget && mModalFocusedWidget != widget) - throw GCN_EXCEPTION("Another widget already has modal focus."); - - mModalFocusedWidget = widget; - - if (mFocusedWidget && !mFocusedWidget->isModalFocused()) - focusNone(); - } - - void FocusHandler::requestModalMouseInputFocus(Widget* widget) - { - if (mModalMouseInputFocusedWidget - && mModalMouseInputFocusedWidget != widget) - { - throw GCN_EXCEPTION("Another widget already has " - "modal input focus."); - } - - mModalMouseInputFocusedWidget = widget; - } - - void FocusHandler::releaseModalFocus(Widget* widget) - { - if (mModalFocusedWidget == widget) - mModalFocusedWidget = nullptr; - } - - void FocusHandler::releaseModalMouseInputFocus(Widget* widget) - { - if (mModalMouseInputFocusedWidget == widget) - mModalMouseInputFocusedWidget = nullptr; - } - - Widget* FocusHandler::getFocused() const - { - return mFocusedWidget; - } - - Widget* FocusHandler::getModalFocused() const - { - return mModalFocusedWidget; - } - - Widget* FocusHandler::getModalMouseInputFocused() const - { - return mModalMouseInputFocusedWidget; - } - - void FocusHandler::focusNext() - { - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - ++ focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget >= sz) - focusedWidget = 0; - - if (focusedWidget == focused) - return; - } - while (!mWidgets.at(focusedWidget)->isFocusable()); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::focusPrevious() - { - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - -- focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget <= 0) - focusedWidget = sz - 1; - - if (focusedWidget == focused) - return; - } - while (!mWidgets.at(focusedWidget)->isFocusable()); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - bool FocusHandler::isFocused(const Widget* widget) const - { - return mFocusedWidget == widget; - } - - void FocusHandler::add(Widget* widget) - { - mWidgets.push_back(widget); - } - - void FocusHandler::remove(Widget* widget) - { - if (isFocused(widget)) - mFocusedWidget = nullptr; - - for (WidgetIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++iter) - { - if ((*iter) == widget) - { - mWidgets.erase(iter); - break; - } - } - - if (mDraggedWidget == widget) - { - mDraggedWidget = nullptr; - return; - } - - if (mLastWidgetWithMouse == widget) - { - mLastWidgetWithMouse = nullptr; - return; - } - - if (mLastWidgetWithModalFocus == widget) - { - mLastWidgetWithModalFocus = nullptr; - return; - } - - if (mLastWidgetWithModalMouseInputFocus == widget) - { - mLastWidgetWithModalMouseInputFocus = nullptr; - return; - } - - if (mLastWidgetPressed == widget) - { - mLastWidgetPressed = nullptr; - return; - } - } - - void FocusHandler::focusNone() - { - if (mFocusedWidget) - { - Widget *const focused = mFocusedWidget; - mFocusedWidget = nullptr; - - Event focusEvent(focused); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::tabNext() - { - if (mFocusedWidget) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - bool done = false; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - ++ focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget >= sz) - focusedWidget = 0; - - if (focusedWidget == focused) - return; - - const Widget *const widget = mWidgets.at(focusedWidget); - if (widget->isFocusable() && widget->isTabInEnabled() && - (!mModalFocusedWidget || widget->isModalFocused())) - { - done = true; - } - } - while (!done); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::tabPrevious() - { - if (mFocusedWidget) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - bool done = false; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - -- focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget <= 0) - focusedWidget = sz - 1; - - if (focusedWidget == focused) - return; - - const Widget *const widget = mWidgets.at(focusedWidget); - if (widget->isFocusable() && widget->isTabInEnabled() && - (!mModalFocusedWidget || widget->isModalFocused())) - { - done = true; - } - } - while (!done); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) - { - Widget *const sourceWidget = focusEvent.getSource(); - - std::list focusListeners - = sourceWidget->_getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusLost(focusEvent); - } - } - - void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent) - { - Widget *const sourceWidget = focusEvent.getSource(); - - std::list focusListeners - = sourceWidget->_getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusGained(focusEvent); - } - } - - Widget* FocusHandler::getDraggedWidget() - { - return mDraggedWidget; - } - - void FocusHandler::setDraggedWidget(Widget* draggedWidget) - { - mDraggedWidget = draggedWidget; - } - - Widget* FocusHandler::getLastWidgetWithMouse() - { - return mLastWidgetWithMouse; - } - - void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse) - { - mLastWidgetWithMouse = lastWidgetWithMouse; - } - - Widget* FocusHandler::getLastWidgetWithModalFocus() - { - return mLastWidgetWithModalFocus; - } - - void FocusHandler::setLastWidgetWithModalFocus(Widget* widget) - { - mLastWidgetWithModalFocus = widget; - } - - Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() - { - return mLastWidgetWithModalMouseInputFocus; - } - - void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget) - { - mLastWidgetWithModalMouseInputFocus = widget; - } - - Widget* FocusHandler::getLastWidgetPressed() - { - return mLastWidgetPressed; - } - - void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed) - { - mLastWidgetPressed = lastWidgetPressed; - } -} // namespace gcn diff --git a/src/guichan/font.cpp b/src/guichan/font.cpp deleted file mode 100644 index 982e1ac8c..000000000 --- a/src/guichan/font.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/font.hpp" - -#include - -#include "debug.h" - -namespace gcn -{ - int Font::getStringIndexAt(const std::string& text, const int x) const - { - const size_t sz = text.size(); - for (size_t i = 0; i < sz; ++i) - { - if (getWidth(text.substr(0, i)) > x) - return i; - } - - return static_cast(sz); - } -} // namespace gcn diff --git a/src/guichan/graphics.cpp b/src/guichan/graphics.cpp deleted file mode 100644 index b63c4b58c..000000000 --- a/src/guichan/graphics.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/graphics.hpp" - -#include "guichan/exception.hpp" -#include "guichan/font.hpp" -#include "guichan/image.hpp" - -#include "debug.h" - -namespace gcn -{ - - Graphics::Graphics() : - mClipStack(), - mFont(nullptr) - { - } - - bool Graphics::pushClipArea(Rectangle area) - { - // Ignore area with a negate width or height - // by simple pushing an empty clip area - // to the stack. - if (area.width < 0 || area.height < 0) - { - ClipRectangle carea; - mClipStack.push(carea); - return true; - } - - if (mClipStack.empty()) - { - ClipRectangle carea; - carea.x = area.x; - carea.y = area.y; - carea.width = area.width; - carea.height = area.height; - carea.xOffset = area.x; - carea.yOffset = area.y; - mClipStack.push(carea); - return true; - } - - const ClipRectangle &top = mClipStack.top(); - ClipRectangle carea; - carea = area; - carea.xOffset = top.xOffset + carea.x; - carea.yOffset = top.yOffset + carea.y; - carea.x += top.xOffset; - carea.y += top.yOffset; - - // Clamp the pushed clip rectangle. - if (carea.x < top.x) - carea.x = top.x; - - if (carea.y < top.y) - carea.y = top.y; - - if (carea.x + carea.width > top.x + top.width) - { - carea.width = top.x + top.width - carea.x; - - if (carea.width < 0) - carea.width = 0; - } - - if (carea.y + carea.height > top.y + top.height) - { - carea.height = top.y + top.height - carea.y; - - if (carea.height < 0) - carea.height = 0; - } - - const bool result = carea.isIntersecting(top); - - mClipStack.push(carea); - - return result; - } - - void Graphics::popClipArea() - { - if (mClipStack.empty()) - throw GCN_EXCEPTION("Tried to pop clip area from empty stack."); - - mClipStack.pop(); - } - - const ClipRectangle& Graphics::getCurrentClipArea() - { - if (mClipStack.empty()) - throw GCN_EXCEPTION("The clip area stack is empty."); - - return mClipStack.top(); - } - - void Graphics::drawImage(const Image* image A_UNUSED, - int dstX A_UNUSED, int dstY A_UNUSED) - { - } - -/* - void Graphics::setFont(Font* font) - { - } - - void Graphics::drawText(const std::string& text, int x, int y, - Alignment alignment) - { - } -*/ -} // namespace gcn diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp deleted file mode 100644 index fa50812de..000000000 --- a/src/guichan/gui.cpp +++ /dev/null @@ -1,765 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/gui.hpp" - -#include "guichan/basiccontainer.hpp" -#include "guichan/exception.hpp" -#include "guichan/focushandler.hpp" -#include "guichan/graphics.hpp" -#include "guichan/input.hpp" -#include "guichan/keyinput.hpp" -#include "guichan/keylistener.hpp" -#include "guichan/mouseinput.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -#include "debug.h" - -namespace gcn -{ - Gui::Gui() : - mTop(nullptr), - mGraphics(nullptr), - mInput(nullptr), - mFocusHandler(new FocusHandler), - mTabbing(true), - mKeyListeners(), - mShiftPressed(false), - mMetaPressed(false), - mControlPressed(false), - mAltPressed(false), - mLastMousePressButton(0), - mLastMousePressTimeStamp(0), - mLastMouseX(0), - mLastMouseY(0), - mClickCount(1), - mLastMouseDragButton(0), - mWidgetWithMouseQueue() - { - } - - Gui::~Gui() - { - if (Widget::widgetExists(mTop)) - setTop(nullptr); - - delete mFocusHandler; - mFocusHandler = nullptr; - } - - void Gui::setTop(Widget* top) - { - if (mTop) - mTop->_setFocusHandler(nullptr); - if (top) - top->_setFocusHandler(mFocusHandler); - - mTop = top; - } - - Widget* Gui::getTop() const - { - return mTop; - } - - void Gui::setGraphics(Graphics* graphics) - { - mGraphics = graphics; - } - - Graphics* Gui::getGraphics() const - { - return mGraphics; - } - - void Gui::setInput(Input* input) - { - mInput = input; - } - - Input* Gui::getInput() const - { - return mInput; - } - - void Gui::logic() - { - } - - void Gui::draw() - { - } - - void Gui::focusNone() - { - mFocusHandler->focusNone(); - } - - void Gui::setTabbingEnabled(bool tabbing) - { - mTabbing = tabbing; - } - - bool Gui::isTabbingEnabled() - { - return mTabbing; - } - - void Gui::addGlobalKeyListener(KeyListener* keyListener) - { - mKeyListeners.push_back(keyListener); - } - - void Gui::removeGlobalKeyListener(KeyListener* keyListener) - { - mKeyListeners.remove(keyListener); - } - - void Gui::handleMouseInput() - { - } - - void Gui::handleKeyInput() - { - } - - void Gui::handleMouseMoved(const MouseInput& mouseInput) - { - // Check if the mouse leaves the application window. - if (!mWidgetWithMouseQueue.empty() && (mouseInput.getX() < 0 - || mouseInput.getY() < 0 || !mTop->getDimension().isPointInRect( - mouseInput.getX(), mouseInput.getY()))) - { - // Distribute an event to all widgets in the - // "widget with mouse" queue. - while (!mWidgetWithMouseQueue.empty()) - { - Widget *const widget = mWidgetWithMouseQueue.front(); - - if (Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEvent::EXITED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY(), - true, - true); - } - - mWidgetWithMouseQueue.pop_front(); - } - - return; - } - - // Check if there is a need to send mouse exited events by - // traversing the "widget with mouse" queue. - bool widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty(); - while (!widgetWithMouseQueueCheckDone) - { - unsigned int iterations = 0; - for (std::deque::iterator - iter = mWidgetWithMouseQueue.begin(); - iter != mWidgetWithMouseQueue.end(); - ++ iter) - { - Widget *const widget = *iter; - - // If a widget in the "widget with mouse queue" doesn't - // exists anymore it should be removed from the queue. - if (!Widget::widgetExists(widget)) - { - mWidgetWithMouseQueue.erase(iter); - break; - } - else - { - int x, y; - widget->getAbsolutePosition(x, y); - - if (x > mouseInput.getX() - || y > mouseInput.getY() - || x + widget->getWidth() <= mouseInput.getX() - || y + widget->getHeight() <= mouseInput.getY() - || !widget->isVisible()) - { - distributeMouseEvent(widget, - MouseEvent::EXITED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY(), - true, - true); - mClickCount = 1; - mLastMousePressTimeStamp = 0; - mWidgetWithMouseQueue.erase(iter); - break; - } - } - - iterations++; - } - - widgetWithMouseQueueCheckDone = - (iterations == mWidgetWithMouseQueue.size()); - } - - // Check all widgets below the mouse to see if they are - // present in the "widget with mouse" queue. If a widget - // is not then it should be added and an entered event should - // be sent to it. - Widget* parent = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - Widget* widget = parent; - - // If a widget has modal mouse input focus then it will - // always be returned from getMouseEventSource, but we only wan't to - // send mouse entered events if the mouse has actually entered the - // widget with modal mouse input focus, hence we need to check if - // that's the case. If it's not we should simply ignore to send any - // mouse entered events. - if (mFocusHandler->getModalMouseInputFocused() - && widget == mFocusHandler->getModalMouseInputFocused() - && Widget::widgetExists(widget)) - { - int x, y; - widget->getAbsolutePosition(x, y); - - if (x > mouseInput.getX() || y > mouseInput.getY() - || x + widget->getWidth() <= mouseInput.getX() - || y + widget->getHeight() <= mouseInput.getY()) - { - parent = nullptr; - } - } - - while (parent) - { - parent = widget->getParent(); - - // Check if the widget is present in the "widget with mouse" queue. - bool widgetIsPresentInQueue = false; - FOR_EACH (std::deque::const_iterator, - iter, mWidgetWithMouseQueue) - { - if (*iter == widget) - { - widgetIsPresentInQueue = true; - break; - } - } - - // Widget is not present, send an entered event and add - // it to the "widget with mouse" queue. - if (!widgetIsPresentInQueue - && Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEvent::ENTERED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY(), - true, - true); - mWidgetWithMouseQueue.push_front(widget); - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - } - - if (mFocusHandler->getDraggedWidget()) - { - distributeMouseEvent(mFocusHandler->getDraggedWidget(), - MouseEvent::DRAGGED, - mLastMouseDragButton, - mouseInput.getX(), - mouseInput.getY()); - } - else - { - Widget *const sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - distributeMouseEvent(sourceWidget, - MouseEvent::MOVED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - } - } - - void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput) - { - Widget* sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - if (mFocusHandler->getDraggedWidget()) - sourceWidget = mFocusHandler->getDraggedWidget(); - - int sourceWidgetX, sourceWidgetY; - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - - distributeMouseEvent(sourceWidget, - MouseEvent::WHEEL_MOVED_DOWN, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - } - - void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput) - { - Widget* sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - if (mFocusHandler->getDraggedWidget()) - sourceWidget = mFocusHandler->getDraggedWidget(); - - int sourceWidgetX, sourceWidgetY; - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - - distributeMouseEvent(sourceWidget, - MouseEvent::WHEEL_MOVED_UP, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - } - - Widget* Gui::getWidgetAt(int x, int y) - { - // If the widget's parent has no child then we have found the widget.. - Widget* parent = mTop; - Widget* child = mTop; - - while (child) - { - Widget *const swap = child; - int parentX, parentY; - parent->getAbsolutePosition(parentX, parentY); - child = parent->getWidgetAt(x - parentX, y - parentY); - parent = swap; - } - - return parent; - } - - Widget* Gui::getMouseEventSource(int x, int y) - { - Widget *const widget = getWidgetAt(x, y); - - // +++ possible nullpointer - if (mFocusHandler->getModalMouseInputFocused() - && !widget->isModalMouseInputFocused()) - { - return mFocusHandler->getModalMouseInputFocused(); - } - - return widget; - } - - Widget* Gui::getKeyEventSource() - { - Widget* widget = mFocusHandler->getFocused(); - - // +++ possible nullpointer - while (widget->_getInternalFocusHandler() - && widget->_getInternalFocusHandler()->getFocused()) - { - widget = widget->_getInternalFocusHandler()->getFocused(); - } - - return widget; - } - - void Gui::distributeMouseEvent(Widget* source, - int type, - int button, - int x, - int y, - bool force, - bool toSourceOnly) - { - Widget* parent = source; - Widget* widget = source; - - if (mFocusHandler->getModalFocused() - && !widget->isModalFocused() - && !force) - { - return; - } - - if (mFocusHandler->getModalMouseInputFocused() - && !widget->isModalMouseInputFocused() - && !force) - { - return; - } - - MouseEvent mouseEvent(source, - mShiftPressed, - mControlPressed, - mAltPressed, - mMetaPressed, - type, - button, - x, - y, - mClickCount); - - while (parent) - { - // If the widget has been removed due to input - // cancel the distribution. - if (!Widget::widgetExists(widget)) - break; - - parent = widget->getParent(); - - if (widget->isEnabled() || force) - { - int widgetX, widgetY; - widget->getAbsolutePosition(widgetX, widgetY); - - mouseEvent.mX = x - widgetX; - mouseEvent.mY = y - widgetY; - - std::list mouseListeners - = widget->_getMouseListeners(); - - // Send the event to all mouse listeners of the widget. - for (std::list::const_iterator - it = mouseListeners.begin(); - it != mouseListeners.end(); - ++it) - { - switch (mouseEvent.getType()) - { - case MouseEvent::ENTERED: - (*it)->mouseEntered(mouseEvent); - break; - case MouseEvent::EXITED: - (*it)->mouseExited(mouseEvent); - break; - case MouseEvent::MOVED: - (*it)->mouseMoved(mouseEvent); - break; - case MouseEvent::PRESSED: - (*it)->mousePressed(mouseEvent); - break; - case MouseEvent::RELEASED: - (*it)->mouseReleased(mouseEvent); - break; - case MouseEvent::WHEEL_MOVED_UP: - (*it)->mouseWheelMovedUp(mouseEvent); - break; - case MouseEvent::WHEEL_MOVED_DOWN: - (*it)->mouseWheelMovedDown(mouseEvent); - break; - case MouseEvent::DRAGGED: - (*it)->mouseDragged(mouseEvent); - break; - case MouseEvent::CLICKED: - (*it)->mouseClicked(mouseEvent); - break; - default: - throw GCN_EXCEPTION("Unknown mouse event type."); - } - } - - if (toSourceOnly) - break; - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - - // If a non modal focused widget has been reach - // and we have modal focus cancel the distribution. - if (mFocusHandler->getModalFocused() - && !widget->isModalFocused()) - { - break; - } - - // If a non modal mouse input focused widget has been reach - // and we have modal mouse input focus cancel the distribution. - if (mFocusHandler->getModalMouseInputFocused() - && !widget->isModalMouseInputFocused()) - { - break; - } - } - } - - void Gui::distributeKeyEvent(KeyEvent& keyEvent) - { - Widget* parent = keyEvent.getSource(); - Widget* widget = keyEvent.getSource(); - - if (mFocusHandler->getModalFocused() - && !widget->isModalFocused()) - { - return; - } - - if (mFocusHandler->getModalMouseInputFocused() - && !widget->isModalMouseInputFocused()) - { - return; - } - - while (parent) - { - // If the widget has been removed due to input - // cancel the distribution. - if (!Widget::widgetExists(widget)) - break; - - parent = widget->getParent(); - - if (widget->isEnabled()) - { - std::list keyListeners - = widget->_getKeyListeners(); - - // Send the event to all key listeners of the source widget. - for (std::list::const_iterator - it = keyListeners.begin(); - it != keyListeners.end(); - ++it) - { - switch (keyEvent.getType()) - { - case KeyEvent::PRESSED: - (*it)->keyPressed(keyEvent); - break; - case KeyEvent::RELEASED: - (*it)->keyReleased(keyEvent); - break; - default: - throw GCN_EXCEPTION("Unknown key event type."); - } - } - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - - // If a non modal focused widget has been reach - // and we have modal focus cancel the distribution. - if (mFocusHandler->getModalFocused() - && !widget->isModalFocused()) - { - break; - } - } - } - - void Gui::distributeKeyEventToGlobalKeyListeners(KeyEvent& keyEvent) - { - for (KeyListenerListIterator it = mKeyListeners.begin(); - it != mKeyListeners.end(); ++ it) - { - switch (keyEvent.getType()) - { - case KeyEvent::PRESSED: - (*it)->keyPressed(keyEvent); - break; - case KeyEvent::RELEASED: - (*it)->keyReleased(keyEvent); - break; - default: - throw GCN_EXCEPTION("Unknown key event type."); - } - - if (keyEvent.isConsumed()) - break; - } - } - - void Gui::handleModalMouseInputFocus() - { - BLOCK_START("Gui::handleModalMouseInputFocus") - // Check if modal mouse input focus has been gained by a widget. - if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() - != mFocusHandler->getModalMouseInputFocused()) - && (!mFocusHandler->getLastWidgetWithModalMouseInputFocus())) - { - handleModalFocusGained(); - mFocusHandler->setLastWidgetWithModalMouseInputFocus( - mFocusHandler->getModalMouseInputFocused()); - } - // Check if modal mouse input focus has been released. - else if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus() - != mFocusHandler->getModalMouseInputFocused()) - && (mFocusHandler->getLastWidgetWithModalMouseInputFocus())) - { - handleModalFocusReleased(); - mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr); - } - BLOCK_END("Gui::handleModalMouseInputFocus") - } - - void Gui::handleModalFocus() - { - BLOCK_START("Gui::handleModalFocus") - // Check if modal focus has been gained by a widget. - if ((mFocusHandler->getLastWidgetWithModalFocus() - != mFocusHandler->getModalFocused()) - && (!mFocusHandler->getLastWidgetWithModalFocus())) - { - handleModalFocusGained(); - mFocusHandler->setLastWidgetWithModalFocus( - mFocusHandler->getModalFocused()); - } - // Check if modal focus has been released. - else if ((mFocusHandler->getLastWidgetWithModalFocus() - != mFocusHandler->getModalFocused()) - && (mFocusHandler->getLastWidgetWithModalFocus())) - { - handleModalFocusReleased(); - mFocusHandler->setLastWidgetWithModalFocus(nullptr); - } - BLOCK_END("Gui::handleModalFocus") - } - - void Gui::handleModalFocusGained() - { - // Distribute an event to all widgets in the "widget with mouse" queue. - while (!mWidgetWithMouseQueue.empty()) - { - Widget *const widget = mWidgetWithMouseQueue.front(); - - if (Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEvent::EXITED, - mLastMousePressButton, - mLastMouseX, - mLastMouseY, - true, - true); - } - - mWidgetWithMouseQueue.pop_front(); - } - - mFocusHandler->setLastWidgetWithModalMouseInputFocus( - mFocusHandler->getModalMouseInputFocused()); - } - - void Gui::handleModalFocusReleased() - { - // Check all widgets below the mouse to see if they are - // present in the "widget with mouse" queue. If a widget - // is not then it should be added and an entered event should - // be sent to it. - Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY); - Widget* parent = widget; - - while (parent) - { - parent = widget->getParent(); - - // Check if the widget is present in the "widget with mouse" queue. - bool widgetIsPresentInQueue = false; - FOR_EACH (std::deque::const_iterator, - iter, mWidgetWithMouseQueue) - { - if (*iter == widget) - { - widgetIsPresentInQueue = true; - break; - } - } - - // Widget is not present, send an entered event and add - // it to the "widget with mouse" queue. - if (!widgetIsPresentInQueue && Widget::widgetExists(widget)) - { - distributeMouseEvent(widget, - MouseEvent::ENTERED, - mLastMousePressButton, - mLastMouseX, - mLastMouseY, - false, - true); - mWidgetWithMouseQueue.push_front(widget); - } - - const Widget *const swap = widget; - widget = parent; - parent = swap->getParent(); - } - } -} // namespace gcn diff --git a/src/guichan/image.cpp b/src/guichan/image.cpp deleted file mode 100644 index d60df27a7..000000000 --- a/src/guichan/image.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/image.hpp" - -#include "guichan/exception.hpp" - -#include "debug.h" - -namespace gcn -{ - Image::Image() - { - } - - Image::~Image() - { - } -} diff --git a/src/guichan/include/guichan/actionevent.hpp b/src/guichan/include/guichan/actionevent.hpp deleted file mode 100644 index b0f75a039..000000000 --- a/src/guichan/include/guichan/actionevent.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_ACTIONEVENT_HPP -#define GCN_ACTIONEVENT_HPP - -#include "guichan/event.hpp" - -#include - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Represents an action event. An action event is an event - * that can be fired by a widget whenever an action has occured. - * What exactly an action is is up to the widget that fires - * the action event. An example is a Button which fires an action - * event as soon as the Button is clicked, another example is - * TextField which fires an action event as soon as the enter - * key is pressed. - * - * Any object can listen for actions from widgets by implementing - * the ActionListener interface. - * - * If you have implement a widget of your own it's a good idea to - * let the widget fire action events whenever you feel an action - * has occured so action listeners of the widget can be informed - * of the state of the widget. - * - * @see Widget::addActionListener, Widget::removeActionListener, - * Widget::distributeActionEvent - * @author Olof Naessén - * @since 0.6.0 - */ - class ActionEvent final : public Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - * @param id An identifier of the event. - */ - ActionEvent(Widget *const source, const std::string &id); - - /** - * Destructor. - */ - virtual ~ActionEvent(); - - /** - * Gets the identifier of the event. An identifier can - * be used to distinguish from two actions from the same - * widget or to let many widgets fire the same widgets - * that should be treated equally. - * - * @return The identifier of the event. - */ - const std::string& getId() const A_WARN_UNUSED; - - protected: - /** - * Holds the identifier of the event. - */ - std::string mId; - }; -} // namespace gcn - -#endif // GCN_ACTIONEVENT_HPP diff --git a/src/guichan/include/guichan/actionlistener.hpp b/src/guichan/include/guichan/actionlistener.hpp deleted file mode 100644 index 0f017873b..000000000 --- a/src/guichan/include/guichan/actionlistener.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_ACTIONLISTENER_HPP -#define GCN_ACTIONLISTENER_HPP - -#include - -#include "guichan/actionevent.hpp" - -namespace gcn -{ - /** - * Interface for listening for action events from widgets. - * - * @see Widget::addActionListener, Widget::removeActionListener, - * ActionEvent - * @author Olof Naessén - * @author Per Larsson - */ - class ActionListener - { - public: - /** - * Destructor. - */ - virtual ~ActionListener() - { } - - /** - * Called when an action is recieved from a widget. It is used - * to be able to recieve a notification that an action has - * occured. - * - * @param actionEvent The event of the action. - * @since 0.6.0 - */ - virtual void action(const ActionEvent& actionEvent) = 0; - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of ActionListener, - * therefore its constructor is protected. - */ - ActionListener() - { } - }; -} // namespace gcn - -#endif // end GCN_ACTIONLISTENER_HPP diff --git a/src/guichan/include/guichan/basiccontainer.hpp b/src/guichan/include/guichan/basiccontainer.hpp deleted file mode 100644 index a3fb18528..000000000 --- a/src/guichan/include/guichan/basiccontainer.hpp +++ /dev/null @@ -1,216 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_BASICCONTAINER_HPP -#define GCN_BASICCONTAINER_HPP - -#include -#include - -#include "guichan/deathlistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * A base class for containers. The class implements the most - * common things for a container. If you are implementing a - * container, consider inheriting from this class. - * - * @see Container - * @since 0.6.0 - */ - class BasicContainer : public Widget, - public DeathListener - { - public: - BasicContainer() : - mWidgets() - { } - - A_DELETE_COPY(BasicContainer) - - /** - * Destructor - */ - virtual ~BasicContainer(); - - /** - * Shows a certain part of a widget in the basic container. - * Used when widgets want a specific part to be visible in - * its parent. An example is a TextArea that wants a specific - * part of its text to be visible when a TextArea is a child - * of a ScrollArea. - * - * @param widget The widget whom wants a specific part of - * itself to be visible. - * @param rectangle The rectangle to be visible. - */ - virtual void showWidgetPart(Widget* widget, Rectangle area); - - // Inherited from Widget - - virtual void moveToTop(Widget* widget); - - virtual void moveToBottom(Widget* widget); - - virtual Rectangle getChildrenArea() A_WARN_UNUSED; - - virtual void focusNext(); - - virtual void focusPrevious(); - - virtual void logic(); - - virtual void _setFocusHandler(FocusHandler* focusHandler); - - void setInternalFocusHandler(FocusHandler* focusHandler); - - virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED; - - - // Inherited from DeathListener - - virtual void death(const Event& event); - - protected: - /** - * Adds a widget to the basic container. - * - * @param widget The widget to add. - * @see remove, clear - */ - void add(Widget* widget); - - /** - * Removes a widget from the basic container. - * - * @param widget The widget to remove. - * @see add, clear - */ - virtual void remove(Widget* widget); - - /** - * Clears the basic container from all widgets. - * - * @see remove, clear - */ - virtual void clear(); - - /** - * Draws the children widgets of the basic container. - * - * @param graphics A graphics object to draw with. - */ - virtual void drawChildren(Graphics* graphics); - - /** - * Calls logic for the children widgets of the basic - * container. - */ - virtual void logicChildren(); - - /** - * Finds a widget given an id. This function can be useful - * when implementing a GUI generator for Guichan, such as - * the ability to create a Guichan GUI from an XML file. - * - * @param id The id to find a widget by. - * @return The widget with the corrosponding id, - NULL of no widget is found. - */ - virtual Widget* findWidgetById(const std::string& id) A_WARN_UNUSED; - - /** - * Typedef. - */ - typedef std::vector WidgetList; - - /** - * Typedef. - */ - typedef WidgetList::iterator WidgetListIterator; - - /** - * Typedef. - */ - typedef WidgetList::const_iterator WidgetListConstIterator; - - /** - * Typedef. - */ - typedef WidgetList::reverse_iterator WidgetListReverseIterator; - - /** - * Typedef. - */ - typedef WidgetList::const_reverse_iterator WidgetListCReverseIterator; - - /** - * Holds all widgets of the basic container. - */ - WidgetList mWidgets; - }; -} // namespace gcn - -#endif // end GCN_BASICCONTAINER_HPP diff --git a/src/guichan/include/guichan/cliprectangle.hpp b/src/guichan/include/guichan/cliprectangle.hpp deleted file mode 100644 index 148a73d5a..000000000 --- a/src/guichan/include/guichan/cliprectangle.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_CLIPRECTANGLE_HPP -#define GCN_CLIPRECTANGLE_HPP - -#include "guichan/rectangle.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * A rectangle used when dealing with clipping. A clip rectangle is - * a regular rectangle extended with variables for x offsets and y - * offsets. The offsets are used for calculations from relative - * screen coordinates to actual screen coordinates. - */ - class ClipRectangle final : public Rectangle - { - public: - /** - * Constructor. - */ - ClipRectangle(); - - /** - * Constructor. - * - * @param x0 The rectangle x coordinate. - * @param y0 The rectangle y coordinate. - * @param width0 The rectangle width. - * @param height0 The rectangle height. - * @param xOffset0 The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset0 The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - */ - ClipRectangle(const int x0, - const int y0, - const int width0, - const int height0, - const int xOffset0, - const int yOffset0); - - /** - * Copy constructor. Copies x, y, width and height - * field from a rectangle to a clip rectangle. - * - * @param other The rectangle to copy data from. - * @returns A clip rectangle with data copyied from a rectangle. - */ - const ClipRectangle& operator=(const Rectangle& other); - - /** - * Holds the x offset of the x coordinate. - */ - int xOffset; - - /** - * Holds the y offset of the y coordinate. - */ - int yOffset; - }; -} // namespace gcn - -#endif // end GCN_CLIPRECTANGLE_HPP diff --git a/src/guichan/include/guichan/color.hpp b/src/guichan/include/guichan/color.hpp deleted file mode 100644 index c32adb2e9..000000000 --- a/src/guichan/include/guichan/color.hpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_COLOR_HPP -#define GCN_COLOR_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * Represents a color with red, green, blue and alpha components. - */ - class Color final - { - public: - /** - * Constructor. Initializes the color to black. - */ - Color(); - - /** - * Constructor. Constructs a color from the bytes in an integer. - * Call it with a hexadecimal constant for HTML-style color representation. - * The alpha component is 255 by default. - * - * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. - * - * NOTE: Because of this constructor, integers will be automatically - * casted to a color by your compiler. - * - * @param color The color to initialise the object with. - */ - explicit Color(const int color); - - /** - * Constructor. The default alpha value is 255. - * - * @param r Red color component (range 0-255). - * @param g Green color component (range 0-255). - * @param b Blue color component (range 0-255). - * @param a Alpha, used for transparency. A value of 0 means - * totaly transparent, 255 is totaly opaque. - */ - Color(const int r, const int g, const int b, const int a = 255); - - /** - * Adds the RGB values of two colors together. The values will be - * clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to add to this color. - * @return The added colors with an alpha value set to 255. - */ - Color operator+(const Color& color) const; - - /** - * Subtracts the RGB values of one color from another. - * The values will be clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to subtract from this color. - * @return The subtracted colors with an alpha value set to 255. - */ - Color operator-(const Color& color) const; - - /** - * Multiplies the RGB values of a color with a float value. - * The values will be clamped if they go out of range. - * - * @param value The value to multiply the color with. - * @return The multiplied colors. The alpha value will, unlike - * the add and subtract operations, be multiplied as - * well. - */ - Color operator*(const float value) const; - - /** - * Compares two colors. - * - * @return True if the two colors have the same RGBA components - * false otherwise. - */ - bool operator==(const Color& color) const; - - /** - * Compares two colors. - * - * @return True if the two colors have different RGBA components, - * false otherwise. - */ - bool operator!=(const Color& color) const; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param color The color to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Color& Color); - - /** - * Holds the red color component (range 0-255). - */ - int r; - - /** - * Holds the green color component (range 0-255). - */ - int g; - - /** - * Holds the blue color component (range 0-255). - */ - int b; - - /** - * Holds the alpha color component. A value of 0 means totally - * transparent while a value of 255 is considered opaque. - */ - int a; - }; -} // namespace gcn - -#endif // end GCN_COLOR_HPP diff --git a/src/guichan/include/guichan/deathlistener.hpp b/src/guichan/include/guichan/deathlistener.hpp deleted file mode 100644 index cc8d11990..000000000 --- a/src/guichan/include/guichan/deathlistener.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_DEATHLISTENER_HPP -#define GCN_DEATHLISTENER_HPP - -#include - -#include "guichan/event.hpp" - -namespace gcn -{ - /** - * Interface for listening for death events from widgets. - * - * @see Widget::addDeathListener, Widget::removeDeathListener - * @author Olof Naessén - * @since 0.6.0 - */ - class DeathListener - { - public: - /** - * Destructor. - */ - virtual ~DeathListener() - { } - - /** - * Called when a widget dies. It is used to be able to recieve - * a notification when a death of a widget occurs. - * - * @param event The event of the death. - */ - virtual void death(const Event& event) = 0; - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of DeathListener, - * therefore its constructor is protected. - */ - DeathListener() - { } - }; -} // namespace gcn - -#endif // end GCN_DEATHLISTENER_HPP diff --git a/src/guichan/include/guichan/event.hpp b/src/guichan/include/guichan/event.hpp deleted file mode 100644 index 2a1f4ca4b..000000000 --- a/src/guichan/include/guichan/event.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_EVENT_HPP -#define GCN_EVENT_HPP - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Base class for all events. All events in Guichan should - * inherit from this class. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - */ - explicit Event(Widget *const source); - - A_DELETE_COPY(Event) - - /** - * Destructor. - */ - virtual ~Event(); - - /** - * Gets the source widget of the event. The function - * is used to tell which widget fired an event. - * - * @return The source widget of the event. - */ - Widget* getSource() const A_WARN_UNUSED; - - protected: - /** - * Holds the source widget of the event. - */ - Widget* mSource; - }; -} // namespace gcn - -#endif // end GCN_EVENT_HPP diff --git a/src/guichan/include/guichan/exception.hpp b/src/guichan/include/guichan/exception.hpp deleted file mode 100644 index a60152c96..000000000 --- a/src/guichan/include/guichan/exception.hpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_EXCEPTION_HPP -#define GCN_EXCEPTION_HPP - -#include - -#include "localconsts.h" - -#ifndef __FUNCTION__ -#define __FUNCTION__ "?" -#endif - -/* - * A macro used to create a standard exception object. - * What it basicly does is that it creates a new exception - * and automatically sets the filename and line number where - * the exception occured by using other compiler macros. - */ -#define GCN_EXCEPTION(mess) gcn::Exception(mess, \ - __FUNCTION__, \ - __FILE__, \ - __LINE__) - -namespace gcn -{ - - /** - * An exception containing a message, a file and a line number - * where the exception occured. Guichan will only throw exceptions - * of this class. - * - * You can use this class for your own exceptions that has - * something to do with a GUI exception. A nifty feature of the - * excpetion class is that it can tell you from which line and - * file it was thrown. To make things easier when throwing - * exceptions there exists a macro for creating exceptions - * which automatically sets the filename and line number. - * - * EXAMPLE: @code - * throw GCN_EXCEPTION("my error message"); - * @endcode - */ - class Exception final - { - public: - /** - * Constructor. - */ - Exception(); - - /** - * Constructor. - * - * @param message The error message of the exception. - */ - explicit Exception(const std::string& message); - - /** - * Constructor. - * - * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead. - * This constructor merely exists for the GCN_EXCEPTION macro to - * use. - * - * @param message The error message of the exception. - * @param function The function name where the exception occured. - * @param filename The name of the file where the exception occured. - * @param line The line number in the source code where the exception - * occured. - */ - Exception(const std::string& message, - const std::string& function, - const std::string& filename, - const unsigned int line); - - /** - * Gets the function name where the exception occured. - * - * @return The function name where the exception occured. - */ - const std::string& getFunction() const A_WARN_UNUSED; - - /** - * Gets the error message of the exception. - * - * @return The error message of the exception. - */ - const std::string& getMessage() const A_WARN_UNUSED; - - /** - * Gets the filename where the exception occured. - * - * @return The filename where the exception occured. - */ - const std::string& getFilename() const A_WARN_UNUSED; - - /** - * Gets the line number where the exception occured. - * - * @return The line number where the exception occured. - */ - unsigned int getLine() const A_WARN_UNUSED; - - protected: - /** - * Holds the name of the function name where the - * exception occured. - */ - std::string mFunction; - - /** - * Holds the error message of the exception. - */ - std::string mMessage; - - /** - * Holds the filename where the exception occured. - */ - std::string mFilename; - - /** - * Holds the line number where the exception occured. - */ - unsigned int mLine; - }; -} // namespace gcn - -#endif // end GCN_EXCEPTION_HPP - -/* - * "Final Fantasy XI is the BEST!... It's even better then water!" - * - Astrolite - * I believe it's WoW now days. - */ diff --git a/src/guichan/include/guichan/focushandler.hpp b/src/guichan/include/guichan/focushandler.hpp deleted file mode 100644 index 6cd326d33..000000000 --- a/src/guichan/include/guichan/focushandler.hpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_FOCUSHANDLER_HPP -#define GCN_FOCUSHANDLER_HPP - -#include - -#include "guichan/event.hpp" - -namespace gcn -{ - class Widget; - - /** - * Handles focus for widgets in a Gui. Each Gui has at least one - * focus handler. - * You will probably not use the focus handler directly as Widget - * has functions that automatically uses the active focus handler. - * - * @see Widget::isFocus, Widget::isModalFocused, - * Widget::isModalMouseInputFocused, Widget::requestFocus, - * Widget::requestModalFocus, Widget::requestModalMouseInputFocus, - * Widget::releaseModalFocus, Widget::relaseModalMouseInputFocus, - * Widget::setFocusable, Widget::isFocusable, FocusListener - * - * @since 0.1.0 - */ - class FocusHandler - { - public: - /** - * Constructor. - */ - FocusHandler(); - - A_DELETE_COPY(FocusHandler) - - /** - * Destructor. - */ - virtual ~FocusHandler() - { } - - /** - * Requests focus for a widget. Focus will only be granted to a widget - * if it's focusable and if no other widget has modal focus. - * If a widget receives focus a focus event will be sent to the - * focus listeners of the widget. - * - * @param widget The widget to request focus for. - * @see isFocused, Widget::requestFocus - */ - virtual void requestFocus(Widget* widget); - - /** - * Requests modal focus for a widget. Focus will only be granted - * to a widget if it's focusable and if no other widget has modal - * focus. - * - * @param widget The widget to request modal focus for. - * @throws Exception when another widget already has modal focus. - * @see releaseModalFocus, Widget::requestModalFocus - */ - virtual void requestModalFocus(Widget* widget); - - /** - * Requests modal mouse input focus for a widget. Focus will only - * be granted to a widget if it's focusable and if no other widget - * has modal mouse input focus. - * - * Modal mouse input focus means no other widget then the widget with - * modal mouse input focus will receive mouse input. The widget with - * modal mouse input focus will also receive mouse input no matter what - * the mouse input is or where the mouse input occurs. - * - * @param widget The widget to focus for modal mouse input focus. - * @throws Exception when another widget already has modal mouse input - * focus. - * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus - */ - virtual void requestModalMouseInputFocus(Widget* widget); - - /** - * Releases modal focus if the widget has modal focus. - * If the widget doesn't have modal focus no relase will occur. - * - * @param widget The widget to release modal focus for. - * @see reuqestModalFocus, Widget::releaseModalFocus - */ - virtual void releaseModalFocus(Widget* widget); - - /** - * Releases modal mouse input focus if the widget has modal mouse input - * focus. If the widget doesn't have modal mouse input focus no relase - * will occur. - * - * @param widget the widget to release modal mouse input focus for. - * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus - */ - virtual void releaseModalMouseInputFocus(Widget* widget); - - /** - * Checks if a widget is focused. - * - * @param widget The widget to check. - * @return True if the widget is focused, false otherwise. - * @see Widget::isFocused - */ - virtual bool isFocused(const Widget* widget) const; - - /** - * Gets the widget with focus. - * - * @return The widget with focus. NULL if no widget has focus. - */ - virtual Widget* getFocused() const A_WARN_UNUSED; - - /** - * Gets the widget with modal focus. - * - * @return The widget with modal focus. NULL if no widget has - * modal focus. - */ - virtual Widget* getModalFocused() const A_WARN_UNUSED; - - /** - * Gets the widget with modal mouse input focus. - * - * @return The widget with modal mouse input focus. NULL if - * no widget has modal mouse input focus. - */ - virtual Widget* getModalMouseInputFocused() const A_WARN_UNUSED; - - /** - * Focuses the next widget added to a conainer. - * If no widget has focus the first widget gets focus. The order - * in which the widgets are focused is determined by the order - * they were added to a container. - * - * @see focusPrevious - */ - virtual void focusNext(); - - /** - * Focuses the previous widget added to a contaienr. - * If no widget has focus the first widget gets focus. The order - * in which the widgets are focused is determined by the order - * they were added to a container. - * - * @see focusNext - */ - virtual void focusPrevious(); - - /** - * Adds a widget to by handles by the focus handler. - * - * @param widget The widget to add. - * @see remove - */ - virtual void add(Widget* widget); - - /** - * Removes a widget from the focus handler. - * - * @param widget The widget to remove. - * @see add - */ - virtual void remove(Widget* widget); - - /** - * Focuses nothing. A focus event will also be sent to the - * focused widget's focus listeners if a widget has focus. - */ - virtual void focusNone(); - - /** - * Focuses the next widget which allows tabbing in unless - * the current focused Widget disallows tabbing out. - * - * @see tabPrevious - */ - virtual void tabNext(); - - /** - * Focuses the previous widget which allows tabbing in unless - * current focused widget disallows tabbing out. - * - * @see tabNext - */ - virtual void tabPrevious(); - - /** - * Gets the widget being dragged. Used by the Gui class to - * keep track of the dragged widget. - * - * @return the widget being dragged. - * @see setDraggedWidget - */ - virtual Widget* getDraggedWidget() A_WARN_UNUSED; - - /** - * Sets the widget being dragged. Used by the Gui class to - * keep track of the dragged widget. - * - * @param draggedWidget The widget being dragged. - * @see getDraggedWidget - */ - virtual void setDraggedWidget(Widget* draggedWidget); - - /** - * Gets the last widget with the mouse. Used by the Gui class - * to keep track the last widget with the mouse. - * - * @return The last widget with the mouse. - * @see setLastWidgetWithMouse - */ - virtual Widget* getLastWidgetWithMouse() A_WARN_UNUSED; - - /** - * Sets the last widget with the mouse. Used by the Gui class - * to keep track the last widget with the mouse. - * - * @param lastWidgetWithMouse The last widget with the mouse. - * @see getLastWidgetWithMouse - */ - virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); - - /** - * Gets the last widget with modal focus. - * - * @return The last widget with modal focus. - * @see setLastWidgetWithModalFocus - */ - virtual Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; - - /** - * Sets the last widget with modal focus. - * - * @param widget The last widget with modal focus. - * @see getLastWidgetWithModalFocus - */ - virtual void setLastWidgetWithModalFocus(Widget* widget); - - /** - * Gets the last widget with modal mouse input focus. - * - * @return The last widget with modal mouse input focus. - * @see setLastWidgetWithModalMouseInputFocus - */ - virtual Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; - - /** - * Sets the last widget with modal mouse input focus. - * - * @param widget The last widget with modal mouse input focus. - * @see getLastWidgetWithModalMouseInputFocus - */ - virtual void setLastWidgetWithModalMouseInputFocus(Widget* widget); - - /** - * Gets the last widget pressed. Used by the Gui class to keep track - * of pressed widgets. - * - * @return The last widget pressed. - * @see setLastWidgetPressed - */ - virtual Widget* getLastWidgetPressed() A_WARN_UNUSED; - - /** - * Sets the last widget pressed. Used by the Gui class to keep track - * of pressed widgets. - * - * @param lastWidgetPressed The last widget pressed. - * @see getLastWidgetPressed - */ - virtual void setLastWidgetPressed(Widget* lastWidgetPressed); - - protected: - /** - * Distributes a focus lost event. - * - * @param focusEvent the event to distribute. - * @since 0.7.0 - */ - virtual void distributeFocusLostEvent(const Event& focusEvent); - - /** - * Distributes a focus gained event. - * - * @param focusEvent the event to distribute. - * @since 0.7.0 - */ - virtual void distributeFocusGainedEvent(const Event& focusEvent); - - /** - * Typedef. - */ - typedef std::vector WidgetVector; - - /** - * Typedef. - */ - typedef WidgetVector::iterator WidgetIterator; - - /** - * Holds the widgets currently being handled by the - * focus handler. - */ - WidgetVector mWidgets; - - /** - * Holds the focused widget. NULL if no widget has focus. - */ - Widget* mFocusedWidget; - - /** - * Holds the modal focused widget. NULL if no widget has - * modal focused. - */ - Widget* mModalFocusedWidget; - - /** - * Holds the modal mouse input focused widget. NULL if no widget - * is being dragged. - */ - Widget* mModalMouseInputFocusedWidget; - - /** - * Holds the dragged widget. NULL if no widget is - * being dragged. - */ - Widget* mDraggedWidget; - - /** - * Holds the last widget with the mouse. - */ - Widget* mLastWidgetWithMouse; - - /** - * Holds the last widget with modal focus. - */ - Widget* mLastWidgetWithModalFocus; - - /** - * Holds the last widget with modal mouse input focus. - */ - Widget* mLastWidgetWithModalMouseInputFocus; - - /** - * Holds the last widget pressed. - */ - Widget* mLastWidgetPressed; - }; -} // namespace gcn - -#endif // end GCN_FOCUSHANDLER_HPP diff --git a/src/guichan/include/guichan/focuslistener.hpp b/src/guichan/include/guichan/focuslistener.hpp deleted file mode 100644 index 6b3de5c83..000000000 --- a/src/guichan/include/guichan/focuslistener.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_FOCUSLISTENER_HPP -#define GCN_FOCUSLISTENER_HPP - -#include - -#include "guichan/event.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for focus events from widgets. - * - * @see Widget::addFocusListener, Widget::removeFocusListener - * @author Olof Naessén - * @since 0.7.0 - */ - class FocusListener - { - public: - /** - * Destructor. - */ - virtual ~FocusListener() - { } - - /** - * Called when a widget gains focus. - * - * @param event Discribes the event. - */ - virtual void focusGained(const Event& event A_UNUSED) - { } - - /** - * Called when a widget loses focus. - * - * @param event Discribes the event. - */ - virtual void focusLost(const Event& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of FocusListener, - * therefore its constructor is protected. - */ - FocusListener() - { } - }; -} // namespace gcn - -#endif // end GCN_FOCUSLISTENER_HPP diff --git a/src/guichan/include/guichan/font.hpp b/src/guichan/include/guichan/font.hpp deleted file mode 100644 index 8e8ad18c9..000000000 --- a/src/guichan/include/guichan/font.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_FONT_HPP -#define GCN_FONT_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - class Graphics; - - /** - * Interface for a font. - * - * @see ImageFont - */ - class Font - { - public: - /** - * Destructor. - */ - virtual ~Font() - { } - - /** - * Gets the width of a string. The width of a string is not necesserily - * the sum of all the widths of it's glyphs. - * - * @param text The string to return the width of. - * @return The width of a string. - */ - virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0; - - /** - * Gets the height of the glyphs in the font. - * - * @return The height of the glyphs int the font. - */ - virtual int getHeight() const A_WARN_UNUSED = 0; - - /** - * Gets a string index in a string providing an x coordinate. - * Used to retrive a string index (for a character in a - * string) at a certain x position. It is especially useful - * when a mouse clicks in a TextField and you want to know which - * character was clicked. - * - * @return A string index in a string providing an x coordinate. - */ - virtual int getStringIndexAt(const std::string& text, - const int x) const A_WARN_UNUSED; - - /** - * Draws a string. - * - * NOTE: You normally won't use this function to draw text since - * Graphics contains better functions for drawing text. - * - * @param graphics A Graphics object to use for drawing. - * @param text The string to draw. - * @param x The x coordinate where to draw the string. - * @param y The y coordinate where to draw the string. - */ - virtual void drawString(Graphics* graphics, const std::string& text, - int x, int y) = 0; - }; -} // namespace gcn - -#endif // end GCN_FONT_HPP diff --git a/src/guichan/include/guichan/graphics.hpp b/src/guichan/include/guichan/graphics.hpp deleted file mode 100644 index dd15827fd..000000000 --- a/src/guichan/include/guichan/graphics.hpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_GRAPHICS_HPP -#define GCN_GRAPHICS_HPP - -#include -#include - -#include "guichan/cliprectangle.hpp" - -namespace gcn -{ - class Color; - class Font; - class Image; - - /** - * Abstract class for providing drawing primitve functions. - * It contains all vital functions for drawing. - * - * Guichan contains implementations of Graphics for common - * libraries like the Allegro library, the HGE library, - * the OpenGL library, the OpenLayer library, and the SDL library. - * To make Guichan usable with other libraries, a Graphics class - * must be implemented. - * - * In Graphics you can set clip areas to limit drawing to certain - * areas of the screen. Clip areas are put on a stack, which - * means that you can push smaller and smaller clip areas onto the - * stack. All coordinates will be relative to the top most clip area. - * In most cases you won't have to worry about the clip areas, - * unless you want to implement some really complex widget. - * Pushing and poping of clip areas are handled automatically by - * container widgets when their child widgets are drawn. - * - * IMPORTANT: Remember to pop each clip area that you pushed on the stack - * after you are done with it. - * - * If you feel that Graphics is to restrictive for your needs, - * there is no one stopping you from using your own code for drawing - * in widgets. You could for instance use pure SDL in the drawing of - * widgets bypassing Graphics. This might however hurt portability of - * your application. - * - * If you implement a Graphics class not present in Guichan we would - * be very happy to add it to Guichan. - * - * @see AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics, - * SDLGraphics, Image - * @since 0.1.0 - */ - class Graphics - { - public: - /** - * Alignments for text drawing. - */ - enum Alignment - { - LEFT = 0, - CENTER, - RIGHT - }; - - /** - * Constructor. - */ - Graphics(); - - A_DELETE_COPY(Graphics) - - /** - * Destructor. - */ - virtual ~Graphics() - { } - - /** - * Initializes drawing. Called by the Gui when Gui::draw() is called. - * It is needed by some implementations of Graphics to perform - * preparations before drawing. An example of such an implementation - * is the OpenGLGraphics. - * - * NOTE: You will never need to call this function yourself, unless - * you use a Graphics object outside of Guichan. - * - * @see _endDraw, Gui::draw - */ - virtual void _beginDraw() - { } - - /** - * Deinitializes drawing. Called by the Gui when a Gui::draw() is done. - * done. It should reset any state changes made by _beginDraw(). - * - * NOTE: You will never need to call this function yourself, unless - * you use a Graphics object outside of Guichan. - * - * @see _beginDraw, Gui::draw - */ - virtual void _endDraw() - { } - - /** - * Pushes a clip area onto the stack. The x and y coordinates in the - * rectangle is relative to the last pushed clip area. - * If the new area falls outside the current clip area, it will be - * clipped as necessary. - * - * If a clip area is outside of the top clip area a clip area with - * zero width and height will be pushed. - * - * @param area The clip area to be pushed onto the stack. - * @return False if the the new area lays outside the current clip - * area. - */ - virtual bool pushClipArea(Rectangle area); - - /** - * Removes the top most clip area from the stack. - * - * @throws Exception if the stack is empty. - */ - virtual void popClipArea(); - - /** - * Gets the current clip area. Usefull if you want to do drawing - * bypassing Graphics. - * - * @return The current clip area. - */ - virtual const ClipRectangle& getCurrentClipArea(); - - /** - * Draws a part of an image. - * - * NOTE: Width and height arguments will not scale the image but - * specifies the size of the part to be drawn. If you want - * to draw the whole image there is a simplified version of - * this function. - * - * EXAMPLE: @code drawImage(myImage, 10, 10, 20, 20, 40, 40); @endcode - * Will draw a rectangular piece of myImage starting at - * coordinate (10, 10) in myImage, with width and height 40. - * The piece will be drawn with it's top left corner at - * coordinate (20, 20). - * - * @param image The image to draw. - * @param srcX The source image x coordinate. - * @param srcY The source image y coordinate. - * @param dstX The destination x coordinate. - * @param dstY The destination y coordinate. - * @param width The width of the piece. - * @param height The height of the piece. - */ - virtual void drawImage(const Image* image, - int srcX, - int srcY, - int dstX, - int dstY, - int width, - int height) = 0; - /** - * Draws an image. A simplified version of the other drawImage. - * It will draw a whole image at the coordinate you specify. - * It is equivalent to calling: - * @code drawImage(myImage, 0, 0, dstX, dstY, image->getWidth(), \ - image->getHeight()); @endcode - */ - virtual void drawImage(const Image* image, int dstX, int dstY); - - /** - * Draws a single point/pixel. - * - * @param x The x coordinate. - * @param y The y coordinate. - */ - virtual void drawPoint(int x, int y) = 0; - - /** - * Ddraws a line. - * - * @param x1 The first x coordinate. - * @param y1 The first y coordinate. - * @param x2 The second x coordinate. - * @param y2 The second y coordinate. - */ - virtual void drawLine(int x1, int y1, int x2, int y2) = 0; - - /** - * Draws a simple, non-filled, rectangle with a one pixel width. - * - * @param rectangle The rectangle to draw. - */ - virtual void drawRectangle(const Rectangle& rectangle) = 0; - - /** - * Draws a filled rectangle. - * - * @param rectangle The filled rectangle to draw. - */ - virtual void fillRectangle(const Rectangle& rectangle) = 0; - - /** - * Sets the color to use when drawing. - * - * @param color A color. - * @see getColor - */ - virtual void setColor(const Color& color) = 0; - - /** - * Gets the color to use when drawing. - * - * @return The color used when drawing. - * @see setColor - */ - virtual const Color& getColor() const = 0; - - protected: - /** - * Holds the clip area stack. - */ - std::stack mClipStack; - - /** - * Holds the current font. - */ - Font* mFont; - }; -} // namespace gcn - -#endif // end GCN_GRAPHICS_HPP diff --git a/src/guichan/include/guichan/gui.hpp b/src/guichan/include/guichan/gui.hpp deleted file mode 100644 index 5aca51f4e..000000000 --- a/src/guichan/include/guichan/gui.hpp +++ /dev/null @@ -1,514 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_GUI_HPP -#define GCN_GUI_HPP - -#include -#include - -#include "guichan/keyevent.hpp" -#include "guichan/mouseevent.hpp" -#include "guichan/mouseinput.hpp" - -namespace gcn -{ - class FocusHandler; - class Graphics; - class Input; - class KeyListener; - class Widget; - - // The following comment will appear in the doxygen main page. - /** - * @mainpage - * @section Introduction - * This documentation is mostly intended as a reference to the API. - * If you want to get started with Guichan, we suggest you check out - * the programs in the examples directory of the Guichan release. - * @n - * @n - * This documentation is, and will always be, work in progress. - * If you find any errors, typos or inconsistencies, or if you feel - * something needs to be explained in more detail - don't hesitate to - * tell us. - */ - - /** - * Contains a Guichan GUI. This is the core class of Guichan to which - * implementations of back ends are passed, to make Guichan work with - * a specific library, and to where the top widget (root widget of GUI) - * is added. If you want to be able to have more then one widget in your - * GUI, the top widget should be a container. - * - * A Gui object cannot work properly without passing back end - * implementations to it. A Gui object must have an implementation of a - * Graphics and an implementation of Input. - * - * NOTE: A complete GUI also must have the ability to load images. - * Images are loaded with the Image class, so to make Guichan - * able to load images an implementation of ImageLoader must be - * passed to Image. - * - * @see Graphics, Input, Image - */ - class Gui - { - public: - /** - * Constructor. - */ - Gui(); - - A_DELETE_COPY(Gui) - - /** - * Destructor. - */ - virtual ~Gui(); - - /** - * Sets the top widget. The top widget is the root widget - * of the GUI. If you want a GUI to be able to contain more - * than one widget the top widget should be a container. - * - * @param top The top widget. - * @see Container - * @since 0.1.0 - */ - virtual void setTop(Widget* top); - - /** - * Gets the top widget. The top widget is the root widget - * of the GUI. - * - * @return The top widget. NULL if no top widget has been set. - * @since 0.1.0 - */ - virtual Widget* getTop() const A_WARN_UNUSED; - - /** - * Sets the graphics object to use for drawing. - * - * @param graphics The graphics object to use for drawing. - * @see getGraphics, AllegroGraphics, HGEGraphics, - * OpenLayerGraphics, OpenGLGraphics, SDLGraphics - * @since 0.1.0 - */ - virtual void setGraphics(Graphics* graphics); - - /** - * Gets the graphics object used for drawing. - * - * @return The graphics object used for drawing. NULL if no - * graphics object has been set. - * @see setGraphics, AllegroGraphics, HGEGraphics, - * OpenLayerGraphics, OpenGLGraphics, SDLGraphics - * @since 0.1.0 - */ - virtual Graphics* getGraphics() const A_WARN_UNUSED; - - /** - * Sets the input object to use for input handling. - * - * @param input The input object to use for input handling. - * @see getInput, AllegroInput, HGEInput, OpenLayerInput, - * SDLInput - * @since 0.1.0 - */ - virtual void setInput(Input* input); - - /** - * Gets the input object being used for input handling. - * - * @return The input object used for handling input. NULL if no - * input object has been set. - * @see setInput, AllegroInput, HGEInput, OpenLayerInput, - * SDLInput - * @since 0.1.0 - */ - virtual Input* getInput() const A_WARN_UNUSED; - - /** - * Performs logic of the GUI. By calling this function all logic - * functions down in the GUI heirarchy will be called. When logic - * is called for Gui, user input will be handled. - * - * @see Widget::logic - * @since 0.1.0 - */ - virtual void logic(); - - /** - * Draws the GUI. By calling this funcion all draw functions - * down in the GUI hierarchy will be called. When draw is called - * the used Graphics object will be initialised and drawing of - * the top widget will commence. - * - * @see Widget::draw - * @since 0.1.0 - */ - virtual void draw(); - - /** - * Focuses none of the widgets in the Gui. - * - * @since 0.1.0 - */ - virtual void focusNone(); - - /** - * Sets tabbing enabled, or not. Tabbing is the usage of - * changing focus by utilising the tab key. - * - * @param tabbing True if tabbing should be enabled, false - * otherwise. - * @see isTabbingEnabled - * @since 0.1.0 - */ - virtual void setTabbingEnabled(bool tabbing); - - /** - * Checks if tabbing is enabled. - * - * @return True if tabbing is enabled, false otherwise. - * @see setTabbingEnabled - * @since 0.1.0 - */ - virtual bool isTabbingEnabled(); - - /** - * Adds a global key listener to the Gui. A global key listener - * will receive all key events generated from the GUI and global - * key listeners will receive the events before key listeners - * of widgets. - * - * @param keyListener The key listener to add. - * @see removeGlobalKeyListener - * @since 0.5.0 - */ - virtual void addGlobalKeyListener(KeyListener* keyListener); - - /** - * Removes global key listener from the Gui. - * - * @param keyListener The key listener to remove. - * @throws Exception if the key listener hasn't been added. - * @see addGlobalKeyListener - * @since 0.5.0 - */ - virtual void removeGlobalKeyListener(KeyListener* keyListener); - - protected: - /** - * Handles all mouse input. - * - * @since 0.6.0 - */ - virtual void handleMouseInput(); - - /** - * Handles key input. - * - * @since 0.6.0 - */ - virtual void handleKeyInput(); - - /** - * Handles mouse moved input. - * - * @param mouseInput The mouse input to handle. - * @since 0.6.0 - */ - virtual void handleMouseMoved(const MouseInput& mouseInput); - - /** - * - * Handles mouse wheel moved down input. - * - * @param mouseInput The mouse input to handle. - * @since 0.6.0 - */ - virtual void handleMouseWheelMovedDown(const MouseInput& mouseInput); - - /** - * Handles mouse wheel moved up input. - * - * @param mouseInput The mouse input to handle. - * @since 0.6.0 - */ - virtual void handleMouseWheelMovedUp(const MouseInput& mouseInput); - - /** - * Handles modal focus. Modal focus needs to be checked at - * each logic iteration as it might be necessary to distribute - * mouse entered or mouse exited events. - * - * @since 0.8.0 - */ - virtual void handleModalFocus(); - - /** - * Handles modal mouse input focus. Modal mouse input focus needs - * to be checked at each logic iteration as it might be necessary to - * distribute mouse entered or mouse exited events. - * - * @since 0.8.0 - */ - virtual void handleModalMouseInputFocus(); - - /** - * Handles modal focus gained. If modal focus has been gained it might - * be necessary to distribute mouse entered or mouse exited events. - * - * @since 0.8.0 - */ - virtual void handleModalFocusGained(); - - /** - * Handles modal mouse input focus gained. If modal focus has been - * gained it might be necessary to distribute mouse entered or mouse - * exited events. - * - * @since 0.8.0 - */ - virtual void handleModalFocusReleased(); - - /** - * Distributes a mouse event. - * - * @param type The type of the event to distribute, - * @param button The button of the event (if any used) to distribute. - * @param x The x coordinate of the event. - * @param y The y coordinate of the event. - * @param fource indicates whether the distribution should be forced or not. - * A forced distribution distributes the event even if a widget - * is not enabled, not visible, another widget has modal - * focus or another widget has modal mouse input focus. - * Default value is false. - * @param toSourceOnly indicates whether the distribution should be to the - * source widget only or to it's parent's mouse listeners - * as well. - * - * @since 0.6.0 - */ - virtual void distributeMouseEvent(Widget* source, - int type, - int button, - int x, - int y, - bool force = false, - bool toSourceOnly = false); - - /** - * Distributes a key event. - * - * @param keyEvent The key event to distribute. - - * @since 0.6.0 - */ - virtual void distributeKeyEvent(KeyEvent& keyEvent); - - /** - * Distributes a key event to the global key listeners. - * - * @param keyEvent The key event to distribute. - * - * @since 0.6.0 - */ - virtual void distributeKeyEventToGlobalKeyListeners(KeyEvent& - keyEvent); - - /** - * Gets the widget at a certain position. - * - * @return The widget at a certain position. - * @since 0.6.0 - */ - virtual Widget* getWidgetAt(int x, int y) A_WARN_UNUSED; - - /** - * Gets the source of the mouse event. - * - * @return The source widget of the mouse event. - * @since 0.6.0 - */ - virtual Widget* getMouseEventSource(int x, int y) A_WARN_UNUSED; - - /** - * Gets the source of the key event. - * - * @return The source widget of the key event. - * @since 0.6.0 - */ - virtual Widget* getKeyEventSource() A_WARN_UNUSED; - - /** - * Holds the top widget. - */ - Widget* mTop; - - /** - * Holds the graphics implementation used. - */ - Graphics* mGraphics; - - /** - * Holds the input implementation used. - */ - Input* mInput; - - /** - * Holds the focus handler for the Gui. - */ - FocusHandler* mFocusHandler; - - /** - * True if tabbing is enabled, false otherwise. - */ - bool mTabbing; - - /** - * Typedef. - */ - typedef std::list KeyListenerList; - - /** - * Typedef. - */ - typedef KeyListenerList::iterator KeyListenerListIterator; - - /** - * Holds the global key listeners of the Gui. - */ - KeyListenerList mKeyListeners; - - /** - * True if shift is pressed, false otherwise. - */ - bool mShiftPressed; - - /** - * True if meta is pressed, false otherwise. - */ - bool mMetaPressed; - - /** - * True if control is pressed, false otherwise. - */ - bool mControlPressed; - - /** - * True if alt is pressed, false otherwise. - */ - bool mAltPressed; - - /** - * Holds the last mouse button pressed. - */ - unsigned int mLastMousePressButton; - - /** - * Holds the last mouse press time stamp. - */ - int mLastMousePressTimeStamp; - - /** - * Holds the last mouse x coordinate. - */ - int mLastMouseX; - - /** - * Holds the last mouse y coordinate. - */ - int mLastMouseY; - - /** - * Holds the current click count. Used to keep track - * of clicks for a the last pressed button. - */ - int mClickCount; - - /** - * Holds the last button used when a drag of a widget - * was initiated. Used to be able to release a drag - * when the same button is released. - */ - int mLastMouseDragButton; - - /** - * Holds a stack with all the widgets with the mouse. - * Used to properly distribute mouse events. - */ - std::deque mWidgetWithMouseQueue; - }; -} // namespace gcn - -#endif // end GCN_GUI_HPP - -/* yakslem - "Women, it's a constant struggle." - * finalman - "Yes, but sometimes they succeed with their guesses." - * yaklsem - "...eh...I was talking about love." - * finalman - "Oh...ok..." - * An awkward silence followed. - */ diff --git a/src/guichan/include/guichan/image.hpp b/src/guichan/include/guichan/image.hpp deleted file mode 100644 index c39fe21ab..000000000 --- a/src/guichan/include/guichan/image.hpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_IMAGE_HPP -#define GCN_IMAGE_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - class Color; - - /** - * Holds an image. To be able to use this class you must first set an - * ImageLoader in Image by calling - * @code Image::setImageLoader(myImageLoader) @endcode - * The function is static. If this is not done, the constructor taking a - * filename will throw an exception. The ImageLoader you use must be - * compatible with the Graphics object you use. - * - * EXAMPLE: If you use SDLGraphics you should use SDLImageLoader. - * Otherwise your program might crash in a most bizarre way. - * @see AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, - * OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader - * @since 0.1.0 - */ - class Image - { - public: - /** - * Constructor. - */ - Image(); - - /** - * Destructor. - */ - virtual ~Image(); - - /** - * Frees an image. - * - * @since 0.5.0 - */ - virtual void free() = 0; - - /** - * Gets the width of the image. - * - * @return The width of the image. - * - * @since 0.1.0 - */ - virtual int getWidth() const A_WARN_UNUSED = 0; - - /** - * Gets the height of the image. - * - * @return The height of the image. - * - * @since 0.1.0 - */ - virtual int getHeight() const A_WARN_UNUSED = 0; - - /** - * Gets the color of a pixel at coordinate (x, y) in the image. - * - * IMPORTANT: Only guaranteed to work before the image has been - * converted to display format. - * - * @param x The x coordinate. - * @param y The y coordinate. - * @return The color of the pixel. - * - * @since 0.5.0 - */ - virtual Color getPixel(int x, int y) A_WARN_UNUSED = 0; - - /** - * Puts a pixel with a certain color at coordinate (x, y). - * - * @param x The x coordinate. - * @param y The y coordinate. - * @param color The color of the pixel to put. - * @since 0.5.0 - */ - virtual void putPixel(int x, int y, const Color& color) = 0; - - /** - * Converts the image, if possible, to display format. - * - * IMPORTANT: Only guaranteed to work before the image has been - * converted to display format. - * @since 0.5.0 - */ - virtual void convertToDisplayFormat() = 0; - }; -} // namespace gcn - -#endif // end GCN_IMAGE_HPP diff --git a/src/guichan/include/guichan/input.hpp b/src/guichan/include/guichan/input.hpp deleted file mode 100644 index 71a15ce85..000000000 --- a/src/guichan/include/guichan/input.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_INPUT_HPP -#define GCN_INPUT_HPP - -#include "localconsts.h" - -namespace gcn -{ - class KeyInput; - class MouseInput; - - /** - * Abstract class for providing functions for user input. - * - * Guichan contains implementations of Input for common - * libraries like the Allegro library, the HGE library, - * and the SDL library. - * To make Guichan usable with other libraries, an Input - * class must be implemented. - * - * @see AllegroInput, HGEInput, OpenLayerInput, - * SDLInput - */ - class Input - { - public: - /** - * Destructor. - */ - virtual ~Input(){ } - - /** - * Checks if the key queue is empty, or not. - * - * @return True if the key queue is empty, - * false otherwise. - */ - virtual bool isKeyQueueEmpty() A_WARN_UNUSED = 0; - - /** - * Dequeues the key input queue. - * - * @return The first key input in the key input queue. - */ - virtual KeyInput dequeueKeyInput() = 0; - - /** - * Checks if the mouse queue is empyt, or not. - * - * @return True if the mouse queue is empty, - * false otherwise. - */ - virtual bool isMouseQueueEmpty() A_WARN_UNUSED = 0; - - /** - * Dequeues the mouse input queue. - * - * @return The first mouse input in the mouse input queue. - */ - virtual MouseInput dequeueMouseInput() = 0; - - /** - * Polls all exsisting input. Called when input should - * be polled. The function exists for compatibility reason - * where some libraries need to poll input at a certain - * logic rate. - */ - virtual void _pollInput() = 0; - }; -} // namespace gcn - -#endif // end GCN_INPUT_HPP diff --git a/src/guichan/include/guichan/inputevent.hpp b/src/guichan/include/guichan/inputevent.hpp deleted file mode 100644 index 30b46676d..000000000 --- a/src/guichan/include/guichan/inputevent.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_INPUTEVENT_HPP -#define GCN_INPUTEVENT_HPP - -#include "guichan/event.hpp" - -namespace gcn -{ - /** - * Base class for all events concerning input. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class InputEvent: public Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. - */ - InputEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed); - - /** - * Checks if shift is pressed. - * - * @return True if shift was pressed at the same time as the key, - * false otherwise. - */ - bool isShiftPressed() const A_WARN_UNUSED; - - /** - * Checks if control is pressed. - * - * @return True if control was pressed at the same time as the key, - * false otherwise. - */ - bool isControlPressed() const A_WARN_UNUSED; - - /** - * Checks if alt is pressed. - * - * @return True if alt was pressed at the same time as the key, - * false otherwise. - */ - bool isAltPressed() const A_WARN_UNUSED; - - /** - * Checks whether meta is pressed. - * - * @return True if meta was pressed at the same time as the key, - * false otherwise. - */ - bool isMetaPressed() const A_WARN_UNUSED; - - /** - * Marks the event as consumed. Input event listeners may discard - * consumed input or act on consumed input. An example of a widget - * that discards consumed input is the ScrollArea widget that - * discards consumed mouse wheel events so the ScrollArea will not - * scroll if for instance a Slider's value inside the ScrollArea was - * changed with the mouse wheel. - * - * @see isConsumed - */ - void consume(); - - /** - * Checks if the input event is consumed. - * - * @return True if the input event is consumed, - * false otherwise. - * @see consume - */ - bool isConsumed() const A_WARN_UNUSED; - - protected: - /** - * True if shift is pressed, false otherwise. - */ - bool mShiftPressed; - - /** - * True if control is pressed, false otherwise. - */ - bool mControlPressed; - - /** - * True if alt is pressed, false otherwise. - */ - bool mAltPressed; - - /** - * True if meta is pressed, false otherwise. - */ - bool mMetaPressed; - - /** - * True if the input event is consumed, - * false otherwise. - */ - bool mIsConsumed; - }; -} // namespace gcn - -#endif // end GCN_INPUTEVENT_HPP diff --git a/src/guichan/include/guichan/key.hpp b/src/guichan/include/guichan/key.hpp deleted file mode 100644 index 46b36a179..000000000 --- a/src/guichan/include/guichan/key.hpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEY_HPP -#define GCN_KEY_HPP - -#include "localconsts.h" - -// windows.h defines DELETE which breaks this file as we have a constant named -// DELETE, hence we undefine DELETE if it is defined and hope people don't use -// that windows define with Guichan. -#if defined (_WIN32) && defined(DELETE) -#undef DELETE -#endif - -namespace gcn -{ - /** - * Represents a key or a character. - */ - class Key final - { - public: - /** - * Constructor. - * - * @param value The ascii or enum value for the key. - */ - explicit Key(const int value = 0); - - /** - * Checks if a key is a character. - * - * @return True if the key is a letter, number or whitespace, - * false otherwise. - */ - bool isCharacter() const A_WARN_UNUSED; - - /** - * Checks if a key is a number. - * - * @return True if the key is a number (0-9), - * false otherwise. - */ - bool isNumber() const A_WARN_UNUSED; - - /** - * Checks if a key is a letter. - * - * @return True if the key is a letter (a-z,A-Z), - * false otherwise. - */ - bool isLetter() const A_WARN_UNUSED; - - /** - * Gets the value of the key. If an ascii value exists it - * will be returned. Otherwise an enum value will be returned. - * - * @return the value of the key. - */ - int getValue() const A_WARN_UNUSED; - - /** - * Compares two keys. - * - * @param key The key to compare this key with. - * @return True if the keys are equal, false otherwise. - */ - bool operator==(const Key& key) const; - - /** - * Compares two keys. - * - * @param key The key to compare this key with. - * @return True if the keys are not equal, false otherwise. - */ - bool operator!=(const Key& key) const; - - /** - * An enum with key values. - */ - enum - { - SPACE = ' ', - TAB = '\t', - ENTER = '\n', - LEFT_ALT = 1000, - RIGHT_ALT, - LEFT_SHIFT, - RIGHT_SHIFT, - LEFT_CONTROL, - RIGHT_CONTROL, - LEFT_META, - RIGHT_META, - LEFT_SUPER, - RIGHT_SUPER, - INSERT, - HOME, - PAGE_UP, - DELETE, - END, - PAGE_DOWN, - ESCAPE, - CAPS_LOCK, - BACKSPACE, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - PRINT_SCREEN, - SCROLL_LOCK, - PAUSE, - NUM_LOCK, - ALT_GR, - LEFT, - RIGHT, - UP, - DOWN - }; - - protected: - /** - * Holds the value of the key. It may be an ascii value - * or an enum value. - */ - int mValue; - }; -} // namespace gcn - -#endif // end GCN_KEY_HPP diff --git a/src/guichan/include/guichan/keyevent.hpp b/src/guichan/include/guichan/keyevent.hpp deleted file mode 100644 index b3a91f640..000000000 --- a/src/guichan/include/guichan/keyevent.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEYEVENT_HPP -#define GCN_KEYEVENT_HPP - -#include "guichan/inputevent.hpp" -#include "guichan/key.hpp" - -namespace gcn -{ - class Widget; - - /** - * Represents a key event. - */ - class KeyEvent: public InputEvent - { - public: - /** - * Key event types. - */ - enum - { - PRESSED = 0, - RELEASED - }; - - /** - * Constructor. - * - * @param source The source widget of the event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. - * @param type The type of the event. A value from KeyEventType. - * @param numericPad True if the event occured on the numeric pad, - * false otherwise. - * @param key The key of the event. - */ - KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const Key& key); - - /** - * Destructor. - */ - virtual ~KeyEvent(); - - /** - * Gets the type of the event. - * - * @return The type of the event. - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Checks if the key event occured on the numeric pad. - * - * @return True if key event occured on the numeric pad, - * false otherwise. - * - */ - bool isNumericPad() const A_WARN_UNUSED; - - /** - * Gets the key of the event. - * - * @return The key of the event. - */ - const Key& getKey() const A_WARN_UNUSED; - - protected: - /** - * Holds the type of the key event. - */ - unsigned int mType; - - /** - * True if the numeric pad was used, false otherwise. - */ - bool mIsNumericPad; - - /** - * Holds the key of the key event. - */ - Key mKey; - }; -} // namespace gcn - -#endif // end GCN_KEYEVENT_HPP diff --git a/src/guichan/include/guichan/keyinput.hpp b/src/guichan/include/guichan/keyinput.hpp deleted file mode 100644 index 421165d1c..000000000 --- a/src/guichan/include/guichan/keyinput.hpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEYINPUT_HPP -#define GCN_KEYINPUT_HPP - -#include "guichan/key.hpp" - -namespace gcn -{ - /** - * Internal class that represents key input. Generally you won't have to - * bother using this class unless you implement an Input class for - * a back end. - * - * @since 0.1.0 - */ - class KeyInput - { - public: - /** - * Constructor. - */ - KeyInput() : - mKey(0), - mType(0), - mShiftPressed(false), - mControlPressed(false), - mAltPressed(false), - mMetaPressed(false), - mNumericPad(false) - { } - - /** - * Constructor. - * - * @param key The key of the key input. - * @param type The type of key input. - */ - KeyInput(const Key& key, unsigned int type); - - /** - * Sets the type of the key input. - * - * @param type The type of key input. - * @see getType - */ - void setType(unsigned int type); - - /** - * Gets the type of the key input. - * - * @return the input type. - * @see setType - */ - int getType() const A_WARN_UNUSED; - - /** - * Sets the key of the key input. - * - * @param key The key of the key input. - * @see getKey - */ - void setKey(const Key& key); - - /** - * Gets the key of the key input. - * - * @return The key of the key input. - * @see setKey - */ - const Key& getKey() const A_WARN_UNUSED; - - /** - * Checks if shift is pressed. - * - * @return True if shift was pressed at the same - * time as the key, false otherwise. - * @see setShiftPressed - * @since 0.6.0 - */ - bool isShiftPressed() const A_WARN_UNUSED; - - /** - * Sets shift to be pressed at the same time as the key, - * or not. - * - * @param pressed True if shift is pressed, false otherwise. - * @see isShiftPressed - * @since 0.6.0 - */ - void setShiftPressed(bool pressed); - - /** - * Checks if control is pressed. - * - * @return True if control was pressed at the same - * time as the key, false otherwise. - * @see setControlPressed - * @since 0.6.0 - */ - bool isControlPressed() const A_WARN_UNUSED; - - /** - * Sets control to be pressed at the same time as the key, - * or not. - * - * @param pressed True if control is pressed, false otherwise. - * @see isControlPressed - * @since 0.6.0 - */ - void setControlPressed(bool pressed); - - /** - * Checks if alt is pressed. - * - * @return True if alt was pressed at the same - * time as the key, false otherwise. - * @see setAltPressed - * @since 0.6.0 - */ - bool isAltPressed() const; - - /** - * Sets the alt to be pressed at the same time as the key, - * or not. - * - * @param pressed True if alt is pressed at the same - * time as the key, , false otherwise. - * @see isAltPressed - * @since 0.6.0 - */ - void setAltPressed(bool pressed); - - /** - * Checks if meta is pressed. - * - * @return True if meta was pressed at the same - * time as the key, false otherwise. - * @see setMetaPressed - * @since 0.6.0 - */ - bool isMetaPressed() const A_WARN_UNUSED; - - /** - * Sets meta to be pressed at the same time as the key, - * or not. - * - * @param pressed True if meta is pressed at the same - * time as the key, false otherwise. - * @see isMetaPressed - * @since 0.6.0 - */ - void setMetaPressed(bool pressed); - - /** - * Checks if the key was pressed at the numeric pad. - * - * @return True if key pressed at the numeric pad, - * false otherwise. - * @setNumericPad - * @since 0.6.0 - */ - bool isNumericPad() const A_WARN_UNUSED; - - /** - * Sets the key to be pressed at the numeric pad. - * - * @param numpad True if the key was pressed at the numeric - * pad, false otherwise. - * @see isNumericPad - * @since 0.6.0 - */ - void setNumericPad(bool numpad); - - /** - * Key input types. This enum corresponds to the enum with event - * types on KeyEvent for easy mapping. - */ - enum - { - PRESSED = 0, - RELEASED - }; - - protected: - /** - * Holds the key of the key input. - */ - Key mKey; - - /** - * Holds the type of the key input. - */ - unsigned int mType; - - /** - * True if shift was pressed at the same time as the key, - * false otherwise. - */ - bool mShiftPressed; - - /** - * True if control was pressed at the same time as the key, - * false otherwise. - */ - bool mControlPressed; - - /** - * True if alt was pressed at the same time as the key, - * false otherwise. - */ - bool mAltPressed; - - /** - * True if meta was pressed at the same time as the key, - * false otherwise. - */ - bool mMetaPressed; - - /** - * True if the numeric pad was used when the key was pressed, - * false otherwise. - */ - bool mNumericPad; - }; -} // namespace gcn - -#endif // end GCN_KEYINPUT_HPP diff --git a/src/guichan/include/guichan/keylistener.hpp b/src/guichan/include/guichan/keylistener.hpp deleted file mode 100644 index bb676052d..000000000 --- a/src/guichan/include/guichan/keylistener.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEYLISTENER_HPP -#define GCN_KEYLISTENER_HPP - -#include "guichan/keyevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - class Key; - - /** - * Interface for listening for key events from widgets. - * - * @see Widget::addKeyListener, Widget::removeKeyListener - */ - class KeyListener - { - public: - /** - * Destructor. - */ - virtual ~KeyListener() - { } - - /** - * Called if a key is pressed when the widget has keyboard focus. - * If a key is held down the widget will generate multiple key - * presses. - * - * @param keyEvent Discribes the event. - */ - virtual void keyPressed(KeyEvent& keyEvent A_UNUSED) - { } - - /** - * Called if a key is released when the widget has keyboard focus. - * - * @param keyEvent Discribes the event. - */ - virtual void keyReleased(KeyEvent& keyEvent A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of KeyListener, - * therefore its constructor is protected. - */ - KeyListener() - { } - }; -} // namespace gcn - -#endif // end GCN_KEYLISTENER_HPP diff --git a/src/guichan/include/guichan/listmodel.hpp b/src/guichan/include/guichan/listmodel.hpp deleted file mode 100644 index 4b98f46fe..000000000 --- a/src/guichan/include/guichan/listmodel.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_LISTMODEL_HPP -#define GCN_LISTMODEL_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * An interface for a model that represents a list. It is - * used in certain widgets, like the ListBox, to handle a - * lists with string elements. If you want to use widgets - * like ListBox, make a derived class from this class that - * represents your list. - */ - class ListModel - { - public: - /** - * Destructor. - */ - virtual ~ListModel() - { } - - /** - * Gets the number of elements in the list. - * - * @return The number of elements in the list - */ - virtual int getNumberOfElements() A_WARN_UNUSED = 0; - - /** - * Gets an element at a certain index in the list. - * - * @param i An index in the list. - * @return An element as a string at the a certain index. - */ - virtual std::string getElementAt(int i) A_WARN_UNUSED = 0; - }; -} // namespace gcn - -#endif // end GCN_LISTMODEL_HPP diff --git a/src/guichan/include/guichan/mouseevent.hpp b/src/guichan/include/guichan/mouseevent.hpp deleted file mode 100644 index 57af098ab..000000000 --- a/src/guichan/include/guichan/mouseevent.hpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_MOUSEEVENT_HPP -#define GCN_MOUSEEVENT_HPP - -#include "guichan/inputevent.hpp" - -namespace gcn -{ - class Gui; - class Widget; - - /** - * Represents a mouse event. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class MouseEvent: public InputEvent - { - public: - /** - * Constructor. - * - * @param source The source widget of the mouse event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. - * @param type The type of the mouse event. - * @param button The button of the mouse event. - * @param x The x coordinate of the event relative to the source widget. - * @param y The y coordinate of the event relative the source widget. - * @param clickCount The number of clicks generated with the same button. - * It's set to zero if another button is used. - */ - MouseEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const unsigned int button, - const int x, - const int y, - const int clickCount); - - /** - * Gets the button of the mouse event. - * - * @return The button of the mouse event. - */ - unsigned int getButton() const A_WARN_UNUSED; - - /** - * Gets the x coordinate of the mouse event. - * The coordinate relative to widget the mouse listener - * receiving the events have registered to. - * - * @return The x coordinate of the mouse event. - * @see Widget::addMouseListener, Widget::removeMouseListener - */ - int getX() const A_WARN_UNUSED; - - /** - * Gets the y coordinate of the mouse event. - * The coordinate relative to widget the mouse listener - * receiving the events have registered to. - * - * @return The y coordinate of the mouse event. - * @see Widget::addMouseListener, Widget::removeMouseListener - */ - int getY() const A_WARN_UNUSED; - - /** - * Gets the number of clicks generated with the same button. - * It's set to zero if another button is used. - * - * @return The number of clicks generated with the same button. - */ - int getClickCount() const A_WARN_UNUSED; - - /** - * Gets the type of the event. - * - * @return The type of the event. - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Mouse event types. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP, - CLICKED, - ENTERED, - EXITED, - DRAGGED - }; - - /** - * Mouse button types. - */ - enum - { - EMPTY = 0, - LEFT, - RIGHT, - MIDDLE - }; - - protected: - /** - * Holds the type of the mouse event. - */ - unsigned int mType; - - /** - * Holds the button of the mouse event. - */ - unsigned int mButton; - - /** - * Holds the x-coordinate of the mouse event. - */ - int mX; - - /** - * Holds the y-coordinate of the mouse event. - */ - int mY; - - /** - * The number of clicks generated with the same button. - * It's set to zero if another button is used. - */ - int mClickCount; - - /** - * Gui is a friend of this class in order to be able to manipulate - * the protected member variables of this class and at the same time - * keep the MouseEvent class as const as possible. Gui needs to - * update the x och y coordinates for the coordinates to be relative - * to widget the mouse listener receiving the events have registered - * to. - */ - friend class Gui; - }; -} // namespace gcn - -#endif // GCN_MOUSEEVENT_HPP diff --git a/src/guichan/include/guichan/mouseinput.hpp b/src/guichan/include/guichan/mouseinput.hpp deleted file mode 100644 index 018205740..000000000 --- a/src/guichan/include/guichan/mouseinput.hpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_MOUSEINPUT_HPP -#define GCN_MOUSEINPUT_HPP - -#include "localconsts.h" - -namespace gcn -{ - - /** - * Internal class that represents mouse input. Generally you won't have to - * bother using this class unless you implement an Input class for - * a back end. - * - * @author Olof Naessén - * @author Per Larsson - * @since 0.1.0 - */ - class MouseInput - { - public: - /** - * Constructor. - */ - MouseInput() : - mType(0), - mButton(0), - mTimeStamp(0), - mX(0), - mY(0) - { } - - /** - * Constructor. - * - * @param button The button pressed. - * @param type The type of mouse input. - * @param x The mouse x coordinate. - * @param y The mouse y coordinate. - * @param timeStamp The timestamp of the mouse input. Used to - * check for double clicks. - */ - MouseInput(const unsigned int button, - const unsigned int type, - const int x, - const int y, - const int timeStamp); - - /** - * Sets the type of the mouse input. - * - * @param type The type of the mouse input. Should be a value from the - * mouse event type enum - * @see getType - * @since 0.1.0 - */ - void setType(unsigned int type); - - /** - * Gets the type of the mouse input. - * - * @return The type of the mouse input. A value from the mouse event - * type enum. - * @see setType - * @since 0.1.0 - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Sets the button pressed. - * - * @param button The button pressed. Should be one of the values - * in the mouse event button enum. - * @see getButton. - * @since 0.1.0 - */ - void setButton(unsigned int button); - - /** - * Gets the button pressed. - * - * @return The button pressed. A value from the mouse event - * button enum. - * @see setButton - * @since 0.1.0 - */ - unsigned int getButton() const A_WARN_UNUSED; - - /** - * Sets the timestamp for the mouse input. - * Used to check for double clicks. - * - * @param timeStamp The timestamp of the mouse input. - * @see getTimeStamp - * @since 0.1.0 - */ - void setTimeStamp(int timeStamp); - - /** - * Gets the time stamp of the input. - * Used to check for double clicks. - * - * @return The time stamp of the mouse input. - * @see setTimeStamp - * @since 0.1.0 - */ - int getTimeStamp() const A_WARN_UNUSED; - - /** - * Sets the x coordinate of the mouse input. - * - * @param x The x coordinate of the mouse input. - * @see getX - * @since 0.6.0 - */ - void setX(int x); - - /** - * Gets the x coordinate of the mouse input. - * - * @return The x coordinate of the mouse input. - * @see setX - * @since 0.6.0 - */ - int getX() const A_WARN_UNUSED; - - /** - * Sets the y coordinate of the mouse input. - * - * @param y The y coordinate of the mouse input. - * @see getY - * @since 0.6.0 - */ - void setY(int y); - - /** - * Gets the y coordinate of the mouse input. - * - * @return The y coordinate of the mouse input. - * @see setY - * @since 0.6.0 - */ - int getY() const A_WARN_UNUSED; - - /** - * Mouse input event types. This enum partially corresponds - * to the enum with event types in MouseEvent for easy mapping. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP - }; - - /** - * Mouse button types. - */ - enum - { - EMPTY = 0, - LEFT, - RIGHT, - MIDDLE - }; - - protected: - /** - * Holds the type of the mouse input. - */ - unsigned int mType; - - /** - * Holds the button of the mouse input. - */ - unsigned int mButton; - - /** - * Holds the timestamp of the mouse input. Used to - * check for double clicks. - */ - int mTimeStamp; - - /** - * Holds the x coordinate of the mouse input. - */ - int mX; - - /** - * Holds the y coordinate of the mouse input. - */ - int mY; - }; -} // namespace gcn - -#endif // end GCN_MOUSEINPUT_HPP diff --git a/src/guichan/include/guichan/mouselistener.hpp b/src/guichan/include/guichan/mouselistener.hpp deleted file mode 100644 index a024d202f..000000000 --- a/src/guichan/include/guichan/mouselistener.hpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_MOUSELISTENER_HPP -#define GCN_MOUSELISTENER_HPP - -#include "guichan/mouseevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for mouse events from widgets. - * - * @see Widget::addMouseListener, Widget::removeMouseListener - * @since 0.1.0 - */ - class MouseListener - { - public: - /** - * Destructor. - */ - virtual ~MouseListener() - { } - - /** - * Called when the mouse has entered into the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseEntered(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has exited the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseExited(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button has been pressed on the widget area. - * - * NOTE: A mouse press is NOT equal to a mouse click. - * Use mouseClickMessage to check for mouse clicks. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mousePressed(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button has been released on the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseReleased(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button is pressed and released (clicked) on - * the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseClicked(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse wheel has moved up on the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse wheel has moved down on the widget area. - * - * @param mousEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has moved in the widget area and no mouse button - * has been pressed (i.e no widget is being dragged). - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseMoved(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has moved and the mouse has previously been - * pressed on the widget. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseDragged(MouseEvent& mouseEvent A_UNUSED) - { - } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of MouseListener, - * therefore its constructor is protected. - */ - MouseListener() - { } - }; -} // namespace gcn - -#endif // end GCN_MOUSELISTENER_HPP diff --git a/src/guichan/include/guichan/rectangle.hpp b/src/guichan/include/guichan/rectangle.hpp deleted file mode 100644 index b8503db98..000000000 --- a/src/guichan/include/guichan/rectangle.hpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_RECTANGLE_HPP -#define GCN_RECTANGLE_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * Represents a rectangle. - * - * @since 0.1.0 - */ - class Rectangle - { - public: - /** - * Constructor. The default rectangle is an empty rectangle - * at the coordinates (0,0). - */ - Rectangle(); - - /** - * Constructor. - * - * @param x The x coordinate of the rectangle. - * @param y The y coordinate of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @since 0.1.0 - */ - Rectangle(const int x, const int y, const int width, const int height); - - /** - * Sets the dimension of a rectangle. - * - * @param x The x coordinate of the rectangle. - * @param y The y coordinate of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @since 0.1.0 - */ - void setAll(int x, int y, int width, int height); - - /** - * Checks if another rectangle intersects with the rectangle. - * - * @param rectangle Another rectangle to check for intersection. - * @return True if the rectangles intersect, false otherwise. - * @since 0.1.0 - */ - bool isIntersecting(const Rectangle& rectangle) const A_WARN_UNUSED; - - /** - * Checks if a point is inside the rectangle - * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @return True if the point is inside the rectangle. - * @since 0.1.0 - */ - bool isPointInRect(int x, int y) const A_WARN_UNUSED; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param rectangle The rectangle to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Rectangle& rectangle); - - /** - * Holds the x coordinate of the rectangle. - */ - int x; - - /** - * Holds the x coordinate of the rectangle. - */ - int y; - - /** - * Holds the width of the rectangle. - */ - int width; - - /** - * Holds the height of the rectangle. - */ - int height; - }; -} // namespace gcn - -#endif // end GCN_RECTANGEL_HPP diff --git a/src/guichan/include/guichan/sdl/sdlpixel.hpp b/src/guichan/include/guichan/sdl/sdlpixel.hpp deleted file mode 100644 index 99818d42e..000000000 --- a/src/guichan/include/guichan/sdl/sdlpixel.hpp +++ /dev/null @@ -1,306 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SDLPIXEL_HPP -#define GCN_SDLPIXEL_HPP - -#include "SDL.h" -#include "guichan/color.hpp" - -namespace gcn -{ - - /** - * Checks a pixels color of an SDL_Surface. - * - * @param surface an SDL_Surface where to check for a pixel color. - * @param x the x coordinate on the surface. - * @param y the y coordinate on the surface. - * @return a color of a pixel. - */ - inline const Color SDLgetPixel(SDL_Surface* surface, int x, int y) - { - if (!surface) - return Color(0, 0, 0, 0); - - int bpp = surface->format->BytesPerPixel; - - SDL_LockSurface(surface); - - Uint8 *p = static_cast(surface->pixels) - + y * surface->pitch + x * bpp; - - unsigned int color = 0; - - switch (bpp) - { - case 1: - color = *p; - break; - - case 2: - color = *reinterpret_cast(p); - break; - - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - color = p[0] << 16 | p[1] << 8 | p[2]; -#else - color = p[0] | p[1] << 8 | p[2] << 16; -#endif - break; - - case 4: - color = *reinterpret_cast(p); - break; - - default: - color = *p; - break; - } - - unsigned char r, g, b, a; - - SDL_GetRGBA(color, surface->format, &r, &g, &b, &a); - SDL_UnlockSurface(surface); - - return Color(r, g, b, a); - } - - /** - * Puts a pixel on an SDL_Surface. - * - * @param x the x coordinate on the surface. - * @param y the y coordinate on the surface. - * @param color the color the pixel should be in. - */ - inline void SDLputPixel(SDL_Surface* surface, int x, int y, - const Color& color) - { - if (!surface) - return; - - int bpp = surface->format->BytesPerPixel; - - SDL_LockSurface(surface); - - Uint8 *p = static_cast(surface->pixels) - + y * surface->pitch + x * bpp; - - Uint32 pixel = SDL_MapRGB(surface->format, - static_cast(color.r), static_cast(color.g), - static_cast(color.b)); - - switch (bpp) - { - case 1: - *p = static_cast(pixel); - break; - - case 2: - *reinterpret_cast(p) = static_cast(pixel); - break; - - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - p[0] = static_cast((pixel >> 16) & 0xff); - p[1] = static_cast((pixel >> 8) & 0xff); - p[2] = static_cast((pixel) & 0xff); -#else - p[0] = static_cast((pixel) & 0xff); - p[1] = static_cast((pixel >> 8) & 0xff); - p[2] = static_cast((pixel >> 16) & 0xff); -#endif - break; - - case 4: - *reinterpret_cast(p) = pixel; - break; - - default: - break; - } - - SDL_UnlockSurface(surface); - } - - /** - * Blends two 32 bit colors together. - * - * @param src the source color. - * @param dst the destination color. - * @param a alpha. - */ - inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, - unsigned char a) - { - unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8; - unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) - * (255 - a)) >> 8; - unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) - * (255 - a)) >> 8; - - return (b & 0xff) | (g & 0xff00) | (r & 0xff0000); - } - - /** - * Blends two 16 bit colors together. - * - * @param src the source color. - * @param dst the destination color. - * @param a alpha. - */ - inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, - unsigned char a, const SDL_PixelFormat *f) - { - unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask) - * (255 - a)) >> 8; - unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask) - * (255 - a)) >> 8; - unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) - * (255 - a)) >> 8; - - return static_cast((b & f->Rmask) - | (g & f->Gmask) | (r & f->Bmask)); - } - - /* - typedef struct{ - SDL_Palette *palette; - Uint8 BitsPerPixel; - Uint8 BytesPerPixel; - Uint32 Rmask, Gmask, Bmask, Amask; - Uint8 Rshift, Gshift, Bshift, Ashift; - Uint8 Rloss, Gloss, Bloss, Aloss; - Uint32 colorkey; - Uint8 alpha; - } SDL_PixelFormat; - */ - - /** - * Puts a pixel on an SDL_Surface with alpha - * - * @param x the x coordinate on the surface. - * @param y the y coordinate on the surface. - * @param color the color the pixel should be in. - */ - inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, - const Color& color) - { - int bpp = surface->format->BytesPerPixel; - - SDL_LockSurface(surface); - - Uint8 *p = static_cast(surface->pixels) - + y * surface->pitch + x * bpp; - - Uint32 pixel = SDL_MapRGB(surface->format, - static_cast(color.r), - static_cast(color.g), - static_cast(color.b)); - - switch (bpp) - { - case 1: - *p = static_cast(pixel); - break; - - case 2: - *reinterpret_cast(p) = SDLAlpha16( - static_cast(pixel), - *reinterpret_cast(p), - static_cast(color.a), surface->format); - break; - - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - p[2] = static_cast((p[2] * (255 - color.a) - + color.b * color.a) >> 8); - p[1] = static_cast((p[1] * (255 - color.a) - + color.g * color.a) >> 8); - p[0] = static_cast((p[0] * (255 - color.a) - + color.r * color.a) >> 8); -#else - p[0] = static_cast((p[0] * (255 - color.a) - + color.b * color.a) >> 8); - p[1] = static_cast((p[1] * (255 - color.a) - + color.g * color.a) >> 8); - p[2] = static_cast((p[2] * (255 - color.a) - + color.r * color.a) >> 8); -#endif - break; - - case 4: - *reinterpret_cast(p) = SDLAlpha32(pixel, - *reinterpret_cast(p), - static_cast(color.a)); - break; - default: - break; - } - - SDL_UnlockSurface(surface); - } -} // namespace gcn - -#endif // end GCN_SDLPIXEL_HPP diff --git a/src/guichan/include/guichan/selectionevent.hpp b/src/guichan/include/guichan/selectionevent.hpp deleted file mode 100644 index a4a3da0b3..000000000 --- a/src/guichan/include/guichan/selectionevent.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SELECTIONEVENT_HPP -#define GCN_SELECTIONEVENT_HPP - -#include "guichan/event.hpp" - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Represents a selection event. - * - * @author Olof Naessén - * @since 0.8.0 - */ - class SelectionEvent final: public Event - { - public: - /** - * Constructor. - * - * @param source source The widget of the selection event. - */ - explicit SelectionEvent(Widget *const source); - - /** - * Destructor. - */ - virtual ~SelectionEvent(); - }; -} // namespace gcn - -#endif // end GCN_SELECTIONEVENT_HPP diff --git a/src/guichan/include/guichan/selectionlistener.hpp b/src/guichan/include/guichan/selectionlistener.hpp deleted file mode 100644 index 0d7f63bd8..000000000 --- a/src/guichan/include/guichan/selectionlistener.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SELECTIONLISTENER_HPP -#define GCN_SELECTIONLISTENER_HPP - -#include - -#include "guichan/selectionevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for selection events from widgets. - * - * @see ListBox::addSelectionListener, - * ListBox::removeSelectionListener, - * DropDown::addSelectionListener, - * DropDown::removeSelectionListener - * @author Olof Naessén - * @since 0.8.0 - */ - class SelectionListener - { - public: - /** - * Destructor. - */ - virtual ~SelectionListener() - { } - - /** - * Called when the value of a selection has been changed in a Widget. - * It is used to be able to recieve a notification that a value has - * been changed. - * - * @param event The event of the value change. - * @since 0.8.0 - */ - virtual void valueChanged(const SelectionEvent& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of SelectionListener, - * therefore its constructor is protected. - */ - SelectionListener() - { } - }; -} // namespace gcn - -#endif // end GCN_SELECTIONLISTENER_HPP diff --git a/src/guichan/include/guichan/widget.hpp b/src/guichan/include/guichan/widget.hpp deleted file mode 100644 index fe02d3b14..000000000 --- a/src/guichan/include/guichan/widget.hpp +++ /dev/null @@ -1,1232 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_WIDGET_HPP -#define GCN_WIDGET_HPP - -#include -#include -#include - -#include "guichan/color.hpp" -#include "guichan/rectangle.hpp" - -#include "localconsts.h" - -namespace gcn -{ - class ActionListener; - class BasicContainer; - class DeathListener; - class FocusHandler; - class FocusListener; - class Font; - class Graphics; - class KeyInput; - class KeyListener; - class MouseInput; - class MouseListener; - class WidgetListener; - - /** - * Abstract class for widgets of Guichan. It contains basic functions - * every widget should have. - * - * NOTE: Functions begining with underscore "_" should not - * be overloaded unless you know what you are doing - * - * @author Olof Naessén - * @author Per Larsson. - * @since 0.1.0 - */ - class Widget - { - public: - /** - * Constructor. Resets member variables. Noteable, a widget is not - * focusable as default, therefore, widgets that are supposed to be - * focusable should overide this default in their own constructor. - */ - Widget(); - - A_DELETE_COPY(Widget) - - /** - * Default destructor. - */ - virtual ~Widget(); - - /** - * Draws the widget. It is called by the parent widget when it is time - * for the widget to draw itself. The graphics object is set up so - * that all drawing is relative to the widget, i.e coordinate (0,0) is - * the top left corner of the widget. It is not possible to draw - * outside of a widget's dimension. - * - * @param graphics aA graphics object to draw with. - * @since 0.1.0 - */ - virtual void draw(Graphics* graphics) = 0; - - /** - * Called when a widget is given a chance to draw a frame around itself. - * The frame is not considered a part of the widget, it only allows a frame - * to be drawn around the widget, thus a frame will never be included when - * calculating if a widget should receive events from user input. Also - * a widget's frame will never be included when calculating a widget's - * position. - * - * The size of the frame is calculated using the widget's frame size. - * If a widget has a frame size of 10 pixels than the area the drawFrame - * function can draw to will be the size of the widget with an additional - * extension of 10 pixels in each direction. - * - * An example when drawFrame is a useful function is if a widget needs - * a glow around itself. - * - * @param graphics A graphics object to draw with. - * @see setFrameSize, getFrameSize - * @since 0.8.0 - */ - virtual void drawFrame(Graphics* graphics); - - /** - * Sets the size of the widget's frame. The frame is not considered a part of - * the widget, it only allows a frame to be drawn around the widget, thus a frame - * will never be included when calculating if a widget should receive events - * from user input. Also a widget's frame will never be included when calculating - * a widget's position. - * - * A frame size of 0 means that the widget has no frame. The default frame size - * is 0. - * - * @param frameSize The size of the widget's frame. - * @see getFrameSize, drawFrame - * @since 0.8.0 - */ - void setFrameSize(unsigned int frameSize); - - /** - * Gets the size of the widget's frame. The frame is not considered a part of - * the widget, it only allows a frame to be drawn around the widget, thus a frame - * will never be included when calculating if a widget should receive events - * from user input. Also a widget's frame will never be included when calculating - * a widget's position. - * - * A frame size of 0 means that the widget has no frame. The default frame size - * is 0. - * - * @return The size of the widget's frame. - * @see setFrameSize, drawFrame - * @since 0.8.0 - */ - unsigned int getFrameSize() const A_WARN_UNUSED; - - /** - * Called for all widgets in the gui each time Gui::logic is called. - * You can do logic stuff here like playing an animation. - * - * @see Gui::logic - * @since 0.1.0 - */ - virtual void logic() - { } - - /** - * Gets the widget's parent container. - * - * @return The widget's parent container. NULL if the widget - * has no parent. - * @since 0.1.0 - */ - virtual Widget* getParent() const A_WARN_UNUSED - { return mParent; } - - /** - * Sets the width of the widget. - * - * @param width The width of the widget. - * @see getWidth, setHeight, getHeight, setSize, - * setDimension, getDimensi - * @since 0.1.0 - */ - void setWidth(int width); - - /** - * Gets the width of the widget. - * - * @return The width of the widget. - * @see setWidth, setHeight, getHeight, setSize, - * setDimension, getDimension - * @since 0.1.0 - */ - int getWidth() const A_WARN_UNUSED - { return mDimension.width; } - - /** - * Sets the height of the widget. - * - * @param height The height of the widget. - * @see getHeight, setWidth, getWidth, setSize, - * setDimension, getDimension - * @since 0.1.0 - */ - void setHeight(int height); - - /** - * Gets the height of the widget. - * - * @return The height of the widget. - * @see setHeight, setWidth, getWidth, setSize, - * setDimension, getDimension - * @since 0.1.0 - */ - int getHeight() const A_WARN_UNUSED - { return mDimension.height; } - - /** - * Sets the size of the widget. - * - * @param width The width of the widget. - * @param height The height of the widget. - * @see setWidth, setHeight, getWidth, getHeight, - * setDimension, getDimension - * @since 0.1.0 - */ - void setSize(int width, int height); - - /** - * Sets the x coordinate of the widget. The coordinate is - * relateive to the widget's parent. - * - * @param x The x coordinate of the widget. - * @see getX, setY, getY, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - void setX(int x); - - /** - * Gets the x coordinate of the widget. The coordinate is - * relative to the widget's parent. - * - * @return The x coordinate of the widget. - * @see setX, setY, getY, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - int getX() const A_WARN_UNUSED - { return mDimension.x; } - - /** - * Sets the y coordinate of the widget. The coordinate is - * relative to the widget's parent. - * - * @param y The y coordinate of the widget. - * @see setY, setX, getX, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - void setY(int y); - - /** - * Gets the y coordinate of the widget. The coordinate is - * relative to the widget's parent. - * - * @return The y coordinate of the widget. - * @see setY, setX, getX, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - int getY() const A_WARN_UNUSED - { return mDimension.y; } - - /** - * Sets position of the widget. The position is relative - * to the widget's parent. - * - * @param x The x coordinate of the widget. - * @param y The y coordinate of the widget. - * @see setX, getX, setY, getY, setDimension, getDimension - * @since 0.1.0 - */ - void setPosition(int x, int y); - - /** - * Sets the dimension of the widget. The dimension is - * relative to the widget's parent. - * - * @param dimension The dimension of the widget. - * @see getDimension, setX, getX, setY, getY, setPosition - * @since 0.1.0 - */ - void setDimension(const Rectangle& dimension); - - /** - * Gets the dimension of the widget. The dimension is - * relative to the widget's parent. - * - * @return The dimension of the widget. - * @see getDimension, setX, getX, setY, getY, setPosition - * @since 0.1.0 - */ - const Rectangle& getDimension() const A_WARN_UNUSED; - - /** - * Sets the widget to be fosusable, or not. - * - * @param focusable True if the widget should be focusable, - * false otherwise. - * @see isFocusable - * @since 0.1.0 - */ - void setFocusable(bool focusable); - - /** - * Checks if a widget is focsable. - * - * @return True if the widget should be focusable, false otherwise. - * @see setFocusable - * @since 0.1.0 - */ - bool isFocusable() const A_WARN_UNUSED; - - /** - * Checks if the widget is focused. - * - * @return True if the widget is focused, false otherwise. - * @since 0.1.0 - */ - virtual bool isFocused() const A_WARN_UNUSED; - - /** - * Sets the widget to enabled, or not. A disabled - * widget will never recieve mouse or key events. - * - * @param enabled True if widget should be enabled, - * false otherwise. - * @see isEnabled - * @since 0.1.0 - */ - void setEnabled(bool enabled); - - /** - * Checks if the widget is enabled. A disabled - * widget will never recieve mouse or key events. - * - * @return True if widget is enabled, false otherwise. - * @see setEnabled - * @since 0.1.0 - */ - bool isEnabled() const A_WARN_UNUSED; - - /** - * Sets the widget to be visible, or not. - * - * @param visible True if widget should be visible, false otherwise. - * @see isVisible - * @since 0.1.0 - */ - void setVisible(bool visible); - - /** - * Checks if the widget is visible. - * - * @return True if widget is be visible, false otherwise. - * @see setVisible - * @since 0.1.0 - */ - bool isVisible() const A_WARN_UNUSED - { return mVisible && (!mParent || mParent->isVisible()); } - - /** - * Sets the base color of the widget. - * - * @param color The baseground color. - * @see getBaseColor - * @since 0.1.0 - */ - void setBaseColor(const Color& color); - - /** - * Gets the base color. - * - * @return The base color. - * @see setBaseColor - * @since 0.1.0 - */ - const Color& getBaseColor() const A_WARN_UNUSED; - - /** - * Sets the foreground color. - * - * @param color The foreground color. - * @see getForegroundColor - * @since 0.1.0 - */ - void setForegroundColor(const Color& color); - - /** - * Gets the foreground color. - * - * @see setForegroundColor - * @since 0.1.0 - */ - const Color& getForegroundColor() const A_WARN_UNUSED; - - /** - * Sets the background color. - * - * @param color The background Color. - * @see setBackgroundColor - * @since 0.1.0 - */ - void setBackgroundColor(const Color& color); - - /** - * Gets the background color. - * - * @see setBackgroundColor - * @since 0.1.0 - */ - const Color& getBackgroundColor() const A_WARN_UNUSED; - - /** - * Sets the selection color. - * - * @param color The selection color. - * @see getSelectionColor - * @since 0.6.0 - */ - void setSelectionColor(const Color& color); - - /** - * Gets the selection color. - * - * @return The selection color. - * @see setSelectionColor - * @since 0.6.0 - */ - const Color& getSelectionColor() const A_WARN_UNUSED; - - /** - * Requests focus for the widget. A widget will only recieve focus - * if it is focusable. - */ - virtual void requestFocus(); - - /** - * Requests a move to the top in the parent widget. - */ - virtual void requestMoveToTop(); - - /** - * Requests a move to the bottom in the parent widget. - */ - virtual void requestMoveToBottom(); - - /** - * Sets the focus handler to be used. - * - * WARNING: This function is used internally and should not - * be called or overloaded unless you know what you - * are doing. - * - * @param focusHandler The focus handler to use. - * @see _getFocusHandler - * @since 0.1.0 - */ - virtual void _setFocusHandler(FocusHandler* focusHandler); - - /** - * Gets the focus handler used. - * - * WARNING: This function is used internally and should not - * be called or overloaded unless you know what you - * are doing. - * - * @return The focus handler used. - * @see _setFocusHandler - * @since 0.1.0 - */ - virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED; - - /** - * Adds an action listener to the widget. When an action event - * is fired by the widget the action listeners of the widget - * will get notified. - * - * @param actionListener The action listener to add. - * @see removeActionListener - * @since 0.1.0 - */ - void addActionListener(ActionListener* actionListener); - - /** - * Removes an added action listener from the widget. - * - * @param actionListener The action listener to remove. - * @see addActionListener - * @since 0.1.0 - */ - void removeActionListener(ActionListener* actionListener); - - /** - * Adds a death listener to the widget. When a death event is - * fired by the widget the death listeners of the widget will - * get notified. - * - * @param deathListener The death listener to add. - * @see removeDeathListener - * @since 0.1.0 - */ - void addDeathListener(DeathListener* deathListener); - - /** - * Removes an added death listener from the widget. - * - * @param deathListener The death listener to remove. - * @see addDeathListener - * @since 0.1.0 - */ - void removeDeathListener(DeathListener* deathListener); - - /** - * Adds a mouse listener to the widget. When a mouse event is - * fired by the widget the mouse listeners of the widget will - * get notified. - * - * @param mouseListener The mouse listener to add. - * @see removeMouseListener - * @since 0.1.0 - */ - void addMouseListener(MouseListener* mouseListener); - - /** - * Removes an added mouse listener from the widget. - * - * @param mouseListener The mouse listener to remove. - * @see addMouseListener - * @since 0.1.0 - */ - void removeMouseListener(MouseListener* mouseListener); - - /** - * Adds a key listener to the widget. When a key event is - * fired by the widget the key listeners of the widget will - * get notified. - * - * @param keyListener The key listener to add. - * @see removeKeyListener - * @since 0.1.0 - */ - void addKeyListener(KeyListener* keyListener); - - /** - * Removes an added key listener from the widget. - * - * @param keyListener The key listener to remove. - * @see addKeyListener - * @since 0.1.0 - */ - void removeKeyListener(KeyListener* keyListener); - - /** - * Adds a focus listener to the widget. When a focus event is - * fired by the widget the key listeners of the widget will - * get notified. - * - * @param focusListener The focus listener to add. - * @see removeFocusListener - * @since 0.7.0 - */ - void addFocusListener(FocusListener* focusListener); - - /** - * Removes an added focus listener from the widget. - * - * @param focusListener The focus listener to remove. - * @see addFocusListener - * @since 0.7.0 - */ - void removeFocusListener(FocusListener* focusListener); - - /** - * Adds a widget listener to the widget. When a widget event is - * fired by the widget the key listeners of the widget will - * get notified. - * - * @param widgetListener The widget listener to add. - * @see removeWidgetListener - * @since 0.8.0 - */ - void addWidgetListener(WidgetListener* widgetListener); - - /** - * Removes an added widget listener from the widget. - * - * @param widgetListener The widget listener to remove. - * @see addWidgetListener - * @since 0.8.0 - */ - void removeWidgetListener(WidgetListener* widgetListener); - - /** - * Sets the action event identifier of the widget. The identifier is - * used to be able to identify which action has occured. - * - * NOTE: An action event identifier should not be used to identify a - * certain widget but rather a certain event in your application. - * Several widgets can have the same action event identifer. - * - * @param actionEventId The action event identifier. - * @see getActionEventId - * @since 0.6.0 - */ - void setActionEventId(const std::string& actionEventId); - - /** - * Gets the action event identifier of the widget. - * - * @return The action event identifier of the widget. - * @see setActionEventId - * @since 0.6.0 - */ - const std::string& getActionEventId() const; - - /** - * Gets the absolute position on the screen for the widget. - * - * @param x The absolute x coordinate will be stored in this parameter. - * @param y The absolute y coordinate will be stored in this parameter. - * @since 0.1.0 - */ - virtual void getAbsolutePosition(int& x, int& y) const; - - /** - * Sets the parent of the widget. A parent must be a BasicContainer. - * - * WARNING: This function is used internally and should not - * be called or overloaded unless you know what you - * are doing. - * - * @param parent The parent of the widget. - * @see getParent - * @since 0.1.0 - */ - virtual void _setParent(Widget* parent); - - /** - * Gets the font set for the widget. If no font has been set, - * the global font will be returned. If no global font has been set, - * the default font will be returend. - * - * @return The font set for the widget. - * @see setFont, setGlobalFont - * @since 0.1.0 - */ - Font *getFont() const A_WARN_UNUSED; - - /** - * Sets the global font to be used by default for all widgets. - * - * @param font The global font. - * @see getGlobalFont - * @since 0.1.0 - */ - static void setGlobalFont(Font* font); - - /** - * Sets the font for the widget. If NULL is passed, the global font - * will be used. - * - * @param font The font to set for the widget. - * @see getFont - * @since 0.1.0 - */ - void setFont(Font* font); - - /** - * Called when the font has changed. If the change is global, - * this function will only be called if the widget doesn't have a - * font already set. - * - * @since 0.1.0 - */ - virtual void fontChanged() - { } - - /** - * Checks if a widget exists or not, that is if it still exists - * an instance of the object. - * - * @param widget The widget to check. - * @return True if an instance of the widget exists, false otherwise. - * @since 0.1.0 - */ - static bool widgetExists(const Widget* widget) A_WARN_UNUSED; - - /** - * Checks if tab in is enabled. Tab in means that you can set focus - * to this widget by pressing the tab button. If tab in is disabled - * then the focus handler will skip this widget and focus the next - * in its focus order. - * - * @return True if tab in is enabled, false otherwise. - * @see setTabInEnabled - * @since 0.1.0 - */ - bool isTabInEnabled() const A_WARN_UNUSED; - - /** - * Sets tab in enabled, or not. Tab in means that you can set focus - * to this widget by pressing the tab button. If tab in is disabled - * then the FocusHandler will skip this widget and focus the next - * in its focus order. - * - * @param enabled True if tab in should be enabled, false otherwise. - * @see isTabInEnabled - * @since 0.1.0 - */ - void setTabInEnabled(bool enabled); - - /** - * Checks if tab out is enabled. Tab out means that you can lose - * focus to this widget by pressing the tab button. If tab out is - * disabled then the FocusHandler ignores tabbing and focus will - * stay with this widget. - * - * @return True if tab out is enabled, false otherwise. - * @see setTabOutEnabled - * @since 0.1.0 - */ - bool isTabOutEnabled() const A_WARN_UNUSED; - - /** - * Sets tab out enabled. Tab out means that you can lose - * focus to this widget by pressing the tab button. If tab out is - * disabled then the FocusHandler ignores tabbing and focus will - * stay with this widget. - * - * @param enabled True if tab out should be enabled, false otherwise. - * @see isTabOutEnabled - * @since 0.1.0 - */ - void setTabOutEnabled(bool enabled); - - /** - * Requests modal focus. When a widget has modal focus, only that - * widget and it's children may recieve input. - * - * @throws Exception if another widget already has modal focus. - * @see releaseModalFocus, isModalFocused - * @since 0.4.0 - */ - virtual void requestModalFocus(); - - /** - * Requests modal mouse input focus. When a widget has modal input focus - * that widget will be the only widget receiving input even if the input - * occurs outside of the widget and no matter what the input is. - * - * @throws Exception if another widget already has modal focus. - * @see releaseModalMouseInputFocus, isModalMouseInputFocused - * @since 0.6.0 - */ - virtual void requestModalMouseInputFocus(); - - /** - * Releases modal focus. Modal focus will only be released if the - * widget has modal focus. - * - * @see requestModalFocus, isModalFocused - * @since 0.4.0 - */ - virtual void releaseModalFocus(); - - /** - * Releases modal mouse input focus. Modal mouse input focus will only - * be released if the widget has modal mouse input focus. - * - * @see requestModalMouseInputFocus, isModalMouseInputFocused - * @since 0.6.0 - */ - virtual void releaseModalMouseInputFocus(); - - /** - * Checks if the widget or it's parent has modal focus. - * - * @return True if the widget has modal focus, false otherwise. - * @see requestModalFocus, releaseModalFocus - * @since 0.8.0 - */ - virtual bool isModalFocused() const A_WARN_UNUSED; - - /** - * Checks if the widget or it's parent has modal mouse input focus. - * - * @return True if the widget has modal mouse input focus, false - * otherwise. - * @see requestModalMouseInputFocus, releaseModalMouseInputFocus - * @since 0.8.0 - */ - virtual bool isModalMouseInputFocused() const A_WARN_UNUSED; - - /** - * Gets a widget from a certain position in the widget. - * This function is used to decide which gets mouse input, - * thus it can be overloaded to change that behaviour. - * - * NOTE: This always returns NULL if the widget is not - * a container. - * - * @param x The x coordinate of the widget to get. - * @param y The y coordinate of the widget to get. - * @return The widget at the specified coodinate, NULL - * if no widget is found. - * @since 0.6.0 - */ - virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED; - - /** - * Gets the mouse listeners of the widget. - * - * @return The mouse listeners of the widget. - * @since 0.6.0 - */ - virtual const std::list& _getMouseListeners() - A_WARN_UNUSED; - - /** - * Gets the key listeners of the widget. - * - * @return The key listeners of the widget. - * @since 0.6.0 - */ - virtual const std::list& _getKeyListeners() - A_WARN_UNUSED; - - /** - * Gets the focus listeners of the widget. - * - * @return The focus listeners of the widget. - * @since 0.7.0 - */ - virtual const std::list& _getFocusListeners() - A_WARN_UNUSED; - - /** - * Gets the area of the widget occupied by the widget's children. - * By default this method returns an empty rectangle as not all - * widgets are containers. If you want to make a container this - * method should return the area where the children resides. This - * method is used when drawing children of a widget when computing - * clip rectangles for the children. - * - * An example of a widget that overloads this method is ScrollArea. - * A ScrollArea has a view of its contant and that view is the - * children area. The size of a ScrollArea's children area might - * vary depending on if the scroll bars of the ScrollArea is shown - * or not. - * - * @return The area of the widget occupied by the widget's children. - * @see BasicContainer - * @see BasicContainer::getChildrenArea - * @see BasicContainer::drawChildren - * @since 0.1.0 - */ - virtual Rectangle getChildrenArea() A_WARN_UNUSED; - - /** - * Gets the internal focus handler used. - * - * @return the internalFocusHandler used. If no internal focus handler - * is used, NULL will be returned. - * @see setInternalFocusHandler - * @since 0.1.0 - */ - virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED; - - /** - * Sets the internal focus handler. An internal focus handler is - * needed if both a widget in the widget and the widget itself - * should be foucsed at the same time. - * - * @param focusHandler The internal focus handler to be used. - * @see getInternalFocusHandler - * @since 0.1.0 - */ - void setInternalFocusHandler(FocusHandler* internalFocusHandler); - - /** - * Moves a widget to the top of this widget. The moved widget will be - * drawn above all other widgets in this widget. - * - * @param widget The widget to move to the top. - * @see moveToBottom - * @since 0.1.0 - */ - virtual void moveToTop(Widget* widget A_UNUSED) - { } - - /** - * Moves a widget in this widget to the bottom of this widget. - * The moved widget will be drawn below all other widgets in this widget. - * - * @param widget The widget to move to the bottom. - * @see moveToTop - * @since 0.1.0 - */ - virtual void moveToBottom(Widget* widget A_UNUSED) - { } - - /** - * Focuses the next widget in the widget. - * - * @see moveToBottom - * @since 0.1.0 - */ - virtual void focusNext() - { } - - /** - * Focuses the previous widget in the widget. - * - * @see moveToBottom - * @since 0.1.0 - */ - virtual void focusPrevious() - { } - - /** - * Tries to show a specific part of a widget by moving it. Used if the - * widget should act as a container. - * - * @param widget The target widget. - * @param area The area to show. - * @since 0.1.0 - */ - virtual void showWidgetPart(Widget* widget A_UNUSED, - Rectangle area A_UNUSED) - { } - - /** - * Sets an id of a widget. An id can be useful if a widget needs to be - * identified in a container. For example, if widgets are created by an - * XML document, a certain widget can be retrieved given that the widget - * has an id. - * - * @param id The id to set to the widget. - * @see getId, BasicContainer::findWidgetById - * @since 0.8.0 - */ - void setId(const std::string& id); - - /** - * Gets the id of a widget. An id can be useful if a widget needs to be - * identified in a container. For example, if widgets are created by an - * XML document, a certain widget can be retrieved given that the widget - * has an id. - * - * @param id The id to set to the widget. - * @see setId, BasicContainer::findWidgetById - * @since 0.8.0 - */ - const std::string& getId() A_WARN_UNUSED; - - /** - * Shows a certain part of a widget in the widget's parent. - * Used when widgets want a specific part to be visible in - * its parent. An example is a TextArea that wants a specific - * part of its text to be visible when a TextArea is a child - * of a ScrollArea. - * - * @param rectangle The rectangle to be shown. - * @since 0.8.0 - */ - virtual void showPart(Rectangle rectangle); - - protected: - /** - * Distributes an action event to all action listeners - * of the widget. - * - * @since 0.8.0 - */ - void distributeActionEvent(); - - /** - * Distributes resized events to all of the widget's listeners. - * - * @since 0.8.0 - */ - void distributeResizedEvent(); - - /** - * Distributes moved events to all of the widget's listeners. - * - * @since 0.8.0 - */ - void distributeMovedEvent(); - - /** - * Distributes hidden events to all of the widget's listeners. - * - * @since 0.8.0 - * @author Olof Naessén - */ - void distributeHiddenEvent(); - - /** - * Distributes shown events to all of the widget's listeners. - * - * @since 0.8.0 - * @author Olof Naessén - */ - void distributeShownEvent(); - - /** - * Typdef. - */ - typedef std::list MouseListenerList; - - /** - * Typdef. - */ - typedef MouseListenerList::iterator MouseListenerIterator; - - /** - * Holds the mouse listeners of the widget. - */ - MouseListenerList mMouseListeners; - - /** - * Typdef. - */ - typedef std::list KeyListenerList; - - /** - * Holds the key listeners of the widget. - */ - KeyListenerList mKeyListeners; - - /** - * Typdef. - */ - typedef KeyListenerList::iterator KeyListenerIterator; - - /** - * Typdef. - */ - typedef std::list ActionListenerList; - - /** - * Holds the action listeners of the widget. - */ - ActionListenerList mActionListeners; - - /** - * Typdef. - */ - typedef ActionListenerList::iterator ActionListenerIterator; - - /** - * Typdef. - */ - typedef std::list DeathListenerList; - - /** - * Holds the death listeners of the widget. - */ - DeathListenerList mDeathListeners; - - /** - * Typdef. - */ - typedef DeathListenerList::iterator DeathListenerIterator; - - /** - * Typdef. - */ - typedef std::list FocusListenerList; - - /** - * Holds the focus listeners of the widget. - */ - FocusListenerList mFocusListeners; - - /** - * Typdef. - */ - typedef FocusListenerList::iterator FocusListenerIterator; - - typedef std::list WidgetListenerList; - - /** - * Holds the widget listeners of the widget. - */ - WidgetListenerList mWidgetListeners; - - /** - * Typdef. - */ - typedef WidgetListenerList::iterator WidgetListenerIterator; - - /** - * Holds the foreground color of the widget. - */ - Color mForegroundColor; - - /** - * Holds the background color of the widget. - */ - Color mBackgroundColor; - - /** - * Holds the base color of the widget. - */ - Color mBaseColor; - - /** - * Holds the selection color of the widget. - */ - Color mSelectionColor; - - /** - * Holds the focus handler used by the widget. - */ - FocusHandler* mFocusHandler; - - /** - * Holds the focus handler used by the widget. NULL - * if no internal focus handler is used. - */ - FocusHandler* mInternalFocusHandler; - - /** - * Holds the parent of the widget. NULL if the widget - * has no parent. - */ - Widget* mParent; - - /** - * Holds the dimension of the widget. - */ - Rectangle mDimension; - - /** - * Holds the frame size of the widget. - */ - unsigned int mFrameSize; - - /** - * Holds the action event of the widget. - */ - std::string mActionEventId; - - /** - * True if the widget focusable, false otherwise. - */ - bool mFocusable; - - /** - * True if the widget visible, false otherwise. - */ - bool mVisible; - - /** - * True if the widget has tab in enabled, false otherwise. - */ - bool mTabIn; - - /** - * True if the widget has tab in enabled, false otherwise. - */ - bool mTabOut; - - /** - * True if the widget is enabled, false otherwise. - */ - bool mEnabled; - - /** - * Holds the id of the widget. - */ - std::string mId; - - /** - * Holds the font used by the widget. - */ - Font* mCurrentFont; - - /** - * Holds the global font used by the widget. - */ - static Font* mGlobalFont; - - /** - * Holds a list of all instances of widgets. - */ - static std::list mWidgets; - - static std::set mWidgetsSet; - }; -} // namespace gcn - -#endif // end GCN_WIDGET_HPP diff --git a/src/guichan/include/guichan/widgetlistener.hpp b/src/guichan/include/guichan/widgetlistener.hpp deleted file mode 100644 index eb584b0ed..000000000 --- a/src/guichan/include/guichan/widgetlistener.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_WIDGETLISTENER_HPP -#define GCN_WIDGETLISTENER_HPP - -#include - -#include "guichan/event.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for events from widgets. When a widget's size, - * location or visibility changes, the relevant method of the listener is - * invoked. - * - * @see Widget::addWidgetListener, Widget::removeWidgetListener - * @author Olof Naessén - * @since 0.8.0 - */ - class WidgetListener - { - public: - /** - * Destructor. - */ - virtual ~WidgetListener() - { } - - /** - * Invoked when a widget changes its size. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetResized(const Event& event A_UNUSED) - { } - - /** - * Invoked when a widget is moved. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetMoved(const Event& event A_UNUSED) - { } - - /** - * Invoked when a widget is hidden, i.e it's set to be - * not visible. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetHidden(const Event& event A_UNUSED) - { } - - /** - * Invoked when a widget is shown, i.e it's set to be - * visible. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetShown(const Event& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of WidgetListener, - * therefore its constructor is protected. - */ - WidgetListener() - { } - }; -} // namespace gcn - -#endif // end GCN_WIDGETLISTENER_HPP diff --git a/src/guichan/include/guichan/widgets/button.hpp b/src/guichan/include/guichan/widgets/button.hpp deleted file mode 100644 index 91c526d4f..000000000 --- a/src/guichan/include/guichan/widgets/button.hpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_BUTTON_HPP -#define GCN_BUTTON_HPP - -#include - -#include "guichan/focuslistener.hpp" -#include "guichan/graphics.hpp" -#include "guichan/keylistener.hpp" -#include "guichan/mouseevent.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a regular clickable button. A button is capable of - * displaying a caption. - * - * If a button is clicked an action event will be sent to all action listener's - * of the button. - * - * @see ImageButton - */ - class Button : public Widget, - public MouseListener, - public KeyListener, - public FocusListener - { - public: - /** - * Constructor. - */ - Button(); - - /** - * Constructor. The button will be automatically resized - * to fit the caption. - * - * @param caption The caption of the button. - */ - explicit Button(const std::string& caption); - - A_DELETE_COPY(Button) - - /** - * Sets the caption of the button. It's advisable to call - * adjustSize after setting of the caption to adjust the - * button's size to fit the caption. - * - * @param caption The caption of the button. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Gets the caption of the button. - * - * @return The caption of the button. - */ - const std::string& getCaption() const; - - /** - * Sets the alignment of the caption. The alignment is relative - * to the center of the button. - * - * @param alignment The alignment of the caption. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. - * - * @return The alignment of the caption. - * @see setAlignment, Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Sets the spacing between the border of the button and its caption. - * - * @param spacing The default value for spacing is 4 and can be changed - * using this method. - * @see getSpacing - */ - void setSpacing(unsigned int spacing); - - /** - * Gets the spacing between the border of the button and its caption. - * - * @return spacing. - * @see setSpacing - */ - unsigned int getSpacing() const; - - /** - * Adjusts the button's size to fit the caption. - */ - void adjustSize(); - - - // Inherited from FocusListener - - virtual void focusLost(const Event& event); - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent) override; - - virtual void mouseEntered(MouseEvent& mouseEvent) override; - - virtual void mouseExited(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - protected: - /** - * Checks if the button is pressed. Convenient method to use - * when overloading the draw method of the button. - * - * @return True if the button is pressed, false otherwise. - */ - bool isPressed() const; - - /** - * Holds the caption of the button. - */ - std::string mCaption; - - /** - * True if the mouse is ontop of the button, false otherwise. - */ - bool mHasMouse; - - /** - * True if a key has been pressed, false otherwise. - */ - bool mKeyPressed; - - /** - * True if a mouse has been pressed, false otherwise. - */ - bool mMousePressed; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - - /** - * Holds the spacing between the border and the caption. - */ - unsigned int mSpacing; - }; -} // namespace gcn - -#endif // end GCN_BUTTON_HPP diff --git a/src/guichan/include/guichan/widgets/checkbox.hpp b/src/guichan/include/guichan/widgets/checkbox.hpp deleted file mode 100644 index 465de566d..000000000 --- a/src/guichan/include/guichan/widgets/checkbox.hpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_CHECKBOX_HPP -#define GCN_CHECKBOX_HPP - -#include - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a check box where a user can select or deselect - * the check box and where the status of the check box is displayed to the user. - * A check box is capable of displaying a caption. - * - * If a check box's state changes an action event will be sent to all action - * listeners of the check box. - */ - class CheckBox : - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Contructor. - */ - CheckBox(); - - /** - * Constructor. The check box will be automatically resized - * to fit the caption. - * - * @param caption The caption of the check box. - * @param marked True if the check box is selected, false otherwise. - */ - CheckBox(const std::string &caption, bool selected = false); - - A_DELETE_COPY(CheckBox) - - /** - * Destructor. - */ - virtual ~CheckBox() - { } - - /** - * Checks if the check box is selected. - * - * @return True if the check box is selected, false otherwise. - * @see setSelected - */ - bool isSelected() const; - - /** - * Sets the check box to be selected or not. - * - * @param selected True if the check box should be set as selected. - * @see isSelected - */ - void setSelected(bool selected); - - /** - * Gets the caption of the check box. - * - * @return The caption of the check box. - * @see setCaption - */ - const std::string &getCaption() const; - - /** - * Sets the caption of the check box. It's advisable to call - * adjustSize after setting of the caption to adjust the - * check box's size to fit the caption. - * - * @param caption The caption of the check box. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Adjusts the check box's size to fit the caption. - */ - void adjustSize(); - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent) override; - - // Inherited from MouseListener - - virtual void mouseClicked(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - - protected: - /** - * Toggles the check box between being selected and - * not being selected. - */ - virtual void toggleSelected(); - - /** - * True if the check box is selected, false otherwise. - */ - bool mSelected; - - /** - * Holds the caption of the check box. - */ - std::string mCaption; - }; -} // namespace gcn - -#endif // end GCN_CHECKBOX_HPP diff --git a/src/guichan/include/guichan/widgets/container.hpp b/src/guichan/include/guichan/widgets/container.hpp deleted file mode 100644 index b6efbf361..000000000 --- a/src/guichan/include/guichan/widgets/container.hpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_CONTAINER_HPP -#define GCN_CONTAINER_HPP - -#include - -#include "guichan/basiccontainer.hpp" -#include "guichan/graphics.hpp" - -namespace gcn -{ - /** - * An implementation of a container able to contain other widgets. A widget's - * position in the container is relative to the container itself and not the screen. - * A container is the most common widget to use as the Gui's top widget as makes the Gui - * able to contain more than one widget. - * - * @see Gui::setTop - */ - class Container: public BasicContainer - { - public: - /** - * Constructor. A container is opauqe as default, if you want a - * none opaque container call setQpaque(false). - * - * @see setOpaque, isOpaque - */ - Container(); - - /** - * Destructor. - */ - virtual ~Container(); - - /** - * Sets the container to be opaque or not. If the container - * is opaque its background will be drawn, if it's not opaque - * its background will not be drawn, and thus making the container - * completely transparent. - * - * NOTE: This is not the same as to set visibility. A non visible - * container will not itself nor will it draw its content. - * - * @param opaque True if the container should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - /** - * Checks if the container is opaque or not. - * - * @return True if the container is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque() const; - - /** - * Adds a widget to the container. - * - * @param widget The widget to add. - * @see remove, clear - */ - virtual void add(Widget* widget); - - /** - * Adds a widget to the container and also specifies the widget's - * position in the container. The position is relative to the container - * and not relative to the screen. - * - * @param widget The widget to add. - * @param x The x coordinate for the widget. - * @param y The y coordinate for the widget. - * @see remove, clear - */ - virtual void add(Widget* widget, int x, int y); - - /** - * Removes a widget from the Container. - * - * @param widget The widget to remove. - * @throws Exception when the widget has not been added to the - * container. - * @see add, clear - */ - virtual void remove(Widget* widget); - - /** - * Clears the container of all widgets. - * - * @see add, remove - */ - virtual void clear(); - - /** - * Finds a widget given an id. - * - * @param id The id to find a widget by. - * @return A widget with a corrosponding id, NULL if no widget - * is found. - * @see Widget::setId - */ - virtual Widget* findWidgetById(const std::string &id); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - protected: - /** - * True if the container is opaque, false otherwise. - */ - bool mOpaque; - }; -} // namespace gcn - -#endif // end GCN_CONTAINER_HPP diff --git a/src/guichan/include/guichan/widgets/label.hpp b/src/guichan/include/guichan/widgets/label.hpp deleted file mode 100644 index a8c2ae7ea..000000000 --- a/src/guichan/include/guichan/widgets/label.hpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_LABEL_HPP -#define GCN_LABEL_HPP - -#include - -#include "guichan/graphics.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * Implementation of a label capable of displaying a caption. - */ - class Label: public Widget - { - public: - /** - * Constructor. - */ - Label(); - - /** - * Constructor. The label will be automatically resized - * to fit the caption. - * - * @param caption The caption of the label. - */ - explicit Label(const std::string& caption); - - A_DELETE_COPY(Label) - - /** - * Gets the caption of the label. - * - * @return The caption of the label. - * @see setCaption - */ - const std::string &getCaption() const; - - /** - * Sets the caption of the label. It's advisable to call - * adjustSize after setting of the caption to adjust the - * label's size to fit the caption. - * - * @param caption The caption of the label. - * @see getCaption, adjustSize - */ - void setCaption(const std::string& caption); - - /** - * Sets the alignment of the caption. The alignment is relative - * to the center of the label. - * - * @param alignemnt The alignment of the caption of the label. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. The alignment is relative to - * the center of the label. - * - * @return The alignment of caption of the label. - * @see setAlignmentm Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Adjusts the label's size to fit the caption. - */ - void adjustSize(); - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - protected: - /** - * Holds the caption of the label. - */ - std::string mCaption; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - }; -} // namespace gcn - -#endif // end GCN_LABEL_HPP diff --git a/src/guichan/include/guichan/widgets/listbox.hpp b/src/guichan/include/guichan/widgets/listbox.hpp deleted file mode 100644 index d28664455..000000000 --- a/src/guichan/include/guichan/widgets/listbox.hpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_LISTBOX_HPP -#define GCN_LISTBOX_HPP - -#include - -#include "guichan/keylistener.hpp" -#include "guichan/listmodel.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - class SelectionListener; - - /** - * An implementation of a list box where an item can be selected. - * - * To be able display a list the list box uses a user provided list model. - * A list model can be any class that implements the ListModel interface. - * - * If an item is selected in the list box a select event will be sent to - * all selection listeners of the list box. If an item is selected by using - * a mouse click or by using the enter or space key an action event will be - * sent to all action listeners of the list box. - */ - class ListBox : - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - ListBox(); - - /** - * Constructor. - * - * @param listModel the list model to use. - */ - explicit ListBox(ListModel *listModel); - - A_DELETE_COPY(ListBox) - - /** - * Destructor. - */ - virtual ~ListBox() - { } - - /** - * Gets the selected item as an index in the list model. - * - * @return the selected item as an index in the list model. - * @see setSelected - */ - int getSelected() const; - - /** - * Sets the selected item. The selected item is represented by - * an index from the list model. - * - * @param selected the selected item as an index from the list model. - * @see getSelected - */ - void setSelected(int selected); - - /** - * Sets the list model to use. - * - * @param listModel the list model to use. - * @see getListModel - */ - void setListModel(ListModel *listModel); - - /** - * Gets the list model used. - * - * @return the list model used. - * @see setListModel - */ - ListModel *getListModel(); - - /** - * Adjusts the size of the list box to fit it's list model. - */ - void adjustSize(); - - /** - * Checks whether the list box wraps when selecting items with a - * keyboard. - * - * Wrapping means that the selection of items will be wrapped. That is, - * if the first item is selected and up is pressed, the last item will - * get selected. If the last item is selected and down is pressed, the - * first item will get selected. - * - * @return true if wrapping is enabled, fasle otherwise. - * @see setWrappingEnabled - */ - bool isWrappingEnabled() const; - - /** - * Sets the list box to wrap or not when selecting items with a - * keyboard. - * - * Wrapping means that the selection of items will be wrapped. That is, - * if the first item is selected and up is pressed, the last item will - * get selected. If the last item is selected and down is pressed, the - * first item will get selected. - * - * @see isWrappingEnabled - */ - void setWrappingEnabled(bool wrappingEnabled); - - /** - * Adds a selection listener to the list box. When the selection - * changes an event will be sent to all selection listeners of the - * list box. - * - * If you delete your selection listener, be sure to also remove it - * using removeSelectionListener(). - * - * @param selectionListener The selection listener to add. - * @since 0.8.0 - */ - void addSelectionListener(SelectionListener* selectionListener); - - /** - * Removes a selection listener from the list box. - * - * @param selectionListener The selection listener to remove. - * @since 0.8.0 - */ - void removeSelectionListener(SelectionListener* selectionListener); - - /** - * Gets the height of a row. Should be overridden if another row - * height than the font height is preferred. - * - * @return The height of a row. - * @since 0.8.0 - */ - virtual unsigned int getRowHeight() const; - - - // Inherited from Widget - - virtual void draw(Graphics* graphics); - - virtual void logic(); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent) override; - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent) override; - - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent) override; - - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - - protected: - /** - * Distributes a value changed event to all selection listeners - * of the list box. - * - * @since 0.8.0 - */ - void distributeValueChangedEvent(); - - /** - * The selected item as an index in the list model. - */ - int mSelected; - - /** - * The list model to use. - */ - ListModel *mListModel; - - /** - * True if wrapping is enabled, false otherwise. - */ - bool mWrappingEnabled; - - /** - * Typdef. - */ - typedef std::list SelectionListenerList; - - /** - * The selection listeners of the list box. - */ - SelectionListenerList mSelectionListeners; - - /** - * Typedef. - */ - typedef SelectionListenerList::iterator SelectionListenerIterator; - }; -} // namespace gcn - -#endif // end GCN_LISTBOX_HPP diff --git a/src/guichan/include/guichan/widgets/radiobutton.hpp b/src/guichan/include/guichan/widgets/radiobutton.hpp deleted file mode 100644 index 2a93a82ee..000000000 --- a/src/guichan/include/guichan/widgets/radiobutton.hpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_RADIOBUTTON_HPP -#define GCN_RADIOBUTTON_HPP - -#include -#include - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a radio button where a user can select or deselect - * the radio button and where the status of the radio button is displayed to the user. - * A radio button can belong to a group and when a radio button belongs to a - * group only one radio button can be selected in the group. A radio button is - * capable of displaying a caption. - * - * If a radio button's state changes an action event will be sent to all action - * listeners of the check box. - */ - class RadioButton : - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - RadioButton(); - - /** - * Constructor. The radio button will be automatically resized - * to fit the caption. - * - * @param caption The caption of the radio button. - * @param group The group the radio button should belong to. - * @param selected True if the radio button should be selected. - */ - RadioButton(const std::string &caption, - const std::string &group, - bool selected = false); - - A_DELETE_COPY(RadioButton) - - /** - * Destructor. - */ - virtual ~RadioButton(); - - /** - * Checks if the radio button is selected. - * - * @return True if the radio button is selecte, false otherwise. - * @see setSelected - */ - bool isSelected() const; - - /** - * Sets the radio button to selected or not. - * - * @param selected True if the radio button should be selected, - * false otherwise. - * @see isSelected - */ - void setSelected(bool selected); - - /** - * Gets the caption of the radio button. - * - * @return The caption of the radio button. - * @see setCaption - */ - const std::string &getCaption() const; - - /** - * Sets the caption of the radio button. It's advisable to call - * adjustSize after setting of the caption to adjust the - * radio button's size to fit the caption. - * - * @param caption The caption of the radio button. - * @see getCaption, adjustSize - */ - void setCaption(const std::string &caption); - - /** - * Sets the group the radio button should belong to. Note that - * a radio button group is unique per application, not per Gui object - * as the group is stored in a static map. - * - * @param group The name of the group. - * @see getGroup - */ - void setGroup(const std::string &group); - - /** - * Gets the group the radio button belongs to. - * - * @return The group the radio button belongs to. - * @see setGroup - */ - const std::string &getGroup() const; - - /** - * Adjusts the radio button's size to fit the caption. - */ - void adjustSize(); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent) override; - - - // Inherited from MouseListener - - virtual void mouseClicked(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - protected: - /** - * Draws the box. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawBox(Graphics *graphics) = 0; - - /** - * True if the radio button is selected, false otherwise. - */ - bool mSelected; - - /** - * Holds the caption of the radio button. - */ - std::string mCaption; - - /** - * Holds the group of the radio button. - */ - std::string mGroup; - - /** - * Typdef. - */ - typedef std::multimap GroupMap; - - /** - * Typdef. - */ - typedef GroupMap::iterator GroupIterator; - - /** - * Holds all available radio button groups. - */ - static GroupMap mGroupMap; - }; -} // namespace gcn - -#endif // end GCN_RADIOBUTTON_HPP diff --git a/src/guichan/include/guichan/widgets/scrollarea.hpp b/src/guichan/include/guichan/widgets/scrollarea.hpp deleted file mode 100644 index 30fa64abc..000000000 --- a/src/guichan/include/guichan/widgets/scrollarea.hpp +++ /dev/null @@ -1,549 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SCROLLAREA_HPP -#define GCN_SCROLLAREA_HPP - -#include - -#include "guichan/basiccontainer.hpp" -#include "guichan/mouselistener.hpp" - -namespace gcn -{ - /** - * Implementation if a scrollable area used to view widgets larger than the scroll area. - * A scroll area can be customized to always show scroll bars or to show them only when - * necessary. - */ - class ScrollArea: - public BasicContainer, - public MouseListener - { - public: - /** - * Scrollpolicies for the horizontal and vertical scrollbar. - * The policies are: - * - * SHOW_ALWAYS - Always show the scrollbars no matter what. - * SHOW_NEVER - Never show the scrollbars no matter waht. - * SHOW_AUTO - Show the scrollbars only when needed. That is if the - * content grows larger then the ScrollArea. - */ - enum ScrollPolicy - { - SHOW_ALWAYS = 0, - SHOW_NEVER, - SHOW_AUTO - }; - - /** - * Constructor. - */ - ScrollArea(); - - /** - * Constructor. - * - * @param content The content of the scroll area. - */ - explicit ScrollArea(Widget *const content); - - /** - * Constructor. - * - * @param content The content of the scroll area. - * @param hPolicy The policy for the horizontal scrollbar. See enum with - * policies. - * @param vPolicy The policy for the vertical scrollbar. See enum with - * policies. - */ - ScrollArea(Widget *content, - ScrollPolicy hPolicy, - ScrollPolicy vPolicy); - - A_DELETE_COPY(ScrollArea) - - /** - * Destructor. - */ - virtual ~ScrollArea(); - - /** - * Sets the content. - * - * @param widget The content of the scroll area. - */ - void setContent(Widget* widget); - - /** - * Gets the content. - * - * @return The content of the scroll area. - */ - Widget* getContent(); - - /** - * Sets the horizontal scrollbar policy. See enum with policies. - * - * @param hPolicy The policy for the horizontal scrollbar. - * @see getHorizontalScrollPolicy - */ - void setHorizontalScrollPolicy(ScrollPolicy hPolicy); - - /** - * Gets the horizontal scrollbar policy. See enum with policies. - * - * @return The policy for the horizontal scrollbar policy. - * @see setHorizontalScrollPolicy, setScrollPolicy - */ - ScrollPolicy getHorizontalScrollPolicy() const; - - /** - * Sets the vertical scrollbar policy. See enum with policies. - * - * @param vPolicy The policy for the vertical scrollbar. - * @see getVerticalScrollPolicy - */ - void setVerticalScrollPolicy(ScrollPolicy vPolicy); - - /** - * Gets the vertical scrollbar policy. See enum with policies. - * - * @return The policy for the vertical scrollbar. - * @see setVerticalScrollPolicy, setScrollPolicy - */ - ScrollPolicy getVerticalScrollPolicy() const; - - /** - * Sets the horizontal and vertical scrollbar policy. - * - * @param hPolicy The policy for the horizontal scrollbar. - * @param vPolicy The policy for the vertical scrollbar. - * @see getVerticalScrollPolicy, getHorizontalScrollPolicy - */ - void setScrollPolicy(ScrollPolicy hPolicy, ScrollPolicy vPolicy); - - /** - * Sets the amount to scroll vertically. - * - * @param vScroll The amount to scroll. - * @see getVerticalScrollAmount - */ - void setVerticalScrollAmount(int vScroll); - - /** - * Gets the amount that is scrolled vertically. - * - * @return The scroll amount on vertical scroll. - * @see setVerticalScrollAmount, setScrollAmount - */ - int getVerticalScrollAmount() const; - - /** - * Sets the amount to scroll horizontally. - * - * @param hScroll The amount to scroll. - * @see getHorizontalScrollAmount - */ - void setHorizontalScrollAmount(int hScroll); - - /** - * Gets the amount that is scrolled horizontally. - * - * @return The scroll amount on horizontal scroll. - * @see setHorizontalScrollAmount, setScrollAmount - */ - int getHorizontalScrollAmount() const; - - /** - * Sets the amount to scroll horizontally and vertically. - * - * @param hScroll The amount to scroll on horizontal scroll. - * @param vScroll The amount to scroll on vertical scroll. - * @see getHorizontalScrollAmount, getVerticalScrollAmount - */ - void setScrollAmount(int hScroll, int vScroll); - - /** - * Gets the maximum amount of horizontal scroll. - * - * @return The horizontal max scroll. - */ - int getHorizontalMaxScroll(); - - /** - * Gets the maximum amount of vertical scroll. - * - * @return The vertical max scroll. - */ - int getVerticalMaxScroll(); - - /** - * Sets the width of the scroll bars. - * - * @param width The width of the scroll bars. - * @see getScrollbarWidth - */ - void setScrollbarWidth(int width); - - /** - * Gets the width of the scroll bars. - * - * @return the width of the ScrollBar. - * @see setScrollbarWidth - */ - int getScrollbarWidth() const; - - /** - * Sets the amount to scroll in pixels when the left scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getLeftButtonScrollAmount - */ - void setLeftButtonScrollAmount(int amount); - - /** - * Sets the amount to scroll in pixels when the right scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getRightButtonScrollAmount - */ - void setRightButtonScrollAmount(int amount); - - /** - * Sets the amount to scroll in pixels when the up scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getUpButtonScrollAmount - */ - void setUpButtonScrollAmount(int amount); - - /** - * Sets the amount to scroll in pixels when the down scroll button is - * pushed. - * - * @param amount The amount to scroll in pixels. - * @see getDownButtonScrollAmount - */ - void setDownButtonScrollAmount(int amount); - - /** - * Gets the amount to scroll in pixels when the left scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setLeftButtonScrollAmount - */ - int getLeftButtonScrollAmount() const; - - /** - * Gets the amount to scroll in pixels when the right scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setRightButtonScrollAmount - */ - int getRightButtonScrollAmount() const; - - /** - * Gets the amount to scroll in pixels when the up scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setUpButtonScrollAmount - */ - int getUpButtonScrollAmount() const; - - /** - * Gets the amount to scroll in pixels when the down scroll button is - * pushed. - * - * @return The amount to scroll in pixels. - * @see setDownButtonScrollAmount - */ - int getDownButtonScrollAmount() const; - - /** - * Sets the scroll area to be opaque, that is sets the scoll area - * to display its background. - * - * @param opaque True if the scoll area should be opaque, false otherwise. - */ - void setOpaque(bool opaque); - - /** - * Checks if the scroll area is opaque, that is if the scroll area - * displays its background. - * - * @return True if the scroll area is opaque, false otherwise. - */ - bool isOpaque() const; - - // Inherited from BasicContainer - - virtual void showWidgetPart(Widget* widget, Rectangle area); - - virtual Rectangle getChildrenArea(); - - virtual Widget *getWidgetAt(int x, int y); - - - // Inherited from Widget - - virtual void draw(Graphics *graphics); - - virtual void logic(); - - void setWidth(int width); - - void setHeight(int height); - - void setDimension(const Rectangle& dimension); - - - // Inherited from MouseListener - - virtual void mouseReleased(MouseEvent& mouseEvent) override; - - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent) override; - - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent) override; - - protected: - /** - * Draws the background of the scroll area, that is - * the area behind the content. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawBackground(Graphics *graphics); - - /** - * Draws the up button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawUpButton(Graphics *graphics); - - /** - * Draws the down button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawDownButton(Graphics *graphics); - - /** - * Draws the left button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawLeftButton(Graphics *graphics); - - /** - * Draws the right button. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawRightButton(Graphics *graphics); - - /** - * Draws the vertical scroll bar. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawVBar(Graphics* graphics); - - /** - * Draws the horizontal scroll bar. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawHBar(Graphics* graphics); - - /** - * Draws the vertical marker. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawVMarker(Graphics* graphics); - - /** - * Draws the horizontal marker. - * - * @param graphics a Graphics object to draw with. - */ - virtual void drawHMarker(Graphics* graphics); - - /** - * Checks the policies for the scroll bars. - */ - virtual void checkPolicies(); - - /** - * Holds the vertical scroll amount. - */ - int mVScroll; - - /** - * Holds the horizontal scroll amount. - */ - int mHScroll; - - /** - * Holds the width of the scroll bars. - */ - int mScrollbarWidth; - - /** - * Holds the horizontal scroll bar policy. - */ - ScrollPolicy mHPolicy; - - /** - * Holds the vertical scroll bar policy. - */ - ScrollPolicy mVPolicy; - - /** - * True if the vertical scroll bar is visible, false otherwise. - */ - bool mVBarVisible; - - /** - * True if the horizontal scroll bar is visible, false otherwise. - */ - bool mHBarVisible; - - /** - * True if the up button is pressed, false otherwise. - */ - bool mUpButtonPressed; - - /** - * True if the down button is pressed, false otherwise. - */ - bool mDownButtonPressed; - - /** - * True if the left button is pressed, false otherwise. - */ - bool mLeftButtonPressed; - - /** - * True if the right button is pressed, false otherwise. - */ - bool mRightButtonPressed; - - /** - * Holds the up button scroll amount. - */ - int mUpButtonScrollAmount; - - /** - * Holds the down button scroll amount. - */ - int mDownButtonScrollAmount; - - /** - * Holds the left button scroll amount. - */ - int mLeftButtonScrollAmount; - - /** - * Holds the right button scroll amount. - */ - int mRightButtonScrollAmount; - - /** - * True if the vertical marked is dragged. - */ - bool mIsVerticalMarkerDragged; - - /** - * True if the horizontal marked is dragged. - */ - bool mIsHorizontalMarkerDragged; - - /** - * Holds the horizontal markers drag offset. - */ - int mHorizontalMarkerDragOffset; - - /** - * Holds the vertical markers drag offset. - */ - int mVerticalMarkerDragOffset; - - /** - * True if the scroll area should be opaque (that is - * display its background), false otherwise. - */ - bool mOpaque; - }; -} // namespace gcn - -#endif // end GCN_SCROLLAREA_HPP diff --git a/src/guichan/include/guichan/widgets/slider.hpp b/src/guichan/include/guichan/widgets/slider.hpp deleted file mode 100644 index 04f774b21..000000000 --- a/src/guichan/include/guichan/widgets/slider.hpp +++ /dev/null @@ -1,293 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SLIDER_HPP -#define GCN_SLIDER_HPP - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a slider where a user can select different values by - * sliding between a start value and an end value of a scale. - * - * If the selected value is changed an action event will be sent to all - * action listeners of the slider. - */ - class Slider : - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Draw orientations for the slider. A slider can be drawn vertically or - * horizontally. - */ - enum Orientation - { - HORIZONTAL = 0, - VERTICAL - }; - - /** - * Constructor. The default start value of the slider scale is zero. - * - * @param scaleEnd The end value of the slider scale. - */ - explicit Slider(const double scaleEnd = 1.0); - - /** - * Constructor. - * - * @param scaleStart The start value of the slider scale. - * @param scaleEnd The end value of the slider scale. - */ - Slider(const double scaleStart, const double scaleEnd); - - A_DELETE_COPY(Slider) - - /** - * Destructor. - */ - virtual ~Slider() - { } - - /** - * Sets the scale of the slider. - * - * @param scaleStart The start value of the scale. - * @param scaleEnd tThe end of value the scale. - * @see getScaleStart, getScaleEnd - */ - void setScale(double scaleStart, double scaleEnd); - - /** - * Gets the start value of the scale. - * - * @return The start value of the scale. - * @see setScaleStart, setScale - */ - double getScaleStart() const; - - /** - * Sets the start value of the scale. - * - * @param scaleStart The start value of the scale. - * @see getScaleStart - */ - void setScaleStart(double scaleStart); - - /** - * Gets the end value of the scale. - * - * @return The end value of the scale. - * @see setScaleEnd, setScale - */ - double getScaleEnd() const; - - /** - * Sets the end value of the scale. - * - * @param scaleEnd The end value of the scale. - * @see getScaleEnd - */ - void setScaleEnd(double scaleEnd); - - /** - * Gets the current selected value. - * - * @return The current selected value. - * @see setValue - */ - double getValue() const; - - /** - * Sets the current selected value. - * - * @param value The current selected value. - * @see getValue - */ - void setValue(double value); - - /** - * Sets the length of the marker. - * - * @param length The length for the marker. - * @see getMarkerLength - */ - void setMarkerLength(int length); - - /** - * Gets the length of the marker. - * - * @return The length of the marker. - * @see setMarkerLength - */ - int getMarkerLength() const; - - /** - * Sets the orientation of the slider. A slider can be drawn vertically - * or horizontally. - * - * @param orientation The orientation of the slider. - * @see getOrientation - */ - void setOrientation(Orientation orientation); - - /** - * Gets the orientation of the slider. A slider can be drawn vertically - * or horizontally. - * - * @return The orientation of the slider. - * @see setOrientation - */ - Orientation getOrientation() const; - - /** - * Sets the step length. The step length is used when the keys LEFT - * and RIGHT are pressed to step in the scale. - * - * @param length The step length. - * @see getStepLength - */ - void setStepLength(double length); - - /** - * Gets the step length. The step length is used when the keys LEFT - * and RIGHT are pressed to step in the scale. - * - * @return the step length. - * @see setStepLength - */ - double getStepLength() const; - - protected: - /** - * Converts a marker position to a value in the scale. - * - * @param position The position to convert. - * @return A scale value corresponding to the position. - * @see valueToMarkerPosition - */ - virtual double markerPositionToValue(int position) const; - - /** - * Converts a value to a marker position. - * - * @param value The value to convert. - * @return A marker position corresponding to the value. - * @see markerPositionToValue - */ - virtual int valueToMarkerPosition(double value) const; - - /** - * Gets the marker position of the current selected value. - * - * @return The marker position of the current selected value. - */ - virtual int getMarkerPosition() const; - - /** - * True if the slider is dragged, false otherwise. - */ - bool mDragged; - - /** - * Holds the current selected value. - */ - double mValue; - - /** - * Holds the step length. The step length is used when the keys LEFT - * and RIGHT are pressed to step in the scale. - */ - double mStepLength; - - /** - * Holds the length of the marker. - */ - int mMarkerLength; - - /** - * Holds the start value of the scale. - */ - double mScaleStart; - - /** - * Holds the end value of the scale. - */ - double mScaleEnd; - - /** - * Holds the orientation of the slider. A slider can be drawn - * vertically or horizontally. - */ - Orientation mOrientation; - }; -} // namespace gcn - -#endif // end GCN_SLIDER_HPP diff --git a/src/guichan/include/guichan/widgets/textbox.hpp b/src/guichan/include/guichan/widgets/textbox.hpp deleted file mode 100644 index a75b52115..000000000 --- a/src/guichan/include/guichan/widgets/textbox.hpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_TEXTBOX_HPP -#define GCN_TEXTBOX_HPP - -#include -#include -#include - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -namespace gcn -{ - /** - * An implementation of a text box where a user can enter text that contains of many lines. - */ - class TextBox: - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - TextBox(); - - /** - * Constructor. - * - * @param text The default text of the text box. - */ - explicit TextBox(const std::string& text); - - A_DELETE_COPY(TextBox) - - /** - * Sets the text of the text box. - * - * @param text The text of the text box. - * @see getText - */ - void setText(const std::string& text); - - /** - * Gets the text of the text box. - * - * @return The text of the text box. - * @see setText - */ - std::string getText() const; - - /** - * Gets a certain row from the text. - * - * @param row The number of the row to get from the text. - * @return A row from the text of the text box. - * @see setTextRow - */ - const std::string& getTextRow(int row) const; - - /** - * Sets the text of a certain row of the text. - * - * @param row The number of the row to set in the text. - * @param text The text to set in the given row number. - * @see getTextRow - */ - void setTextRow(int row, const std::string& text); - - /** - * Gets the number of rows in the text. - * - * @return The number of rows in the text. - */ - unsigned int getNumberOfRows() const; - - /** - * Gets the caret position in the text. - * - * @return The caret position in the text. - * @see setCaretPosition - */ - unsigned int getCaretPosition() const; - - /** - * Sets the position of the caret in the text. - * - * @param position the positon of the caret. - * @see getCaretPosition - */ - void setCaretPosition(unsigned int position); - - /** - * Gets the row number where the caret is currently located. - * - * @return The row number where the caret is currently located. - * @see setCaretRow - */ - unsigned int getCaretRow() const; - - /** - * Sets the row where the caret should be currently located. - * - * @param The row where the caret should be currently located. - * @see getCaretRow - */ - void setCaretRow(int row); - - /** - * Gets the column where the caret is currently located. - * - * @return The column where the caret is currently located. - * @see setCaretColumn - */ - unsigned int getCaretColumn() const; - - /** - * Sets the column where the caret should be currently located. - * - * @param The column where the caret should be currently located. - * @see getCaretColumn - */ - void setCaretColumn(int column); - - /** - * Sets the row and the column where the caret should be curretly - * located. - * - * @param row The row where the caret should be currently located. - * @param column The column where the caret should be currently located. - * @see getCaretRow, getCaretColumn - */ - void setCaretRowColumn(int row, int column); - - /** - * Scrolls the text to the caret if the text box is in a scroll area. - * - * @see ScrollArea - */ - virtual void scrollToCaret(); - - /** - * Checks if the text box is editable. - * - * @return True it the text box is editable, false otherwise. - * @see setEditable - */ - bool isEditable() const; - - /** - * Sets the text box to be editable or not. - * - * @param editable True if the text box should be editable, false otherwise. - */ - void setEditable(bool editable); - - /** - * Adds a row of text to the end of the text. - * - * @param row The row to add. - */ - virtual void addRow(const std::string &row); - - /** - * Checks if the text box is opaque. An opaque text box will draw - * it's background and it's text. A non opaque text box only draw it's - * text making it transparent. - * - * @return True if the text box is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque(); - - /** - * Sets the text box to be opaque or not. An opaque text box will draw - * it's background and it's text. A non opaque text box only draw it's - * text making it transparent. - * - * @param opaque True if the text box should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - - // Inherited from Widget - -// virtual void draw(Graphics* graphics); - - virtual void fontChanged(); - - - // Inherited from KeyListener - - virtual void keyPressed(KeyEvent& keyEvent) override; - - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - protected: - /** - * Draws the caret. Overloaded this method if you want to - * change the style of the caret. - * - * @param graphics a Graphics object to draw with. - * @param x the x position. - * @param y the y position. - */ - virtual void drawCaret(Graphics* graphics, int x, int y); - - /** - * Adjusts the text box's size to fit the text. - */ - virtual void adjustSize(); - - /** - * Holds all the rows of the text. - */ - std::vector mTextRows; - - /** - * Holds the current column of the caret. - */ - int mCaretColumn; - - /** - * Holds the current row of the caret. - */ - int mCaretRow; - - /** - * True if the text box is editable, false otherwise. - */ - bool mEditable; - - /** - * True if the text box is editable, false otherwise. - */ - bool mOpaque; - }; -} // namespace gcn - -#endif // end GCN_TEXTBOX_HPP diff --git a/src/guichan/include/guichan/widgets/textfield.hpp b/src/guichan/include/guichan/widgets/textfield.hpp deleted file mode 100644 index b1293045f..000000000 --- a/src/guichan/include/guichan/widgets/textfield.hpp +++ /dev/null @@ -1,190 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_TEXTFIELD_HPP -#define GCN_TEXTFIELD_HPP - -#include "guichan/keylistener.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widget.hpp" - -#include - -namespace gcn -{ - /** - * An implementation of a text field where a user can enter a line of text. - */ - class TextField: - public Widget, - public MouseListener, - public KeyListener - { - public: - /** - * Constructor. - */ - TextField(); - - /** - * Constructor. The text field will be automatically resized - * to fit the text. - * - * @param text The default text of the text field. - */ - explicit TextField(const std::string& text); - - A_DELETE_COPY(TextField) - - /** - * Sets the text of the text field. - * - * @param text The text of the text field. - * @see getText - */ - void setText(const std::string& text); - - /** - * Gets the text of the text field. - * - * @return The text of the text field. - * @see setText - */ - const std::string& getText() const; - - /** - * Adjusts the size of the text field to fit the text. - */ - void adjustSize(); - - /** - * Adjusts the height of the text field to fit caption. - */ - void adjustHeight(); - - /** - * Sets the caret position. As there is only one line of text - * in a text field the position is the caret's x coordinate. - * - * @param position The caret position. - * @see getCaretPosition - */ - void setCaretPosition(unsigned int position); - - /** - * Gets the caret position. As there is only one line of text - * in a text field the position is the caret's x coordinate. - * - * @return The caret position. - * @see setCaretPosition - */ - unsigned int getCaretPosition() const; - - - // Inherited from Widget - - virtual void fontChanged(); - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - protected: - /** - * Draws the caret. Overloaded this method if you want to - * change the style of the caret. - * - * @param graphics the Graphics object to draw with. - * @param x the caret's x-position. - */ - virtual void drawCaret(Graphics* graphics, int x); - - /** - * Scrolls the text horizontally so that the caret shows if needed. - * The method is used any time a user types in the text field so the - * caret always will be shown. - */ - void fixScroll(); - - /** - * Holds the text of the text box. - */ - std::string mText; - - /** - * Holds the caret position. - */ - unsigned int mCaretPosition; - - /** - * Holds the amount scrolled in x. If a user types more characters than - * the text field can display, due to the text field being to small, the - * text needs to scroll in order to show the last type character. - */ - int mXScroll; - }; -} // namespace gcn - -#endif // end GCN_TEXTFIELD_HPP diff --git a/src/guichan/include/guichan/widgets/window.hpp b/src/guichan/include/guichan/widgets/window.hpp deleted file mode 100644 index bf5dd2e7c..000000000 --- a/src/guichan/include/guichan/widgets/window.hpp +++ /dev/null @@ -1,269 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_WINDOW_HPP -#define GCN_WINDOW_HPP - -#include - -#include "guichan/mouselistener.hpp" -#include "guichan/widgets/container.hpp" - -namespace gcn -{ - /** - * An implementation of a movable window that can contain other widgets. - */ - class Window : public Container, - public MouseListener - { - public: - /** - * Constructor. - */ - Window(); - - /** - * Constructor. The window will be automatically resized in height - * to fit the caption. - * - * @param caption the caption of the window. - */ - explicit Window(const std::string& caption); - - A_DELETE_COPY(Window) - - /** - * Destructor. - */ - virtual ~Window(); - - /** - * Sets the caption of the window. - * - * @param caption The caption of the window. - * @see getCaption - */ - void setCaption(const std::string& caption); - - /** - * Gets the caption of the window. - * - * @return the caption of the window. - * @see setCaption - */ - const std::string& getCaption() const; - - /** - * Sets the alignment of the caption. - * - * @param alignment The alignment of the caption. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. - * - * @return The alignment of caption. - * @see setAlignment, Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Sets the padding of the window. The padding is the distance between the - * window border and the content. - * - * @param padding The padding of the window. - * @see getPadding - */ - void setPadding(unsigned int padding); - - /** - * Gets the padding of the window. The padding is the distance between the - * window border and the content. - * - * @return The padding of the window. - * @see setPadding - */ - unsigned int getPadding() const; - - /** - * Sets the title bar height. - * - * @param height The title height value. - * @see getTitleBarHeight - */ - void setTitleBarHeight(unsigned int height); - - /** - * Gets the title bar height. - * - * @return The title bar height. - * @see setTitleBarHeight - */ - unsigned int getTitleBarHeight(); - - /** - * Sets the window to be moveble or not. - * - * @param movable True if the window should be movable, false otherwise. - * @see isMovable - */ - void setMovable(bool movable); - - /** - * Checks if the window is movable. - * - * @return True if the window is movable, false otherwise. - * @see setMovable - */ - bool isMovable() const; - - /** - * Sets the window to be opaque or not. An opaque window will draw it's background - * and it's content. A non opaque window will only draw it's content. - * - * @param opaque True if the window should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - /** - * Checks if the window is opaque. - * - * @return True if the window is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque(); - - /** - * Resizes the window to fit the content. - */ - virtual void resizeToContent(); - - // Inherited from BasicContainer - - virtual Rectangle getChildrenArea(); - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - virtual void mouseReleased(MouseEvent& mouseEvent) override; - - protected: - /** - * Holds the caption of the window. - */ - std::string mCaption; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - - /** - * Holds the padding of the window. - */ - unsigned int mPadding; - - /** - * Holds the title bar height of the window. - */ - unsigned int mTitleBarHeight; - - /** - * True if the window is movable, false otherwise. - */ - bool mMovable; - - /** - * True if the window is opaque, false otherwise. - */ - bool mOpaque; - - /** - * Holds a drag offset as an x coordinate where the drag of the window - * started if the window is being dragged. It's used to move the window - * correctly when dragged. - */ - int mDragOffsetX; - - /** - * Holds a drag offset as an y coordinate where the drag of the window - * started if the window is being dragged. It's used to move the window - * correctly when dragged. - */ - int mDragOffsetY; - - /** - * True if the window is being moved, false otherwise. - */ - bool mMoved; - }; -} // namespace gcn - -#endif // end GCN_WINDOW_HPP diff --git a/src/guichan/inputevent.cpp b/src/guichan/inputevent.cpp deleted file mode 100644 index ac7eea5bd..000000000 --- a/src/guichan/inputevent.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/inputevent.hpp" - -#include "debug.h" - -namespace gcn -{ - InputEvent::InputEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed) - :Event(source), - mShiftPressed(shiftPressed), - mControlPressed(controlPressed), - mAltPressed(altPressed), - mMetaPressed(metaPressed), - mIsConsumed(false) - { - } - - bool InputEvent::isShiftPressed() const - { - return mShiftPressed; - } - - bool InputEvent::isControlPressed() const - { - return mControlPressed; - } - - bool InputEvent::isAltPressed() const - { - return mAltPressed; - } - - bool InputEvent::isMetaPressed() const - { - return mMetaPressed; - } - - void InputEvent::consume() - { - mIsConsumed = true; - } - - bool InputEvent::isConsumed() const - { - return mIsConsumed; - } -} // namespace gcn diff --git a/src/guichan/key.cpp b/src/guichan/key.cpp deleted file mode 100644 index 24d817fdb..000000000 --- a/src/guichan/key.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/key.hpp" - -#include "debug.h" - -namespace gcn -{ - Key::Key(const int value) : - mValue(value) - { - } - - bool Key::isCharacter() const - { - return (mValue >= 32 && mValue <= 126) - || (mValue >= 162 && mValue <= 255) - || (mValue == 9); - } - - bool Key::isNumber() const - { - return mValue >= 48 && mValue <= 57; - } - - bool Key::isLetter() const - { - return (((mValue >= 65 && mValue <= 90) - || (mValue >= 97 && mValue <= 122) - || (mValue >= 192 && mValue <= 255)) - && (mValue != 215) && (mValue != 247)); - } - - int Key::getValue() const - { - return mValue; - } - - bool Key::operator==(const Key& key) const - { - return mValue == key.mValue; - } - - bool Key::operator!=(const Key& key) const - { - return (mValue != key.mValue); - } -} // namespace gcn diff --git a/src/guichan/keyevent.cpp b/src/guichan/keyevent.cpp deleted file mode 100644 index 1f325ef1d..000000000 --- a/src/guichan/keyevent.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/keyevent.hpp" - -#include "debug.h" - -namespace gcn -{ - KeyEvent::KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const Key& key) : - InputEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), - mType(type), - mIsNumericPad(numericPad), - mKey(key) - { - } - - KeyEvent::~KeyEvent() - { - } - - unsigned int KeyEvent::getType() const - { - return mType; - } - - bool KeyEvent::isNumericPad() const - { - return mIsNumericPad; - } - - const Key& KeyEvent::getKey() const - { - return mKey; - } -} // namespace gcn diff --git a/src/guichan/keyinput.cpp b/src/guichan/keyinput.cpp deleted file mode 100644 index a18113c8d..000000000 --- a/src/guichan/keyinput.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/keyinput.hpp" - -#include "debug.h" - -namespace gcn -{ - KeyInput::KeyInput(const Key& key, unsigned int type) : - mKey(key), - mType(type), - mShiftPressed(false), - mControlPressed(false), - mAltPressed(false), - mMetaPressed(false), - mNumericPad(false) - { - } - - void KeyInput::setType(unsigned int type) - { - mType = type; - } - - int KeyInput::getType() const - { - return mType; - } - - void KeyInput::setKey(const Key& key) - { - mKey = key; - } - - const Key& KeyInput::getKey() const - { - return mKey; - } - - bool KeyInput::isShiftPressed() const - { - return mShiftPressed; - } - - void KeyInput::setShiftPressed(bool pressed) - { - mShiftPressed = pressed; - } - - bool KeyInput::isControlPressed() const - { - return mControlPressed; - } - - void KeyInput::setControlPressed(bool pressed) - { - mControlPressed = pressed; - } - - bool KeyInput::isAltPressed() const - { - return mAltPressed; - } - - void KeyInput::setAltPressed(bool pressed) - { - mAltPressed = pressed; - } - - bool KeyInput::isMetaPressed() const - { - return mMetaPressed; - } - - void KeyInput::setMetaPressed(bool pressed) - { - mMetaPressed = pressed; - } - - bool KeyInput::isNumericPad() const - { - return mNumericPad; - } - - void KeyInput::setNumericPad(bool numpad) - { - mNumericPad = numpad; - } -} // namespace gcn diff --git a/src/guichan/mouseevent.cpp b/src/guichan/mouseevent.cpp deleted file mode 100644 index c24be1252..000000000 --- a/src/guichan/mouseevent.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/mouseevent.hpp" - -#include "debug.h" - -namespace gcn -{ - MouseEvent::MouseEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const unsigned int button, - const int x, - const int y, - const int clickCount) : - InputEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), - mType(type), - mButton(button), - mX(x), - mY(y), - mClickCount(clickCount) - { - } - - unsigned int MouseEvent::getButton() const - { - return mButton; - } - - int MouseEvent::getX() const - { - return mX; - } - - int MouseEvent::getY() const - { - return mY; - } - - int MouseEvent::getClickCount() const - { - return mClickCount; - } - - unsigned int MouseEvent::getType() const - { - return mType; - } -} // namespace gcn diff --git a/src/guichan/mouseinput.cpp b/src/guichan/mouseinput.cpp deleted file mode 100644 index b13708bb7..000000000 --- a/src/guichan/mouseinput.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - MouseInput::MouseInput(const unsigned int button, - const unsigned int type, - const int x, - const int y, - const int timeStamp) : - mType(type), - mButton(button), - mTimeStamp(timeStamp), - mX(x), - mY(y) - { - } - - void MouseInput::setType(unsigned int type) - { - mType = type; - } - - unsigned int MouseInput::getType() const - { - return mType; - } - - void MouseInput::setButton(unsigned int button) - { - mButton = button; - } - - unsigned int MouseInput::getButton() const - { - return mButton; - } - - int MouseInput::getTimeStamp() const - { - return mTimeStamp; - } - - void MouseInput::setTimeStamp(int timeStamp) - { - mTimeStamp = timeStamp; - } - - void MouseInput::setX(int x) - { - mX = x; - } - - int MouseInput::getX() const - { - return mX; - } - - void MouseInput::setY(int y) - { - mY = y; - } - - int MouseInput::getY() const - { - return mY; - } -} // namespace gcn diff --git a/src/guichan/rectangle.cpp b/src/guichan/rectangle.cpp deleted file mode 100644 index 3aca53a0a..000000000 --- a/src/guichan/rectangle.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/rectangle.hpp" - -#include "debug.h" - -namespace gcn -{ - Rectangle::Rectangle() - : x(0), - y(0), - width(0), - height(0) - { - } - - Rectangle::Rectangle(const int x_, const int y_, - const int width_, const int height_) : - x(x_), - y(y_), - width(width_), - height(height_) - { - } - - void Rectangle::setAll(int x_, int y_, int width_, int height_) - { - x = x_; - y = y_; - width = width_; - height = height_; - } - - bool Rectangle::isIntersecting(const Rectangle& rectangle) const - { - int x_ = x; - int y_ = y; - int width_ = width; - int height_ = height; - - x_ -= rectangle.x; - y_ -= rectangle.y; - - if (x_ < 0) - { - width_ += x_; -// x_ = 0; - } - else if (x_ + width_ > rectangle.width) - { - width_ = rectangle.width - x_; - } - - if (y_ < 0) - { - height_ += y_; -// y_ = 0; - } - else if (y_ + height_ > rectangle.height) - { - height_ = rectangle.height - y_; - } - - if (width_ <= 0 || height_ <= 0) - { - return false; - } - - return true; - } - - bool Rectangle::isPointInRect(int x_, int y_) const - { - return x_ >= x - && y_ >= y - && x_ < x + width - && y_ < y + height; - } - - std::ostream& operator<<(std::ostream& out, - const Rectangle& rectangle) - { - out << "Rectangle [x = " << rectangle.x - << ", y = " << rectangle.y - << ", width = " << rectangle.width - << ", height = " << rectangle.height - << "]"; - - return out; - } -} // namespace gcn diff --git a/src/guichan/selectionevent.cpp b/src/guichan/selectionevent.cpp deleted file mode 100644 index 2606d84ef..000000000 --- a/src/guichan/selectionevent.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/selectionevent.hpp" - -#include "debug.h" - -namespace gcn -{ - SelectionEvent::SelectionEvent(Widget *const source) : - Event(source) - { - } - - SelectionEvent::~SelectionEvent() - { - } -} // namespace gcn diff --git a/src/guichan/widget.cpp b/src/guichan/widget.cpp deleted file mode 100644 index 0cd7883d7..000000000 --- a/src/guichan/widget.cpp +++ /dev/null @@ -1,695 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widget.hpp" - -#include "guichan/actionevent.hpp" -#include "guichan/actionlistener.hpp" -#include "guichan/basiccontainer.hpp" -#include "guichan/deathlistener.hpp" -#include "guichan/event.hpp" -#include "guichan/exception.hpp" -#include "guichan/focushandler.hpp" -#include "guichan/graphics.hpp" -#include "guichan/keyinput.hpp" -#include "guichan/keylistener.hpp" -#include "guichan/mouseinput.hpp" -#include "guichan/mouselistener.hpp" -#include "guichan/widgetlistener.hpp" - -#include "debug.h" - -namespace gcn -{ - Font* Widget::mGlobalFont = nullptr; - std::list Widget::mWidgets; - std::set Widget::mWidgetsSet; - - Widget::Widget() : - mMouseListeners(), - mKeyListeners(), - mActionListeners(), - mDeathListeners(), - mFocusListeners(), - mWidgetListeners(), - mForegroundColor(0x000000), - mBackgroundColor(0xffffff), - mBaseColor(0x808090), - mSelectionColor(0xc3d9ff), - mFocusHandler(nullptr), - mInternalFocusHandler(nullptr), - mParent(nullptr), - mDimension(), - mFrameSize(0), - mActionEventId(), - mFocusable(false), - mVisible(true), - mTabIn(true), - mTabOut(true), - mEnabled(true), - mId(), - mCurrentFont(nullptr) - { - mWidgets.push_back(this); - mWidgetsSet.insert(this); - } - - Widget::~Widget() - { - for (DeathListenerIterator iter = mDeathListeners.begin(); - iter != mDeathListeners.end(); - ++iter) - { - Event event(this); - (*iter)->death(event); - } - - _setFocusHandler(nullptr); - - mWidgets.remove(this); - mWidgetsSet.erase(this); - } - - void Widget::drawFrame(Graphics* graphics) - { - BLOCK_START("Widget::drawFrame") - const Color &faceColor = getBaseColor(); - Color highlightColor = faceColor + Color(0x303030); - Color shadowColor = faceColor - Color(0x303030); - const int alpha = getBaseColor().a; - const int width = getWidth() + getFrameSize() * 2 - 1; - const int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor.a = alpha; - shadowColor.a = alpha; - - for (unsigned int i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - BLOCK_END("Widget::drawFrame") - } - - void Widget::_setParent(Widget* parent) - { - mParent = parent; - } - - void Widget::setWidth(int width) - { - Rectangle newDimension = mDimension; - newDimension.width = width; - - setDimension(newDimension); - } - - void Widget::setHeight(int height) - { - Rectangle newDimension = mDimension; - newDimension.height = height; - - setDimension(newDimension); - } - - void Widget::setX(int x) - { - Rectangle newDimension = mDimension; - newDimension.x = x; - - setDimension(newDimension); - } - - void Widget::setY(int y) - { - Rectangle newDimension = mDimension; - newDimension.y = y; - - setDimension(newDimension); - } - - void Widget::setPosition(int x, int y) - { - Rectangle newDimension = mDimension; - newDimension.x = x; - newDimension.y = y; - - setDimension(newDimension); - } - - void Widget::setDimension(const Rectangle& dimension) - { - const Rectangle oldDimension = mDimension; - mDimension = dimension; - - if (mDimension.width != oldDimension.width - || mDimension.height != oldDimension.height) - { - distributeResizedEvent(); - } - - if (mDimension.x != oldDimension.x - || mDimension.y != oldDimension.y) - { - distributeMovedEvent(); - } - } - - void Widget::setFrameSize(unsigned int frameSize) - { - mFrameSize = frameSize; - } - - unsigned int Widget::getFrameSize() const - { - return mFrameSize; - } - - const Rectangle& Widget::getDimension() const - { - return mDimension; - } - - const std::string& Widget::getActionEventId() const - { - return mActionEventId; - } - - void Widget::setActionEventId(const std::string& actionEventId) - { - mActionEventId = actionEventId; - } - - bool Widget::isFocused() const - { - if (!mFocusHandler) - return false; - - return (mFocusHandler->isFocused(this)); - } - - void Widget::setFocusable(bool focusable) - { - if (!focusable && isFocused()) - { - mFocusHandler->focusNone(); - } - - mFocusable = focusable; - } - - bool Widget::isFocusable() const - { - return mFocusable && isVisible() && isEnabled(); - } - - void Widget::requestFocus() - { - if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } - - if (isFocusable()) - mFocusHandler->requestFocus(this); - } - - void Widget::requestMoveToTop() - { - if (mParent) - mParent->moveToTop(this); - } - - void Widget::requestMoveToBottom() - { - if (mParent) - mParent->moveToBottom(this); - } - - void Widget::setVisible(bool visible) - { - if (!visible && isFocused()) - mFocusHandler->focusNone(); - - if (visible) - distributeShownEvent(); - else - distributeHiddenEvent(); - - mVisible = visible; - } - - void Widget::setBaseColor(const Color& color) - { - mBaseColor = color; - } - - const Color& Widget::getBaseColor() const - { - return mBaseColor; - } - - void Widget::setForegroundColor(const Color& color) - { - mForegroundColor = color; - } - - const Color& Widget::getForegroundColor() const - { - return mForegroundColor; - } - - void Widget::setBackgroundColor(const Color& color) - { - mBackgroundColor = color; - } - - const Color& Widget::getBackgroundColor() const - { - return mBackgroundColor; - } - - void Widget::setSelectionColor(const Color& color) - { - mSelectionColor = color; - } - - const Color& Widget::getSelectionColor() const - { - return mSelectionColor; - } - - void Widget::_setFocusHandler(FocusHandler* focusHandler) - { - if (mFocusHandler) - { - releaseModalFocus(); - mFocusHandler->remove(this); - } - - if (focusHandler) - focusHandler->add(this); - - mFocusHandler = focusHandler; - } - - FocusHandler* Widget::_getFocusHandler() - { - return mFocusHandler; - } - - void Widget::addActionListener(ActionListener* actionListener) - { - mActionListeners.push_back(actionListener); - } - - void Widget::removeActionListener(ActionListener* actionListener) - { - mActionListeners.remove(actionListener); - } - - void Widget::addDeathListener(DeathListener* deathListener) - { - mDeathListeners.push_back(deathListener); - } - - void Widget::removeDeathListener(DeathListener* deathListener) - { - mDeathListeners.remove(deathListener); - } - - void Widget::addKeyListener(KeyListener* keyListener) - { - mKeyListeners.push_back(keyListener); - } - - void Widget::removeKeyListener(KeyListener* keyListener) - { - mKeyListeners.remove(keyListener); - } - - void Widget::addFocusListener(FocusListener* focusListener) - { - mFocusListeners.push_back(focusListener); - } - - void Widget::removeFocusListener(FocusListener* focusListener) - { - mFocusListeners.remove(focusListener); - } - - void Widget::addMouseListener(MouseListener* mouseListener) - { - mMouseListeners.push_back(mouseListener); - } - - void Widget::removeMouseListener(MouseListener* mouseListener) - { - mMouseListeners.remove(mouseListener); - } - - void Widget::addWidgetListener(WidgetListener* widgetListener) - { - mWidgetListeners.push_back(widgetListener); - } - - void Widget::removeWidgetListener(WidgetListener* widgetListener) - { - mWidgetListeners.remove(widgetListener); - } - - void Widget::getAbsolutePosition(int& x, int& y) const - { - if (!mParent) - { - x = mDimension.x; - y = mDimension.y; - return; - } - - int parentX; - int parentY; - - mParent->getAbsolutePosition(parentX, parentY); - - const Rectangle &rect = mParent->getChildrenArea(); - x = parentX + mDimension.x + rect.x; - y = parentY + mDimension.y + rect.y; - } - - Font* Widget::getFont() const - { - if (!mCurrentFont) - return mGlobalFont; - return mCurrentFont; - } - - void Widget::setGlobalFont(Font* font) - { - mGlobalFont = font; - - for (std::list::const_iterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++iter) - { - if (!(*iter)->mCurrentFont) - (*iter)->fontChanged(); - } - } - - void Widget::setFont(Font* font) - { - mCurrentFont = font; - fontChanged(); - } - - bool Widget::widgetExists(const Widget* widget) - { - return mWidgetsSet.find(const_cast(widget)) - != mWidgetsSet.end(); - } - - bool Widget::isTabInEnabled() const - { - return mTabIn; - } - - void Widget::setTabInEnabled(bool enabled) - { - mTabIn = enabled; - } - - bool Widget::isTabOutEnabled() const - { - return mTabOut; - } - - void Widget::setTabOutEnabled(bool enabled) - { - mTabOut = enabled; - } - - void Widget::setSize(int width, int height) - { - Rectangle newDimension = mDimension; - newDimension.width = width; - newDimension.height = height; - - setDimension(newDimension); - } - - void Widget::setEnabled(bool enabled) - { - mEnabled = enabled; - } - - bool Widget::isEnabled() const - { - return mEnabled && isVisible(); - } - - void Widget::requestModalFocus() - { - if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } - - mFocusHandler->requestModalFocus(this); - } - - void Widget::requestModalMouseInputFocus() - { - if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } - - mFocusHandler->requestModalMouseInputFocus(this); - } - - void Widget::releaseModalFocus() - { - if (!mFocusHandler) - return; - - mFocusHandler->releaseModalFocus(this); - } - - void Widget::releaseModalMouseInputFocus() - { - if (!mFocusHandler) - return; - - mFocusHandler->releaseModalMouseInputFocus(this); - } - - bool Widget::isModalFocused() const - { - if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } - - if (mParent) - { - return (mFocusHandler->getModalFocused() == this) - || mParent->isModalFocused(); - } - - return mFocusHandler->getModalFocused() == this; - } - - bool Widget::isModalMouseInputFocused() const - { - if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } - - if (mParent) - { - return (mFocusHandler->getModalMouseInputFocused() == this) - || mParent->isModalMouseInputFocused(); - } - - return mFocusHandler->getModalMouseInputFocused() == this; - } - - Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED) - { - return nullptr; - } - - const std::list& Widget::_getMouseListeners() - { - return mMouseListeners; - } - - const std::list& Widget::_getKeyListeners() - { - return mKeyListeners; - } - - const std::list& Widget::_getFocusListeners() - { - return mFocusListeners; - } - - Rectangle Widget::getChildrenArea() - { - return Rectangle(0, 0, 0, 0); - } - - FocusHandler* Widget::_getInternalFocusHandler() - { - return mInternalFocusHandler; - } - - void Widget::setInternalFocusHandler(FocusHandler* focusHandler) - { - mInternalFocusHandler = focusHandler; - } - - void Widget::setId(const std::string& id) - { - mId = id; - } - - const std::string& Widget::getId() - { - return mId; - } - - void Widget::distributeResizedEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++ iter) - { - Event event(this); - (*iter)->widgetResized(event); - } - } - - void Widget::distributeMovedEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++ iter) - { - Event event(this); - (*iter)->widgetMoved(event); - } - } - - void Widget::distributeHiddenEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++ iter) - { - Event event(this); - (*iter)->widgetHidden(event); - } - } - - void Widget::distributeActionEvent() - { - for (ActionListenerIterator iter = mActionListeners.begin(); - iter != mActionListeners.end(); - ++iter) - { - ActionEvent actionEvent(this, mActionEventId); - (*iter)->action(actionEvent); - } - } - - void Widget::distributeShownEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++iter) - { - Event event(this); - (*iter)->widgetShown(event); - } - } - - void Widget::showPart(Rectangle rectangle) - { - if (mParent) - mParent->showWidgetPart(this, rectangle); - } -} // namespace gcn diff --git a/src/guichan/widgets/button.cpp b/src/guichan/widgets/button.cpp deleted file mode 100644 index 1226e157a..000000000 --- a/src/guichan/widgets/button.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/button.hpp" - -#include "guichan/exception.hpp" -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/mouseevent.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - Button::Button() : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - gcn::FocusListener(), - mCaption(), - mHasMouse(false), - mKeyPressed(false), - mMousePressed(false), - mAlignment(Graphics::CENTER), - mSpacing(4) - { - setFocusable(true); - adjustSize(); - setFrameSize(1); - - addMouseListener(this); - addKeyListener(this); - addFocusListener(this); - } - - Button::Button(const std::string& caption) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - gcn::FocusListener(), - mCaption(caption), - mHasMouse(false), - mKeyPressed(false), - mMousePressed(false), - mAlignment(Graphics::CENTER), - mSpacing(4) - { - setFocusable(true); - adjustSize(); - setFrameSize(1); - - addMouseListener(this); - addKeyListener(this); - addFocusListener(this); - } - - void Button::setCaption(const std::string& caption) - { - mCaption = caption; - } - - const std::string& Button::getCaption() const - { - return mCaption; - } - - void Button::setAlignment(Graphics::Alignment alignment) - { - mAlignment = alignment; - } - - Graphics::Alignment Button::getAlignment() const - { - return mAlignment; - } - - void Button::setSpacing(unsigned int spacing) - { - mSpacing = spacing; - } - - unsigned int Button::getSpacing() const - { - return mSpacing; - } - - void Button::adjustSize() - { - } - - bool Button::isPressed() const - { - if (mMousePressed) - return mHasMouse; - else - return mKeyPressed; - } - - void Button::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - mMousePressed = true; - mouseEvent.consume(); - } - } - - void Button::mouseExited(MouseEvent& mouseEvent A_UNUSED) - { - mHasMouse = false; - } - - void Button::mouseEntered(MouseEvent& mouseEvent A_UNUSED) - { - mHasMouse = true; - } - - void Button::mouseDragged(MouseEvent& mouseEvent) - { - mouseEvent.consume(); - } - - void Button::focusLost(const Event& event A_UNUSED) - { - mMousePressed = false; - mKeyPressed = false; - } -} // namespace gcn diff --git a/src/guichan/widgets/checkbox.cpp b/src/guichan/widgets/checkbox.cpp deleted file mode 100644 index 4b3c7b966..000000000 --- a/src/guichan/widgets/checkbox.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/checkbox.hpp" - -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - - CheckBox::CheckBox() : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mSelected(false), - mCaption() - { - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - } - - CheckBox::CheckBox(const std::string &caption, bool selected) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mSelected(selected), - mCaption() - { - setCaption(caption); - - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - - adjustSize(); - } - - bool CheckBox::isSelected() const - { - return mSelected; - } - - void CheckBox::setSelected(bool selected) - { - mSelected = selected; - } - - const std::string &CheckBox::getCaption() const - { - return mCaption; - } - - void CheckBox::setCaption(const std::string& caption) - { - mCaption = caption; - } - - void CheckBox::keyPressed(KeyEvent& keyEvent A_UNUSED) - { - } - - void CheckBox::mouseClicked(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - toggleSelected(); - } - } - - void CheckBox::mouseDragged(MouseEvent& mouseEvent) - { - mouseEvent.consume(); - } - - void CheckBox::adjustSize() - { - } - - void CheckBox::toggleSelected() - { - mSelected = !mSelected; - distributeActionEvent(); - } -} // namespace gcn diff --git a/src/guichan/widgets/container.cpp b/src/guichan/widgets/container.cpp deleted file mode 100644 index 7ea07e529..000000000 --- a/src/guichan/widgets/container.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/container.hpp" - -#include "guichan/exception.hpp" -#include "guichan/graphics.hpp" - -#include "debug.h" - -namespace gcn -{ - - Container::Container() : - BasicContainer(), - mOpaque(true) - { - } - - Container::~Container() - { - } - - void Container::draw(Graphics* graphics) - { - BLOCK_START("Container::draw") - if (isOpaque()) - { - graphics->setColor(getBaseColor()); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); - } - - drawChildren(graphics); - BLOCK_END("Container::draw") - } - - void Container::setOpaque(bool opaque) - { - mOpaque = opaque; - } - - bool Container::isOpaque() const - { - return mOpaque; - } - - void Container::add(Widget* widget) - { - BasicContainer::add(widget); - } - - void Container::add(Widget* widget, int x, int y) - { - widget->setPosition(x, y); - BasicContainer::add(widget); - } - - void Container::remove(Widget* widget) - { - BasicContainer::remove(widget); - } - - void Container::clear() - { - BasicContainer::clear(); - } - - Widget* Container::findWidgetById(const std::string &id) - { - return BasicContainer::findWidgetById(id); - } -} // namespace gcn diff --git a/src/guichan/widgets/label.cpp b/src/guichan/widgets/label.cpp deleted file mode 100644 index 92962e907..000000000 --- a/src/guichan/widgets/label.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/label.hpp" - -#include "guichan/exception.hpp" -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" - -#include "debug.h" - -namespace gcn -{ - Label::Label() : - gcn::Widget(), - mCaption(), - mAlignment(Graphics::LEFT) - { - } - - Label::Label(const std::string& caption) : - gcn::Widget(), - mCaption(caption), - mAlignment(Graphics::LEFT) - { - setWidth(getFont()->getWidth(caption)); - setHeight(getFont()->getHeight()); - } - - const std::string &Label::getCaption() const - { - return mCaption; - } - - void Label::setCaption(const std::string& caption) - { - mCaption = caption; - } - - void Label::setAlignment(Graphics::Alignment alignment) - { - mAlignment = alignment; - } - - Graphics::Alignment Label::getAlignment() const - { - return mAlignment; - } - - void Label::draw(Graphics* graphics A_UNUSED) - { - } - - void Label::adjustSize() - { - } -} // namespace gcn diff --git a/src/guichan/widgets/listbox.cpp b/src/guichan/widgets/listbox.cpp deleted file mode 100644 index 9122e8cc8..000000000 --- a/src/guichan/widgets/listbox.cpp +++ /dev/null @@ -1,241 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/listbox.hpp" - -#include "guichan/basiccontainer.hpp" -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/listmodel.hpp" -#include "guichan/mouseinput.hpp" -#include "guichan/selectionlistener.hpp" - -#include "debug.h" - -namespace gcn -{ - ListBox::ListBox() : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mSelected(-1), - mListModel(nullptr), - mWrappingEnabled(false), - mSelectionListeners() - { - setWidth(100); - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - } - - ListBox::ListBox(ListModel *listModel) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mSelected(-1), - mListModel(listModel), - mWrappingEnabled(false), - mSelectionListeners() - { - setWidth(100); - adjustSize(); - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - } - - void ListBox::draw(Graphics* graphics A_UNUSED) - { - } - - void ListBox::logic() - { - } - - int ListBox::getSelected() const - { - return mSelected; - } - - void ListBox::setSelected(int selected) - { - if (!mListModel) - { - mSelected = -1; - } - else - { - if (selected < 0) - mSelected = -1; - else if (selected >= mListModel->getNumberOfElements()) - mSelected = mListModel->getNumberOfElements() - 1; - else - mSelected = selected; - } - - Rectangle scroll; - - if (mSelected < 0) - scroll.y = 0; - else - scroll.y = getRowHeight() * mSelected; - - scroll.height = getRowHeight(); - showPart(scroll); - - distributeValueChangedEvent(); - } - - void ListBox::keyPressed(KeyEvent &keyEvent A_UNUSED) - { - } - - void ListBox::mousePressed(MouseEvent &mouseEvent A_UNUSED) - { - } - - void ListBox::mouseWheelMovedUp(MouseEvent& mouseEvent) - { - if (isFocused()) - { - if (getSelected() > 0 ) - setSelected(getSelected() - 1); - - mouseEvent.consume(); - } - } - - void ListBox::mouseWheelMovedDown(MouseEvent& mouseEvent) - { - if (isFocused()) - { - setSelected(getSelected() + 1); - - mouseEvent.consume(); - } - } - - void ListBox::mouseDragged(MouseEvent& mouseEvent) - { - mouseEvent.consume(); - } - - void ListBox::setListModel(ListModel *listModel) - { - mSelected = -1; - mListModel = listModel; - adjustSize(); - } - - ListModel* ListBox::getListModel() - { - return mListModel; - } - - void ListBox::adjustSize() - { - } - - bool ListBox::isWrappingEnabled() const - { - return mWrappingEnabled; - } - - void ListBox::setWrappingEnabled(bool wrappingEnabled) - { - mWrappingEnabled = wrappingEnabled; - } - - void ListBox::addSelectionListener(SelectionListener* selectionListener) - { - mSelectionListeners.push_back(selectionListener); - } - - void ListBox::removeSelectionListener(SelectionListener* selectionListener) - { - mSelectionListeners.remove(selectionListener); - } - - void ListBox::distributeValueChangedEvent() - { - for (SelectionListenerIterator iter = mSelectionListeners.begin(); - iter != mSelectionListeners.end(); - ++ iter) - { - SelectionEvent event(this); - (*iter)->valueChanged(event); - } - } - - unsigned int ListBox::getRowHeight() const - { - return getFont()->getHeight(); - } -} // namespace gcn diff --git a/src/guichan/widgets/radiobutton.cpp b/src/guichan/widgets/radiobutton.cpp deleted file mode 100644 index 26ce731ed..000000000 --- a/src/guichan/widgets/radiobutton.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/radiobutton.hpp" - -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - RadioButton::GroupMap RadioButton::mGroupMap; - - RadioButton::RadioButton() : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mSelected(false), - mCaption(), - mGroup() - { - setSelected(false); - - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - } - - RadioButton::RadioButton(const std::string &caption, - const std::string &group, - bool selected) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mSelected(false), - mCaption(), - mGroup() - { - setCaption(caption); - setGroup(group); - setSelected(selected); - - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - - adjustSize(); - } - - RadioButton::~RadioButton() - { - // Remove us from the group list - setGroup(""); - } - - bool RadioButton::isSelected() const - { - return mSelected; - } - - void RadioButton::setSelected(bool selected) - { - if (selected && mGroup != "") - { - for (GroupIterator iter = mGroupMap.lower_bound(mGroup), - iterEnd = mGroupMap.upper_bound(mGroup); - iter != iterEnd; - ++ iter) - { - if (iter->second->isSelected()) - iter->second->setSelected(false); - } - } - - mSelected = selected; - } - - const std::string &RadioButton::getCaption() const - { - return mCaption; - } - - void RadioButton::setCaption(const std::string &caption) - { - mCaption = caption; - } - - void RadioButton::keyPressed(KeyEvent& keyEvent A_UNUSED) - { - } - - void RadioButton::mouseClicked(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - setSelected(true); - distributeActionEvent(); - } - } - - void RadioButton::mouseDragged(MouseEvent& mouseEvent) - { - mouseEvent.consume(); - } - - void RadioButton::setGroup(const std::string &group) - { - if (mGroup != "") - { - for (GroupIterator iter = mGroupMap.lower_bound(mGroup), - iterEnd = mGroupMap.upper_bound(mGroup); - iter != iterEnd; - ++ iter) - { - if (iter->second == this) - { - mGroupMap.erase(iter); - break; - } - } - } - - if (group != "") - { - mGroupMap.insert( - std::pair(group, this)); - } - - mGroup = group; - } - - const std::string &RadioButton::getGroup() const - { - return mGroup; - } - - void RadioButton::adjustSize() - { - } -} // namespace gcn diff --git a/src/guichan/widgets/scrollarea.cpp b/src/guichan/widgets/scrollarea.cpp deleted file mode 100644 index ddc4405e2..000000000 --- a/src/guichan/widgets/scrollarea.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/scrollarea.hpp" - -#include "guichan/exception.hpp" -#include "guichan/graphics.hpp" - -#include "debug.h" - -namespace gcn -{ - ScrollArea::ScrollArea() : - gcn::BasicContainer(), - gcn::MouseListener(), - mVScroll(0), - mHScroll(0), - mScrollbarWidth(12), - mHPolicy(SHOW_AUTO), - mVPolicy(SHOW_AUTO), - mVBarVisible(false), - mHBarVisible(false), - mUpButtonPressed(false), - mDownButtonPressed(false), - mLeftButtonPressed(false), - mRightButtonPressed(false), - mUpButtonScrollAmount(10), - mDownButtonScrollAmount(10), - mLeftButtonScrollAmount(10), - mRightButtonScrollAmount(10), - mIsVerticalMarkerDragged(false), - mIsHorizontalMarkerDragged(false), - mHorizontalMarkerDragOffset(0), - mVerticalMarkerDragOffset(0), - mOpaque(true) - { - addMouseListener(this); - } - - ScrollArea::ScrollArea(Widget *const content) : - gcn::BasicContainer(), - gcn::MouseListener(), - mVScroll(0), - mHScroll(0), - mScrollbarWidth(12), - mHPolicy(SHOW_AUTO), - mVPolicy(SHOW_AUTO), - mVBarVisible(false), - mHBarVisible(false), - mUpButtonPressed(false), - mDownButtonPressed(false), - mLeftButtonPressed(false), - mRightButtonPressed(false), - mUpButtonScrollAmount(10), - mDownButtonScrollAmount(10), - mLeftButtonScrollAmount(10), - mRightButtonScrollAmount(10), - mIsVerticalMarkerDragged(false), - mIsHorizontalMarkerDragged(false), - mHorizontalMarkerDragOffset(0), - mVerticalMarkerDragOffset(0), - mOpaque(true) - { - setContent(content); - addMouseListener(this); - } - - ScrollArea::ScrollArea(Widget *content, - ScrollPolicy hPolicy, - ScrollPolicy vPolicy) : - gcn::BasicContainer(), - gcn::MouseListener(), - mVScroll(0), - mHScroll(0), - mScrollbarWidth(12), - mHPolicy(hPolicy), - mVPolicy(vPolicy), - mVBarVisible(false), - mHBarVisible(false), - mUpButtonPressed(false), - mDownButtonPressed(false), - mLeftButtonPressed(false), - mRightButtonPressed(false), - mUpButtonScrollAmount(10), - mDownButtonScrollAmount(10), - mLeftButtonScrollAmount(10), - mRightButtonScrollAmount(10), - mIsVerticalMarkerDragged(false), - mIsHorizontalMarkerDragged(false), - mHorizontalMarkerDragOffset(0), - mVerticalMarkerDragOffset(0), - mOpaque(true) - { - setContent(content); - addMouseListener(this); - } - - ScrollArea::~ScrollArea() - { - setContent(nullptr); - } - - void ScrollArea::setContent(Widget* widget) - { - if (widget) - { - clear(); - add(widget); - widget->setPosition(0, 0); - } - else - { - clear(); - } - - checkPolicies(); - } - - Widget* ScrollArea::getContent() - { - if (!mWidgets.empty()) - return *mWidgets.begin(); - - return nullptr; - } - - void ScrollArea::setHorizontalScrollPolicy(ScrollPolicy hPolicy) - { - mHPolicy = hPolicy; - checkPolicies(); - } - - ScrollArea::ScrollPolicy ScrollArea::getHorizontalScrollPolicy() const - { - return mHPolicy; - } - - void ScrollArea::setVerticalScrollPolicy(ScrollPolicy vPolicy) - { - mVPolicy = vPolicy; - checkPolicies(); - } - - ScrollArea::ScrollPolicy ScrollArea::getVerticalScrollPolicy() const - { - return mVPolicy; - } - - void ScrollArea::setScrollPolicy(ScrollPolicy hPolicy, - ScrollPolicy vPolicy) - { - mHPolicy = hPolicy; - mVPolicy = vPolicy; - checkPolicies(); - } - - void ScrollArea::setVerticalScrollAmount(int vScroll) - { - const int max = getVerticalMaxScroll(); - - mVScroll = vScroll; - - if (vScroll > max) - mVScroll = max; - - if (vScroll < 0) - mVScroll = 0; - } - - int ScrollArea::getVerticalScrollAmount() const - { - return mVScroll; - } - - void ScrollArea::setHorizontalScrollAmount(int hScroll) - { - const int max = getHorizontalMaxScroll(); - - mHScroll = hScroll; - - if (hScroll > max) - mHScroll = max; - else if (hScroll < 0) - mHScroll = 0; - } - - int ScrollArea::getHorizontalScrollAmount() const - { - return mHScroll; - } - - void ScrollArea::setScrollAmount(int hScroll, int vScroll) - { - setHorizontalScrollAmount(hScroll); - setVerticalScrollAmount(vScroll); - } - - int ScrollArea::getHorizontalMaxScroll() - { - checkPolicies(); - - const Widget *const content = getContent(); - if (!content) - return 0; - - const int value = content->getWidth() - getChildrenArea().width + - 2 * content->getFrameSize(); - - if (value < 0) - return 0; - - return value; - } - - int ScrollArea::getVerticalMaxScroll() - { - checkPolicies(); - - const Widget *const content = getContent(); - if (!content) - return 0; - - int value; - - value = content->getHeight() - getChildrenArea().height + - 2 * content->getFrameSize(); - - if (value < 0) - return 0; - - return value; - } - - void ScrollArea::setScrollbarWidth(int width) - { - if (width > 0) - mScrollbarWidth = width; - else - throw GCN_EXCEPTION("Width should be greater then 0."); - } - - int ScrollArea::getScrollbarWidth() const - { - return mScrollbarWidth; - } - - void ScrollArea::mouseReleased(MouseEvent& mouseEvent) - { - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mIsHorizontalMarkerDragged = false; - mIsVerticalMarkerDragged = false; - - mouseEvent.consume(); - } - - void ScrollArea::draw(Graphics *graphics A_UNUSED) - { - } - - void ScrollArea::drawHBar(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawVBar(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawBackground(Graphics *graphics A_UNUSED) - { - } - - void ScrollArea::drawUpButton(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawDownButton(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawLeftButton(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawRightButton(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawVMarker(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::drawHMarker(Graphics* graphics A_UNUSED) - { - } - - void ScrollArea::logic() - { - BLOCK_START("ScrollArea::logic") - checkPolicies(); - - setVerticalScrollAmount(getVerticalScrollAmount()); - setHorizontalScrollAmount(getHorizontalScrollAmount()); - - Widget *const content = getContent(); - if (content) - { - const int frameSize = content->getFrameSize(); - content->setPosition(-mHScroll + frameSize, -mVScroll + frameSize); - content->logic(); - } - BLOCK_END("ScrollArea::logic") - } - - void ScrollArea::checkPolicies() - { - const int w = getWidth(); - const int h = getHeight(); - - mHBarVisible = false; - mVBarVisible = false; - - const Widget *const content = getContent(); - if (!content) - { - mHBarVisible = (mHPolicy == SHOW_ALWAYS); - mVBarVisible = (mVPolicy == SHOW_ALWAYS); - return; - } - - if (mHPolicy == SHOW_AUTO && - mVPolicy == SHOW_AUTO) - { - if (content->getWidth() <= w - && content->getHeight() <= h) - { - mHBarVisible = false; - mVBarVisible = false; - } - - if (content->getWidth() > w) - { - mHBarVisible = true; - } - - if ((content->getHeight() > h) - || (mHBarVisible && content->getHeight() - > h - mScrollbarWidth)) - { - mVBarVisible = true; - } - - if (mVBarVisible && content->getWidth() > w - mScrollbarWidth) - mHBarVisible = true; - - return; - } - - switch (mHPolicy) - { - case SHOW_NEVER: - mHBarVisible = false; - break; - - case SHOW_ALWAYS: - mHBarVisible = true; - break; - - case SHOW_AUTO: - if (mVPolicy == SHOW_NEVER) - { - mHBarVisible = (content->getWidth() > w); - } - else // (mVPolicy == SHOW_ALWAYS) - { - mHBarVisible = (content->getWidth() - > w - mScrollbarWidth); - } - break; - - default: - throw GCN_EXCEPTION("Horizontal scroll policy invalid."); - } - - switch (mVPolicy) - { - case SHOW_NEVER: - mVBarVisible = false; - break; - - case SHOW_ALWAYS: - mVBarVisible = true; - break; - - case SHOW_AUTO: - if (mHPolicy == SHOW_NEVER) - { - mVBarVisible = (content->getHeight() > h); - } - else // (mHPolicy == SHOW_ALWAYS) - { - mVBarVisible = (content->getHeight() - > h - mScrollbarWidth); - } - break; - default: - throw GCN_EXCEPTION("Vertical scroll policy invalid."); - } - } - - Rectangle ScrollArea::getChildrenArea() - { - const Rectangle area = Rectangle(0, 0, - mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(), - mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight()); - - if (area.width < 0 || area.height < 0) - return Rectangle(); - - return area; - } - - void ScrollArea::showWidgetPart(Widget* widget, Rectangle area) - { - const Widget *const content = getContent(); - if (widget != content) - throw GCN_EXCEPTION("Widget not content widget"); - - BasicContainer::showWidgetPart(widget, area); - - setHorizontalScrollAmount(content->getFrameSize() - - content->getX()); - setVerticalScrollAmount(content->getFrameSize() - - content->getY()); - } - - Widget *ScrollArea::getWidgetAt(int x, int y) - { - if (getChildrenArea().isPointInRect(x, y)) - return getContent(); - - return nullptr; - } - - void ScrollArea::mouseWheelMovedUp(MouseEvent& mouseEvent) - { - if (mouseEvent.isConsumed()) - return; - - setVerticalScrollAmount(getVerticalScrollAmount() - - getChildrenArea().height / 8); - - mouseEvent.consume(); - } - - void ScrollArea::mouseWheelMovedDown(MouseEvent& mouseEvent) - { - if (mouseEvent.isConsumed()) - return; - - setVerticalScrollAmount(getVerticalScrollAmount() - + getChildrenArea().height / 8); - - mouseEvent.consume(); - } - - void ScrollArea::setWidth(int width) - { - Widget::setWidth(width); - checkPolicies(); - } - - void ScrollArea::setHeight(int height) - { - Widget::setHeight(height); - checkPolicies(); - } - - void ScrollArea::setDimension(const Rectangle& dimension) - { - Widget::setDimension(dimension); - checkPolicies(); - } - - void ScrollArea::setLeftButtonScrollAmount(int amount) - { - mLeftButtonScrollAmount = amount; - } - - void ScrollArea::setRightButtonScrollAmount(int amount) - { - mRightButtonScrollAmount = amount; - } - - void ScrollArea::setUpButtonScrollAmount(int amount) - { - mUpButtonScrollAmount = amount; - } - - void ScrollArea::setDownButtonScrollAmount(int amount) - { - mDownButtonScrollAmount = amount; - } - - int ScrollArea::getLeftButtonScrollAmount() const - { - return mLeftButtonScrollAmount; - } - - int ScrollArea::getRightButtonScrollAmount() const - { - return mRightButtonScrollAmount; - } - - int ScrollArea::getUpButtonScrollAmount() const - { - return mUpButtonScrollAmount; - } - - int ScrollArea::getDownButtonScrollAmount() const - { - return mDownButtonScrollAmount; - } - - void ScrollArea::setOpaque(bool opaque) - { - mOpaque = opaque; - } - - bool ScrollArea::isOpaque() const - { - return mOpaque; - } -} // namespace gcn diff --git a/src/guichan/widgets/slider.cpp b/src/guichan/widgets/slider.cpp deleted file mode 100644 index 849101fd8..000000000 --- a/src/guichan/widgets/slider.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/slider.hpp" - -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - Slider::Slider(const double scaleEnd) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mDragged(false), - mValue(0), - mStepLength(scaleEnd / 10), - mMarkerLength(10), - mScaleStart(0), - mScaleEnd(scaleEnd), - mOrientation(HORIZONTAL) - { - setFocusable(true); - setFrameSize(1); - - addMouseListener(this); - addKeyListener(this); - } - - Slider::Slider(const double scaleStart, const double scaleEnd) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mDragged(false), - mValue(scaleStart), - mStepLength((scaleEnd - scaleStart) / 10), - mMarkerLength(10), - mScaleStart(scaleStart), - mScaleEnd(scaleEnd), - mOrientation(HORIZONTAL) - { - setFocusable(true); - setFrameSize(1); - - addMouseListener(this); - addKeyListener(this); - } - - void Slider::setScale(double scaleStart, double scaleEnd) - { - mScaleStart = scaleStart; - mScaleEnd = scaleEnd; - } - - double Slider::getScaleStart() const - { - return mScaleStart; - } - - void Slider::setScaleStart(double scaleStart) - { - mScaleStart = scaleStart; - } - - double Slider::getScaleEnd() const - { - return mScaleEnd; - } - - void Slider::setScaleEnd(double scaleEnd) - { - mScaleEnd = scaleEnd; - } - - void Slider::setValue(double value) - { - if (value > getScaleEnd()) - { - mValue = getScaleEnd(); - return; - } - - if (value < getScaleStart()) - { - mValue = getScaleStart(); - return; - } - - mValue = value; - } - - double Slider::getValue() const - { - return mValue; - } - - int Slider::getMarkerLength() const - { - return mMarkerLength; - } - - void Slider::setMarkerLength(int length) - { - mMarkerLength = length; - } - - void Slider::setOrientation(Slider::Orientation orientation) - { - mOrientation = orientation; - } - - Slider::Orientation Slider::getOrientation() const - { - return mOrientation; - } - - double Slider::markerPositionToValue(int v) const - { - int w; - if (getOrientation() == HORIZONTAL) - w = getWidth(); - else - w = getHeight(); - - const double pos = v / (static_cast(w) - getMarkerLength()); - return (1.0 - pos) * getScaleStart() + pos * getScaleEnd(); - } - - int Slider::valueToMarkerPosition(double value) const - { - int v; - if (getOrientation() == HORIZONTAL) - v = getWidth(); - else - v = getHeight(); - - const int w = static_cast((v - getMarkerLength()) - * (value - getScaleStart()) - / (getScaleEnd() - getScaleStart())); - - if (w < 0) - return 0; - - if (w > v - getMarkerLength()) - return v - getMarkerLength(); - - return w; - } - - void Slider::setStepLength(double length) - { - mStepLength = length; - } - - double Slider::getStepLength() const - { - return mStepLength; - } - - int Slider::getMarkerPosition() const - { - return valueToMarkerPosition(getValue()); - } -} // namespace gcn diff --git a/src/guichan/widgets/textbox.cpp b/src/guichan/widgets/textbox.cpp deleted file mode 100644 index e3bfd39f5..000000000 --- a/src/guichan/widgets/textbox.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/textbox.hpp" - -#include "guichan/basiccontainer.hpp" -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - TextBox::TextBox() : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mTextRows(), - mCaretColumn(0), - mCaretRow(0), - mEditable(true), - mOpaque(true) - { - setText(""); - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - adjustSize(); - } - - TextBox::TextBox(const std::string& text) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mTextRows(), - mCaretColumn(0), - mCaretRow(0), - mEditable(true), - mOpaque(true) - { - setText(text); - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - adjustSize(); - } - - void TextBox::setText(const std::string& text) - { - mCaretColumn = 0; - mCaretRow = 0; - - mTextRows.clear(); - - size_t pos, lastPos = 0; - int length; - do - { - pos = text.find("\n", lastPos); - - if (pos != std::string::npos) - length = static_cast(pos - lastPos); - else - length = static_cast(text.size() - lastPos); - std::string sub = text.substr(lastPos, length); - mTextRows.push_back(sub); - lastPos = pos + 1; - } while (pos != std::string::npos); - - adjustSize(); - } - -/* - void TextBox::draw(Graphics* graphics) - { - } -*/ - - void TextBox::drawCaret(Graphics* graphics, int x, int y) - { - graphics->setColor(mForegroundColor); - graphics->drawLine(x, getFont()->getHeight() + y, x, y); - } - - void TextBox::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - mCaretRow = mouseEvent.getY() / getFont()->getHeight(); - - const int sz = static_cast(mTextRows.size()); - if (mCaretRow >= sz) - mCaretRow = sz - 1; - - mCaretColumn = getFont()->getStringIndexAt( - mTextRows[mCaretRow], mouseEvent.getX()); - } - } - - void TextBox::mouseDragged(MouseEvent& mouseEvent) - { - mouseEvent.consume(); - } - - void TextBox::keyPressed(KeyEvent& keyEvent A_UNUSED) - { - } - - void TextBox::adjustSize() - { - int width = 0; - for (size_t i = 0, sz = mTextRows.size(); i < sz; ++i) - { - const int w = getFont()->getWidth(mTextRows[i]); - if (width < w) - width = w; - } - - setWidth(width + 1); - setHeight(static_cast(getFont()->getHeight() * mTextRows.size())); - } - - void TextBox::setCaretPosition(unsigned int position) - { - for (int row = 0, sz = static_cast(mTextRows.size()); - row < sz; row ++) - { - if (position <= mTextRows[row].size()) - { - mCaretRow = row; - mCaretColumn = position; - return; // we are done - } - else - { - position--; - } - } - - // position beyond end of text - mCaretRow = static_cast(mTextRows.size() - 1); - mCaretColumn = static_cast(mTextRows[mCaretRow].size()); - } - - unsigned int TextBox::getCaretPosition() const - { - int pos = 0, row; - - for (row = 0; row < mCaretRow; row++) - pos += static_cast(mTextRows[row].size()); - - return pos + mCaretColumn; - } - - void TextBox::setCaretRowColumn(int row, int column) - { - setCaretRow(row); - setCaretColumn(column); - } - - void TextBox::setCaretRow(int row) - { - mCaretRow = row; - - const int sz = static_cast(mTextRows.size()); - if (mCaretRow >= sz) - mCaretRow = sz - 1; - - if (mCaretRow < 0) - mCaretRow = 0; - - setCaretColumn(mCaretColumn); - } - - unsigned int TextBox::getCaretRow() const - { - return mCaretRow; - } - - void TextBox::setCaretColumn(int column) - { - mCaretColumn = column; - - const int sz = static_cast(mTextRows[mCaretRow].size()); - if (mCaretColumn > sz) - mCaretColumn = sz; - - if (mCaretColumn < 0) - mCaretColumn = 0; - } - - unsigned int TextBox::getCaretColumn() const - { - return mCaretColumn; - } - - const std::string& TextBox::getTextRow(int row) const - { - return mTextRows[row]; - } - - void TextBox::setTextRow(int row, const std::string& text) - { - mTextRows[row] = text; - - if (mCaretRow == row) - setCaretColumn(mCaretColumn); - - adjustSize(); - } - - unsigned int TextBox::getNumberOfRows() const - { - return static_cast(mTextRows.size()); - } - - std::string TextBox::getText() const - { - if (mTextRows.empty()) - return std::string(""); - - int i; - std::string text; - - const int sz = static_cast(mTextRows.size()); - for (i = 0; i < sz - 1; ++ i) - text.append(mTextRows[i]).append("\n"); - text.append(mTextRows[i]); - - return text; - } - - void TextBox::fontChanged() - { - adjustSize(); - } - - void TextBox::scrollToCaret() - { - Rectangle scroll; - scroll.x = getFont()->getWidth( - mTextRows[mCaretRow].substr(0, mCaretColumn)); - scroll.y = getFont()->getHeight() * mCaretRow; - scroll.width = getFont()->getWidth(" "); - - // add 2 for some extra space - scroll.height = getFont()->getHeight() + 2; - - showPart(scroll); - } - - void TextBox::setEditable(bool editable) - { - mEditable = editable; - } - - bool TextBox::isEditable() const - { - return mEditable; - } - - void TextBox::addRow(const std::string &row) - { - mTextRows.push_back(row); - adjustSize(); - } - - bool TextBox::isOpaque() - { - return mOpaque; - } - - void TextBox::setOpaque(bool opaque) - { - mOpaque = opaque; - } -} // namespace gcn diff --git a/src/guichan/widgets/textfield.cpp b/src/guichan/widgets/textfield.cpp deleted file mode 100644 index 1e4309266..000000000 --- a/src/guichan/widgets/textfield.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/textfield.hpp" - -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/key.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - TextField::TextField() : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mText(), - mCaretPosition(0), - mXScroll(0) - { - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - } - - TextField::TextField(const std::string& text) : - gcn::Widget(), - gcn::MouseListener(), - gcn::KeyListener(), - mText(text), - mCaretPosition(0), - mXScroll(0) - { - adjustSize(); - - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - } - - void TextField::setText(const std::string& text) - { - const size_t sz = text.size(); - if (sz < mCaretPosition) - mCaretPosition = sz; - mText = text; - } - - void TextField::drawCaret(Graphics* graphics A_UNUSED, int x A_UNUSED) - { - } - - void TextField::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.getButton() == MouseEvent::LEFT) - { - mCaretPosition = getFont()->getStringIndexAt( - mText, mouseEvent.getX() + mXScroll); - fixScroll(); - } - } - - void TextField::mouseDragged(MouseEvent& mouseEvent) - { - mouseEvent.consume(); - } - - void TextField::adjustSize() - { - } - - void TextField::adjustHeight() - { - } - - void TextField::fixScroll() - { - } - - void TextField::setCaretPosition(unsigned int position A_UNUSED) - { - } - - unsigned int TextField::getCaretPosition() const - { - return mCaretPosition; - } - - const std::string& TextField::getText() const - { - return mText; - } - - void TextField::fontChanged() - { - } -} // namespace gcn diff --git a/src/guichan/widgets/window.cpp b/src/guichan/widgets/window.cpp deleted file mode 100644 index 8865444e0..000000000 --- a/src/guichan/widgets/window.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "guichan/widgets/window.hpp" - -#include "guichan/exception.hpp" -#include "guichan/font.hpp" -#include "guichan/graphics.hpp" -#include "guichan/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - Window::Window() : - Container(), - gcn::MouseListener(), - mCaption(), - mAlignment(Graphics::CENTER), - mPadding(2), - mTitleBarHeight(16), - mMovable(true), - mOpaque(true), - mDragOffsetX(0), - mDragOffsetY(0), - mMoved(false) - { - mFrameSize = 1; - addMouseListener(this); - } - - Window::Window(const std::string& caption) : - Container(), - gcn::MouseListener(), - mCaption(caption), - mAlignment(Graphics::CENTER), - mPadding(2), - mTitleBarHeight(16), - mMovable(true), - mOpaque(true), - mDragOffsetX(0), - mDragOffsetY(0), - mMoved(false) - { - mFrameSize = 1; - addMouseListener(this); - } - - Window::~Window() - { - } - - void Window::setPadding(unsigned int padding) - { - mPadding = padding; - } - - unsigned int Window::getPadding() const - { - return mPadding; - } - - void Window::setTitleBarHeight(unsigned int height) - { - mTitleBarHeight = height; - } - - unsigned int Window::getTitleBarHeight() - { - return mTitleBarHeight; - } - - void Window::setCaption(const std::string& caption) - { - mCaption = caption; - } - - const std::string& Window::getCaption() const - { - return mCaption; - } - - void Window::setAlignment(Graphics::Alignment alignment) - { - mAlignment = alignment; - } - - Graphics::Alignment Window::getAlignment() const - { - return mAlignment; - } - - void Window::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.getSource() != this) - return; - - if (getParent()) - getParent()->moveToTop(this); - - mDragOffsetX = mouseEvent.getX(); - mDragOffsetY = mouseEvent.getY(); - - mMoved = mouseEvent.getY() <= static_cast(mTitleBarHeight); - } - - void Window::mouseReleased(MouseEvent& mouseEvent A_UNUSED) - { - mMoved = false; - } - - void Window::mouseDragged(MouseEvent& mouseEvent) - { - if (mouseEvent.isConsumed() || mouseEvent.getSource() != this) - return; - - if (isMovable() && mMoved) - { - setPosition(mouseEvent.getX() - mDragOffsetX + getX(), - mouseEvent.getY() - mDragOffsetY + getY()); - } - - mouseEvent.consume(); - } - - Rectangle Window::getChildrenArea() - { - return Rectangle(getPadding(), - getTitleBarHeight(), - getWidth() - getPadding() * 2, - getHeight() - getPadding() - getTitleBarHeight()); - } - - void Window::setMovable(bool movable) - { - mMovable = movable; - } - - bool Window::isMovable() const - { - return mMovable; - } - - void Window::setOpaque(bool opaque) - { - mOpaque = opaque; - } - - bool Window::isOpaque() - { - return mOpaque; - } - - void Window::resizeToContent() - { - int w = 0, h = 0; - for (WidgetListConstIterator it = mWidgets.begin(); - it != mWidgets.end(); ++ it) - { - if ((*it)->getX() + (*it)->getWidth() > w) - w = (*it)->getX() + (*it)->getWidth(); - - if ((*it)->getY() + (*it)->getHeight() > h) - h = (*it)->getY() + (*it)->getHeight(); - } - - setSize(w + 2* getPadding(), h + getPadding() + getTitleBarHeight()); - } -} // namespace gcn diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index cc37001cc..7243bbf97 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -51,8 +51,8 @@ #include "utils/timer.h" -#include -#include +#include "gui/base/exception.hpp" +#include "gui/base/focushandler.hpp" #include diff --git a/src/input/keyevent.h b/src/input/keyevent.h index e0b2e8e17..3637d720c 100644 --- a/src/input/keyevent.h +++ b/src/input/keyevent.h @@ -21,8 +21,8 @@ #ifndef INPUT_KEYEVENT_H #define INPUT_KEYEVENT_H -#include -#include +#include "gui/base/key.hpp" +#include "gui/base/keyevent.hpp" #include diff --git a/src/input/keyinput.h b/src/input/keyinput.h index 25deeae19..d68c071f2 100644 --- a/src/input/keyinput.h +++ b/src/input/keyinput.h @@ -21,7 +21,7 @@ #ifndef INPUT_KEYINPUT_H #define INPUT_KEYINPUT_H -#include +#include "gui/base/keyinput.hpp" #include diff --git a/src/mouseinput.h b/src/mouseinput.h index 1ed155aa8..47e04eceb 100644 --- a/src/mouseinput.h +++ b/src/mouseinput.h @@ -21,7 +21,7 @@ #ifndef MOUSEINPUT_H #define MOUSEINPUT_H -#include +#include "gui/base/mouseinput.hpp" #include "localconsts.h" diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index 54de26887..bf72baf25 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -26,8 +26,8 @@ #include "gui/theme.h" -#include -#include +#include "gui/base/color.hpp" +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/render/graphics.h b/src/render/graphics.h index 0cb510195..93d46b475 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -29,8 +29,8 @@ #include "render/renderers.h" -#include -#include +#include "gui/base/color.hpp" +#include "gui/base/graphics.hpp" #ifdef USE_SDL2 #include diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 97f231d08..285b2dac2 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -36,7 +36,7 @@ #include "utils/sdlcheckutils.h" -#include +#include "gui/base/sdl/sdlpixel.hpp" #include "debug.h" diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 22a66a911..c158844ae 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -36,7 +36,7 @@ #include "utils/sdlcheckutils.h" -#include +#include "gui/base/sdl/sdlpixel.hpp" #include "debug.h" diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index e0e22cac9..9e950c12f 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -31,7 +31,7 @@ #include "utils/sdlcheckutils.h" -#include +#include "gui/base/sdl/sdlpixel.hpp" #include "debug.h" diff --git a/src/text.cpp b/src/text.cpp index d0027b8ae..fdd538d72 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -32,7 +32,7 @@ #include "resources/image.h" -#include +#include "gui/base/font.hpp" #include "debug.h" diff --git a/src/text.h b/src/text.h index 2c6b9b2b4..ed980e588 100644 --- a/src/text.h +++ b/src/text.h @@ -26,7 +26,7 @@ #include "render/graphics.h" -#include +#include "gui/base/color.hpp" #include "localconsts.h" diff --git a/src/touchmanager.h b/src/touchmanager.h index 6f7b96a6d..e203da69f 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -27,7 +27,7 @@ #include "input/keydata.h" -#include +#include "gui/base/rectangle.hpp" #include #include -- cgit v1.2.3-70-g09d2 From b5995578d5cf52e8553b668bc9343f02e8a0fc93 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 18:45:57 +0300 Subject: fix compilation error. --- src/gui/base/widget.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index fe02d3b14..847e340e1 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -68,8 +68,8 @@ #include #include -#include "guichan/color.hpp" -#include "guichan/rectangle.hpp" +#include "gui/base/color.hpp" +#include "gui/base/rectangle.hpp" #include "localconsts.h" -- cgit v1.2.3-70-g09d2 From 41d545176ffad2fb33158ca3415d2a0a983fffdb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 19:02:24 +0300 Subject: Remove unused image base class. --- src/CMakeLists.txt | 2 - src/Makefile.am | 2 - src/gui/base/graphics.cpp | 2 +- src/gui/base/image.cpp | 83 ------------------------ src/gui/base/image.hpp | 162 ---------------------------------------------- 5 files changed, 1 insertion(+), 250 deletions(-) delete mode 100644 src/gui/base/image.cpp delete mode 100644 src/gui/base/image.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f540d2552..79280485c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -782,7 +782,6 @@ SET(SRCS gui/base/font.hpp gui/base/graphics.hpp gui/base/gui.hpp - gui/base/image.hpp gui/base/input.hpp gui/base/inputevent.hpp gui/base/key.hpp @@ -820,7 +819,6 @@ SET(SRCS gui/base/font.cpp gui/base/graphics.cpp gui/base/gui.cpp - gui/base/image.cpp gui/base/inputevent.cpp gui/base/key.cpp gui/base/keyevent.cpp diff --git a/src/Makefile.am b/src/Makefile.am index f53c0f432..028041582 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -171,7 +171,6 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/font.hpp \ gui/base/graphics.hpp \ gui/base/gui.hpp \ - gui/base/image.hpp \ gui/base/input.hpp \ gui/base/inputevent.hpp \ gui/base/key.hpp \ @@ -209,7 +208,6 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/font.cpp \ gui/base/graphics.cpp \ gui/base/gui.cpp \ - gui/base/image.cpp \ gui/base/inputevent.cpp \ gui/base/key.cpp \ gui/base/keyevent.cpp \ diff --git a/src/gui/base/graphics.cpp b/src/gui/base/graphics.cpp index 229543bc9..fd76a1e6f 100644 --- a/src/gui/base/graphics.cpp +++ b/src/gui/base/graphics.cpp @@ -69,7 +69,7 @@ #include "gui/base/exception.hpp" #include "gui/base/font.hpp" -#include "gui/base/image.hpp" +#include "resources/image.h" #include "debug.h" diff --git a/src/gui/base/image.cpp b/src/gui/base/image.cpp deleted file mode 100644 index 01e30dc20..000000000 --- a/src/gui/base/image.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/image.hpp" - -#include "gui/base/exception.hpp" - -#include "debug.h" - -namespace gcn -{ - Image::Image() - { - } - - Image::~Image() - { - } -} diff --git a/src/gui/base/image.hpp b/src/gui/base/image.hpp deleted file mode 100644 index c39fe21ab..000000000 --- a/src/gui/base/image.hpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_IMAGE_HPP -#define GCN_IMAGE_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - class Color; - - /** - * Holds an image. To be able to use this class you must first set an - * ImageLoader in Image by calling - * @code Image::setImageLoader(myImageLoader) @endcode - * The function is static. If this is not done, the constructor taking a - * filename will throw an exception. The ImageLoader you use must be - * compatible with the Graphics object you use. - * - * EXAMPLE: If you use SDLGraphics you should use SDLImageLoader. - * Otherwise your program might crash in a most bizarre way. - * @see AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader, - * OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader - * @since 0.1.0 - */ - class Image - { - public: - /** - * Constructor. - */ - Image(); - - /** - * Destructor. - */ - virtual ~Image(); - - /** - * Frees an image. - * - * @since 0.5.0 - */ - virtual void free() = 0; - - /** - * Gets the width of the image. - * - * @return The width of the image. - * - * @since 0.1.0 - */ - virtual int getWidth() const A_WARN_UNUSED = 0; - - /** - * Gets the height of the image. - * - * @return The height of the image. - * - * @since 0.1.0 - */ - virtual int getHeight() const A_WARN_UNUSED = 0; - - /** - * Gets the color of a pixel at coordinate (x, y) in the image. - * - * IMPORTANT: Only guaranteed to work before the image has been - * converted to display format. - * - * @param x The x coordinate. - * @param y The y coordinate. - * @return The color of the pixel. - * - * @since 0.5.0 - */ - virtual Color getPixel(int x, int y) A_WARN_UNUSED = 0; - - /** - * Puts a pixel with a certain color at coordinate (x, y). - * - * @param x The x coordinate. - * @param y The y coordinate. - * @param color The color of the pixel to put. - * @since 0.5.0 - */ - virtual void putPixel(int x, int y, const Color& color) = 0; - - /** - * Converts the image, if possible, to display format. - * - * IMPORTANT: Only guaranteed to work before the image has been - * converted to display format. - * @since 0.5.0 - */ - virtual void convertToDisplayFormat() = 0; - }; -} // namespace gcn - -#endif // end GCN_IMAGE_HPP -- cgit v1.2.3-70-g09d2 From 29f929794c7519b049de0be3af635f05d7e83be6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 20:31:52 +0300 Subject: move some methods from base/graphics into render/graphics. Remove base/graphcs. --- src/CMakeLists.txt | 2 - src/Makefile.am | 3 - src/being/being.cpp | 8 +- src/gui/base/basiccontainer.cpp | 3 +- src/gui/base/font.hpp | 4 +- src/gui/base/graphics.cpp | 179 ------------------ src/gui/base/graphics.hpp | 294 ----------------------------- src/gui/base/gui.cpp | 3 +- src/gui/base/gui.hpp | 3 +- src/gui/base/widget.cpp | 3 +- src/gui/base/widget.hpp | 3 +- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/button.hpp | 3 +- src/gui/base/widgets/checkbox.cpp | 3 +- src/gui/base/widgets/container.cpp | 3 +- src/gui/base/widgets/container.hpp | 3 +- src/gui/base/widgets/label.cpp | 3 +- src/gui/base/widgets/label.hpp | 3 +- src/gui/base/widgets/listbox.cpp | 3 +- src/gui/base/widgets/radiobutton.cpp | 3 +- src/gui/base/widgets/scrollarea.cpp | 3 +- src/gui/base/widgets/slider.cpp | 3 +- src/gui/base/widgets/textbox.cpp | 3 +- src/gui/base/widgets/textfield.cpp | 3 +- src/gui/base/widgets/window.cpp | 3 +- src/gui/sdlfont.cpp | 2 +- src/gui/sdlfont.h | 2 +- src/gui/viewport.cpp | 10 +- src/gui/viewport.h | 2 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/avatarlistbox.h | 2 +- src/gui/widgets/browserbox.cpp | 13 +- src/gui/widgets/browserbox.h | 2 +- src/gui/widgets/button.cpp | 8 +- src/gui/widgets/button.h | 2 +- src/gui/widgets/checkbox.cpp | 4 +- src/gui/widgets/checkbox.h | 4 +- src/gui/widgets/colorpage.cpp | 2 +- src/gui/widgets/colorpage.h | 2 +- src/gui/widgets/desktop.cpp | 2 +- src/gui/widgets/desktop.h | 2 +- src/gui/widgets/dropdown.cpp | 6 +- src/gui/widgets/dropdown.h | 6 +- src/gui/widgets/dropshortcutcontainer.cpp | 2 +- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 2 +- src/gui/widgets/emoteshortcutcontainer.cpp | 2 +- src/gui/widgets/emoteshortcutcontainer.h | 2 +- src/gui/widgets/extendedlistbox.cpp | 5 +- src/gui/widgets/extendedlistbox.h | 2 +- src/gui/widgets/guitable.cpp | 5 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/icon.cpp | 2 +- src/gui/widgets/icon.h | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 2 +- src/gui/widgets/itemshortcutcontainer.cpp | 2 +- src/gui/widgets/itemshortcutcontainer.h | 2 +- src/gui/widgets/label.cpp | 2 +- src/gui/widgets/label.h | 2 +- src/gui/widgets/listbox.cpp | 5 +- src/gui/widgets/listbox.h | 2 +- src/gui/widgets/passwordfield.cpp | 2 +- src/gui/widgets/passwordfield.h | 2 +- src/gui/widgets/playerbox.cpp | 4 +- src/gui/widgets/playerbox.h | 4 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 2 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/progressbar.h | 2 +- src/gui/widgets/progressindicator.cpp | 2 +- src/gui/widgets/progressindicator.h | 2 +- src/gui/widgets/radiobutton.cpp | 4 +- src/gui/widgets/radiobutton.h | 4 +- src/gui/widgets/scrollarea.cpp | 26 +-- src/gui/widgets/scrollarea.h | 26 +-- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/widgets/shoplistbox.h | 2 +- src/gui/widgets/shortcutcontainer.h | 2 +- src/gui/widgets/slider.cpp | 2 +- src/gui/widgets/slider.h | 2 +- src/gui/widgets/sliderlist.cpp | 2 +- src/gui/widgets/sliderlist.h | 2 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.h | 2 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 2 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/tabs/tab.h | 2 +- src/gui/widgets/textbox.cpp | 2 +- src/gui/widgets/textbox.h | 2 +- src/gui/widgets/textfield.cpp | 12 +- src/gui/widgets/textfield.h | 6 +- src/gui/widgets/textpreview.cpp | 2 +- src/gui/widgets/textpreview.h | 2 +- src/gui/widgets/window.cpp | 12 +- src/gui/widgets/window.h | 4 +- src/gui/widgets/windowcontainer.cpp | 2 +- src/gui/widgets/windowcontainer.h | 2 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 2 +- src/gui/windows/buydialog.cpp | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/chatwindow.h | 2 +- src/gui/windows/connectiondialog.cpp | 2 +- src/gui/windows/connectiondialog.h | 2 +- src/gui/windows/debugwindow.cpp | 2 +- src/gui/windows/debugwindow.h | 2 +- src/gui/windows/equipmentwindow.cpp | 2 +- src/gui/windows/equipmentwindow.h | 2 +- src/gui/windows/minimap.cpp | 2 +- src/gui/windows/minimap.h | 2 +- src/gui/windows/ministatuswindow.cpp | 2 +- src/gui/windows/ministatuswindow.h | 2 +- src/gui/windows/outfitwindow.cpp | 6 +- src/gui/windows/outfitwindow.h | 2 +- src/gui/windows/selldialog.cpp | 2 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/skilldialog.cpp | 2 +- src/render/graphics.cpp | 124 +++++++++++- src/render/graphics.h | 163 ++++++++++++++-- src/render/mobileopenglgraphics.cpp | 4 +- src/render/normalopenglgraphics.cpp | 4 +- src/render/nullopenglgraphics.cpp | 4 +- src/render/safeopenglgraphics.cpp | 4 +- src/render/sdl2graphics.cpp | 47 ++++- src/render/sdl2graphics.h | 43 +++++ src/render/sdl2softwaregraphics.cpp | 4 +- src/render/sdlgraphics.cpp | 4 +- src/text.cpp | 10 +- src/text.h | 9 +- 132 files changed, 589 insertions(+), 700 deletions(-) delete mode 100644 src/gui/base/graphics.cpp delete mode 100644 src/gui/base/graphics.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 79280485c..65570ee7b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -780,7 +780,6 @@ SET(SRCS gui/base/focushandler.hpp gui/base/focuslistener.hpp gui/base/font.hpp - gui/base/graphics.hpp gui/base/gui.hpp gui/base/input.hpp gui/base/inputevent.hpp @@ -817,7 +816,6 @@ SET(SRCS gui/base/exception.cpp gui/base/focushandler.cpp gui/base/font.cpp - gui/base/graphics.cpp gui/base/gui.cpp gui/base/inputevent.cpp gui/base/key.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 028041582..7fe7a5e2e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,7 +32,6 @@ dyecmd_SOURCES = gui/base/actionevent.cpp \ gui/base/event.cpp \ gui/base/exception.cpp \ gui/base/font.cpp \ - gui/base/graphics.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ gui/base/actionevent.hpp \ @@ -41,7 +40,6 @@ dyecmd_SOURCES = gui/base/actionevent.cpp \ gui/base/event.hpp \ gui/base/exception.hpp \ gui/base/font.hpp \ - gui/base/graphics.hpp \ gui/base/rectangle.hpp \ gui/base/widget.hpp @@ -206,7 +204,6 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/exception.cpp \ gui/base/focushandler.cpp \ gui/base/font.cpp \ - gui/base/graphics.cpp \ gui/base/gui.cpp \ gui/base/inputevent.cpp \ gui/base/key.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index dfb335f9b..8b2ece2b7 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -519,7 +519,7 @@ void Being::setSpeech(const std::string &text, const std::string &channel, mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(), - gcn::Graphics::CENTER, + Graphics::CENTER, &userPalette->getColor(UserPalette::PARTICLE), true); } @@ -1856,7 +1856,7 @@ void Being::drawSpeech(const int offsetX, const int offsetY) if (!mText && userPalette) { mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(), - gcn::Graphics::CENTER, &Theme::getThemeColor( + Graphics::CENTER, &Theme::getThemeColor( Theme::BUBBLE_TEXT), true); } } @@ -2019,12 +2019,12 @@ void Being::showName() mDispName = new FlashText(displayName, getPixelX() + mInfo->getNameOffsetX(), getPixelY() + mInfo->getNameOffsetY(), - gcn::Graphics::CENTER, mNameColor, font); + Graphics::CENTER, mNameColor, font); } else { mDispName = new FlashText(displayName, getPixelX(), getPixelY(), - gcn::Graphics::CENTER, mNameColor, font); + Graphics::CENTER, mNameColor, font); } updateCoords(); diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 45bb1e231..7a937fb42 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -71,9 +71,10 @@ #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/font.hpp b/src/gui/base/font.hpp index 8e8ad18c9..075af4136 100644 --- a/src/gui/base/font.hpp +++ b/src/gui/base/font.hpp @@ -68,10 +68,10 @@ #include "localconsts.h" +class Graphics; + namespace gcn { - class Graphics; - /** * Interface for a font. * diff --git a/src/gui/base/graphics.cpp b/src/gui/base/graphics.cpp deleted file mode 100644 index fd76a1e6f..000000000 --- a/src/gui/base/graphics.cpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/graphics.hpp" - -#include "gui/base/exception.hpp" -#include "gui/base/font.hpp" -#include "resources/image.h" - -#include "debug.h" - -namespace gcn -{ - - Graphics::Graphics() : - mClipStack(), - mFont(nullptr) - { - } - - bool Graphics::pushClipArea(Rectangle area) - { - // Ignore area with a negate width or height - // by simple pushing an empty clip area - // to the stack. - if (area.width < 0 || area.height < 0) - { - ClipRectangle carea; - mClipStack.push(carea); - return true; - } - - if (mClipStack.empty()) - { - ClipRectangle carea; - carea.x = area.x; - carea.y = area.y; - carea.width = area.width; - carea.height = area.height; - carea.xOffset = area.x; - carea.yOffset = area.y; - mClipStack.push(carea); - return true; - } - - const ClipRectangle &top = mClipStack.top(); - ClipRectangle carea; - carea = area; - carea.xOffset = top.xOffset + carea.x; - carea.yOffset = top.yOffset + carea.y; - carea.x += top.xOffset; - carea.y += top.yOffset; - - // Clamp the pushed clip rectangle. - if (carea.x < top.x) - carea.x = top.x; - - if (carea.y < top.y) - carea.y = top.y; - - if (carea.x + carea.width > top.x + top.width) - { - carea.width = top.x + top.width - carea.x; - - if (carea.width < 0) - carea.width = 0; - } - - if (carea.y + carea.height > top.y + top.height) - { - carea.height = top.y + top.height - carea.y; - - if (carea.height < 0) - carea.height = 0; - } - - const bool result = carea.isIntersecting(top); - - mClipStack.push(carea); - - return result; - } - - void Graphics::popClipArea() - { - if (mClipStack.empty()) - throw GCN_EXCEPTION("Tried to pop clip area from empty stack."); - - mClipStack.pop(); - } - - const ClipRectangle& Graphics::getCurrentClipArea() - { - if (mClipStack.empty()) - throw GCN_EXCEPTION("The clip area stack is empty."); - - return mClipStack.top(); - } - - void Graphics::drawImage(const Image* image A_UNUSED, - int dstX A_UNUSED, int dstY A_UNUSED) - { - } - -/* - void Graphics::setFont(Font* font) - { - } - - void Graphics::drawText(const std::string& text, int x, int y, - Alignment alignment) - { - } -*/ -} // namespace gcn diff --git a/src/gui/base/graphics.hpp b/src/gui/base/graphics.hpp deleted file mode 100644 index d3128c8ae..000000000 --- a/src/gui/base/graphics.hpp +++ /dev/null @@ -1,294 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_GRAPHICS_HPP -#define GCN_GRAPHICS_HPP - -#include -#include - -#include "gui/base/cliprectangle.hpp" - -namespace gcn -{ - class Color; - class Font; - class Image; - - /** - * Abstract class for providing drawing primitve functions. - * It contains all vital functions for drawing. - * - * Guichan contains implementations of Graphics for common - * libraries like the Allegro library, the HGE library, - * the OpenGL library, the OpenLayer library, and the SDL library. - * To make Guichan usable with other libraries, a Graphics class - * must be implemented. - * - * In Graphics you can set clip areas to limit drawing to certain - * areas of the screen. Clip areas are put on a stack, which - * means that you can push smaller and smaller clip areas onto the - * stack. All coordinates will be relative to the top most clip area. - * In most cases you won't have to worry about the clip areas, - * unless you want to implement some really complex widget. - * Pushing and poping of clip areas are handled automatically by - * container widgets when their child widgets are drawn. - * - * IMPORTANT: Remember to pop each clip area that you pushed on the stack - * after you are done with it. - * - * If you feel that Graphics is to restrictive for your needs, - * there is no one stopping you from using your own code for drawing - * in widgets. You could for instance use pure SDL in the drawing of - * widgets bypassing Graphics. This might however hurt portability of - * your application. - * - * If you implement a Graphics class not present in Guichan we would - * be very happy to add it to Guichan. - * - * @see AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics, - * SDLGraphics, Image - * @since 0.1.0 - */ - class Graphics - { - public: - /** - * Alignments for text drawing. - */ - enum Alignment - { - LEFT = 0, - CENTER, - RIGHT - }; - - /** - * Constructor. - */ - Graphics(); - - A_DELETE_COPY(Graphics) - - /** - * Destructor. - */ - virtual ~Graphics() - { } - - /** - * Initializes drawing. Called by the Gui when Gui::draw() is called. - * It is needed by some implementations of Graphics to perform - * preparations before drawing. An example of such an implementation - * is the OpenGLGraphics. - * - * NOTE: You will never need to call this function yourself, unless - * you use a Graphics object outside of Guichan. - * - * @see _endDraw, Gui::draw - */ - virtual void _beginDraw() - { } - - /** - * Deinitializes drawing. Called by the Gui when a Gui::draw() is done. - * done. It should reset any state changes made by _beginDraw(). - * - * NOTE: You will never need to call this function yourself, unless - * you use a Graphics object outside of Guichan. - * - * @see _beginDraw, Gui::draw - */ - virtual void _endDraw() - { } - - /** - * Pushes a clip area onto the stack. The x and y coordinates in the - * rectangle is relative to the last pushed clip area. - * If the new area falls outside the current clip area, it will be - * clipped as necessary. - * - * If a clip area is outside of the top clip area a clip area with - * zero width and height will be pushed. - * - * @param area The clip area to be pushed onto the stack. - * @return False if the the new area lays outside the current clip - * area. - */ - virtual bool pushClipArea(Rectangle area); - - /** - * Removes the top most clip area from the stack. - * - * @throws Exception if the stack is empty. - */ - virtual void popClipArea(); - - /** - * Gets the current clip area. Usefull if you want to do drawing - * bypassing Graphics. - * - * @return The current clip area. - */ - virtual const ClipRectangle& getCurrentClipArea(); - - /** - * Draws a part of an image. - * - * NOTE: Width and height arguments will not scale the image but - * specifies the size of the part to be drawn. If you want - * to draw the whole image there is a simplified version of - * this function. - * - * EXAMPLE: @code drawImage(myImage, 10, 10, 20, 20, 40, 40); @endcode - * Will draw a rectangular piece of myImage starting at - * coordinate (10, 10) in myImage, with width and height 40. - * The piece will be drawn with it's top left corner at - * coordinate (20, 20). - * - * @param image The image to draw. - * @param srcX The source image x coordinate. - * @param srcY The source image y coordinate. - * @param dstX The destination x coordinate. - * @param dstY The destination y coordinate. - * @param width The width of the piece. - * @param height The height of the piece. - */ - virtual void drawImage(const Image* image, - int srcX, - int srcY, - int dstX, - int dstY, - int width, - int height) = 0; - /** - * Draws an image. A simplified version of the other drawImage. - * It will draw a whole image at the coordinate you specify. - * It is equivalent to calling: - * @code drawImage(myImage, 0, 0, dstX, dstY, image->getWidth(), \ - image->getHeight()); @endcode - */ - virtual void drawImage(const Image* image, int dstX, int dstY); - - /** - * Draws a single point/pixel. - * - * @param x The x coordinate. - * @param y The y coordinate. - */ - virtual void drawPoint(int x, int y) = 0; - - /** - * Ddraws a line. - * - * @param x1 The first x coordinate. - * @param y1 The first y coordinate. - * @param x2 The second x coordinate. - * @param y2 The second y coordinate. - */ - virtual void drawLine(int x1, int y1, int x2, int y2) = 0; - - /** - * Draws a simple, non-filled, rectangle with a one pixel width. - * - * @param rectangle The rectangle to draw. - */ - virtual void drawRectangle(const Rectangle& rectangle) = 0; - - /** - * Draws a filled rectangle. - * - * @param rectangle The filled rectangle to draw. - */ - virtual void fillRectangle(const Rectangle& rectangle) = 0; - - /** - * Sets the color to use when drawing. - * - * @param color A color. - * @see getColor - */ - virtual void setColor(const Color& color) = 0; - - /** - * Gets the color to use when drawing. - * - * @return The color used when drawing. - * @see setColor - */ - virtual const Color& getColor() const = 0; - - protected: - /** - * Holds the clip area stack. - */ - std::stack mClipStack; - - /** - * Holds the current font. - */ - Font* mFont; - }; -} // namespace gcn - -#endif // end GCN_GRAPHICS_HPP diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index e4827f716..73d6ff380 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -70,7 +70,6 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/input.hpp" #include "gui/base/keyinput.hpp" #include "gui/base/keylistener.hpp" @@ -78,6 +77,8 @@ #include "gui/base/mouselistener.hpp" #include "gui/base/widget.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index b1daba0fc..28a231101 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -71,10 +71,11 @@ #include "gui/base/mouseevent.hpp" #include "gui/base/mouseinput.hpp" +class Graphics; + namespace gcn { class FocusHandler; - class Graphics; class Input; class KeyListener; class Widget; diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index 2e8719446..eeb5849c7 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -74,13 +74,14 @@ #include "gui/base/event.hpp" #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/keyinput.hpp" #include "gui/base/keylistener.hpp" #include "gui/base/mouseinput.hpp" #include "gui/base/mouselistener.hpp" #include "gui/base/widgetlistener.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 847e340e1..b6a81261e 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -73,6 +73,8 @@ #include "localconsts.h" +class Graphics; + namespace gcn { class ActionListener; @@ -81,7 +83,6 @@ namespace gcn class FocusHandler; class FocusListener; class Font; - class Graphics; class KeyInput; class KeyListener; class MouseInput; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index a52bf2d78..3e699670a 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -69,11 +69,12 @@ #include "gui/base/exception.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseevent.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index 4ae08eb16..cd41a1b02 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -67,12 +67,13 @@ #include #include "gui/base/focuslistener.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/keylistener.hpp" #include "gui/base/mouseevent.hpp" #include "gui/base/mouselistener.hpp" #include "gui/base/widget.hpp" +#include "render/graphics.h" + namespace gcn { /** diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 908b4f509..615808a85 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -68,10 +68,11 @@ #include "gui/base/widgets/checkbox.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp index 1e6de018b..d72f2a682 100644 --- a/src/gui/base/widgets/container.cpp +++ b/src/gui/base/widgets/container.cpp @@ -68,7 +68,8 @@ #include "gui/base/widgets/container.hpp" #include "gui/base/exception.hpp" -#include "gui/base/graphics.hpp" + +#include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widgets/container.hpp b/src/gui/base/widgets/container.hpp index a5cbdb31b..bffe6e884 100644 --- a/src/gui/base/widgets/container.hpp +++ b/src/gui/base/widgets/container.hpp @@ -67,7 +67,8 @@ #include #include "gui/base/basiccontainer.hpp" -#include "gui/base/graphics.hpp" + +#include "render/graphics.h" namespace gcn { diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index 42fcd78f4..f4576d908 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -69,7 +69,8 @@ #include "gui/base/exception.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" + +#include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widgets/label.hpp b/src/gui/base/widgets/label.hpp index f1ef30b89..90a395f7b 100644 --- a/src/gui/base/widgets/label.hpp +++ b/src/gui/base/widgets/label.hpp @@ -66,9 +66,10 @@ #include -#include "gui/base/graphics.hpp" #include "gui/base/widget.hpp" +#include "render/graphics.h" + namespace gcn { /** diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index b97bf47d4..dcf443c77 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -69,12 +69,13 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouseinput.hpp" #include "gui/base/selectionlistener.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index bfd5b1ff8..1e1da2622 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -68,10 +68,11 @@ #include "gui/base/widgets/radiobutton.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index e3dcfc61c..308cee473 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -68,7 +68,8 @@ #include "gui/base/widgets/scrollarea.hpp" #include "gui/base/exception.hpp" -#include "gui/base/graphics.hpp" + +#include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index a1a106303..e9ab36e86 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -67,10 +67,11 @@ #include "gui/base/widgets/slider.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 2e9ca0563..411fc7dd5 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -69,10 +69,11 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 586e49663..3349ebccb 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -68,10 +68,11 @@ #include "gui/base/widgets/textfield.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index c7a108ab8..6373bcb63 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -69,9 +69,10 @@ #include "gui/base/exception.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/mouseinput.hpp" +#include "render/graphics.h" + #include "debug.h" namespace gcn diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index 8246cea94..bed4a9f31 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -444,7 +444,7 @@ void SDLFont::clear() mCache[f].clear(); } -void SDLFont::drawString(gcn::Graphics *const graphics, +void SDLFont::drawString(Graphics *const graphics, const std::string &text, const int x, const int y) { diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h index 79ee0fbfb..1cb6f5c99 100644 --- a/src/gui/sdlfont.h +++ b/src/gui/sdlfont.h @@ -131,7 +131,7 @@ class SDLFont final : public gcn::Font /** * @see Font::drawString */ - void drawString(gcn::Graphics *const graphics, + void drawString(Graphics *const graphics, const std::string &text, const int x, const int y) override final; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 9982840de..2a91d1991 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -114,22 +114,20 @@ void Viewport::setMap(Map *const map) mMap = map; } -void Viewport::draw(gcn::Graphics *gcnGraphics) +void Viewport::draw(Graphics *graphics) { BLOCK_START("Viewport::draw 1") static int lastTick = tick_time; if (!mMap || !player_node) { - gcnGraphics->setColor(gcn::Color(64, 64, 64)); - gcnGraphics->fillRectangle( + graphics->setColor(gcn::Color(64, 64, 64)); + graphics->fillRectangle( gcn::Rectangle(0, 0, getWidth(), getHeight())); BLOCK_END("Viewport::draw 1") return; } - Graphics *const graphics = static_cast(gcnGraphics); - // Avoid freaking out when tick_time overflows if (tick_time < lastTick) lastTick = tick_time; @@ -260,7 +258,7 @@ void Viewport::draw(gcn::Graphics *gcnGraphics) miniStatusWindow->drawIcons(graphics); // Draw contained widgets - WindowContainer::draw(gcnGraphics); + WindowContainer::draw(graphics); BLOCK_END("Viewport::draw 1") } diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 848a1ae8c..7e18d8395 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -83,7 +83,7 @@ class Viewport final : public WindowContainer, /** * Draws the viewport. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Implements player to keep following mouse. diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 4a477b802..e6f03493f 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -90,7 +90,7 @@ AvatarListBox::~AvatarListBox() } } -void AvatarListBox::draw(gcn::Graphics *gcnGraphics) +void AvatarListBox::draw(Graphics *gcnGraphics) { BLOCK_START("AvatarListBox::draw") if (!mListModel || !player_node) diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index 99c1132b2..46e5c8dea 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -53,7 +53,7 @@ public: /** * Draws the list box. */ - void draw(gcn::Graphics *gcnGraphics) override final; + void draw(Graphics *gcnGraphics) override final; void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index d7ce9ab12..e0fbf3d17 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -37,10 +37,11 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/base/graphics.hpp" #include "gui/base/font.hpp" #include "gui/base/cliprectangle.hpp" +#include "render/graphics.h" + #include #include "debug.h" @@ -446,13 +447,15 @@ void BrowserBox::mouseMoved(gcn::MouseEvent &event) ? static_cast(i - mLinks.begin()) : -1; } -void BrowserBox::draw(gcn::Graphics *graphics) +void BrowserBox::draw(Graphics *graphics) { BLOCK_START("BrowserBox::draw") - const gcn::ClipRectangle &cr = graphics->getCurrentClipArea(); + const gcn::ClipRectangle *const cr = graphics->getCurrentClipArea(); + if (!cr) + return; Graphics *const graphics2 = static_cast(graphics); - mYStart = cr.y - cr.yOffset; - const int yEnd = mYStart + cr.height; + mYStart = cr->y - cr->yOffset; + const int yEnd = mYStart + cr->height; if (mYStart < 0) mYStart = 0; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index deefd886a..85ce9b96b 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -165,7 +165,7 @@ class BrowserBox final : public gcn::Widget, /** * Draws the browser box. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void updateHeight(); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index faefd6f6c..8954ecf8e 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -350,7 +350,7 @@ void Button::updateAlpha() } } -void Button::draw(gcn::Graphics *graphics) +void Button::draw(Graphics *graphics) { BLOCK_START("Button::draw") int mode; @@ -437,7 +437,7 @@ void Button::draw(gcn::Graphics *graphics) switch (mAlignment) { default: - case gcn::Graphics::LEFT: + case Graphics::LEFT: { if (mImages) { @@ -450,7 +450,7 @@ void Button::draw(gcn::Graphics *graphics) } break; } - case gcn::Graphics::CENTER: + case Graphics::CENTER: { const int width1 = font->getWidth(mCaption); if (mImages) @@ -465,7 +465,7 @@ void Button::draw(gcn::Graphics *graphics) } break; } - case gcn::Graphics::RIGHT: + case Graphics::RIGHT: { const int width1 = font->getWidth(mCaption); textX = width - width1 - padding; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index aeec63b82..949993a48 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -102,7 +102,7 @@ class Button final : public gcn::Button, /** * Draws the button. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Update the alpha value to the button components. diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index fa227f5ca..e72296516 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -94,7 +94,7 @@ CheckBox::~CheckBox() } } -void CheckBox::draw(gcn::Graphics *const graphics) +void CheckBox::draw(Graphics *const graphics) { BLOCK_START("CheckBox::draw") drawBox(graphics); @@ -129,7 +129,7 @@ void CheckBox::updateAlpha() } } -void CheckBox::drawBox(gcn::Graphics *const graphics) +void CheckBox::drawBox(Graphics *const graphics) { if (!mSkin || !mDrawBox) return; diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index d0864d0d5..a49c38d47 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -59,7 +59,7 @@ class CheckBox final : public gcn::CheckBox, /** * Draws the caption, then calls drawBox to draw the check box. */ - void draw(gcn::Graphics *const graphics) override final; + void draw(Graphics *const graphics) override final; /** * Update the alpha value to the checkbox components. @@ -69,7 +69,7 @@ class CheckBox final : public gcn::CheckBox, /** * Draws the check box, not the caption. */ - void drawBox(gcn::Graphics *const graphics); + void drawBox(Graphics *const graphics); /** * Called when the mouse enteres the widget area. diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 9730f7006..1d85874df 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -47,7 +47,7 @@ ColorPage::~ColorPage() { } -void ColorPage::draw(gcn::Graphics *graphics) +void ColorPage::draw(Graphics *graphics) { BLOCK_START("ColorPage::draw") diff --git a/src/gui/widgets/colorpage.h b/src/gui/widgets/colorpage.h index c1c90eddf..84a3011a9 100644 --- a/src/gui/widgets/colorpage.h +++ b/src/gui/widgets/colorpage.h @@ -36,7 +36,7 @@ class ColorPage final : public ListBox ~ColorPage(); - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void resetAction(); diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 32c8a4988..4a4a73b53 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -103,7 +103,7 @@ void Desktop::widgetResized(const gcn::Event &event A_UNUSED) setBestFittingWallpaper(); } -void Desktop::draw(gcn::Graphics *graphics) +void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") Graphics *const g = static_cast(graphics); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 88034fbbc..6982ce525 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -61,7 +61,7 @@ class Desktop final : public Container, private gcn::WidgetListener void widgetResized(const gcn::Event &event) override final; - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void postInit(); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 3669d3eab..354c88423 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -214,7 +214,7 @@ void DropDown::updateAlpha() } } -void DropDown::draw(gcn::Graphics* graphics) +void DropDown::draw(Graphics* graphics) { BLOCK_START("DropDown::draw") int h; @@ -286,7 +286,7 @@ void DropDown::draw(gcn::Graphics* graphics) BLOCK_END("DropDown::draw") } -void DropDown::drawFrame(gcn::Graphics *graphics) +void DropDown::drawFrame(Graphics *graphics) { BLOCK_START("DropDown::drawFrame") const int bs2 = getFrameSize(); @@ -296,7 +296,7 @@ void DropDown::drawFrame(gcn::Graphics *graphics) BLOCK_END("DropDown::drawFrame") } -void DropDown::drawButton(gcn::Graphics *graphics) +void DropDown::drawButton(Graphics *graphics) { const int height = mDroppedDown ? mFoldedUpHeight : mDimension.height; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index da2eb64f9..af566fb69 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -82,9 +82,9 @@ class DropDown final : public gcn::ActionListener, */ void updateAlpha(); - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; - void drawFrame(gcn::Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final; // Inherited from KeyListener @@ -142,7 +142,7 @@ class DropDown final : public gcn::ActionListener, * * @param graphics a Graphics object to draw with. */ - void drawButton(gcn::Graphics *graphics); + void drawButton(Graphics *graphics); PopupList *mPopup; gcn::Color mShadowColor; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 857eed024..892a74638 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -94,7 +94,7 @@ void DropShortcutContainer::setWidget2(const Widget2 *const widget) mUnEquipedColor2 = getThemeColor(Theme::ITEM_NOT_EQUIPPED_OUTLINE); } -void DropShortcutContainer::draw(gcn::Graphics *graphics) +void DropShortcutContainer::draw(Graphics *graphics) { if (!dropShortcut) return; diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index b5a144cba..6b7a9f151 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -50,7 +50,7 @@ class DropShortcutContainer final : public ShortcutContainer /** * Draws the items. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Handles mouse when dragged. diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index f2f84ed56..869ae5d08 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -59,7 +59,7 @@ EmotePage::~EmotePage() mVertexes = nullptr; } -void EmotePage::draw(gcn::Graphics *graphics) +void EmotePage::draw(Graphics *graphics) { BLOCK_START("EmotePage::draw") diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 1603bab5e..9cd2867aa 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -41,7 +41,7 @@ class EmotePage final : public gcn::Widget, ~EmotePage(); - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void mousePressed(gcn::MouseEvent &mouseEvent) override final; diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 8d83ffeae..bdb5c3163 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -99,7 +99,7 @@ void EmoteShortcutContainer::setWidget2(const Widget2 *const widget) mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE); } -void EmoteShortcutContainer::draw(gcn::Graphics *graphics) +void EmoteShortcutContainer::draw(Graphics *graphics) { if (!emoteShortcut) return; diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index 2c99aaf87..62999207e 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -53,7 +53,7 @@ class EmoteShortcutContainer final : public ShortcutContainer /** * Draws the items. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Handles mouse when dragged. diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 6aaf85bbe..66065295c 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -23,9 +23,10 @@ #include "gui/widgets/extendedlistmodel.h" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/listmodel.hpp" +#include "render/graphics.h" + #include "debug.h" ExtendedListBox::ExtendedListBox(const Widget2 *const widget, @@ -47,7 +48,7 @@ ExtendedListBox::~ExtendedListBox() { } -void ExtendedListBox::draw(gcn::Graphics *graphics) +void ExtendedListBox::draw(Graphics *graphics) { if (!mListModel) return; diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 30e7a32fb..9fa14fa9e 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -59,7 +59,7 @@ class ExtendedListBox final : public ListBox /** * Draws the list box. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void adjustSize() override; diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 9630f5c17..6928b11d8 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -30,9 +30,10 @@ #include "utils/dtor.h" #include "gui/base/actionlistener.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/key.hpp" +#include "render/graphics.h" + #include "debug.h" float GuiTable::mAlpha = 1.0; @@ -293,7 +294,7 @@ void GuiTable::installActionListeners() } // -- widget ops -void GuiTable::draw(gcn::Graphics* graphics) +void GuiTable::draw(Graphics* graphics) { if (!mModel || !getRowHeight()) return; diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index e91482078..2154d0889 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -113,7 +113,7 @@ public: } // Inherited from Widget - void draw(gcn::Graphics* graphics) override final; + void draw(Graphics* graphics) override final; gcn::Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED; diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 4fb511c85..e9b7cd525 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -67,7 +67,7 @@ void Icon::setImage(Image *const image) } } -void Icon::draw(gcn::Graphics *g) +void Icon::draw(Graphics *g) { BLOCK_START("Icon::draw") if (mImage) diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 98cb83b61..a39cec517 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -68,7 +68,7 @@ class Icon final : public gcn::Widget, /** * Draws the Icon. */ - void draw(gcn::Graphics *g) override final; + void draw(Graphics *g) override final; private: Image *mImage; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 0361c54e7..eedbc1bd0 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -245,7 +245,7 @@ void ItemContainer::logic() BLOCK_END("ItemContainer::logic") } -void ItemContainer::draw(gcn::Graphics *graphics) +void ItemContainer::draw(Graphics *graphics) { if (!mInventory || !mShowMatrix) return; diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index c7ca851d9..cfacb05c6 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -85,7 +85,7 @@ class ItemContainer final : public gcn::Widget, /** * Draws the items. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; // KeyListener void keyPressed(gcn::KeyEvent &event) override final; diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 1334afae7..78b9c0e62 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -112,7 +112,7 @@ void ItemShortcutContainer::setWidget2(const Widget2 *const widget) mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE); } -void ItemShortcutContainer::draw(gcn::Graphics *graphics) +void ItemShortcutContainer::draw(Graphics *graphics) { BLOCK_START("ItemShortcutContainer::draw") const ItemShortcut *const selShortcut = itemShortcut[mNumber]; diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index f9ec24589..c2dbe93a3 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -51,7 +51,7 @@ class ItemShortcutContainer final : public ShortcutContainer /** * Draws the items. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Handles mouse when dragged. diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 767830f5d..89ba17cd6 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -76,7 +76,7 @@ void Label::init() mPadding = 0; } -void Label::draw(gcn::Graphics* graphics) +void Label::draw(Graphics* graphics) { BLOCK_START("Label::draw") int textX; diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 2fc2393fb..0b96b87e4 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -59,7 +59,7 @@ class Label final : public gcn::Label, public Widget2 /** * Draws the label. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void adjustSize(); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 767067801..0a7956476 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -31,9 +31,10 @@ #include "gui/base/focushandler.hpp" #include "gui/base/font.hpp" -#include "gui/base/graphics.hpp" #include "gui/base/listmodel.hpp" +#include "render/graphics.h" + #include "debug.h" float ListBox::mAlpha = 1.0; @@ -98,7 +99,7 @@ void ListBox::updateAlpha() mAlpha = alpha; } -void ListBox::draw(gcn::Graphics *graphics) +void ListBox::draw(Graphics *graphics) { if (!mListModel) return; diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 784193fdf..459aea2e3 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -58,7 +58,7 @@ class ListBox : public gcn::ListBox, /** * Draws the list box. */ - void draw(gcn::Graphics *graphics) override; + void draw(Graphics *graphics) override; /** * Update the alpha value to the graphic components. diff --git a/src/gui/widgets/passwordfield.cpp b/src/gui/widgets/passwordfield.cpp index b2ee6ccad..1b562b7f0 100644 --- a/src/gui/widgets/passwordfield.cpp +++ b/src/gui/widgets/passwordfield.cpp @@ -31,7 +31,7 @@ PasswordField::PasswordField(const Widget2 *const widget, { } -void PasswordField::draw(gcn::Graphics *graphics) +void PasswordField::draw(Graphics *graphics) { BLOCK_START("PasswordField::draw") // std::string uses cow, thus cheap copy diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index 322d71b8b..f72350763 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -44,7 +44,7 @@ class PasswordField final : public TextField /** * Draws the password field. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; protected: int mPasswordChar; diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 6fda932bf..260f80099 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -107,7 +107,7 @@ void PlayerBox::init(std::string name, std::string selectedName) } } -void PlayerBox::draw(gcn::Graphics *graphics) +void PlayerBox::draw(Graphics *graphics) { BLOCK_START("PlayerBox::draw") if (mBeing) @@ -130,7 +130,7 @@ void PlayerBox::draw(gcn::Graphics *graphics) BLOCK_END("PlayerBox::draw") } -void PlayerBox::drawFrame(gcn::Graphics *graphics) +void PlayerBox::drawFrame(Graphics *graphics) { BLOCK_START("PlayerBox::drawFrame") if (mDrawBackground) diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index b78c8c3f1..9671715b0 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -71,12 +71,12 @@ class PlayerBox final : public Widget2, /** * Draws the scroll area. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Draws the background and border of the scroll area. */ - void drawFrame(gcn::Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final; Being *getBeing() A_WARN_UNUSED { return mBeing; } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index c0de328e7..56d5d0d0c 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -94,7 +94,7 @@ void Popup::setWindowContainer(WindowContainer *const wc) windowContainer = wc; } -void Popup::draw(gcn::Graphics *graphics) +void Popup::draw(Graphics *graphics) { BLOCK_START("Popup::draw") Graphics *const g = static_cast(graphics); diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 7e7001891..f0fd1b932 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -75,7 +75,7 @@ class Popup : public Container, public gcn::MouseListener, /** * Draws the popup. */ - void draw(gcn::Graphics *graphics) override; + void draw(Graphics *graphics) override; /** * Sets the size of this popup. diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 61ecc9080..28c87f4ec 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -146,7 +146,7 @@ void ProgressBar::updateAlpha() mAlpha = alpha; } -void ProgressBar::draw(gcn::Graphics *graphics) +void ProgressBar::draw(Graphics *graphics) { BLOCK_START("ProgressBar::draw") updateAlpha(); diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index ca32fc165..022d86ab3 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -70,7 +70,7 @@ class ProgressBar final : public gcn::Widget, /** * Draws the progress bar. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Sets the current progress. diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index d89ff7f2a..358518132 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -65,7 +65,7 @@ void ProgressIndicator::logic() BLOCK_END("ProgressIndicator::logic") } -void ProgressIndicator::draw(gcn::Graphics *graphics) +void ProgressIndicator::draw(Graphics *graphics) { BLOCK_START("ProgressIndicator::draw") if (mIndicator) diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index fc9ab5b5f..8dd33bf4d 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -46,7 +46,7 @@ class ProgressIndicator final : public gcn::Widget, void logic() override final; - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; private: SimpleAnimation *mIndicator; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index a81afa037..4a47a4b4e 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -110,7 +110,7 @@ void RadioButton::updateAlpha() } } -void RadioButton::drawBox(gcn::Graphics* graphics) +void RadioButton::drawBox(Graphics* graphics) { if (!mSkin) return; @@ -154,7 +154,7 @@ void RadioButton::drawBox(gcn::Graphics* graphics) } } -void RadioButton::draw(gcn::Graphics* graphics) +void RadioButton::draw(Graphics* graphics) { BLOCK_START("RadioButton::draw") drawBox(graphics); diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index dca2d1167..ff6f5aafd 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -56,13 +56,13 @@ class RadioButton final : public gcn::RadioButton, /** * Draws the radiobutton, not the caption. */ - void drawBox(gcn::Graphics* graphics) override final; + void drawBox(Graphics* graphics) override final; /** * Implementation of the draw methods. * Thus, avoiding the rhomb around the radio button. */ - void draw(gcn::Graphics* graphics) override final; + void draw(Graphics* graphics) override final; /** * Called when the mouse enteres the widget area. diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index a260142a1..89e75f4d7 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -248,7 +248,7 @@ void ScrollArea::updateAlpha() } } -void ScrollArea::draw(gcn::Graphics *graphics) +void ScrollArea::draw(Graphics *graphics) { BLOCK_START("ScrollArea::draw") if (mVBarVisible || mHBarVisible) @@ -329,7 +329,7 @@ void ScrollArea::draw(gcn::Graphics *graphics) BLOCK_END("ScrollArea::draw") } -void ScrollArea::updateCalcFlag(gcn::Graphics *const graphics) +void ScrollArea::updateCalcFlag(Graphics *const graphics) { if (!mRedraw) { @@ -356,7 +356,7 @@ void ScrollArea::updateCalcFlag(gcn::Graphics *const graphics) } } -void ScrollArea::drawFrame(gcn::Graphics *graphics) +void ScrollArea::drawFrame(Graphics *graphics) { BLOCK_START("ScrollArea::drawFrame") if (mOpaque) @@ -392,7 +392,7 @@ void ScrollArea::setOpaque(bool opaque) setFrameSize(mOpaque ? 2 : 0); } -void ScrollArea::drawButton(gcn::Graphics *const graphics, +void ScrollArea::drawButton(Graphics *const graphics, const BUTTON_DIR dir) { int state = 0; @@ -430,7 +430,7 @@ void ScrollArea::drawButton(gcn::Graphics *const graphics, } } -void ScrollArea::calcButton(gcn::Graphics *const graphics, +void ScrollArea::calcButton(Graphics *const graphics, const BUTTON_DIR dir) { int state = 0; @@ -468,7 +468,7 @@ void ScrollArea::calcButton(gcn::Graphics *const graphics, } } -void ScrollArea::drawVBar(gcn::Graphics *const graphics) +void ScrollArea::drawVBar(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalBarDimension(); Graphics *const g = static_cast(graphics); @@ -491,7 +491,7 @@ void ScrollArea::drawVBar(gcn::Graphics *const graphics) } } -void ScrollArea::calcVBar(gcn::Graphics *const graphics) +void ScrollArea::calcVBar(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalBarDimension(); Graphics *const g = static_cast(graphics); @@ -514,7 +514,7 @@ void ScrollArea::calcVBar(gcn::Graphics *const graphics) } } -void ScrollArea::drawHBar(gcn::Graphics *const graphics) +void ScrollArea::drawHBar(Graphics *const graphics) { const gcn::Rectangle &dim = getHorizontalBarDimension(); Graphics *const g = static_cast(graphics); @@ -539,7 +539,7 @@ void ScrollArea::drawHBar(gcn::Graphics *const graphics) } } -void ScrollArea::calcHBar(gcn::Graphics *const graphics) +void ScrollArea::calcHBar(Graphics *const graphics) { const gcn::Rectangle &dim = getHorizontalBarDimension(); Graphics *const g = static_cast(graphics); @@ -564,7 +564,7 @@ void ScrollArea::calcHBar(gcn::Graphics *const graphics) } } -void ScrollArea::drawVMarker(gcn::Graphics *const graphics) +void ScrollArea::drawVMarker(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalMarkerDimension(); @@ -580,7 +580,7 @@ void ScrollArea::drawVMarker(gcn::Graphics *const graphics) } } -void ScrollArea::calcVMarker(gcn::Graphics *const graphics) +void ScrollArea::calcVMarker(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalMarkerDimension(); @@ -596,7 +596,7 @@ void ScrollArea::calcVMarker(gcn::Graphics *const graphics) } } -void ScrollArea::drawHMarker(gcn::Graphics *const graphics) +void ScrollArea::drawHMarker(Graphics *const graphics) { const gcn::Rectangle dim = getHorizontalMarkerDimension(); @@ -612,7 +612,7 @@ void ScrollArea::drawHMarker(gcn::Graphics *const graphics) } } -void ScrollArea::calcHMarker(gcn::Graphics *const graphics) +void ScrollArea::calcHMarker(Graphics *const graphics) { const gcn::Rectangle dim = getHorizontalMarkerDimension(); diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 58bd73107..fe60399df 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -84,12 +84,12 @@ class ScrollArea final : public gcn::ScrollArea, /** * Draws the scroll area. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Draws the background and border of the scroll area. */ - void drawFrame(gcn::Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final; /** * Sets whether the widget should draw its background or not. @@ -158,19 +158,19 @@ class ScrollArea final : public gcn::ScrollArea, */ void init(std::string skinName); - void drawButton(gcn::Graphics *const graphics, const BUTTON_DIR dir); - void calcButton(gcn::Graphics *const graphics, const BUTTON_DIR dir); - void drawVBar(gcn::Graphics *const graphics) override final; - void drawHBar(gcn::Graphics *const graphics) override final; - void drawVMarker(gcn::Graphics *const graphics) override final; - void drawHMarker(gcn::Graphics *const graphics) override final; + void drawButton(Graphics *const graphics, const BUTTON_DIR dir); + void calcButton(Graphics *const graphics, const BUTTON_DIR dir); + void drawVBar(Graphics *const graphics) override final; + void drawHBar(Graphics *const graphics) override final; + void drawVMarker(Graphics *const graphics) override final; + void drawHMarker(Graphics *const graphics) override final; - void calcVBar(gcn::Graphics *const graphics); - void calcHBar(gcn::Graphics *const graphics); - void calcVMarker(gcn::Graphics *const graphics); - void calcHMarker(gcn::Graphics *const graphics); + void calcVBar(Graphics *const graphics); + void calcHBar(Graphics *const graphics); + void calcVMarker(Graphics *const graphics); + void calcHMarker(Graphics *const graphics); - void updateCalcFlag(gcn::Graphics *const graphics); + void updateCalcFlag(Graphics *const graphics); static int instances; static float mAlpha; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 4a7fda039..644023c43 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -82,7 +82,7 @@ void ShopListBox::setPlayersMoney(const int money) mPlayerMoney = money; } -void ShopListBox::draw(gcn::Graphics *gcnGraphics) +void ShopListBox::draw(Graphics *gcnGraphics) { BLOCK_START("ShopListBox::draw") if (!mListModel || !mShopItems) diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 095d187eb..509af8393 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -56,7 +56,7 @@ class ShopListBox final : public ListBox /** * Draws the list box. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * gives information about the current player's money diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 88e27320a..4d4ff2389 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -53,7 +53,7 @@ class ShortcutContainer : public gcn::Widget, /** * Draws the shortcuts */ - virtual void draw(gcn::Graphics *graphics) override = 0; + virtual void draw(Graphics *graphics) override = 0; /** * Invoked when a widget changes its size. This is used to determine diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 750b58528..1427bb6eb 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -118,7 +118,7 @@ void Slider::updateAlpha() } } -void Slider::draw(gcn::Graphics *graphics) +void Slider::draw(Graphics *graphics) { BLOCK_START("Slider::draw") if (!buttons[0].grid[HSTART] || !buttons[1].grid[HSTART] diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index d5d4a30fe..c59e0c47f 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -65,7 +65,7 @@ class Slider final : public gcn::Slider, /** * Draws the slider. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Called when the mouse enteres the widget area. diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 4416a00b7..b75f65820 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -103,7 +103,7 @@ void SliderList::resize() updateLabel(); } -void SliderList::draw(gcn::Graphics *graphics) +void SliderList::draw(Graphics *graphics) { BLOCK_START("SliderList::draw") const int width = mDimension.width; diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 016a60290..e0f63517b 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -55,7 +55,7 @@ class SliderList final : public Container, void resize(); - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void action(const gcn::ActionEvent &event) override final; diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index e59b9fbdb..7c59676b9 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -90,7 +90,7 @@ void SpellShortcutContainer::setWidget2(const Widget2 *const widget) mForegroundColor2 = getThemeColor(Theme::TEXT_OUTLINE); } -void SpellShortcutContainer::draw(gcn::Graphics *graphics) +void SpellShortcutContainer::draw(Graphics *graphics) { if (!spellShortcut) return; diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 37e7b5660..3115e47fe 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -50,7 +50,7 @@ class SpellShortcutContainer final : public ShortcutContainer /** * Draws the items. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Handles mouse when dragged. diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 8cb8fd78a..2a212ce75 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -139,7 +139,7 @@ Tab *TabbedArea::getTab(const std::string &name) const return nullptr; } -void TabbedArea::draw(gcn::Graphics *graphics) +void TabbedArea::draw(Graphics *graphics) { BLOCK_START("TabbedArea::draw") if (mTabs.empty()) diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 7a023903f..dede91767 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -60,7 +60,7 @@ class TabbedArea final : public Widget2, /** * Draw the tabbed area. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Return how many tabs have been created. diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 4f1703d31..d0561cadf 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -153,7 +153,7 @@ void Tab::updateAlpha() } } -void Tab::draw(gcn::Graphics *graphics) +void Tab::draw(Graphics *graphics) { BLOCK_START("Tab::draw") int mode = TAB_STANDARD; diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index fa9846ab4..66f7521d9 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -68,7 +68,7 @@ class Tab : public gcn::BasicContainer, /** * Draw the tabbed area. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Set the normal color for the tab's text. diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 3f56ecfcf..8aaca4211 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -350,7 +350,7 @@ void TextBox::keyPressed(gcn::KeyEvent& keyEvent) keyEvent.consume(); } -void TextBox::draw(gcn::Graphics* graphics) +void TextBox::draw(Graphics* graphics) { BLOCK_START("TextBox::draw") if (mOpaque) diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 797707716..d8841cfeb 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -62,7 +62,7 @@ class TextBox final : public gcn::TextBox, void keyPressed(gcn::KeyEvent& keyEvent) override final; - void draw(gcn::Graphics* graphics) override final; + void draw(Graphics* graphics) override final; void setForegroundColor(const gcn::Color &color); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index b655de830..b1d188f22 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -137,7 +137,7 @@ void TextField::updateAlpha() } } -void TextField::draw(gcn::Graphics *graphics) +void TextField::draw(Graphics *graphics) { BLOCK_START("TextField::draw") updateAlpha(); @@ -155,7 +155,7 @@ void TextField::draw(gcn::Graphics *graphics) BLOCK_END("TextField::draw") } -void TextField::drawFrame(gcn::Graphics *graphics) +void TextField::drawFrame(Graphics *graphics) { BLOCK_START("TextField::drawFrame") const int bs = 2 * mFrameSize; @@ -661,12 +661,14 @@ void TextField::handleCopy() const sendBuffer(text); } -void TextField::drawCaret(gcn::Graphics* graphics, int x) +void TextField::drawCaret(Graphics* graphics, int x) { - const gcn::Rectangle &clipArea = graphics->getCurrentClipArea(); + const gcn::Rectangle *const clipArea = graphics->getCurrentClipArea(); + if (!clipArea) + return; graphics->setColor(*mCaretColor); - graphics->drawLine(x + mPadding, clipArea.height - mPadding, + graphics->drawLine(x + mPadding, clipArea->height - mPadding, x + mPadding, mPadding); } diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index d8ab2c830..d3d1ff0eb 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -60,7 +60,7 @@ class TextField : public gcn::TextField, /** * Draws the text field. */ - virtual void draw(gcn::Graphics *graphics) override; + virtual void draw(Graphics *graphics) override; /** * Update the alpha value to the graphic components. @@ -70,7 +70,7 @@ class TextField : public gcn::TextField, /** * Draws the background and border. */ - void drawFrame(gcn::Graphics *graphics) override final; + void drawFrame(Graphics *graphics) override final; /** * Determine whether the field should be numeric or not @@ -142,7 +142,7 @@ class TextField : public gcn::TextField, void caretDeleteWord(); protected: - void drawCaret(gcn::Graphics* graphics, int x) override final; + void drawCaret(Graphics* graphics, int x) override final; void fixScroll(); diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 8d473dd46..5cfb2abb5 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -79,7 +79,7 @@ TextPreview::~TextPreview() } } -void TextPreview::draw(gcn::Graphics* graphics) +void TextPreview::draw(Graphics* graphics) { BLOCK_START("TextPreview::draw") if (client->getGuiAlpha() != mAlpha) diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index bfb361a9b..f529e470c 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -102,7 +102,7 @@ class TextPreview final : public gcn::Widget, * * @param graphics graphics to draw into */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; /** * Set opacity for this widget (whether or not to show the background diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c78582a91..26ca0a29f 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -74,7 +74,7 @@ Window::Window(const std::string &caption, const bool modal, mVertexes(new ImageCollection), mCaptionOffsetX(7), mCaptionOffsetY(5), - mCaptionAlign(gcn::Graphics::LEFT), + mCaptionAlign(Graphics::LEFT), mTitlePadding(4), mGripPadding(2), mResizeHandles(-1), @@ -123,12 +123,12 @@ Window::Window(const std::string &caption, const bool modal, mCaptionOffsetY = getOption("captionoffsety"); if (!mCaptionOffsetY) mCaptionOffsetY = 5; - mCaptionAlign = static_cast( + mCaptionAlign = static_cast( getOption("captionalign")); - if (mCaptionAlign < gcn::Graphics::LEFT - || mCaptionAlign > gcn::Graphics::RIGHT) + if (mCaptionAlign < Graphics::LEFT + || mCaptionAlign > Graphics::RIGHT) { - mCaptionAlign = gcn::Graphics::LEFT; + mCaptionAlign = Graphics::LEFT; } setTitleBarHeight(getOption("titlebarHeight")); if (!mTitleBarHeight) @@ -203,7 +203,7 @@ void Window::setWindowContainer(WindowContainer *const wc) windowContainer = wc; } -void Window::draw(gcn::Graphics *graphics) +void Window::draw(Graphics *graphics) { if (!mSkin) return; diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 29fd589a5..68ce1a293 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -80,7 +80,7 @@ class Window : public gcn::Window, /** * Draws the window. */ - void draw(gcn::Graphics *graphics) override; + void draw(Graphics *graphics) override; /** * Sets the size of this window. @@ -501,7 +501,7 @@ class Window : public gcn::Window, ImageCollection *mVertexes; int mCaptionOffsetX; int mCaptionOffsetY; - gcn::Graphics::Alignment mCaptionAlign; + Graphics::Alignment mCaptionAlign; int mTitlePadding; int mGripPadding; int mResizeHandles; diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index d23f29bad..5adde3cae 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -79,7 +79,7 @@ void WindowContainer::moveWidgetAfter(gcn::Widget *const after, } #ifdef USE_PROFILER -void WindowContainer::draw(gcn::Graphics* graphics) +void WindowContainer::draw(Graphics* graphics) { BLOCK_START("WindowContainer::draw") Container::draw(graphics); diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index 2ee4ea37d..d940a4e91 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -57,7 +57,7 @@ class WindowContainer : public Container gcn::Widget *const widget); #ifdef USE_PROFILER - void draw(gcn::Graphics* graphics); + void draw(Graphics* graphics); #endif private: diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index a094b5b08..127d3657d 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -419,7 +419,7 @@ void WindowMenu::saveButtons() const config.deleteKey("windowmenu" + toString(f)); } -void WindowMenu::drawChildren(gcn::Graphics* graphics) +void WindowMenu::drawChildren(Graphics* graphics) { if (mHaveMouse || !mAutoHide || (mAutoHide == 1 && mainGraphics && (mSmallWindow || mainGraphics->mWidth > 800))) diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index a87f655d8..bf8298b75 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -118,7 +118,7 @@ class WindowMenu final : public Container, #endif protected: - void drawChildren(gcn::Graphics* graphics) override final; + void drawChildren(Graphics* graphics) override final; private: inline void addButton(const char *const text, diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index cfefa8159..ccddc76cd 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -247,7 +247,7 @@ void BuyDialog::init() mSlider = new Slider(1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); - mQuantityLabel->setAlignment(gcn::Graphics::CENTER); + mQuantityLabel->setAlignment(Graphics::CENTER); // TRANSLATORS: buy dialog label mMoneyLabel = new Label(this, strprintf( _("Price: %s / Total: %s"), "", "")); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index a21efbe52..5bff2ee4b 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1902,7 +1902,7 @@ void ChatWindow::mouseExited(gcn::MouseEvent& mouseEvent) Window::mouseExited(mouseEvent); } -void ChatWindow::draw(gcn::Graphics* graphics) +void ChatWindow::draw(Graphics* graphics) { BLOCK_START("ChatWindow::draw") if (!mAutoHide || mHaveMouse) diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 742c79876..d20f68ecc 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -280,7 +280,7 @@ class ChatWindow final : public Window, void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) override final; - void draw(gcn::Graphics* graphics) override final; + void draw(Graphics* graphics) override final; void updateVisibility(); diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp index 6d01dcaae..b0ffc25cd 100644 --- a/src/gui/windows/connectiondialog.cpp +++ b/src/gui/windows/connectiondialog.cpp @@ -66,7 +66,7 @@ void ConnectionDialog::action(const gcn::ActionEvent &) client->setState(mCancelState); } -void ConnectionDialog::draw(gcn::Graphics *graphics) +void ConnectionDialog::draw(Graphics *graphics) { BLOCK_START("ConnectionDialog::draw") // Don't draw the window background, only draw the children diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h index dd3c84e5e..773522839 100644 --- a/src/gui/windows/connectiondialog.h +++ b/src/gui/windows/connectiondialog.h @@ -57,7 +57,7 @@ class ConnectionDialog final : public Window, private gcn::ActionListener */ void action(const gcn::ActionEvent &) override; - void draw(gcn::Graphics *graphics) override; + void draw(Graphics *graphics) override; private: State mCancelState; diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 30d202054..4f57b9798 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -129,7 +129,7 @@ void DebugWindow::slowLogic() BLOCK_END("DebugWindow::slowLogic") } -void DebugWindow::draw(gcn::Graphics *g) +void DebugWindow::draw(Graphics *g) { BLOCK_START("DebugWindow::draw") Window::draw(g); diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h index 13e73c29e..83d6676da 100644 --- a/src/gui/windows/debugwindow.h +++ b/src/gui/windows/debugwindow.h @@ -147,7 +147,7 @@ class DebugWindow final : public Window */ void slowLogic(); - void draw(gcn::Graphics *g) override final; + void draw(Graphics *g) override final; void setPing(int pingTime); diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index c796c8433..e7bf02aa9 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -156,7 +156,7 @@ EquipmentWindow::~EquipmentWindow() mVertexes = nullptr; } -void EquipmentWindow::draw(gcn::Graphics *graphics) +void EquipmentWindow::draw(Graphics *graphics) { BLOCK_START("EquipmentWindow::draw") // Draw window graphics diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index 4b6ae8b4c..1ce8611a7 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -81,7 +81,7 @@ class EquipmentWindow final : public Window, public gcn::ActionListener /** * Draws the equipment window. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void action(const gcn::ActionEvent &event) override final; diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 02be64a13..181055053 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -233,7 +233,7 @@ void Minimap::toggle() mShow = isWindowVisible(); } -void Minimap::draw(gcn::Graphics *graphics) +void Minimap::draw(Graphics *graphics) { BLOCK_START("Minimap::draw") Window::draw(graphics); diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h index 90c08db0f..661412c57 100644 --- a/src/gui/windows/minimap.h +++ b/src/gui/windows/minimap.h @@ -60,7 +60,7 @@ class Minimap final : public Window, public ConfigListener /** * Draws the minimap. */ - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void mouseMoved(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index b5832c7b7..3513bb2ff 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -308,7 +308,7 @@ void MiniStatusWindow::logic() BLOCK_END("MiniStatusWindow::logic") } -void MiniStatusWindow::draw(gcn::Graphics *graphics) +void MiniStatusWindow::draw(Graphics *graphics) { BLOCK_START("MiniStatusWindow::draw") drawChildren(graphics); diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index 2a5903eca..7748f51d1 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -68,7 +68,7 @@ class MiniStatusWindow final : public Popup, void logic() override final; - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void mouseMoved(gcn::MouseEvent &mouseEvent) override final; diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index d686056ac..677337b70 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -91,8 +91,8 @@ OutfitWindow::OutfitWindow(): setMinWidth(145); setMinHeight(220); - mCurrentLabel->setAlignment(gcn::Graphics::CENTER); - mKeyLabel->setAlignment(gcn::Graphics::CENTER); + mCurrentLabel->setAlignment(Graphics::CENTER); + mKeyLabel->setAlignment(Graphics::CENTER); mUnequipCheck->setActionEventId("unequip"); mUnequipCheck->addActionListener(this); @@ -310,7 +310,7 @@ void OutfitWindow::copyOutfit(const int src, const int dst) save(); } -void OutfitWindow::draw(gcn::Graphics *graphics) +void OutfitWindow::draw(Graphics *graphics) { BLOCK_START("OutfitWindow::draw") Window::draw(graphics); diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 6d54889e6..01e72aefc 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -52,7 +52,7 @@ class OutfitWindow final : public Window, void action(const gcn::ActionEvent &event) override final; - void draw(gcn::Graphics *graphics) override final; + void draw(Graphics *graphics) override final; void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 15389a9c3..a4ff29f78 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -94,7 +94,7 @@ void SellDialog::init() mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); - mQuantityLabel->setAlignment(gcn::Graphics::CENTER); + mQuantityLabel->setAlignment(Graphics::CENTER); // TRANSLATORS: sell dialog label mMoneyLabel = new Label(this, strprintf(_("Price: %s / Total: %s"), "", "")); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index dec80b50a..82a264ac7 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -157,7 +157,7 @@ public: mHighlightColor = getThemeColor(Theme::HIGHLIGHT); } - void draw(gcn::Graphics *graphics) override final + void draw(Graphics *graphics) override final { if (!mListModel) return; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index c4505b37c..674848725 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -100,7 +100,7 @@ class SkillListBox final : public ListBox return static_cast(mListModel)->getSkillAt(selected); } - void draw(gcn::Graphics *gcnGraphics) override + void draw(Graphics *gcnGraphics) override { if (!mListModel) return; diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 7e3687006..653b4d4c0 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + #include "render/graphics.h" #include "main.h" @@ -48,11 +91,11 @@ Graphics *mainGraphics = nullptr; Graphics::Graphics() : - gcn::Graphics(), mWidth(0), mHeight(0), mActualWidth(0), mActualHeight(0), + mClipStack(), mWindow(nullptr), #ifdef USE_SDL2 mRenderer(nullptr), @@ -503,3 +546,82 @@ void Graphics::setWindowSize(const int width A_UNUSED, SDL_SetWindowSize(mWindow, width, height); #endif } + +bool Graphics::pushClipArea(gcn::Rectangle area) +{ + // Ignore area with a negate width or height + // by simple pushing an empty clip area + // to the stack. + if (area.width < 0 || area.height < 0) + { + gcn::ClipRectangle carea; + mClipStack.push(carea); + return true; + } + + if (mClipStack.empty()) + { + gcn::ClipRectangle carea; + carea.x = area.x; + carea.y = area.y; + carea.width = area.width; + carea.height = area.height; + carea.xOffset = area.x; + carea.yOffset = area.y; + mClipStack.push(carea); + return true; + } + + const gcn::ClipRectangle &top = mClipStack.top(); + gcn::ClipRectangle carea; + carea = area; + carea.xOffset = top.xOffset + carea.x; + carea.yOffset = top.yOffset + carea.y; + carea.x += top.xOffset; + carea.y += top.yOffset; + + // Clamp the pushed clip rectangle. + if (carea.x < top.x) + carea.x = top.x; + + if (carea.y < top.y) + carea.y = top.y; + + if (carea.x + carea.width > top.x + top.width) + { + carea.width = top.x + top.width - carea.x; + + if (carea.width < 0) + carea.width = 0; + } + + if (carea.y + carea.height > top.y + top.height) + { + carea.height = top.y + top.height - carea.y; + + if (carea.height < 0) + carea.height = 0; + } + + const bool result = carea.isIntersecting(top); + + mClipStack.push(carea); + + return result; +} + +void Graphics::popClipArea() +{ + if (mClipStack.empty()) + return; + + mClipStack.pop(); +} + +const gcn::ClipRectangle *Graphics::getCurrentClipArea() const +{ + if (mClipStack.empty()) + return nullptr; + + return &mClipStack.top(); +} diff --git a/src/render/graphics.h b/src/render/graphics.h index 93d46b475..53eb4af12 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 RENDER_GRAPHICS_H #define RENDER_GRAPHICS_H @@ -29,13 +72,15 @@ #include "render/renderers.h" +#include "gui/base/cliprectangle.hpp" #include "gui/base/color.hpp" -#include "gui/base/graphics.hpp" #ifdef USE_SDL2 #include #endif +#include + #include "localconsts.h" class Image; @@ -94,7 +139,7 @@ class ImageRect final /** * A central point of control for graphics. */ -class Graphics : public gcn::Graphics +class Graphics { public: A_DELETE_COPY(Graphics) @@ -104,6 +149,16 @@ class Graphics : public gcn::Graphics */ virtual ~Graphics(); + /** + * Alignments for text drawing. + */ + enum Alignment + { + LEFT = 0, + CENTER, + RIGHT + }; + void setWindow(SDL_Window *const window, const int width, const int height) { @@ -145,14 +200,6 @@ class Graphics : public gcn::Graphics */ virtual bool resizeScreen(const int width, const int height); - // override unused abstract function - void drawImage(const gcn::Image* image A_UNUSED, - int srcX A_UNUSED, int srcY A_UNUSED, - int dstX A_UNUSED, int dstY A_UNUSED, - int width A_UNUSED, int height A_UNUSED) override final - { - } - /** * Draws a resclaled version of the image */ @@ -211,8 +258,7 @@ class Graphics : public gcn::Graphics const int w, const int h, const ImageRect &imgRect) = 0; - virtual void fillRectangle(const gcn::Rectangle& rectangle) - override = 0; + virtual void fillRectangle(const gcn::Rectangle& rectangle) = 0; /** * Updates the screen. This is done by either copying the buffer to the @@ -246,9 +292,6 @@ class Graphics : public gcn::Graphics const int x2, const int y2, const int width, const int height); - const gcn::Font *getFont() const A_WARN_UNUSED - { return mFont; } - gcn::ClipRectangle &getTopClip() A_WARN_UNUSED { return mClipStack.top(); } @@ -288,7 +331,7 @@ class Graphics : public gcn::Graphics virtual void initArrays() { } - void setColor(const gcn::Color &color) override + virtual void setColor(const gcn::Color &color) { mColor = color; mColor2 = color; @@ -305,7 +348,7 @@ class Graphics : public gcn::Graphics mAlpha = (color.a != 255); } - const gcn::Color &getColor() const override + const gcn::Color &getColor() const { return mColor; } const gcn::Color &getColor2() const @@ -353,6 +396,87 @@ class Graphics : public gcn::Graphics void setScale(int scale); + /** + * Pushes a clip area onto the stack. The x and y coordinates in the + * rectangle is relative to the last pushed clip area. + * If the new area falls outside the current clip area, it will be + * clipped as necessary. + * + * If a clip area is outside of the top clip area a clip area with + * zero width and height will be pushed. + * + * @param area The clip area to be pushed onto the stack. + * @return False if the the new area lays outside the current clip + * area. + */ + virtual bool pushClipArea(gcn::Rectangle area); + + /** + * Removes the top most clip area from the stack. + * + * @throws Exception if the stack is empty. + */ + virtual void popClipArea(); + + /** + * Ddraws a line. + * + * @param x1 The first x coordinate. + * @param y1 The first y coordinate. + * @param x2 The second x coordinate. + * @param y2 The second y coordinate. + */ + virtual void drawLine(int x1, int y1, int x2, int y2) = 0; + + /** + * Draws a simple, non-filled, rectangle with a one pixel width. + * + * @param rectangle The rectangle to draw. + */ + virtual void drawRectangle(const gcn::Rectangle &rectangle) = 0; + + /** + * Gets the current clip area. Usefull if you want to do drawing + * bypassing Graphics. + * + * @return The current clip area. + */ + virtual const gcn::ClipRectangle *getCurrentClipArea() const; + + /** + * Draws a single point/pixel. + * + * @param x The x coordinate. + * @param y The y coordinate. + */ + virtual void drawPoint(int x, int y) = 0; + + /** + * Initializes drawing. Called by the Gui when Gui::draw() is called. + * It is needed by some implementations of Graphics to perform + * preparations before drawing. An example of such an implementation + * is the OpenGLGraphics. + * + * NOTE: You will never need to call this function yourself, unless + * you use a Graphics object outside of Guichan. + * + * @see _endDraw, Gui::draw + */ + virtual void _beginDraw() + { } + + /** + * Deinitializes drawing. Called by the Gui when a Gui::draw() is done. + * done. It should reset any state changes made by _beginDraw(). + * + * NOTE: You will never need to call this function yourself, unless + * you use a Graphics object outside of Guichan. + * + * @see _beginDraw, Gui::draw + */ + virtual void _endDraw() + { } + int mWidth; int mHeight; int mActualWidth; @@ -382,6 +506,11 @@ class Graphics : public gcn::Graphics bool videoInfo(); + /** + * Holds the clip area stack. + */ + std::stack mClipStack; + SDL_Window *mWindow; #ifdef USE_SDL2 diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 82bf04dc8..252dc0766 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -963,7 +963,7 @@ bool MobileOpenGLGraphics::pushClipArea(gcn::Rectangle area) transY = -clipArea.yOffset; } - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; @@ -990,7 +990,7 @@ void MobileOpenGLGraphics::popClipArea() int transX = -clipArea1.xOffset; int transY = -clipArea1.yOffset; - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index e8e1a2116..aea3f5d24 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -1223,7 +1223,7 @@ bool NormalOpenGLGraphics::pushClipArea(gcn::Rectangle area) transY = -clipArea.yOffset; } - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; @@ -1251,7 +1251,7 @@ void NormalOpenGLGraphics::popClipArea() int transX = -clipArea1.xOffset; int transY = -clipArea1.yOffset; - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 3ea1e4182..d1c6ed0a6 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -947,7 +947,7 @@ bool NullOpenGLGraphics::pushClipArea(gcn::Rectangle area) transY = -clipArea.yOffset; } - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; @@ -958,7 +958,7 @@ bool NullOpenGLGraphics::pushClipArea(gcn::Rectangle area) void NullOpenGLGraphics::popClipArea() { - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index bf9334655..c27db4f47 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -535,7 +535,7 @@ bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area) transY = -clipArea.yOffset; } - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &clipArea = mClipStack.top(); @@ -551,7 +551,7 @@ bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area) void SafeOpenGLGraphics::popClipArea() { - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 285b2dac2..46d8360b6 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + #ifdef USE_SDL2 #include "render/sdl2graphics.h" @@ -621,7 +664,7 @@ void SDLGraphics::_endDraw() bool SDLGraphics::pushClipArea(gcn::Rectangle area) { - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = @@ -637,7 +680,7 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area) void SDLGraphics::popClipArea() { - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index c4e0d74a7..1e581dc39 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 RENDER_SDL2GRAPHICS_H #define RENDER_SDL2GRAPHICS_H diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index c158844ae..e78a87c7e 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -1126,7 +1126,7 @@ void SDL2SoftwareGraphics::_endDraw() bool SDL2SoftwareGraphics::pushClipArea(gcn::Rectangle area) { - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = @@ -1142,7 +1142,7 @@ bool SDL2SoftwareGraphics::pushClipArea(gcn::Rectangle area) void SDL2SoftwareGraphics::popClipArea() { - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 9e950c12f..2226be0da 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -1122,7 +1122,7 @@ void SDLGraphics::_endDraw() bool SDLGraphics::pushClipArea(gcn::Rectangle area) { - const bool result = gcn::Graphics::pushClipArea(area); + const bool result = Graphics::pushClipArea(area); const gcn::ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { @@ -1138,7 +1138,7 @@ bool SDLGraphics::pushClipArea(gcn::Rectangle area) void SDLGraphics::popClipArea() { - gcn::Graphics::popClipArea(); + Graphics::popClipArea(); if (mClipStack.empty()) return; diff --git a/src/text.cpp b/src/text.cpp index fdd538d72..a1ffea08c 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -40,7 +40,7 @@ int Text::mInstances = 0; ImageRect Text::mBubble; Text::Text(const std::string &text, const int x, const int y, - const gcn::Graphics::Alignment alignment, + const Graphics::Alignment alignment, const gcn::Color *const color, const bool isSpeech, gcn::Font *const font) : mFont(font ? font : (gui ? gui->getFont() : nullptr)), @@ -78,13 +78,13 @@ Text::Text(const std::string &text, const int x, const int y, switch (alignment) { - case gcn::Graphics::LEFT: + case Graphics::LEFT: mXOffset = 0; break; - case gcn::Graphics::CENTER: + case Graphics::CENTER: mXOffset = mWidth / 2; break; - case gcn::Graphics::RIGHT: + case Graphics::RIGHT: mXOffset = mWidth; break; default: @@ -151,7 +151,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) } FlashText::FlashText(const std::string &text, const int x, const int y, - const gcn::Graphics::Alignment alignment, + const Graphics::Alignment alignment, const gcn::Color *const color, gcn::Font *const font) : Text(text, x, y, alignment, color, false, font), mTime(0) diff --git a/src/text.h b/src/text.h index ed980e588..b21ca51a7 100644 --- a/src/text.h +++ b/src/text.h @@ -30,6 +30,11 @@ #include "localconsts.h" +namespace gcn +{ + class Font; +} + class Text { friend class TextManager; @@ -39,7 +44,7 @@ class Text * Constructor creates a text object to display on the screen. */ Text(const std::string &text, const int x, const int y, - const gcn::Graphics::Alignment alignment, + const Graphics::Alignment alignment, const gcn::Color *const color, const bool isSpeech = false, gcn::Font *const font = nullptr); @@ -90,7 +95,7 @@ class FlashText final : public Text { public: FlashText(const std::string &text, const int x, const int y, - const gcn::Graphics::Alignment alignment, + const Graphics::Alignment alignment, const gcn::Color *const color, gcn::Font *const font = nullptr); -- cgit v1.2.3-70-g09d2 From ca9fac131283ed536971799bef0d1fff4ef8adc1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 22:21:02 +0300 Subject: Remove useless graphics casts. --- src/gui/gui.cpp | 9 +- src/gui/widgets/avatarlistbox.cpp | 4 +- src/gui/widgets/browserbox.cpp | 5 +- src/gui/widgets/button.cpp | 40 ++++---- src/gui/widgets/checkbox.cpp | 9 +- src/gui/widgets/colorpage.cpp | 7 +- src/gui/widgets/desktop.cpp | 17 ++-- src/gui/widgets/dropdown.cpp | 16 ++-- src/gui/widgets/dropshortcutcontainer.cpp | 11 +-- src/gui/widgets/emotepage.cpp | 7 +- src/gui/widgets/emoteshortcutcontainer.cpp | 10 +- src/gui/widgets/extendedlistbox.cpp | 15 +-- src/gui/widgets/icon.cpp | 3 +- src/gui/widgets/itemcontainer.cpp | 17 ++-- src/gui/widgets/itemshortcutcontainer.cpp | 28 +++--- src/gui/widgets/label.cpp | 3 +- src/gui/widgets/listbox.cpp | 9 +- src/gui/widgets/playerbox.cpp | 12 +-- src/gui/widgets/popup.cpp | 9 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/progressindicator.cpp | 2 +- src/gui/widgets/radiobutton.cpp | 9 +- src/gui/widgets/scrollarea.cpp | 145 +++++++++++++++++------------ src/gui/widgets/shoplistbox.cpp | 3 +- src/gui/widgets/slider.cpp | 50 ++++++---- src/gui/widgets/spellshortcutcontainer.cpp | 11 +-- src/gui/widgets/tabs/tab.cpp | 25 ++--- src/gui/widgets/textbox.cpp | 3 +- src/gui/widgets/textfield.cpp | 10 +- src/gui/widgets/textpreview.cpp | 17 ++-- src/gui/widgets/window.cpp | 48 ++++++---- src/gui/windows/debugwindow.cpp | 3 +- src/gui/windows/equipmentwindow.cpp | 30 +++--- src/gui/windows/minimap.cpp | 8 +- src/gui/windows/outfitwindow.cpp | 5 +- src/gui/windows/serverdialog.cpp | 9 +- src/gui/windows/skilldialog.cpp | 4 +- src/text.cpp | 8 +- 38 files changed, 328 insertions(+), 295 deletions(-) (limited to 'src') diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 00a3da25e..4da397a73 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -499,13 +499,12 @@ void Gui::draw() if ((client->getMouseFocused() || button & SDL_BUTTON(1)) && mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0F) { - Graphics *g2 = static_cast(mGraphics); const Image *const image = dragDrop.getItemImage(); if (image) { const int posX = mouseX - (image->mBounds.w / 2); const int posY = mouseY - (image->mBounds.h / 2); - g2->drawImage2(image, posX, posY); + mGraphics->drawImage2(image, posX, posY); } if (mGuiFont) { @@ -514,8 +513,8 @@ void Gui::draw() { const int posX = mouseX - mGuiFont->getWidth(str) / 2; const int posY = mouseY + (image ? image->mBounds.h / 2 : 0); - g2->setColorAll(mForegroundColor, mForegroundColor2); - mGuiFont->drawString(g2, str, posX, posY); + mGraphics->setColorAll(mForegroundColor, mForegroundColor2); + mGuiFont->drawString(mGraphics, str, posX, posY); } } @@ -523,7 +522,7 @@ void Gui::draw() if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); - g2->drawImage2(mouseCursor, mouseX - 15, mouseY - 17); + mGraphics->drawImage2(mouseCursor, mouseX - 15, mouseY - 17); } } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index e6f03493f..9a1aa40ab 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -90,7 +90,7 @@ AvatarListBox::~AvatarListBox() } } -void AvatarListBox::draw(Graphics *gcnGraphics) +void AvatarListBox::draw(Graphics *graphics) { BLOCK_START("AvatarListBox::draw") if (!mListModel || !player_node) @@ -102,10 +102,8 @@ void AvatarListBox::draw(Graphics *gcnGraphics) AvatarListModel *const model = static_cast( mListModel); updateAlpha(); - Graphics *const graphics = static_cast(gcnGraphics); gcn::Font *const font = getFont(); - const int fontHeight = getFont()->getHeight(); const gcn::Widget *const parent = mParent; const std::string name = player_node->getName(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index e0fbf3d17..024dde9c8 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -453,7 +453,6 @@ void BrowserBox::draw(Graphics *graphics) const gcn::ClipRectangle *const cr = graphics->getCurrentClipArea(); if (!cr) return; - Graphics *const graphics2 = static_cast(graphics); mYStart = cr->y - cr->yOffset; const int yEnd = mYStart + cr->height; if (mYStart < 0) @@ -503,7 +502,7 @@ void BrowserBox::draw(Graphics *graphics) break; if (!part.mType) { - graphics2->setColorAll(part.mColor, part.mColor2); + graphics->setColorAll(part.mColor, part.mColor2); if (part.mBold) boldFont->drawString(graphics, part.mText, part.mX, part.mY); else @@ -511,7 +510,7 @@ void BrowserBox::draw(Graphics *graphics) } else if (part.mImage) { - graphics2->drawImage2(part.mImage, part.mX, part.mY); + graphics->drawImage2(part.mImage, part.mX, part.mY); } } diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 8954ecf8e..6d326116d 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -373,8 +373,6 @@ void Button::draw(Graphics *graphics) updateAlpha(); - Graphics *const g2 = static_cast(graphics); - bool recalc = false; if (mRedraw) { @@ -384,7 +382,7 @@ void Button::draw(Graphics *graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - gcn::ClipRectangle &rect = g2->getTopClip(); + gcn::ClipRectangle &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { recalc = true; @@ -396,7 +394,7 @@ void Button::draw(Graphics *graphics) recalc = true; mMode = mode; } - else if (g2->getRedraw()) + else if (graphics->getRedraw()) { recalc = true; } @@ -408,16 +406,16 @@ void Button::draw(Graphics *graphics) switch (mode) { case BUTTON_DISABLED: - g2->setColorAll(mDisabledColor, mDisabledColor2); + graphics->setColorAll(mDisabledColor, mDisabledColor2); break; case BUTTON_PRESSED: - g2->setColorAll(mPressedColor, mPressedColor2); + graphics->setColorAll(mPressedColor, mPressedColor2); break; case BUTTON_HIGHLIGHTED: - g2->setColorAll(mHighlightedColor, mHighlightedColor2); + graphics->setColorAll(mHighlightedColor, mHighlightedColor2); break; default: - g2->setColorAll(mEnabledColor, mEnabledColor2); + graphics->setColorAll(mEnabledColor, mEnabledColor2); break; } @@ -481,39 +479,39 @@ void Button::draw(Graphics *graphics) mRedraw = false; mMode = mode; mVertexes2->clear(); - g2->calcWindow(mVertexes2, 0, 0, width, height, + graphics->calcWindow(mVertexes2, + 0, 0, + width, height, skin->getBorder()); if (mImages) { if (isPressed()) { - g2->calcTileCollection(mVertexes2, mImages[mode], + graphics->calcTileCollection(mVertexes2, + mImages[mode], imageX + 1, imageY + 1); } else { - g2->calcTileCollection(mVertexes2, - mImages[mode], imageX, imageY); + graphics->calcTileCollection(mVertexes2, + mImages[mode], + imageX, imageY); } } } - g2->drawTileCollection(mVertexes2); + graphics->drawTileCollection(mVertexes2); } else { - g2->drawImageRect(0, 0, width, height, skin->getBorder()); + graphics->drawImageRect(0, 0, width, height, skin->getBorder()); if (mImages) { if (isPressed()) - { - g2->drawImage2(mImages[mode], imageX + 1, imageY + 1); - } + graphics->drawImage2(mImages[mode], imageX + 1, imageY + 1); else - { - g2->drawImage2(mImages[mode], imageX, imageY); - } + graphics->drawImage2(mImages[mode], imageX, imageY); } } @@ -522,7 +520,7 @@ void Button::draw(Graphics *graphics) textX ++; textY ++; } - font->drawString(g2, mCaption, textX, textY); + font->drawString(graphics, mCaption, textX, textY); BLOCK_END("Button::draw") } diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index e72296516..2f11dc2ce 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -100,9 +100,7 @@ void CheckBox::draw(Graphics *const graphics) drawBox(graphics); gcn::Font *const font = getFont(); - static_cast(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); - + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); BLOCK_END("CheckBox::draw") @@ -167,8 +165,9 @@ void CheckBox::drawBox(Graphics *const graphics) if (box) { - static_cast(graphics)->drawImage2( - box, mImagePadding, (getHeight() - mImageSize) / 2); + graphics->drawImage2(box, + mImagePadding, + (getHeight() - mImageSize) / 2); } } diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 1d85874df..a9cf4f71e 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -53,7 +53,6 @@ void ColorPage::draw(Graphics *graphics) const ColorModel *const model = static_cast( mListModel); - Graphics *const g = static_cast(graphics); mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); @@ -70,20 +69,20 @@ void ColorPage::draw(Graphics *graphics) mDimension.width - 2 * mPadding, rowHeight)); const ColorPair *const colors = model->getColorAt(mSelected); - g->setColorAll(*colors->color1, *colors->color2); + graphics->setColorAll(*colors->color1, *colors->color2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, (width - font->getWidth(str)) / 2, mSelected * rowHeight + mPadding); } - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding; i < sz; ++i, y += rowHeight) { if (i != mSelected) { const ColorPair *const colors = model->getColorAt(i); - g->setColorAll(*colors->color1, *colors->color2); + graphics->setColorAll(*colors->color1, *colors->color2); const std::string str = mListModel->getElementAt(i); font->drawString(graphics, str, (width - font->getWidth(str)) / 2, y); diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 4a4a73b53..b46fe3289 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -106,7 +106,6 @@ void Desktop::widgetResized(const gcn::Event &event A_UNUSED) void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") - Graphics *const g = static_cast(graphics); const gcn::Rectangle &rect = mDimension; const int width = rect.width; @@ -118,30 +117,30 @@ void Desktop::draw(Graphics *graphics) if (width > wallpWidth || height > wallpHeight) { - g->setColor(mBackgroundGrayColor); - g->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->setColor(mBackgroundGrayColor); + graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); } if (imageHelper->useOpenGL() == RENDER_SOFTWARE) { - g->drawImage2(mWallpaper, + graphics->drawImage2(mWallpaper, (width - wallpWidth) / 2, (height - wallpHeight) / 2); } else { - g->drawRescaledImage(mWallpaper, 0, 0, width, height); + graphics->drawRescaledImage(mWallpaper, 0, 0, width, height); } } else { - g->setColor(mBackgroundGrayColor); - g->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->setColor(mBackgroundGrayColor); + graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); } // Draw a thin border under the application version... - g->setColor(mBackgroundColor); - g->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); + graphics->setColor(mBackgroundColor); + graphics->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); BLOCK_END("Desktop::draw") diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 354c88423..7aa53e83f 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -235,8 +235,7 @@ void DropDown::draw(Graphics* graphics) if (model && mPopup->getSelected() >= 0) { gcn::Font *const font = getFont(); - static_cast(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); if (mExtended) { const int sel = mPopup->getSelected(); @@ -250,9 +249,9 @@ void DropDown::draw(Graphics* graphics) } else { - static_cast(graphics)->drawImage2( - image, mImagePadding, (mDimension.height - - image->getHeight()) / 2 + mPadding); + graphics->drawImage2(image, + mImagePadding, + (mDimension.height - image->getHeight()) / 2 + mPadding); font->drawString(graphics, model->getElementAt(sel), image->getWidth() + mImagePadding + mSpacing, mPadding); } @@ -291,8 +290,9 @@ void DropDown::drawFrame(Graphics *graphics) BLOCK_START("DropDown::drawFrame") const int bs2 = getFrameSize(); const gcn::Rectangle &rect = mDimension; - static_cast(graphics)->drawImageRect( - 0, 0, rect.width + bs2, rect.height + bs2, skinRect); + graphics->drawImageRect(0, 0, + rect.width + bs2, rect.height + bs2, + skinRect); BLOCK_END("DropDown::drawFrame") } @@ -303,7 +303,7 @@ void DropDown::drawButton(Graphics *graphics) Image *image = buttons[mDroppedDown][mPushed]; if (image) { - static_cast(graphics)->drawImage2(image, + graphics->drawImage2(image, mDimension.width - image->getWidth() - mImagePadding, (height - image->getHeight()) / 2); } diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 892a74638..9b37682fe 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -107,8 +107,7 @@ void DropShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *const g = static_cast(graphics); - drawBackground(g); + drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) @@ -144,12 +143,12 @@ void DropShortcutContainer::draw(Graphics *graphics) caption = "Eq."; image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); if (item->isEquipped()) - g->setColorAll(mEquipedColor, mEquipedColor2); + graphics->setColorAll(mEquipedColor, mEquipedColor2); else - g->setColorAll(mUnEquipedColor, mUnEquipedColor2); - font->drawString(g, caption, + graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2); + font->drawString(graphics, caption, itemX + (mBoxWidth - font->getWidth(caption)) / 2, itemY + mBoxHeight - 14); } diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 869ae5d08..6101c20ae 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -68,7 +68,6 @@ void EmotePage::draw(Graphics *graphics) const std::vector &images = mEmotes->getImages(); - Graphics *const g = static_cast(graphics); const unsigned int width = mDimension.width; unsigned int x = 0; unsigned int y = 0; @@ -84,7 +83,7 @@ void EmotePage::draw(Graphics *graphics) const Image *const image = *it; if (image) { - g->calcTileCollection(mVertexes, image, x, y); + graphics->calcTileCollection(mVertexes, image, x, y); x += emoteWidth; if (x + emoteWidth > width) { @@ -94,7 +93,7 @@ void EmotePage::draw(Graphics *graphics) } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { @@ -103,7 +102,7 @@ void EmotePage::draw(Graphics *graphics) const Image *const image = *it; if (image) { - g->drawImage2(image, x, y); + graphics->drawImage2(image, x, y); x += emoteWidth; if (x + emoteWidth > width) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index bdb5c3163..dc25d9e5c 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -112,11 +112,10 @@ void EmoteShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - Graphics *const g = static_cast(graphics); gcn::Font *const font = getFont(); - drawBackground(g); + drawBackground(graphics); - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); for (unsigned i = 0; i < mMaxItems; i++) { const int emoteX = (i % mGridWidth) * mBoxWidth; @@ -126,7 +125,7 @@ void EmoteShortcutContainer::draw(Graphics *graphics) const std::string key = inputManager.getKeyValueString( Input::KEY_EMOTE_1 + i); - font->drawString(g, key, emoteX + 2, emoteY + 2); + font->drawString(graphics, key, emoteX + 2, emoteY + 2); } unsigned sz = static_cast(mEmoteImg.size()); if (sz > mMaxItems) @@ -139,7 +138,8 @@ void EmoteShortcutContainer::draw(Graphics *graphics) const AnimatedSprite *const sprite = emoteImg->sprite; if (sprite) { - sprite->draw(g, (i % mGridWidth) * mBoxWidth + 2, + sprite->draw(graphics, + (i % mGridWidth) * mBoxWidth + 2, (i / mGridWidth) * mBoxHeight + 10); } } diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 66065295c..f06e89e55 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -56,7 +56,6 @@ void ExtendedListBox::draw(Graphics *graphics) BLOCK_START("ExtendedListBox::draw") ExtendedListModel *const model = static_cast( mListModel); - Graphics *const g = static_cast(graphics); updateAlpha(); gcn::Font *const font = getFont(); @@ -147,13 +146,14 @@ void ExtendedListBox::draw(Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - g->drawImage2(image, mImagePadding, item.y + (height - - image->getHeight()) / 2 + mPadding); + graphics->drawImage2(image, + mImagePadding, + item.y + (height - image->getHeight()) / 2 + mPadding); } } } - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); for (int f = 0; f < itemsSz; ++f) { @@ -181,13 +181,14 @@ void ExtendedListBox::draw(Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - g->drawImage2(image, mImagePadding, item.y + (height - - image->getHeight()) / 2 + mPadding); + graphics->drawImage2(image, + mImagePadding, + item.y + (height - image->getHeight()) / 2 + mPadding); } } } - g->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); for (int f = 0; f < selSz; ++f) { diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index e9b7cd525..66313d397 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -67,12 +67,11 @@ void Icon::setImage(Image *const image) } } -void Icon::draw(Graphics *g) +void Icon::draw(Graphics *graphics) { BLOCK_START("Icon::draw") if (mImage) { - Graphics *const graphics = static_cast(g); graphics->drawImage2(mImage, (mDimension.width - mImage->mBounds.w) / 2, (mDimension.height - mImage->mBounds.h) / 2); diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index eedbc1bd0..0913dcae3 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -251,7 +251,6 @@ void ItemContainer::draw(Graphics *graphics) return; BLOCK_START("ItemContainer::draw") - Graphics *const g = static_cast(graphics); gcn::Font *const font = getFont(); for (int j = 0; j < mGridRows; j++) @@ -278,16 +277,18 @@ void ItemContainer::draw(Graphics *graphics) if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelImg) - g->drawImage2(mSelImg, itemX, itemY); + graphics->drawImage2(mSelImg, itemX, itemY); } image->setAlpha(1.0F); // ensure the image if fully drawn... - g->drawImage2(image, itemX + mPaddingItemX, + graphics->drawImage2(image, + itemX + mPaddingItemX, itemY + mPaddingItemY); if (mProtectedImg && PlayerInfo::isItemProtected( item->getId())) { - g->drawImage2(mProtectedImg, - itemX + mPaddingItemX, itemY + mPaddingItemY); + graphics->drawImage2(mProtectedImg, + itemX + mPaddingItemX, + itemY + mPaddingItemY); } } } @@ -324,11 +325,11 @@ void ItemContainer::draw(Graphics *graphics) } if (item->isEquipped()) - g->setColorAll(mEquipedColor, mEquipedColor2); + graphics->setColorAll(mEquipedColor, mEquipedColor2); else - g->setColorAll(mUnEquipedColor, mUnEquipedColor2); + graphics->setColorAll(mUnEquipedColor, mUnEquipedColor2); - font->drawString(g, caption, + font->drawString(graphics, caption, itemX + (mBoxWidth - font->getWidth(caption)) / 2, itemY + mEquippedTextPadding); } diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 78b9c0e62..2438050d9 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -129,9 +129,8 @@ void ItemShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - Graphics *const g = static_cast(graphics); gcn::Font *const font = getFont(); - drawBackground(g); + drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) @@ -149,8 +148,8 @@ void ItemShortcutContainer::draw(Graphics *graphics) // Draw item keyboard shortcut. const std::string key = inputManager.getKeyValueString( Input::KEY_SHORTCUT_1 + i); - g->setColorAll(mForegroundColor, mForegroundColor); - font->drawString(g, key, itemX + 2, itemY + 2); + graphics->setColorAll(mForegroundColor, mForegroundColor); + font->drawString(graphics, key, itemX + 2, itemY + 2); const int itemId = selShortcut->getItem(i); const unsigned char itemColor = selShortcut->getItemColor(i); @@ -175,12 +174,17 @@ void ItemShortcutContainer::draw(Graphics *graphics) caption = "Eq."; image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); if (item->isEquipped()) - g->setColorAll(mEquipedColor, mEquipedColor2); + { + graphics->setColorAll(mEquipedColor, mEquipedColor2); + } else - g->setColorAll(mUnEquipedColor, mUnEquipedColor2); - font->drawString(g, caption, + { + graphics->setColorAll(mUnEquipedColor, + mUnEquipedColor2); + } + font->drawString(graphics, caption, itemX + (mBoxWidth - font->getWidth(caption)) / 2, itemY + mBoxHeight - 14); } @@ -199,11 +203,11 @@ void ItemShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); } } - font->drawString(g, spell->getSymbol(), + font->drawString(graphics, spell->getSymbol(), itemX + 2, itemY + mBoxHeight / 2); } } @@ -218,10 +222,10 @@ void ItemShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); } - font->drawString(g, skill->data->shortName, itemX + 2, + font->drawString(graphics, skill->data->shortName, itemX + 2, itemY + mBoxHeight / 2); } } diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 89ba17cd6..b2b709052 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -101,8 +101,7 @@ void Label::draw(Graphics* graphics) break; } - static_cast(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, textX, textY); BLOCK_END("Label::draw") } diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 0a7956476..e71907f37 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -106,7 +106,6 @@ void ListBox::draw(Graphics *graphics) BLOCK_START("ListBox::draw") updateAlpha(); - Graphics *const g = static_cast(graphics); mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); @@ -123,7 +122,7 @@ void ListBox::draw(Graphics *graphics) rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); - g->setColorAll(mForegroundSelectedColor, + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, @@ -131,7 +130,7 @@ void ListBox::draw(Graphics *graphics) mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding + mItemPadding; i < sz; ++i, y += rowHeight) @@ -153,14 +152,14 @@ void ListBox::draw(Graphics *graphics) rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); - g->setColorAll(mForegroundSelectedColor, + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); const std::string str = mListModel->getElementAt(mSelected); font->drawString(graphics, str, mPadding, mSelected * rowHeight + mPadding + mItemPadding); } // Draw the list elements - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int sz = mListModel->getNumberOfElements(); for (int i = 0, y = mPadding + mItemPadding; i < sz; ++i, y += rowHeight) diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 260f80099..0639fe1b0 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -115,7 +115,7 @@ void PlayerBox::draw(Graphics *graphics) const int bs = mFrameSize; const int x = mDimension.width / 2 + bs + mOffsetX; const int y = mDimension.height - bs + mOffsetY; - mBeing->drawSpriteAt(static_cast(graphics), x, y); + mBeing->drawSpriteAt(graphics, x, y); } if (client->getGuiAlpha() != mAlpha) @@ -140,15 +140,9 @@ void PlayerBox::drawFrame(Graphics *graphics) const int h = mDimension.height + bs; if (!mSelected) - { - static_cast(graphics)->drawImageRect( - 0, 0, w, h, mBackground); - } + graphics->drawImageRect(0, 0, w, h, mBackground); else - { - static_cast(graphics)->drawImageRect( - 0, 0, w, h, mSelectedBackground); - } + graphics->drawImageRect(0, 0, w, h, mSelectedBackground); } BLOCK_END("PlayerBox::drawFrame") } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 56d5d0d0c..c1319737e 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -97,7 +97,6 @@ void Popup::setWindowContainer(WindowContainer *const wc) void Popup::draw(Graphics *graphics) { BLOCK_START("Popup::draw") - Graphics *const g = static_cast(graphics); if (mSkin) { @@ -107,16 +106,18 @@ void Popup::draw(Graphics *graphics) { mRedraw = false; mVertexes->clear(); - g->calcWindow(mVertexes, 0, 0, + graphics->calcWindow(mVertexes, + 0, 0, mDimension.width, mDimension.height, mSkin->getBorder()); } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { - g->drawImageRect(0, 0, mDimension.width, mDimension.height, + graphics->drawImageRect(0, 0, + mDimension.width, mDimension.height, mSkin->getBorder()); } } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 28c87f4ec..242b6ba6e 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -151,7 +151,7 @@ void ProgressBar::draw(Graphics *graphics) BLOCK_START("ProgressBar::draw") updateAlpha(); mBackgroundColor.a = static_cast(mAlpha * 255); - render(static_cast(graphics)); + render(graphics); BLOCK_END("ProgressBar::draw") } diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 358518132..b3f5b0e54 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -73,7 +73,7 @@ void ProgressIndicator::draw(Graphics *graphics) // Draw the indicator centered on the widget const int x = (mDimension.width - 32) / 2; const int y = (mDimension.height - 32) / 2; - mIndicator->draw(static_cast(graphics), x, y); + mIndicator->draw(graphics, x, y); } BLOCK_END("ProgressIndicator::draw") } diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 4a47a4b4e..092841dcf 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -149,8 +149,9 @@ void RadioButton::drawBox(Graphics* graphics) if (box) { - static_cast(graphics)->drawImage2( - box, mImagePadding, (getHeight() - mImageSize) / 2); + graphics->drawImage2(box, + mImagePadding, + (getHeight() - mImageSize) / 2); } } @@ -160,9 +161,7 @@ void RadioButton::draw(Graphics* graphics) drawBox(graphics); gcn::Font *const font = getFont(); - static_cast(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); - + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); BLOCK_END("RadioButton::draw") diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 89e75f4d7..26add84c1 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -282,8 +282,7 @@ void ScrollArea::draw(Graphics *graphics) calcHMarker(graphics); } } - static_cast(graphics)->drawTileCollection( - mVertexes); + graphics->drawTileCollection(mVertexes); } else { @@ -315,11 +314,10 @@ void ScrollArea::draw(Graphics *graphics) if (mRedraw) { - Graphics *g = static_cast(graphics); - const bool redraw = g->getRedraw(); - g->setRedraw(true); + const bool redraw = graphics->getRedraw(); + graphics->setRedraw(true); drawChildren(graphics); - g->setRedraw(redraw); + graphics->setRedraw(redraw); } else { @@ -335,8 +333,7 @@ void ScrollArea::updateCalcFlag(Graphics *const graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - const gcn::ClipRectangle &rect = static_cast( - graphics)->getTopClip(); + const gcn::ClipRectangle &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { mRedraw = true; @@ -349,7 +346,7 @@ void ScrollArea::updateCalcFlag(Graphics *const graphics) mDrawWidth = rect.width; mDrawHeight = rect.height; } - else if (static_cast(graphics)->getRedraw()) + else if (graphics->getRedraw()) { mRedraw = true; } @@ -372,15 +369,18 @@ void ScrollArea::drawFrame(Graphics *graphics) if (mRedraw) { mVertexes2->clear(); - static_cast(graphics)->calcWindow( - mVertexes2, 0, 0, w, h, background); + graphics->calcWindow(mVertexes2, + 0, 0, + w, h, + background); } - static_cast(graphics)->drawTileCollection(mVertexes2); + graphics->drawTileCollection(mVertexes2); } else { - static_cast(graphics)->drawImageRect( - 0, 0, w, h, background); + graphics->drawImageRect(0, 0, + w, h, + background); } } BLOCK_END("ScrollArea::drawFrame") @@ -424,10 +424,7 @@ void ScrollArea::drawButton(Graphics *const graphics, } if (buttons[dir][state]) - { - static_cast(graphics)->drawImage2( - buttons[dir][state], dim.x, dim.y); - } + graphics->drawImage2(buttons[dir][state], dim.x, dim.y); } void ScrollArea::calcButton(Graphics *const graphics, @@ -471,21 +468,21 @@ void ScrollArea::calcButton(Graphics *const graphics, void ScrollArea::drawVBar(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalBarDimension(); - Graphics *const g = static_cast(graphics); if (vBackground.grid[4]) { - g->drawPattern(vBackground.grid[4], + graphics->drawPattern(vBackground.grid[4], dim.x, dim.y, dim.width, dim.height); } if (vBackground.grid[1]) { - g->drawPattern(vBackground.grid[1], - dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight()); + graphics->drawPattern(vBackground.grid[1], + dim.x, dim.y, + dim.width, vBackground.grid[1]->getHeight()); } if (vBackground.grid[7]) { - g->drawPattern(vBackground.grid[7], + graphics->drawPattern(vBackground.grid[7], dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y, dim.width, vBackground.grid[7]->getHeight()); } @@ -494,21 +491,25 @@ void ScrollArea::drawVBar(Graphics *const graphics) void ScrollArea::calcVBar(Graphics *const graphics) { const gcn::Rectangle &dim = getVerticalBarDimension(); - Graphics *const g = static_cast(graphics); if (vBackground.grid[4]) { - g->calcPattern(mVertexes, vBackground.grid[4], - dim.x, dim.y, dim.width, dim.height); + graphics->calcPattern(mVertexes, + vBackground.grid[4], + dim.x, dim.y, + dim.width, dim.height); } if (vBackground.grid[1]) { - g->calcPattern(mVertexes, vBackground.grid[1], - dim.x, dim.y, dim.width, vBackground.grid[1]->getHeight()); + graphics->calcPattern(mVertexes, + vBackground.grid[1], + dim.x, dim.y, + dim.width, vBackground.grid[1]->getHeight()); } if (vBackground.grid[7]) { - g->calcPattern(mVertexes, vBackground.grid[7], + graphics->calcPattern(mVertexes, + vBackground.grid[7], dim.x, dim.height - vBackground.grid[7]->getHeight() + dim.y, dim.width, vBackground.grid[7]->getHeight()); } @@ -517,50 +518,59 @@ void ScrollArea::calcVBar(Graphics *const graphics) void ScrollArea::drawHBar(Graphics *const graphics) { const gcn::Rectangle &dim = getHorizontalBarDimension(); - Graphics *const g = static_cast(graphics); if (hBackground.grid[4]) { - g->drawPattern(hBackground.grid[4], - dim.x, dim.y, dim.width, dim.height); + graphics->drawPattern(hBackground.grid[4], + dim.x, dim.y, + dim.width, dim.height); } if (hBackground.grid[3]) { - g->drawPattern(hBackground.grid[3], - dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height); + graphics->drawPattern(hBackground.grid[3], + dim.x, dim.y, + hBackground.grid[3]->getWidth(), dim.height); } if (hBackground.grid[5]) { - g->drawPattern(hBackground.grid[5], - dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y, - hBackground.grid[5]->getWidth(), dim.height); + graphics->drawPattern(hBackground.grid[5], + dim.x + dim.width - hBackground.grid[5]->getWidth(), + dim.y, + hBackground.grid[5]->getWidth(), + dim.height); } } void ScrollArea::calcHBar(Graphics *const graphics) { const gcn::Rectangle &dim = getHorizontalBarDimension(); - Graphics *const g = static_cast(graphics); if (hBackground.grid[4]) { - g->calcPattern(mVertexes, hBackground.grid[4], - dim.x, dim.y, dim.width, dim.height); + graphics->calcPattern(mVertexes, + hBackground.grid[4], + dim.x, dim.y, + dim.width, dim.height); } if (hBackground.grid[3]) { - g->calcPattern(mVertexes, hBackground.grid[3], - dim.x, dim.y, hBackground.grid[3]->getWidth(), dim.height); + graphics->calcPattern(mVertexes, + hBackground.grid[3], + dim.x, dim.y, + hBackground.grid[3]->getWidth(), dim.height); } if (hBackground.grid[5]) { - g->calcPattern(mVertexes, hBackground.grid[5], - dim.x + dim.width - hBackground.grid[5]->getWidth(), dim.y, - hBackground.grid[5]->getWidth(), dim.height); + graphics->calcPattern(mVertexes, + hBackground.grid[5], + dim.x + dim.width - hBackground.grid[5]->getWidth(), + dim.y, + hBackground.grid[5]->getWidth(), + dim.height); } } @@ -570,13 +580,15 @@ void ScrollArea::drawVMarker(Graphics *const graphics) if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { - static_cast(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->drawImageRect(dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->drawImageRect(dim.x, dim.y, + dim.width, dim.height, + vMarker); } } @@ -586,13 +598,17 @@ void ScrollArea::calcVMarker(Graphics *const graphics) if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { - static_cast(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarker); } } @@ -602,13 +618,16 @@ void ScrollArea::drawHMarker(Graphics *const graphics) if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { - static_cast(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->drawImageRect(dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast(graphics)-> - drawImageRect(dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->drawImageRect( + dim.x, dim.y, + dim.width, dim.height, + vMarker); } } @@ -618,13 +637,17 @@ void ScrollArea::calcHMarker(Graphics *const graphics) if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { - static_cast(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarkerHi); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarkerHi); } else { - static_cast(graphics)->calcWindow( - mVertexes, dim.x, dim.y, dim.width, dim.height, vMarker); + graphics->calcWindow(mVertexes, + dim.x, dim.y, + dim.width, dim.height, + vMarker); } } diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 644023c43..8f45abeb3 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -82,7 +82,7 @@ void ShopListBox::setPlayersMoney(const int money) mPlayerMoney = money; } -void ShopListBox::draw(Graphics *gcnGraphics) +void ShopListBox::draw(Graphics *graphics) { BLOCK_START("ShopListBox::draw") if (!mListModel || !mShopItems) @@ -95,7 +95,6 @@ void ShopListBox::draw(Graphics *gcnGraphics) mAlpha = client->getGuiAlpha(); const int alpha = static_cast(mAlpha * 255.0F); - Graphics *graphics = static_cast(gcnGraphics); gcn::Font *const font = getFont(); const int sz = mListModel->getNumberOfElements(); diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 1427bb6eb..8eb27824d 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -133,19 +133,18 @@ void Slider::draw(Graphics *graphics) int x = 0; const int y = mHasMouse ? (h - buttons[1].grid[HSTART]->getHeight()) / 2 : (h - buttons[0].grid[HSTART]->getHeight()) / 2; - Graphics *const g = static_cast(graphics); updateAlpha(); if (isBatchDrawRenders(openGLMode)) { - if (mRedraw || g->getRedraw()) + if (mRedraw || graphics->getRedraw()) { mRedraw = false; mVertexes->clear(); if (!mHasMouse) { - g->calcTileCollection(mVertexes, + graphics->calcTileCollection(mVertexes, buttons[0].grid[HSTART], x, y); const int width = buttons[0].grid[HSTART]->getWidth(); @@ -155,24 +154,31 @@ void Slider::draw(Graphics *graphics) if (buttons[0].grid[HMID]) { const Image *const hMid = buttons[0].grid[HMID]; - g->calcPattern(mVertexes, hMid, x, y, + graphics->calcPattern(mVertexes, + hMid, + x, y, w, hMid->getHeight()); } x += w; - g->calcTileCollection(mVertexes, buttons[0].grid[HEND], x, y); + graphics->calcTileCollection(mVertexes, + buttons[0].grid[HEND], + x, y); const Image *const img = buttons[0].grid[HGRIP]; if (img) { - g->calcTileCollection(mVertexes, img, getMarkerPosition(), + graphics->calcTileCollection(mVertexes, + img, + getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } else { - g->calcTileCollection(mVertexes, - buttons[1].grid[HSTART], x, y); + graphics->calcTileCollection(mVertexes, + buttons[1].grid[HSTART], + x, y); const int width = buttons[1].grid[HSTART]->getWidth(); w -= width; @@ -183,32 +189,36 @@ void Slider::draw(Graphics *graphics) if (buttons[1].grid[HMID]) { const Image *const hMid = buttons[1].grid[HMID]; - g->calcPattern(mVertexes, hMid, x, y, + graphics->calcPattern(mVertexes, + hMid, + x, y, w, hMid->getHeight()); } x += w; if (buttons[1].grid[HEND]) { - g->calcTileCollection(mVertexes, + graphics->calcTileCollection(mVertexes, buttons[1].grid[HEND], x, y); } const Image *const img = buttons[1].grid[HGRIP]; if (img) { - g->calcTileCollection(mVertexes, img, getMarkerPosition(), + graphics->calcTileCollection(mVertexes, + img, + getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { if (!mHasMouse) { - g->drawImage2(buttons[0].grid[HSTART], x, y); + graphics->drawImage2(buttons[0].grid[HSTART], x, y); const int width = buttons[0].grid[HSTART]->getWidth(); w -= width + buttons[0].grid[HEND]->getWidth(); x += width; @@ -216,22 +226,22 @@ void Slider::draw(Graphics *graphics) if (buttons[0].grid[HMID]) { const Image *const hMid = buttons[0].grid[HMID]; - g->drawPattern(hMid, x, y, w, hMid->getHeight()); + graphics->drawPattern(hMid, x, y, w, hMid->getHeight()); } x += w; - g->drawImage2(buttons[0].grid[HEND], x, y); + graphics->drawImage2(buttons[0].grid[HEND], x, y); const Image *const img = buttons[0].grid[HGRIP]; if (img) { - g->drawImage2(img, getMarkerPosition(), + graphics->drawImage2(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } else { - g->drawImage2(buttons[1].grid[HSTART], x, y); + graphics->drawImage2(buttons[1].grid[HSTART], x, y); const int width = buttons[1].grid[HSTART]->getWidth(); w -= width; @@ -242,17 +252,17 @@ void Slider::draw(Graphics *graphics) if (buttons[1].grid[HMID]) { const Image *const hMid = buttons[1].grid[HMID]; - g->drawPattern(hMid, x, y, w, hMid->getHeight()); + graphics->drawPattern(hMid, x, y, w, hMid->getHeight()); } x += w; if (buttons[1].grid[HEND]) - g->drawImage2(buttons[1].grid[HEND], x, y); + graphics->drawImage2(buttons[1].grid[HEND], x, y); const Image *const img = buttons[1].grid[HGRIP]; if (img) { - g->drawImage2(img, getMarkerPosition(), + graphics->drawImage2(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 7c59676b9..696b0fbb4 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -103,12 +103,11 @@ void SpellShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - Graphics *const g = static_cast(graphics); gcn::Font *const font = getFont(); const int selectedId = spellShortcut->getSelectedItem(); - g->setColorAll(mForegroundColor, mForegroundColor2); - drawBackground(g); + graphics->setColorAll(mForegroundColor, mForegroundColor2); + drawBackground(graphics); for (unsigned i = 0; i < mMaxItems; i++) { @@ -118,7 +117,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) const int itemId = getItemByIndex(i); if (selectedId >= 0 && itemId == selectedId) { - g->drawRectangle(gcn::Rectangle(itemX + 1, itemY + 1, + graphics->drawRectangle(gcn::Rectangle(itemX + 1, itemY + 1, mBoxWidth - 1, mBoxHeight - 1)); } @@ -135,11 +134,11 @@ void SpellShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); } } - font->drawString(g, spell->getSymbol(), + font->drawString(graphics, spell->getSymbol(), itemX + 2, itemY + mBoxHeight / 2); } } diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index d0561cadf..bba1ef7b6 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -204,19 +204,19 @@ void Tab::draw(Graphics *graphics) updateAlpha(); - Graphics *const g = static_cast(graphics); - // draw tab if (isBatchDrawRenders(openGLMode)) { const ImageRect &rect = skin->getBorder(); - if (mRedraw || mode != mMode || g->getRedraw()) + if (mRedraw || mode != mMode || graphics->getRedraw()) { mMode = mode; mRedraw = false; mVertexes->clear(); - g->calcWindow(mVertexes, 0, 0, - mDimension.width, mDimension.height, rect); + graphics->calcWindow(mVertexes, + 0, 0, + mDimension.width, mDimension.height, + rect); if (mImage) { @@ -224,25 +224,28 @@ void Tab::draw(Graphics *graphics) if (skin1) { const int padding = skin1->getPadding(); - g->calcTileCollection(mVertexes, mImage, - padding, padding); + graphics->calcTileCollection(mVertexes, + mImage, + padding, + padding); } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { - g->drawImageRect(0, 0, - mDimension.width, mDimension.height, skin->getBorder()); + graphics->drawImageRect(0, 0, + mDimension.width, mDimension.height, + skin->getBorder()); if (mImage) { const Skin *const skin1 = tabImg[TAB_STANDARD]; if (skin1) { const int padding = skin1->getPadding(); - g->drawImage2(mImage, padding, padding); + graphics->drawImage2(mImage, padding, padding); } } } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 8aaca4211..6bd301b32 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -367,8 +367,7 @@ void TextBox::draw(Graphics* graphics) mCaretRow * font->getHeight()); } - static_cast(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); const int fontHeight = font->getHeight(); for (size_t i = 0, sz = mTextRows.size(); i < sz; i++) diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index b1d188f22..fdcd84089 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -149,8 +149,7 @@ void TextField::draw(Graphics *graphics) font->getWidth(mText.substr(0, mCaretPosition)) - mXScroll); } - static_cast(graphics)->setColorAll( - mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mText, mPadding - mXScroll, mPadding); BLOCK_END("TextField::draw") } @@ -159,8 +158,11 @@ void TextField::drawFrame(Graphics *graphics) { BLOCK_START("TextField::drawFrame") const int bs = 2 * mFrameSize; - static_cast(graphics)->drawImageRect(0, 0, - mDimension.width + bs, mDimension.height + bs, skin); + graphics->drawImageRect(0, + 0, + mDimension.width + bs, + mDimension.height + bs, + skin); BLOCK_END("TextField::drawFrame") } diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 5cfb2abb5..5ef553b3c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -84,18 +84,17 @@ void TextPreview::draw(Graphics* graphics) BLOCK_START("TextPreview::draw") if (client->getGuiAlpha() != mAlpha) mAlpha = client->getGuiAlpha(); - Graphics *const g = static_cast(graphics); const int intAlpha = static_cast(mAlpha * 255.0F); const int alpha = mTextAlpha ? intAlpha : 255; if (mOpaque) { - g->setColor(gcn::Color(static_cast(mBGColor->r), + graphics->setColor(gcn::Color(static_cast(mBGColor->r), static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0F))); - g->fillRectangle(gcn::Rectangle(0, 0, + graphics->fillRectangle(gcn::Rectangle(0, 0, mDimension.width, mDimension.height)); } @@ -108,20 +107,20 @@ void TextPreview::draw(Graphics* graphics) + 2 * ((mOutline || mShadow) ? 1 :0); const int y = font->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); - g->setColor(gcn::Color(static_cast(mTextBGColor->r), + graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), intAlpha)); - g->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); + graphics->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); } } - g->setColorAll(gcn::Color(mTextColor->r, mTextColor->g, mTextColor->b, - alpha), gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, - alpha)); + graphics->setColorAll(gcn::Color(mTextColor->r, + mTextColor->g, mTextColor->b, alpha), + gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); if (mOutline && mTextColor != mTextColor2) - g->setColor2(Theme::getThemeColor(Theme::OUTLINE)); + graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE)); mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1); BLOCK_END("TextPreview::draw") diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 26ca0a29f..54ec3c859 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -209,7 +209,6 @@ void Window::draw(Graphics *graphics) return; BLOCK_START("Window::draw") - Graphics *const g = static_cast(graphics); bool update = false; if (isBatchDrawRenders(openGLMode)) @@ -225,8 +224,11 @@ void Window::draw(Graphics *graphics) mRedraw = false; update = true; mVertexes->clear(); - g->calcWindow(mVertexes, 0, 0, mDimension.width, - mDimension.height, mSkin->getBorder()); + graphics->calcWindow(mVertexes, + 0, 0, + mDimension.width, + mDimension.height, + mSkin->getBorder()); // Draw Close Button if (mCloseWindowButton) @@ -235,8 +237,10 @@ void Window::draw(Graphics *graphics) mResizeHandles == CLOSE); if (button) { - g->calcTileCollection(mVertexes, button, - mCloseRect.x, mCloseRect.y); + graphics->calcTileCollection(mVertexes, + button, + mCloseRect.x, + mCloseRect.y); } } // Draw Sticky Button @@ -245,27 +249,33 @@ void Window::draw(Graphics *graphics) const Image *const button = mSkin->getStickyImage(mSticky); if (button) { - g->calcTileCollection(mVertexes, button, - mStickyRect.x, mStickyRect.y); + graphics->calcTileCollection(mVertexes, + button, + mStickyRect.x, + mStickyRect.y); } } if (mGrip) { - g->calcTileCollection(mVertexes, mGrip, - mGripRect.x, mGripRect.y); + graphics->calcTileCollection(mVertexes, + mGrip, + mGripRect.x, + mGripRect.y); } } else { mLastRedraw = false; } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { - g->drawImageRect(0, 0, mDimension.width, - mDimension.height, mSkin->getBorder()); + graphics->drawImageRect(0, 0, + mDimension.width, + mDimension.height, + mSkin->getBorder()); // Draw Close Button if (mCloseWindowButton) @@ -273,24 +283,24 @@ void Window::draw(Graphics *graphics) const Image *const button = mSkin->getCloseImage( mResizeHandles == CLOSE); if (button) - g->drawImage2(button, mCloseRect.x, mCloseRect.y); + graphics->drawImage2(button, mCloseRect.x, mCloseRect.y); } // Draw Sticky Button if (mStickyButton) { const Image *const button = mSkin->getStickyImage(mSticky); if (button) - g->drawImage2(button, mStickyRect.x, mStickyRect.y); + graphics->drawImage2(button, mStickyRect.x, mStickyRect.y); } if (mGrip) - g->drawImage2(mGrip, mGripRect.x, mGripRect.y); + graphics->drawImage2(mGrip, mGripRect.x, mGripRect.y); } // Draw title if (mShowTitle) { - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); int x; switch (mCaptionAlign) { @@ -305,14 +315,14 @@ void Window::draw(Graphics *graphics) x = mCaptionOffsetX - mCaptionFont->getWidth(mCaption); break; } - mCaptionFont->drawString(g, mCaption, x, mCaptionOffsetY); + mCaptionFont->drawString(graphics, mCaption, x, mCaptionOffsetY); } if (update) { - g->setRedraw(update); + graphics->setRedraw(update); drawChildren(graphics); - g->setRedraw(false); + graphics->setRedraw(false); } else { diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 4f57b9798..7cc074086 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -139,8 +139,7 @@ void DebugWindow::draw(Graphics *g) const Being *const target = player_node->getTarget(); if (target) { - Graphics *const g2 = static_cast(g); - target->draw(g2, -target->getPixelX() + mapTileSize / 2 + target->draw(g, -target->getPixelX() + mapTileSize / 2 + mDimension.width / 2, -target->getPixelY() + mapTileSize + mDimension.height / 2); } diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index e7bf02aa9..327cabe6a 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -161,7 +161,6 @@ void EquipmentWindow::draw(Graphics *graphics) BLOCK_START("EquipmentWindow::draw") // Draw window graphics Window::draw(graphics); - Graphics *const g = static_cast(graphics); int i = 0; gcn::Font *const font = getFont(); @@ -179,17 +178,19 @@ void EquipmentWindow::draw(Graphics *graphics) continue; if (i == mSelected) { - g->calcTileCollection(mVertexes, - mSlotHighlightedBackground, box->x, box->y); + graphics->calcTileCollection(mVertexes, + mSlotHighlightedBackground, + box->x, box->y); } else { - g->calcTileCollection(mVertexes, mSlotBackground, + graphics->calcTileCollection(mVertexes, + mSlotBackground, box->x, box->y); } } } - g->drawTileCollection(mVertexes); + graphics->drawTileCollection(mVertexes); } else { @@ -200,9 +201,14 @@ void EquipmentWindow::draw(Graphics *graphics) if (!box) continue; if (i == mSelected) - g->drawImage2(mSlotHighlightedBackground, box->x, box->y); + { + graphics->drawImage2(mSlotHighlightedBackground, + box->x, box->y); + } else - g->drawImage2(mSlotBackground, box->x, box->y); + { + graphics->drawImage2(mSlotBackground, box->x, box->y); + } } } @@ -228,13 +234,14 @@ void EquipmentWindow::draw(Graphics *graphics) { image->setAlpha(1.0F); // Ensure the image is drawn // with maximum opacity - g->drawImage2(image, box->x + mItemPadding, + graphics->drawImage2(image, box->x + mItemPadding, box->y + mItemPadding); if (i == EQUIP_PROJECTILE_SLOT) { - g->setColorAll(mLabelsColor, mLabelsColor2); + graphics->setColorAll(mLabelsColor, mLabelsColor2); const std::string str = toString(item->getQuantity()); - font->drawString(g, str, + font->drawString(graphics, + str, box->x + (mBoxSize - font->getWidth(str)) / 2, box->y - fontHeight); } @@ -242,7 +249,8 @@ void EquipmentWindow::draw(Graphics *graphics) } else if (box->image) { - g->drawImage2(box->image, box->x + mItemPadding, + graphics->drawImage2(box->image, + box->x + mItemPadding, box->y + mItemPadding); } } diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 181055053..691506753 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -244,8 +244,6 @@ void Minimap::draw(Graphics *graphics) return; } - Graphics *const graph = static_cast(graphics); - const gcn::Rectangle a = getChildrenArea(); graphics->pushClipArea(a); @@ -286,7 +284,7 @@ void Minimap::draw(Graphics *graphics) mMapOriginY = 0; } - graph->drawImage2(mMapImage, mMapOriginX, mMapOriginY); + graphics->drawImage2(mMapImage, mMapOriginX, mMapOriginY); } const ActorSprites &actors = actorManager->getAll(); @@ -401,8 +399,8 @@ void Minimap::draw(Graphics *graphics) const Vector &pos = player_node->getPosition(); - const int gw = graph->getWidth(); - const int gh = graph->getHeight(); + const int gw = graphics->getWidth(); + const int gh = graphics->getHeight(); int x = static_cast((pos.x - (gw / 2) + viewport->getCameraRelativeX()) * mWidthProportion) / 32 + mMapOriginX; diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 677337b70..3729841bc 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -314,7 +314,6 @@ void OutfitWindow::draw(Graphics *graphics) { BLOCK_START("OutfitWindow::draw") Window::draw(graphics); - Graphics *const g = static_cast(graphics); if (mCurrentOutfit < 0 || mCurrentOutfit >= static_cast(OUTFITS_COUNT)) @@ -348,7 +347,7 @@ void OutfitWindow::draw(Graphics *graphics) const Image *const image = item->getImage(); if (image) { - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); foundItem = true; } } @@ -359,7 +358,7 @@ void OutfitWindow::draw(Graphics *graphics) mItemColors[mCurrentOutfit][i]); if (image) { - g->drawImage2(image, itemX, itemY); + graphics->drawImage2(image, itemX, itemY); image->decRef(); } } diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 82a264ac7..b7e21556c 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -164,12 +164,11 @@ public: ServersListModel *const model = static_cast( mListModel); - Graphics *const g = static_cast(graphics); updateAlpha(); mHighlightColor.a = static_cast(mAlpha * 255.0F); - g->setColor(mHighlightColor); + graphics->setColor(mHighlightColor); const int height = getRowHeight(); mNotSupportedColor.a = static_cast(mAlpha * 255.0F); @@ -196,12 +195,12 @@ public: if (mSelected == i) { - g->setColorAll(mForegroundSelectedColor, + graphics->setColorAll(mForegroundSelectedColor, mForegroundSelectedColor2); } else { - g->setColorAll(mForegroundColor, mForegroundColor2); + graphics->setColorAll(mForegroundColor, mForegroundColor2); } int top; @@ -224,7 +223,7 @@ public: if (info.version.first > 0) { - g->setColorAll(mNotSupportedColor, mNotSupportedColor2); + graphics->setColorAll(mNotSupportedColor, mNotSupportedColor2); font2->drawString(graphics, info.version.second, width - info.version.first - mPadding, top); } diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 674848725..7e823b742 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -100,15 +100,13 @@ class SkillListBox final : public ListBox return static_cast(mListModel)->getSkillAt(selected); } - void draw(Graphics *gcnGraphics) override + void draw(Graphics *graphics) override { if (!mListModel) return; SkillModel *const model = static_cast(mListModel); updateAlpha(); - Graphics *const graphics = static_cast( - gcnGraphics); mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); diff --git a/src/text.cpp b/src/text.cpp index a1ffea08c..943d31f67 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -137,9 +137,11 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) BLOCK_START("Text::draw") if (mIsSpeech) { - static_cast(graphics)->drawImageRect( - mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10, - mBubble); + graphics->drawImageRect(mX - xOff - 5, + mY - yOff - 5, + mWidth + 10, + mHeight + 10, + mBubble); } graphics->setColor(*mColor); -- cgit v1.2.3-70-g09d2 From e3ec854f275cc6f79129bbdd3129be277100908f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 22:45:17 +0300 Subject: Move some listeners classes into listeners directory. --- src/CMakeLists.txt | 6 ++--- src/Makefile.am | 6 ++--- src/being/localplayer.h | 2 +- src/client.h | 2 +- src/configlistener.h | 50 ------------------------------------ src/configuration.cpp | 3 ++- src/depricatedevent.cpp | 3 ++- src/depricatedlistener.cpp | 39 ---------------------------- src/depricatedlistener.h | 40 ----------------------------- src/eventsmanager.h | 2 +- src/gui/theme.h | 2 +- src/gui/viewport.h | 3 ++- src/gui/widgets/avatarlistbox.h | 2 +- src/gui/windowmenu.h | 2 +- src/gui/windows/botcheckerwindow.h | 2 +- src/gui/windows/chatwindow.h | 4 +-- src/gui/windows/inventorywindow.h | 3 ++- src/gui/windows/killstats.h | 2 +- src/gui/windows/ministatuswindow.h | 3 ++- src/gui/windows/npcdialog.h | 2 +- src/gui/windows/statuswindow.h | 2 +- src/gui/windows/whoisonline.h | 2 +- src/listeners/configlistener.h | 50 ++++++++++++++++++++++++++++++++++++ src/listeners/depricatedlistener.cpp | 39 ++++++++++++++++++++++++++++ src/listeners/depricatedlistener.h | 40 +++++++++++++++++++++++++++++ src/map.h | 3 ++- src/maplayer.h | 3 ++- src/soundmanager.h | 2 +- src/touchmanager.h | 2 +- 29 files changed, 164 insertions(+), 157 deletions(-) delete mode 100644 src/configlistener.h delete mode 100644 src/depricatedlistener.cpp delete mode 100644 src/depricatedlistener.h create mode 100644 src/listeners/configlistener.h create mode 100644 src/listeners/depricatedlistener.cpp create mode 100644 src/listeners/depricatedlistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 65570ee7b..042ed6af6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -607,7 +607,7 @@ SET(SRCS commands.h being/compoundsprite.cpp being/compoundsprite.h - configlistener.h + listeners/configlistener.h configuration.cpp configuration.h debug.h @@ -615,8 +615,8 @@ SET(SRCS defaults.h depricatedevent.cpp depricatedevent.h - depricatedlistener.cpp - depricatedlistener.h + listeners/depricatedlistener.cpp + listeners/depricatedlistener.h dragdrop.h effectmanager.cpp effectmanager.h diff --git a/src/Makefile.am b/src/Makefile.am index 7fe7a5e2e..4aa93893f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -732,7 +732,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ commands.h \ being/compoundsprite.cpp \ being/compoundsprite.h \ - configlistener.h \ + listeners/configlistener.h \ configuration.cpp \ configuration.h \ debug.h \ @@ -740,8 +740,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ defaults.h \ depricatedevent.cpp \ depricatedevent.h \ - depricatedlistener.cpp \ - depricatedlistener.h \ + listeners/depricatedlistener.cpp \ + listeners/depricatedlistener.h \ dragdrop.h \ dropshortcut.cpp \ dropshortcut.h \ diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 1bbf7dcc8..16c317bab 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -23,7 +23,7 @@ #ifndef BEING_LOCALPLAYER_H #define BEING_LOCALPLAYER_H -#include "depricatedlistener.h" +#include "listeners/depricatedlistener.h" #include "being/actorspritelistener.h" #include "being/being.h" diff --git a/src/client.h b/src/client.h index c26e91eae..f020087ea 100644 --- a/src/client.h +++ b/src/client.h @@ -23,7 +23,7 @@ #ifndef CLIENT_H #define CLIENT_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include "net/serverinfo.h" diff --git a/src/configlistener.h b/src/configlistener.h deleted file mode 100644 index 3de898692..000000000 --- a/src/configlistener.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CONFIGLISTENER_H -#define CONFIGLISTENER_H - -#include - -/** - * The listener interface for receiving notifications about changes to - * configuration options. - * - * \ingroup CORE - */ -class ConfigListener -{ - public: - /** - * Destructor. - */ - virtual ~ConfigListener() - { } - - /** - * Called when an option changed. The config listener will have to be - * registered to the option name first. - */ - virtual void optionChanged(const std::string &name) = 0; -}; - -#endif // CONFIGLISTENER_H diff --git a/src/configuration.cpp b/src/configuration.cpp index d4b9f122b..7d6fc43fd 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -22,9 +22,10 @@ #include "configuration.h" -#include "configlistener.h" #include "logger.h" +#include "listeners/configlistener.h" + #include "utils/paths.h" #include "debug.h" diff --git a/src/depricatedevent.cpp b/src/depricatedevent.cpp index 8d021e2f3..fc499c47b 100644 --- a/src/depricatedevent.cpp +++ b/src/depricatedevent.cpp @@ -21,9 +21,10 @@ #include "depricatedevent.h" -#include "depricatedlistener.h" #include "variabledata.h" +#include "listeners/depricatedlistener.h" + #include "debug.h" DepricatedListenMap DepricatedEvent::mBindings; diff --git a/src/depricatedlistener.cpp b/src/depricatedlistener.cpp deleted file mode 100644 index 0cd473852..000000000 --- a/src/depricatedlistener.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "depricatedlistener.h" - -#include "debug.h" - -DepricatedListener::~DepricatedListener() -{ - DepricatedEvent::remove(this); -} - -void DepricatedListener::listen(Channels channel) -{ - DepricatedEvent::bind(this, channel); -} - -void DepricatedListener::ignore(Channels channel) -{ - DepricatedEvent::unbind(this, channel); -} diff --git a/src/depricatedlistener.h b/src/depricatedlistener.h deleted file mode 100644 index 52596b70f..000000000 --- a/src/depricatedlistener.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef DEPRICATEDLISTENER_H -#define DEPRICATEDLISTENER_H - -#include "depricatedevent.h" - -class DepricatedListener -{ - public: - virtual ~DepricatedListener(); - - void listen(Channels channel); - - void ignore(Channels channel); - - virtual void processEvent(const Channels channel, - const DepricatedEvent &event) = 0; -}; - -#endif // DEPRICATEDLISTENER_H diff --git a/src/eventsmanager.h b/src/eventsmanager.h index 5433a83fb..e54c4dee4 100644 --- a/src/eventsmanager.h +++ b/src/eventsmanager.h @@ -21,7 +21,7 @@ #ifndef EVENTSMANAGER_H #define EVENTSMANAGER_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include diff --git a/src/gui/theme.h b/src/gui/theme.h index b40be2881..826902004 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -25,7 +25,7 @@ #ifndef GUI_THEME_H #define GUI_THEME_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include "render/graphics.h" diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 7e18d8395..9adaa6c18 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -23,9 +23,10 @@ #ifndef GUI_VIEWPORT_H #define GUI_VIEWPORT_H -#include "configlistener.h" #include "position.h" +#include "listeners/configlistener.h" + #include "gui/widgets/windowcontainer.h" #include "gui/base/mouselistener.hpp" diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index 46e5c8dea..ec384368c 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -24,7 +24,7 @@ #include "avatar.h" -#include "configlistener.h" +#include "listeners/configlistener.h" #include "gui/widgets/listbox.h" diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index bf8298b75..f6838115c 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -23,7 +23,7 @@ #ifndef GUI_WINDOWMENU_H #define GUI_WINDOWMENU_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include "gui/widgets/container.h" #include "gui/widgets/button.h" diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h index e7c9ecbb0..1346862d2 100644 --- a/src/gui/windows/botcheckerwindow.h +++ b/src/gui/windows/botcheckerwindow.h @@ -23,7 +23,7 @@ #ifndef GUI_BOTCHECKERWINDOW_H #define GUI_BOTCHECKERWINDOW_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include "gui/widgets/window.h" diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index d20f68ecc..6678eac28 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -23,9 +23,9 @@ #ifndef GUI_WINDOWS_CHATWINDOW_H #define GUI_WINDOWS_CHATWINDOW_H -#include "depricatedlistener.h" +#include "listeners/depricatedlistener.h" -#include "configlistener.h" +#include "listeners/configlistener.h" #include "gui/widgets/window.h" diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index da6e56a77..c0289e70d 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -24,7 +24,8 @@ #define GUI_WINDOWS_INVENTORYWINDOW_H #include "inventory.h" -#include "depricatedlistener.h" + +#include "listeners/depricatedlistener.h" #include "gui/widgets/window.h" diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index 181e43a51..46dbf842b 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -25,7 +25,7 @@ #include "gui/base/actionlistener.hpp" -#include "depricatedlistener.h" +#include "listeners/depricatedlistener.h" #include "gui/widgets/window.h" diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index 7748f51d1..5fccae02e 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -24,7 +24,8 @@ #define GUI_WINDOWS_MINISTATUSWINDOW_H #include "inventory.h" -#include "depricatedlistener.h" + +#include "listeners/depricatedlistener.h" #include "gui/widgets/popup.h" diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index 21c3f93e5..8646e5365 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -23,7 +23,7 @@ #ifndef GUI_WINDOWS_NPCDIALOG_H #define GUI_WINDOWS_NPCDIALOG_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include "gui/widgets/extendedlistmodel.h" #include "gui/widgets/window.h" diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h index 5e100b64e..c9efe6edd 100644 --- a/src/gui/windows/statuswindow.h +++ b/src/gui/windows/statuswindow.h @@ -23,7 +23,7 @@ #ifndef GUI_WINDOWS_STATUSWINDOW_H #define GUI_WINDOWS_STATUSWINDOW_H -#include "depricatedlistener.h" +#include "listeners/depricatedlistener.h" #include "gui/widgets/window.h" diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index da5ab010d..d60805983 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -23,7 +23,7 @@ #ifndef GUI_WINDOWS_WHOISONLINE_H #define GUI_WINDOWS_WHOISONLINE_H -#include "configlistener.h" +#include "listeners/configlistener.h" #include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" diff --git a/src/listeners/configlistener.h b/src/listeners/configlistener.h new file mode 100644 index 000000000..757d24bfc --- /dev/null +++ b/src/listeners/configlistener.h @@ -0,0 +1,50 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LISTENERS_CONFIGLISTENER_H +#define LISTENERS_CONFIGLISTENER_H + +#include + +/** + * The listener interface for receiving notifications about changes to + * configuration options. + * + * \ingroup CORE + */ +class ConfigListener +{ + public: + /** + * Destructor. + */ + virtual ~ConfigListener() + { } + + /** + * Called when an option changed. The config listener will have to be + * registered to the option name first. + */ + virtual void optionChanged(const std::string &name) = 0; +}; + +#endif // LISTENERS_CONFIGLISTENER_H diff --git a/src/listeners/depricatedlistener.cpp b/src/listeners/depricatedlistener.cpp new file mode 100644 index 000000000..c853c028d --- /dev/null +++ b/src/listeners/depricatedlistener.cpp @@ -0,0 +1,39 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "listeners/depricatedlistener.h" + +#include "debug.h" + +DepricatedListener::~DepricatedListener() +{ + DepricatedEvent::remove(this); +} + +void DepricatedListener::listen(Channels channel) +{ + DepricatedEvent::bind(this, channel); +} + +void DepricatedListener::ignore(Channels channel) +{ + DepricatedEvent::unbind(this, channel); +} diff --git a/src/listeners/depricatedlistener.h b/src/listeners/depricatedlistener.h new file mode 100644 index 000000000..175eec74a --- /dev/null +++ b/src/listeners/depricatedlistener.h @@ -0,0 +1,40 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LISTENERS_DEPRICATEDLISTENER_H +#define LISTENERS_DEPRICATEDLISTENER_H + +#include "depricatedevent.h" + +class DepricatedListener +{ + public: + virtual ~DepricatedListener(); + + void listen(Channels channel); + + void ignore(Channels channel); + + virtual void processEvent(const Channels channel, + const DepricatedEvent &event) = 0; +}; + +#endif // LISTENERS_DEPRICATEDLISTENER_H diff --git a/src/map.h b/src/map.h index 26303da7a..d33857415 100644 --- a/src/map.h +++ b/src/map.h @@ -23,12 +23,13 @@ #ifndef MAP_H #define MAP_H -#include "configlistener.h" #include "position.h" #include "properties.h" #include "being/actor.h" +#include "listeners/configlistener.h" + #include "render/renderers.h" #include diff --git a/src/maplayer.h b/src/maplayer.h index dcfdb991e..88db82214 100644 --- a/src/maplayer.h +++ b/src/maplayer.h @@ -23,10 +23,11 @@ #ifndef MAPLAYER_H #define MAPLAYER_H -#include "configlistener.h" #include "position.h" #include "main.h" +#include "listeners/configlistener.h" + #include "being/actor.h" #include diff --git a/src/soundmanager.h b/src/soundmanager.h index 9eb1ea8a2..9a09f383d 100644 --- a/src/soundmanager.h +++ b/src/soundmanager.h @@ -25,7 +25,7 @@ #include -#include "configlistener.h" +#include "listeners/configlistener.h" #include diff --git a/src/touchmanager.h b/src/touchmanager.h index e203da69f..6419c4b17 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -23,7 +23,7 @@ #include "resources/image.h" -#include "configlistener.h" +#include "listeners/configlistener.h" #include "input/keydata.h" -- cgit v1.2.3-70-g09d2 From 9502e9c968fac129ab57d7b0496c874086995b04 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 23:14:41 +0300 Subject: move actionlistener from base into listeners. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/being/localplayer.h | 4 +- src/client.cpp | 6 +- src/client.h | 7 +- src/gui/base/actionlistener.hpp | 112 ------------------------------- src/gui/base/widget.cpp | 2 +- src/gui/base/widget.hpp | 2 +- src/gui/popups/popupmenu.cpp | 2 +- src/gui/popups/popupmenu.h | 6 +- src/gui/widgets/button.cpp | 8 +-- src/gui/widgets/button.h | 8 +-- src/gui/widgets/characterviewbase.h | 6 +- src/gui/widgets/checkbox.cpp | 2 +- src/gui/widgets/checkbox.h | 2 +- src/gui/widgets/dropdown.cpp | 4 +- src/gui/widgets/dropdown.h | 7 +- src/gui/widgets/guitable.cpp | 6 +- src/gui/widgets/itemlinkhandler.cpp | 4 +- src/gui/widgets/setupitem.cpp | 4 +- src/gui/widgets/setupitem.h | 4 +- src/gui/widgets/sliderlist.cpp | 4 +- src/gui/widgets/sliderlist.h | 7 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 5 +- src/gui/widgets/tabs/setuptab.cpp | 2 +- src/gui/widgets/tabs/setuptab.h | 4 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textfield.h | 2 +- src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 4 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 4 +- src/gui/windows/botcheckerwindow.cpp | 2 +- src/gui/windows/botcheckerwindow.h | 4 +- src/gui/windows/buydialog.cpp | 6 +- src/gui/windows/buydialog.h | 4 +- src/gui/windows/buyselldialog.cpp | 4 +- src/gui/windows/buyselldialog.h | 5 +- src/gui/windows/changeemaildialog.cpp | 2 +- src/gui/windows/changeemaildialog.h | 5 +- src/gui/windows/changepassworddialog.cpp | 2 +- src/gui/windows/changepassworddialog.h | 5 +- src/gui/windows/charcreatedialog.cpp | 2 +- src/gui/windows/charcreatedialog.h | 4 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/charselectdialog.h | 4 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/chatwindow.h | 4 +- src/gui/windows/confirmdialog.cpp | 2 +- src/gui/windows/confirmdialog.h | 5 +- src/gui/windows/connectiondialog.cpp | 2 +- src/gui/windows/connectiondialog.h | 5 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/didyouknowwindow.h | 4 +- src/gui/windows/editdialog.cpp | 2 +- src/gui/windows/editdialog.h | 5 +- src/gui/windows/editserverdialog.cpp | 2 +- src/gui/windows/editserverdialog.h | 5 +- src/gui/windows/emotewindow.cpp | 2 +- src/gui/windows/emotewindow.h | 2 +- src/gui/windows/equipmentwindow.cpp | 2 +- src/gui/windows/equipmentwindow.h | 5 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/helpwindow.h | 7 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/itemamountwindow.cpp | 2 +- src/gui/windows/itemamountwindow.h | 4 +- src/gui/windows/killstats.cpp | 2 +- src/gui/windows/killstats.h | 5 +- src/gui/windows/logindialog.cpp | 6 +- src/gui/windows/logindialog.h | 5 +- src/gui/windows/npcdialog.cpp | 2 +- src/gui/windows/npcdialog.h | 4 +- src/gui/windows/npcpostdialog.cpp | 2 +- src/gui/windows/npcpostdialog.h | 4 +- src/gui/windows/okdialog.cpp | 2 +- src/gui/windows/okdialog.h | 4 +- src/gui/windows/outfitwindow.cpp | 2 +- src/gui/windows/outfitwindow.h | 4 +- src/gui/windows/questswindow.cpp | 2 +- src/gui/windows/questswindow.h | 4 +- src/gui/windows/quitdialog.cpp | 2 +- src/gui/windows/quitdialog.h | 5 +- src/gui/windows/registerdialog.cpp | 4 +- src/gui/windows/registerdialog.h | 6 +- src/gui/windows/selldialog.cpp | 4 +- src/gui/windows/selldialog.h | 4 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 4 +- src/gui/windows/setupwindow.cpp | 2 +- src/gui/windows/setupwindow.h | 4 +- src/gui/windows/shopwindow.cpp | 2 +- src/gui/windows/shopwindow.h | 4 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/skilldialog.h | 5 +- src/gui/windows/socialwindow.cpp | 14 ++-- src/gui/windows/socialwindow.h | 4 +- src/gui/windows/statuswindow.cpp | 6 +- src/gui/windows/statuswindow.h | 4 +- src/gui/windows/textcommandeditor.cpp | 2 +- src/gui/windows/textcommandeditor.h | 5 +- src/gui/windows/textdialog.cpp | 2 +- src/gui/windows/textdialog.h | 5 +- src/gui/windows/tradewindow.cpp | 2 +- src/gui/windows/tradewindow.h | 4 +- src/gui/windows/unregisterdialog.cpp | 2 +- src/gui/windows/unregisterdialog.h | 5 +- src/gui/windows/updaterwindow.cpp | 2 +- src/gui/windows/updaterwindow.h | 4 +- src/gui/windows/whoisonline.h | 4 +- src/gui/windows/worldselectdialog.cpp | 2 +- src/gui/windows/worldselectdialog.h | 5 +- src/listeners/actionlistener.h | 109 ++++++++++++++++++++++++++++++ src/net/ea/playerhandler.cpp | 4 +- src/net/ea/tradehandler.cpp | 2 +- 117 files changed, 332 insertions(+), 316 deletions(-) delete mode 100644 src/gui/base/actionlistener.hpp create mode 100644 src/listeners/actionlistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 042ed6af6..fccf99fb6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -770,7 +770,7 @@ SET(SRCS walklayer.cpp walklayer.h gui/base/actionevent.hpp - gui/base/actionlistener.hpp + listeners/actionlistener.h gui/base/basiccontainer.hpp gui/base/cliprectangle.hpp gui/base/color.hpp diff --git a/src/Makefile.am b/src/Makefile.am index 4aa93893f..422b08586 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -157,7 +157,7 @@ endif endif manaplus_SOURCES += gui/base/actionevent.hpp \ - gui/base/actionlistener.hpp \ + listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ diff --git a/src/being/localplayer.h b/src/being/localplayer.h index 16c317bab..f43cfe0bb 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -30,7 +30,7 @@ #include "gui/userpalette.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include @@ -41,7 +41,7 @@ class FloorItem; class Map; class OkDialog; -class AwayListener final : public gcn::ActionListener +class AwayListener final : public ActionListener { public: void action(const gcn::ActionEvent &event) override final; diff --git a/src/client.cpp b/src/client.cpp index ab3add135..3812fc9a9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -193,7 +193,7 @@ int textures_count = 0; extern "C" char const *_nl_locale_name_default(void); #endif -class AccountListener final : public gcn::ActionListener +class AccountListener final : public ActionListener { public: void action(const gcn::ActionEvent &) @@ -202,7 +202,7 @@ class AccountListener final : public gcn::ActionListener } } accountListener; -class LoginListener final : public gcn::ActionListener +class LoginListener final : public ActionListener { public: void action(const gcn::ActionEvent &) @@ -212,7 +212,7 @@ class LoginListener final : public gcn::ActionListener } loginListener; Client::Client(const Options &options) : - gcn::ActionListener(), + ActionListener(), mOptions(options), mConfigDir(), mServerConfigDir(), diff --git a/src/client.h b/src/client.h index f020087ea..aedad4569 100644 --- a/src/client.h +++ b/src/client.h @@ -27,7 +27,7 @@ #include "net/serverinfo.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include @@ -57,7 +57,7 @@ extern unsigned int tmwServerVersion; extern int start_time; extern int textures_count; -class ErrorListener : public gcn::ActionListener +class ErrorListener : public ActionListener { public: void action(const gcn::ActionEvent &event) override final; @@ -142,7 +142,8 @@ struct PacketLimit * The core part of the client. This class initializes all subsystems, runs * the event loop, and shuts everything down again. */ -class Client final : public ConfigListener, public gcn::ActionListener +class Client final : public ConfigListener, + public ActionListener { public: /** diff --git a/src/gui/base/actionlistener.hpp b/src/gui/base/actionlistener.hpp deleted file mode 100644 index 8a40fbb8c..000000000 --- a/src/gui/base/actionlistener.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_ACTIONLISTENER_HPP -#define GCN_ACTIONLISTENER_HPP - -#include - -#include "gui/base/actionevent.hpp" - -namespace gcn -{ - /** - * Interface for listening for action events from widgets. - * - * @see Widget::addActionListener, Widget::removeActionListener, - * ActionEvent - * @author Olof Naessén - * @author Per Larsson - */ - class ActionListener - { - public: - /** - * Destructor. - */ - virtual ~ActionListener() - { } - - /** - * Called when an action is recieved from a widget. It is used - * to be able to recieve a notification that an action has - * occured. - * - * @param actionEvent The event of the action. - * @since 0.6.0 - */ - virtual void action(const ActionEvent& actionEvent) = 0; - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of ActionListener, - * therefore its constructor is protected. - */ - ActionListener() - { } - }; -} // namespace gcn - -#endif // end GCN_ACTIONLISTENER_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index eeb5849c7..c14914cc2 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -68,7 +68,7 @@ #include "gui/base/widget.hpp" #include "gui/base/actionevent.hpp" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/basiccontainer.hpp" #include "gui/base/deathlistener.hpp" #include "gui/base/event.hpp" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index b6a81261e..1c05c2d03 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -73,11 +73,11 @@ #include "localconsts.h" +class ActionListener; class Graphics; namespace gcn { - class ActionListener; class BasicContainer; class DeathListener; class FocusHandler; diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 4d12e835e..343baba01 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -2838,7 +2838,7 @@ void PopupMenu::showGMPopup() } RenameListener::RenameListener() : - gcn::ActionListener(), + ActionListener(), mMapItemX(0), mMapItemY(0), mDialog(nullptr) diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 498132ded..a79dd3162 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -28,7 +28,7 @@ #include "being/actorsprite.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/listmodel.hpp" #include "localconsts.h" @@ -47,7 +47,7 @@ class TextField; class ProgressBar; class Window; -class RenameListener final : public gcn::ActionListener +class RenameListener final : public ActionListener { public: RenameListener(); @@ -67,7 +67,7 @@ class RenameListener final : public gcn::ActionListener TextDialog *mDialog; }; -class PlayerListener : public gcn::ActionListener +class PlayerListener : public ActionListener { public: PlayerListener(); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 6d326116d..7cbdff44d 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -81,7 +81,7 @@ Button::Button(const Widget2 *const widget) : Button::Button(const Widget2 *const widget, const std::string &restrict caption, const std::string &restrict actionEventId, - gcn::ActionListener *const listener) : + ActionListener *const listener) : gcn::Button(caption), Widget2(widget), gcn::WidgetListener(), @@ -121,7 +121,7 @@ Button::Button(const Widget2 *const widget, const std::string &restrict imageName, const int imageWidth, const int imageHeight, const std::string &restrict actionEventId, - gcn::ActionListener *const listener) : + ActionListener *const listener) : gcn::Button(caption), Widget2(widget), gcn::WidgetListener(), @@ -161,7 +161,7 @@ Button::Button(const Widget2 *const widget, const std::string &restrict imageName, const int imageWidth, const int imageHeight, const std::string &restrict actionEventId, - gcn::ActionListener *const listener) : + ActionListener *const listener) : gcn::Button(), Widget2(widget), gcn::WidgetListener(), @@ -201,7 +201,7 @@ Button::Button(const Widget2 *const widget, const std::string &restrict caption, const std::string &restrict imageName, const std::string &restrict actionEventId, - gcn::ActionListener *const listener) : + ActionListener *const listener) : gcn::Button(caption), Widget2(widget), gcn::WidgetListener(), diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 949993a48..e80593f7f 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -59,7 +59,7 @@ class Button final : public gcn::Button, Button(const Widget2 *const widget, const std::string &restrict caption, const std::string &restrict actionEventId, - gcn::ActionListener *const listener); + ActionListener *const listener); /** * Constructor, sets the caption of the button to the given string and @@ -70,7 +70,7 @@ class Button final : public gcn::Button, const std::string &restrict imageName, const int imageWidth, const int imageHeight, const std::string &actionEventId, - gcn::ActionListener *const listener); + ActionListener *const listener); /** * Constructor, sets the caption of the button to the given string and @@ -80,7 +80,7 @@ class Button final : public gcn::Button, const std::string &restrict imageName, const int imageWidth, const int imageHeight, const std::string &restrict actionEventId, - gcn::ActionListener *const listener); + ActionListener *const listener); /** * Constructor, sets the caption of the button to the given string and @@ -90,7 +90,7 @@ class Button final : public gcn::Button, const std::string &restrict imageName, const std::string &restrict caption, const std::string &restrict actionEventId, - gcn::ActionListener *const listener); + ActionListener *const listener); A_DELETE_COPY(Button) diff --git a/src/gui/widgets/characterviewbase.h b/src/gui/widgets/characterviewbase.h index af3722e4b..16b6c3e0d 100644 --- a/src/gui/widgets/characterviewbase.h +++ b/src/gui/widgets/characterviewbase.h @@ -25,12 +25,12 @@ #include "gui/widgets/container.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "localconsts.h" class CharacterViewBase : public Container, - public gcn::ActionListener + public ActionListener { public: A_DELETE_COPY(CharacterViewBase) @@ -50,7 +50,7 @@ class CharacterViewBase : public Container, protected: CharacterViewBase(CharSelectDialog *const widget, const int padding) : Container(widget), - gcn::ActionListener(), + ActionListener(), mParent(widget), mPadding(padding), mSelected(0) diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 2f11dc2ce..0721e29f6 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -39,7 +39,7 @@ float CheckBox::mAlpha = 1.0; CheckBox::CheckBox(const Widget2 *const widget, const std::string &restrict caption, const bool selected, - gcn::ActionListener *const listener, + ActionListener *const listener, const std::string &restrict eventId) : gcn::CheckBox(caption, selected), Widget2(widget), diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index a49c38d47..8e5958c92 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -46,7 +46,7 @@ class CheckBox final : public gcn::CheckBox, CheckBox(const Widget2 *const widget, const std::string &restrict caption, const bool selected = false, - gcn::ActionListener *const listener = nullptr, + ActionListener *const listener = nullptr, const std::string &restrict eventId = ""); A_DELETE_COPY(CheckBox) diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 7aa53e83f..070afdbb5 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -54,9 +54,9 @@ DropDown::DropDown(const Widget2 *const widget, gcn::ListModel *const listModel, const bool extended, const bool modal, - gcn::ActionListener *const listener, + ActionListener *const listener, const std::string &eventId): - gcn::ActionListener(), + ActionListener(), gcn::BasicContainer(), gcn::KeyListener(), gcn::MouseListener(), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index af566fb69..0b6ada6dd 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -25,7 +25,6 @@ #include "gui/widgets/widget2.h" -#include "gui/base/actionlistener.hpp" #include "gui/base/basiccontainer.hpp" #include "gui/base/focuslistener.hpp" #include "gui/base/keylistener.hpp" @@ -33,6 +32,8 @@ #include "gui/base/mouselistener.hpp" #include "gui/base/selectionlistener.hpp" +#include "listeners/actionlistener.h" + #include "localconsts.h" class Image; @@ -49,7 +50,7 @@ class Skin; * DropDown you must give DropDown an implemented ListModel which represents * your list. */ -class DropDown final : public gcn::ActionListener, +class DropDown final : public ActionListener, public gcn::BasicContainer, public gcn::KeyListener, public gcn::MouseListener, @@ -70,7 +71,7 @@ class DropDown final : public gcn::ActionListener, gcn::ListModel *const listModel, const bool extended = false, const bool modal = false, - gcn::ActionListener *const listener = nullptr, + ActionListener *const listener = nullptr, const std::string &eventId = ""); A_DELETE_COPY(DropDown) diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 6928b11d8..e2af7f16d 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -29,7 +29,7 @@ #include "utils/dtor.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/key.hpp" #include "render/graphics.h" @@ -38,7 +38,7 @@ float GuiTable::mAlpha = 1.0; -class GuiTableActionListener final : public gcn::ActionListener +class GuiTableActionListener final : public ActionListener { public: GuiTableActionListener(GuiTable *restrict _table, @@ -62,7 +62,7 @@ protected: GuiTableActionListener::GuiTableActionListener(GuiTable *restrict table, gcn::Widget *restrict widget, int row, int column) : - gcn::ActionListener(), + ActionListener(), mTable(table), mRow(row), mColumn(column), diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index c10979bef..96494ed0b 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -37,14 +37,14 @@ #include -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/mouseinput.hpp" #include "debug.h" namespace { - struct OpenUrlListener : public gcn::ActionListener + struct OpenUrlListener : public ActionListener { OpenUrlListener() : url() diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 4f0ea025d..8453a9722 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -51,7 +51,7 @@ SetupItem::SetupItem(const std::string &restrict text, SetupTabScroll *restrict const parent, const std::string &restrict eventName, const bool mainConfig) : - gcn::ActionListener(), + ActionListener(), Widget2(), mText(text), mDescription(description), @@ -75,7 +75,7 @@ SetupItem::SetupItem(const std::string &restrict text, const std::string &restrict eventName, const std::string &restrict def, const bool mainConfig) : - gcn::ActionListener(), + ActionListener(), Widget2(), mText(text), mDescription(description), diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 027f91824..dd5eda1d9 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -24,7 +24,7 @@ #include "gui/widgets/button.h" #include "gui/widgets/tabs/setuptabscroll.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include #include @@ -45,7 +45,7 @@ namespace gcn class ListModel; } -class SetupItem : public gcn::ActionListener, +class SetupItem : public ActionListener, public Widget2 { public: diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index b75f65820..0ae0890dc 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -36,7 +36,7 @@ static const int sliderHeight = 30; SliderList::SliderList(const Widget2 *const widget, gcn::ListModel *const listModel) : Container(widget), - gcn::ActionListener(), + ActionListener(), gcn::MouseListener(), mLabel(new Label(this)), mListModel(listModel), @@ -48,7 +48,7 @@ SliderList::SliderList(const Widget2 *const widget, setHeight(sliderHeight); } -void SliderList::postInit(gcn::ActionListener *const listener, +void SliderList::postInit(ActionListener *const listener, const std::string &eventId) { mPrevEventId = eventId + "_prev"; diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index e0f63517b..3d86f8735 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -21,10 +21,11 @@ #ifndef GUI_WIDGETS_SLIDERLIST_H #define GUI_WIDGETS_SLIDERLIST_H -#include "gui/base/actionlistener.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouselistener.hpp" +#include "listeners/actionlistener.h" + #include "gui/widgets/container.h" #include "localconsts.h" @@ -33,7 +34,7 @@ class Button; class Label; class SliderList final : public Container, - public gcn::ActionListener, + public ActionListener, public gcn::MouseListener { public: @@ -44,7 +45,7 @@ class SliderList final : public Container, ~SliderList(); - void postInit(gcn::ActionListener *const listener, + void postInit(ActionListener *const listener, const std::string &eventId); void updateAlpha(); diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 2a212ce75..d659cd6b6 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -35,7 +35,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : Widget2(widget), - gcn::ActionListener(), + ActionListener(), gcn::BasicContainer(), gcn::KeyListener(), gcn::MouseListener(), diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index dede91767..af7fe5429 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -25,12 +25,13 @@ #include "gui/widgets/widget2.h" -#include "gui/base/actionlistener.hpp" #include "gui/base/keylistener.hpp" #include "gui/base/mouselistener.hpp" #include "gui/base/widgetlistener.hpp" #include "gui/base/widgets/container.hpp" +#include "listeners/actionlistener.h" + class Button; class Image; class Tab; @@ -39,7 +40,7 @@ class Tab; * A tabbed area, the same as the guichan tabbed area in 0.8, but extended */ class TabbedArea final : public Widget2, - public gcn::ActionListener, + public ActionListener, public gcn::BasicContainer, public gcn::KeyListener, public gcn::MouseListener, diff --git a/src/gui/widgets/tabs/setuptab.cpp b/src/gui/widgets/tabs/setuptab.cpp index c445e2ad7..efead5a3c 100644 --- a/src/gui/widgets/tabs/setuptab.cpp +++ b/src/gui/widgets/tabs/setuptab.cpp @@ -26,7 +26,7 @@ SetupTab::SetupTab(const Widget2 *const widget) : Container(widget), - gcn::ActionListener(), + ActionListener(), gcn::WidgetListener(), mName() { diff --git a/src/gui/widgets/tabs/setuptab.h b/src/gui/widgets/tabs/setuptab.h index d8e76f812..1621b0713 100644 --- a/src/gui/widgets/tabs/setuptab.h +++ b/src/gui/widgets/tabs/setuptab.h @@ -25,7 +25,7 @@ #include "gui/widgets/container.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/widgetlistener.hpp" #include @@ -36,7 +36,7 @@ * A container for the contents of a tab in the setup window. */ class SetupTab : public Container, - public gcn::ActionListener, + public ActionListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index fdcd84089..692a5608e 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -53,7 +53,7 @@ ImageRect TextField::skin; TextField::TextField(const Widget2 *restrict const widget, const std::string &restrict text, const bool loseFocusOnTab, - gcn::ActionListener *restrict const listener, + ActionListener *restrict const listener, const std::string &restrict eventId, const bool sendAlwaysEvents): gcn::TextField(text), diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index d3d1ff0eb..80d022bb1 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -48,7 +48,7 @@ class TextField : public gcn::TextField, explicit TextField(const Widget2 *restrict const widget, const std::string &restrict text = "", const bool loseFocusOnTab = true, - gcn::ActionListener *restrict + ActionListener *restrict const listener = nullptr, const std::string &restrict eventId = "", const bool sendAlwaysEvents = false); diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 34cbeebb5..ee8d6f719 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -27,7 +27,7 @@ WidgetGroup::WidgetGroup(const Widget2 *const widget, const int spacing) : Container(widget), gcn::WidgetListener(), - gcn::ActionListener(), + ActionListener(), mSpacing(spacing), mCount(0), mGroup(group), diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 897183839..e648a17e5 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -23,14 +23,14 @@ #include "gui/widgets/container.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/widgetlistener.hpp" #include "localconsts.h" class WidgetGroup : public Container, public gcn::WidgetListener, - public gcn::ActionListener + public ActionListener { public: A_DELETE_COPY(WidgetGroup) diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 127d3657d..3ef3e73ce 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -44,7 +44,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : Container(widget), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), gcn::MouseListener(), mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "") diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index f6838115c..d7e16e7fa 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -28,7 +28,7 @@ #include "gui/widgets/container.h" #include "gui/widgets/button.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/selectionlistener.hpp" #include "localconsts.h" @@ -77,7 +77,7 @@ struct ButtonText final */ class WindowMenu final : public Container, public ConfigListener, - public gcn::ActionListener, + public ActionListener, public gcn::SelectionListener, public gcn::MouseListener { diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index b94093ebb..20ade8ae4 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -260,7 +260,7 @@ protected: BotCheckerWindow::BotCheckerWindow(): // TRANSLATORS: bot checker window header Window(_("Bot Checker"), false, nullptr, "botchecker.xml"), - gcn::ActionListener(), + ActionListener(), mTableModel(new UsersTableModel(this)), mTable(new GuiTable(this, mTableModel)), playersScrollArea(new ScrollArea(mTable, true, diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h index 1346862d2..3db396321 100644 --- a/src/gui/windows/botcheckerwindow.h +++ b/src/gui/windows/botcheckerwindow.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" struct BOTCHK final { @@ -43,7 +43,7 @@ class UsersTableModel; class StaticTableModel; class BotCheckerWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public ConfigListener { public: diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index ccddc76cd..2d6d7d9db 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -193,7 +193,7 @@ BuyDialog::DialogList BuyDialog::instances; BuyDialog::BuyDialog() : // TRANSLATORS: buy dialog name Window(_("Create items"), false, nullptr, "buy.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), mNpcId(-2), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(), mSortModel(nullptr), @@ -205,7 +205,7 @@ BuyDialog::BuyDialog() : BuyDialog::BuyDialog(const int npcId) : // TRANSLATORS: buy dialog name Window(_("Buy"), false, nullptr, "buy.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(), mSortModel(nullptr), @@ -217,7 +217,7 @@ BuyDialog::BuyDialog(const int npcId) : BuyDialog::BuyDialog(std::string nick) : // TRANSLATORS: buy dialog name Window(_("Buy"), false, nullptr, "buy.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick), mSortModel(new SortListModelBuy), diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 594fd0a30..ef51c04b2 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/selectionlistener.hpp" class Button; @@ -45,7 +45,7 @@ class Slider; * \ingroup Interface */ class BuyDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::SelectionListener { public: diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp index 22f39f449..5a1914040 100644 --- a/src/gui/windows/buyselldialog.cpp +++ b/src/gui/windows/buyselldialog.cpp @@ -37,7 +37,7 @@ BuySellDialog::DialogList BuySellDialog::dialogInstances; BuySellDialog::BuySellDialog(const int npcId) : // TRANSLATORS: shop window name Window(_("Shop"), false, nullptr, "buysell.xml"), - gcn::ActionListener(), + ActionListener(), mNpcId(npcId), mNick(""), mBuyButton(nullptr) @@ -48,7 +48,7 @@ BuySellDialog::BuySellDialog(const int npcId) : BuySellDialog::BuySellDialog(const std::string &nick) : // TRANSLATORS: shop window name Window(_("Shop"), false, nullptr, "buysell.xml"), - gcn::ActionListener(), + ActionListener(), mNpcId(-1), mNick(nick), mBuyButton(nullptr) diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h index 107730b2d..84bac0cac 100644 --- a/src/gui/windows/buyselldialog.h +++ b/src/gui/windows/buyselldialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; @@ -34,7 +34,8 @@ class Button; * * \ingroup Interface */ -class BuySellDialog final : public Window, public gcn::ActionListener +class BuySellDialog final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp index a9f3b3449..3ed9ff213 100644 --- a/src/gui/windows/changeemaildialog.cpp +++ b/src/gui/windows/changeemaildialog.cpp @@ -45,7 +45,7 @@ ChangeEmailDialog::ChangeEmailDialog(LoginData *const data): // TRANSLATORS: change email dialog header Window(_("Change Email Address"), true, nullptr, "changeemail.xml"), - gcn::ActionListener(), + ActionListener(), mFirstEmailField(new TextField(this)), mSecondEmailField(new TextField(this)), // TRANSLATORS: button in change email dialog diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h index 4a13d5e52..cdbd371d1 100644 --- a/src/gui/windows/changeemaildialog.h +++ b/src/gui/windows/changeemaildialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; class LoginData; @@ -37,7 +37,8 @@ class WrongDataNoticeListener; * * \ingroup Interface */ -class ChangeEmailDialog final : public Window, public gcn::ActionListener +class ChangeEmailDialog final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp index 4646947fa..24823cddc 100644 --- a/src/gui/windows/changepassworddialog.cpp +++ b/src/gui/windows/changepassworddialog.cpp @@ -46,7 +46,7 @@ ChangePasswordDialog::ChangePasswordDialog(LoginData *const data): // TRANSLATORS: change password window name Window(_("Change Password"), true, nullptr, "changepassword.xml"), - gcn::ActionListener(), + ActionListener(), mOldPassField(new PasswordField(this)), mFirstPassField(new PasswordField(this)), mSecondPassField(new PasswordField(this)), diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h index 011229d15..ac7d35308 100644 --- a/src/gui/windows/changepassworddialog.h +++ b/src/gui/windows/changepassworddialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; class LoginData; @@ -37,7 +37,8 @@ class WrongDataNoticeListener; * * \ingroup Interface */ -class ChangePasswordDialog final : public Window, public gcn::ActionListener +class ChangePasswordDialog final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index cbce28db7..e581cc2c9 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -63,7 +63,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, const int slot) : // TRANSLATORS: char create dialog name Window(_("New Character"), true, parent, "charcreate.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mCharSelectDialog(parent), mNameField(new TextField(this, "")), diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index c59b631dc..89e3c832a 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -27,7 +27,7 @@ #include "gui/windows/charselectdialog.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" class Label; @@ -42,7 +42,7 @@ class TextField; * \ingroup Interface */ class CharCreateDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 3f44617f8..37e93938c 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -88,7 +88,7 @@ CharSelectDialog::CharSelectDialog(LoginData *const data): Window(strprintf(_("Account %s (last login time %s)"), data->username.c_str(), data->lastLogin.c_str()), false, nullptr, "char.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mLoginData(data), // TRANSLATORS: char select dialog. button. diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index df08c9058..66b2f933e 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -29,7 +29,7 @@ #include "net/charserverhandler.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" class Button; @@ -45,7 +45,7 @@ class TextDialog; * \ingroup Interface */ class CharSelectDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 5bff2ee4b..12ef73516 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -202,7 +202,7 @@ static const char *const ACTION_COLOR_PICKER = "color picker"; ChatWindow::ChatWindow(): // TRANSLATORS: chat window name Window(_("Chat"), false, nullptr, "chat.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mItemLinkHandler(new ItemLinkHandler), mChatTabs(new TabbedArea(this)), diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 6678eac28..6e4415728 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -29,7 +29,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" #include @@ -83,7 +83,7 @@ struct CHATLOG final * \ingroup Interface */ class ChatWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener, public DepricatedListener, public ConfigListener diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 1ba3ebf65..950c6eada 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -39,7 +39,7 @@ ConfirmDialog::ConfirmDialog(const std::string &restrict title, const bool ignore, const bool modal, Window *const parent): Window(title, modal, parent, "confirm.xml"), - gcn::ActionListener(), + ActionListener(), mTextBox(new TextBox(this)), mIgnore(ignore) { diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h index 9d5c9f23b..a123dae71 100644 --- a/src/gui/windows/confirmdialog.h +++ b/src/gui/windows/confirmdialog.h @@ -29,7 +29,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class TextBox; @@ -38,7 +38,8 @@ class TextBox; * * \ingroup GUI */ -class ConfirmDialog : public Window, public gcn::ActionListener +class ConfirmDialog : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp index b0ffc25cd..a50747958 100644 --- a/src/gui/windows/connectiondialog.cpp +++ b/src/gui/windows/connectiondialog.cpp @@ -34,7 +34,7 @@ ConnectionDialog::ConnectionDialog(const std::string &text, const State cancelState): Window("", false, nullptr, "connection.xml"), - gcn::ActionListener(), + ActionListener(), mCancelState(cancelState) { setTitleBarHeight(0); diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h index 773522839..b27aa892e 100644 --- a/src/gui/windows/connectiondialog.h +++ b/src/gui/windows/connectiondialog.h @@ -27,14 +27,15 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" /** * The connection dialog. * * \ingroup Interface */ -class ConnectionDialog final : public Window, private gcn::ActionListener +class ConnectionDialog final : public Window, + private ActionListener { public: /** diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 93166e6fa..d393a7dd5 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -48,7 +48,7 @@ static const int maxTip = 18; DidYouKnowWindow::DidYouKnowWindow() : // TRANSLATORS: did you know window name Window(_("Did You Know?"), false, nullptr, "didyouknow.xml"), - gcn::ActionListener(), + ActionListener(), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, "browserbox.xml")), mScrollArea(new ScrollArea(mBrowserBox, diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h index 85bbe8107..ff4599657 100644 --- a/src/gui/windows/didyouknowwindow.h +++ b/src/gui/windows/didyouknowwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; class BrowserBox; @@ -38,7 +38,7 @@ class ScrollArea; */ class DidYouKnowWindow final : public Window, public LinkHandler, - public gcn::ActionListener + public ActionListener { public: /** diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp index 5c002212f..3f087b803 100644 --- a/src/gui/windows/editdialog.cpp +++ b/src/gui/windows/editdialog.cpp @@ -33,7 +33,7 @@ EditDialog::EditDialog(const std::string &restrict title, const std::string &restrict eventOk, const int width, Window *const parent, const bool modal): Window(title, modal, parent, "edit.xml"), - gcn::ActionListener(), + ActionListener(), mEventOk(eventOk), mTextField(new TextField(this)) { diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h index 9c84558a6..f37369a89 100644 --- a/src/gui/windows/editdialog.h +++ b/src/gui/windows/editdialog.h @@ -28,7 +28,7 @@ #include "gui/widgets/window.h" #include "gui/widgets/textfield.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #define ACTION_EDIT_OK "edit ok" @@ -37,7 +37,8 @@ * * \ingroup GUI */ -class EditDialog final : public Window, public gcn::ActionListener +class EditDialog final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 900fe840b..0b065bb0c 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -63,7 +63,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, const int index) : // TRANSLATORS: edit server dialog name Window(_("Edit Server"), true, parent), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mServerAddressField(new TextField(this, std::string())), mPortField(new TextField(this, std::string())), diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index cbb789fbb..5ef780ef0 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -31,8 +31,9 @@ class ServerDialog; #include "net/serverinfo.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" + #include "gui/base/listmodel.hpp" /** @@ -75,7 +76,7 @@ class TypeListModel : public gcn::ListModel * \ingroup Interface */ class EditServerDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index 9dd5f648c..2d2fdbd26 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -207,7 +207,7 @@ void EmoteWindow::clearFont() setVisible(false); } -void EmoteWindow::addListeners(gcn::ActionListener *const listener) +void EmoteWindow::addListeners(ActionListener *const listener) { mEmotePage->addActionListener(listener); mColorPage->addActionListener(listener); diff --git a/src/gui/windows/emotewindow.h b/src/gui/windows/emotewindow.h index 0f15b7bc6..2ddc64886 100644 --- a/src/gui/windows/emotewindow.h +++ b/src/gui/windows/emotewindow.h @@ -59,7 +59,7 @@ class EmoteWindow final : public Window void clearFont(); - void addListeners(gcn::ActionListener *const listener); + void addListeners(ActionListener *const listener); void widgetResized(const gcn::Event &event) override final; diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 327cabe6a..3f7f19948 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -57,7 +57,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, const bool foring): // TRANSLATORS: equipment window name Window(_("Equipment"), false, nullptr, "equipment.xml"), - gcn::ActionListener(), + ActionListener(), mEquipment(equipment), mItemPopup(new ItemPopup), mPlayerBox(new PlayerBox("equipment_playerbox.xml", diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index 1ce8611a7..7ce8e6409 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -30,7 +30,7 @@ #include "utils/xml.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include @@ -60,7 +60,8 @@ struct EquipmentBox final * * \ingroup Interface */ -class EquipmentWindow final : public Window, public gcn::ActionListener +class EquipmentWindow final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index eb2300e0e..288c38138 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -48,7 +48,7 @@ HelpWindow::HelpWindow() : // TRANSLATORS: help window name Window(_("Help"), false, nullptr, "help.xml"), - gcn::ActionListener(), + ActionListener(), // TRANSLATORS: help window. button. mDYKButton(new Button(this, _("Did you know..."), "DYK", this)), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h index a9d1a0279..ae7d68c7c 100644 --- a/src/gui/windows/helpwindow.h +++ b/src/gui/windows/helpwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "localconsts.h" @@ -44,8 +44,9 @@ typedef std::map HelpTagsMap; /** * The help window. */ -class HelpWindow final : public Window, public LinkHandler, - public gcn::ActionListener +class HelpWindow final : public Window, + public LinkHandler, + public ActionListener { public: /** diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 23c1980be..25f1a0110 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -101,7 +101,7 @@ InventoryWindow::WindowList InventoryWindow::invInstances; InventoryWindow::InventoryWindow(Inventory *const inventory): Window("Inventory", false, nullptr, "inventory.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), gcn::SelectionListener(), InventoryListener(), diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index c0289e70d..0ff314fb8 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -29,7 +29,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" #include "gui/base/selectionlistener.hpp" @@ -51,7 +51,7 @@ class TextPopup; * \ingroup Interface */ class InventoryWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener, public gcn::SelectionListener, public InventoryListener, diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 975892888..d35854375 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -138,7 +138,7 @@ void ItemAmountWindow::finish(Item *const item, const int amount, ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, Item *const item, const int maxRange) : Window("", false, parent, "amount.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mItemAmountTextField(new IntTextField(this, 1)), mItemPriceTextField(nullptr), diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index dd3b498fb..760555c6c 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "gui/base/keylistener.hpp" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class DropDown; class Icon; @@ -43,7 +43,7 @@ class Slider; * \ingroup Interface */ class ItemAmountWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index 0adabc3ad..dec951458 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -40,7 +40,7 @@ KillStats::KillStats() : // TRANSLATORS: kill stats window name Window(_("Kill stats"), false, nullptr, "killstats.xml"), - gcn::ActionListener(), + ActionListener(), mKillCounter(0), mExpCounter(0), mKillTCounter(0), diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index 46dbf842b..2dcc41b97 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -23,8 +23,7 @@ #ifndef GUI_WINDOWS_KILLSTATS_H #define GUI_WINDOWS_KILLSTATS_H -#include "gui/base/actionlistener.hpp" - +#include "listeners/actionlistener.h" #include "listeners/depricatedlistener.h" #include "gui/widgets/window.h" @@ -33,7 +32,7 @@ class Label; class Button; class KillStats final : public Window, - private gcn::ActionListener, + private ActionListener, public DepricatedListener { public: diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 8ec6144a0..cc8d02471 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -53,10 +53,10 @@ std::string LoginDialog::savedPasswordKey(""); namespace { - struct OpenUrlListener : public gcn::ActionListener + struct OpenUrlListener : public ActionListener { OpenUrlListener() : - gcn::ActionListener(), + ActionListener(), url() { } @@ -143,7 +143,7 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName, std::string *const updateHost): // TRANSLATORS: login dialog name Window(_("Login"), false, nullptr, "login.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mLoginData(data), mUserField(new TextField(this, mLoginData->username)), diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index 5099644ea..77fb75dd5 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" #include @@ -44,7 +44,8 @@ class UpdateTypeModel; * * \ingroup Interface */ -class LoginDialog final : public Window, public gcn::ActionListener, +class LoginDialog final : public Window, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 093f17e29..6e33422b2 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -80,7 +80,7 @@ typedef std::vector::iterator ImageVectorIter; NpcDialog::NpcDialog(const int npcId) : // TRANSLATORS: npc dialog name Window(_("NPC"), false, nullptr, "npc.xml"), - gcn::ActionListener(), + ActionListener(), mNpcId(npcId), mDefaultInt(0), mDefaultString(), diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index 8646e5365..e9ad99242 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -30,7 +30,7 @@ #include "utils/stringvector.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include @@ -56,7 +56,7 @@ typedef std::map NpcDialogs; * \ingroup Interface */ class NpcDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public ExtendedListModel, public ConfigListener { diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp index 63ae6f53b..1666d1bd6 100644 --- a/src/gui/windows/npcpostdialog.cpp +++ b/src/gui/windows/npcpostdialog.cpp @@ -42,7 +42,7 @@ NpcPostDialog::DialogList NpcPostDialog::instances; NpcPostDialog::NpcPostDialog(const int npcId): // TRANSLATORS: npc post dialog caption Window(_("NPC"), false, nullptr, "npcpost.xml"), - gcn::ActionListener(), + ActionListener(), mNpcId(npcId), mText(new TextBox(this)), mSender(new TextField(this)) diff --git a/src/gui/windows/npcpostdialog.h b/src/gui/windows/npcpostdialog.h index b8237a694..6ce070808 100644 --- a/src/gui/windows/npcpostdialog.h +++ b/src/gui/windows/npcpostdialog.h @@ -25,13 +25,13 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class TextBox; class TextField; class NpcPostDialog final : public Window, - public gcn::ActionListener + public ActionListener { public: /** diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index c1ce6f13f..eb22d6c87 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -40,7 +40,7 @@ OkDialog::OkDialog(const std::string &restrict title, const bool showCenter, Window *const parent, const int minWidth) : Window(title, modal, parent, "ok.xml"), - gcn::ActionListener(), + ActionListener(), mTextBox(new TextBox(this)) { mTextBox->setEditable(false); diff --git a/src/gui/windows/okdialog.h b/src/gui/windows/okdialog.h index 7e63c9787..6809bee1a 100644 --- a/src/gui/windows/okdialog.h +++ b/src/gui/windows/okdialog.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class TextBox; @@ -44,7 +44,7 @@ enum * \ingroup GUI */ class OkDialog final : public Window, - public gcn::ActionListener + public ActionListener { public: /** diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 3729841bc..2d59c6a43 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -51,7 +51,7 @@ OutfitWindow::OutfitWindow(): // TRANSLATORS: outfits window name Window(_("Outfits"), false, nullptr, "outfits.xml"), - gcn::ActionListener(), + ActionListener(), // TRANSLATORS: outfits window button mPreviousButton(new Button(this, _("<"), "previous", this)), // TRANSLATORS: outfits window button diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 01e72aefc..4c3b5951c 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" const unsigned int OUTFITS_COUNT = 100; const unsigned int OUTFIT_ITEM_COUNT = 16; @@ -35,7 +35,7 @@ class CheckBox; class Label; class OutfitWindow final : public Window, - private gcn::ActionListener + private ActionListener { public: /** diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index e5f599f0f..c37bc860c 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -122,7 +122,7 @@ struct QuestEffect final QuestsWindow::QuestsWindow() : // TRANSLATORS: quests window name Window(_("Quests"), false, nullptr, "quests.xml"), - gcn::ActionListener(), + ActionListener(), mQuestsModel(new QuestsModel), mQuestsListBox(new ExtendedListBox(this, mQuestsModel, "extendedlistbox.xml")), diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h index edb9d845e..fdb2c98aa 100644 --- a/src/gui/windows/questswindow.h +++ b/src/gui/windows/questswindow.h @@ -27,7 +27,7 @@ #include "utils/xml.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include #include @@ -48,7 +48,7 @@ typedef std::map NpcQuestEffectMap; typedef NpcQuestEffectMap::const_iterator NpcQuestEffectMapCIter; class QuestsWindow final : public Window, - public gcn::ActionListener + public ActionListener { public: QuestsWindow(); diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index ff9f669b7..375ab415e 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -49,7 +49,7 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): // TRANSLATORS: quit dialog name Window(_("Quit"), true, nullptr, "quit.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mOptions(), // TRANSLATORS: quit dialog button diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h index d5d315074..d99ab72d8 100644 --- a/src/gui/windows/quitdialog.h +++ b/src/gui/windows/quitdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" #include @@ -38,7 +38,8 @@ class RadioButton; * * \ingroup Interface */ -class QuitDialog final : public Window, public gcn::ActionListener, +class QuitDialog final : public Window, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 1867b6b40..66a5ad187 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -44,7 +44,7 @@ #include "debug.h" WrongDataNoticeListener::WrongDataNoticeListener(): - gcn::ActionListener(), + ActionListener(), mTarget(nullptr) { } @@ -63,7 +63,7 @@ void WrongDataNoticeListener::action(const gcn::ActionEvent &event) RegisterDialog::RegisterDialog(LoginData *const data) : // TRANSLATORS: register dialog name Window(_("Register"), false, nullptr, "register.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mLoginData(data), mUserField(new TextField(this, mLoginData->username)), diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h index 1b53581b6..fea74e776 100644 --- a/src/gui/windows/registerdialog.h +++ b/src/gui/windows/registerdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" class Button; @@ -38,7 +38,7 @@ class TextField; * to the field which contained wrong data when the Ok button was pressed on * the error notice. */ -class WrongDataNoticeListener final : public gcn::ActionListener +class WrongDataNoticeListener final : public ActionListener { public: WrongDataNoticeListener(); @@ -58,7 +58,7 @@ class WrongDataNoticeListener final : public gcn::ActionListener * \ingroup Interface */ class RegisterDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index a4ff29f78..888a2432d 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -53,7 +53,7 @@ SellDialog::DialogList SellDialog::instances; SellDialog::SellDialog(const int npcId) : // TRANSLATORS: sell dialog name Window(_("Sell"), false, nullptr, "sell.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { @@ -63,7 +63,7 @@ SellDialog::SellDialog(const int npcId) : SellDialog::SellDialog(const std::string &nick): // TRANSLATORS: sell dialog name Window(_("Sell"), false, nullptr, "sell.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h index ca973ea03..c23112f8a 100644 --- a/src/gui/windows/selldialog.h +++ b/src/gui/windows/selldialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/selectionlistener.hpp" class Button; @@ -42,7 +42,7 @@ class Slider; * \ingroup Interface */ class SellDialog final : public Window, - private gcn::ActionListener, + private ActionListener, private gcn::SelectionListener { public: diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index b7e21556c..1a02f95c6 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -244,7 +244,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, const std::string &dir) : // TRANSLATORS: servers dialog name Window(_("Choose Your Server"), false, nullptr, "server.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), gcn::SelectionListener(), mMutex(), diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index d17ebcf42..3ea3b23a4 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -31,7 +31,7 @@ #include "utils/mutex.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/selectionlistener.hpp" @@ -91,7 +91,7 @@ class ServersListModel final : public gcn::ListModel * \ingroup Interface */ class ServerDialog final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::KeyListener, public gcn::SelectionListener { diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 0780865aa..85e4938ef 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -58,7 +58,7 @@ SetupWindow *setupWindow = nullptr; SetupWindow::SetupWindow() : // TRANSLATORS: setup window name Window(_("Setup"), false, nullptr, "setup.xml"), - gcn::ActionListener(), + ActionListener(), mTabs(), mModsTab(nullptr), mWindowsToReset(), diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index bd67fa860..c65f1cfea 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include @@ -41,7 +41,7 @@ class TabbedArea; * \ingroup GUI */ class SetupWindow final : public Window, - public gcn::ActionListener + public ActionListener { public: SetupWindow(); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index a940e4cdb..1485f18c9 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -71,7 +71,7 @@ ShopWindow::DialogList ShopWindow::instances; ShopWindow::ShopWindow(): // TRANSLATORS: shop window name Window(_("Personal Shop"), false, nullptr, "shop.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), // TRANSLATORS: shop window button mCloseButton(new Button(this, _("Close"), "close", this)), diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 2430073da..606080986 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/selectionlistener.hpp" class Button; @@ -43,7 +43,7 @@ class ShopListBox; * \ingroup Interface */ class ShopWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public gcn::SelectionListener { public: diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 7e823b742..f2af65c3c 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -279,7 +279,7 @@ class SkillTab final : public Tab SkillDialog::SkillDialog() : // TRANSLATORS: skills dialog name Window(_("Skills"), false, nullptr, "skills.xml"), - gcn::ActionListener(), + ActionListener(), mSkills(), mTabs(new TabbedArea(this)), mDeleteTabs(), diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 0fb6c1100..d58aa5cca 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" const int SKILL_MIN_ID = 200000; const unsigned int SKILL_VAR_MIN_ID = 1000000; @@ -43,7 +43,8 @@ struct SkillInfo; * * \ingroup Interface */ -class SkillDialog final : public Window, public gcn::ActionListener +class SkillDialog final : public Window, + public ActionListener { public: SkillDialog(); diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 2385066be..8b5fdf95c 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -169,13 +169,13 @@ protected: std::string mCounterString; }; -class SocialGuildTab final : public SocialTab, public gcn::ActionListener +class SocialGuildTab final : public SocialTab, public ActionListener { public: SocialGuildTab(const Widget2 *const widget, Guild *const guild, const bool showBackground) : SocialTab(widget), - gcn::ActionListener(), + ActionListener(), mGuild(guild) { // TRANSLATORS: tab in social window @@ -305,13 +305,13 @@ private: Guild *mGuild; }; -class SocialGuildTab2 final : public SocialTab, public gcn::ActionListener +class SocialGuildTab2 final : public SocialTab, public ActionListener { public: SocialGuildTab2(const Widget2 *const widget, Guild *const guild, const bool showBackground) : SocialTab(widget), - gcn::ActionListener() + ActionListener() { // TRANSLATORS: tab in social window setCaption(_("Guild")); @@ -372,13 +372,13 @@ public: } }; -class SocialPartyTab final : public SocialTab, public gcn::ActionListener +class SocialPartyTab final : public SocialTab, public ActionListener { public: SocialPartyTab(const Widget2 *const widget, Party *const party, const bool showBackground) : SocialTab(widget), - gcn::ActionListener(), + ActionListener(), mParty(party) { // TRANSLATORS: tab in social window @@ -1276,7 +1276,7 @@ private: SocialWindow::SocialWindow() : // TRANSLATORS: social window name Window(_("Social"), false, nullptr, "social.xml"), - gcn::ActionListener(), + ActionListener(), PlayerRelationsListener(), mGuildInvited(0), mGuildAcceptDialog(nullptr), diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 283cfde69..84c713787 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -26,7 +26,7 @@ #include "being/playerrelationslistener.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include #include @@ -48,7 +48,7 @@ class TextDialog; * \ingroup Interface */ class SocialWindow final : public Window, - private gcn::ActionListener, + private ActionListener, public PlayerRelationsListener { public: diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index 80e86e66f..a95eb807c 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -113,7 +113,7 @@ class DerDisplay final : public AttrDisplay { return DERIVED; } }; -class ChangeDisplay final : public AttrDisplay, gcn::ActionListener +class ChangeDisplay final : public AttrDisplay, ActionListener { public: ChangeDisplay(const Widget2 *const widget, @@ -142,7 +142,7 @@ class ChangeDisplay final : public AttrDisplay, gcn::ActionListener StatusWindow::StatusWindow() : Window(player_node ? player_node->getName() : "?", false, nullptr, "status.xml"), - gcn::ActionListener(), + ActionListener(), // TRANSLATORS: status window label mLvlLabel(new Label(this, strprintf(_("Level: %d"), 0))), // TRANSLATORS: status window label @@ -820,7 +820,7 @@ ChangeDisplay::ChangeDisplay(const Widget2 *const widget, const int id, const std::string &restrict name, const std::string &restrict shortName) : AttrDisplay(widget, id, name, shortName), - gcn::ActionListener(), + ActionListener(), mNeeded(1), // TRANSLATORS: status window label mPoints(new Label(this, _("Max"))), diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h index c9efe6edd..31e1dda69 100644 --- a/src/gui/windows/statuswindow.h +++ b/src/gui/windows/statuswindow.h @@ -27,7 +27,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include @@ -44,7 +44,7 @@ class VertContainer; * \ingroup Interface */ class StatusWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public DepricatedListener { public: diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 4ae098a3c..72796b6b9 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -160,7 +160,7 @@ public: TextCommandEditor::TextCommandEditor(TextCommand *const command) : // TRANSLATORS: command editor name Window(_("Command Editor"), false, nullptr, "commandeditor.xml"), - gcn::ActionListener(), + ActionListener(), mIsMagicCommand(command->getCommandType() == TEXT_COMMAND_MAGIC), mCommand(command), // TRANSLATORS: command editor button diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h index 4b63aaf29..7b3921618 100644 --- a/src/gui/windows/textcommandeditor.h +++ b/src/gui/windows/textcommandeditor.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; class DropDown; @@ -38,7 +38,8 @@ class TargetTypeModel; class TextCommand; class TextField; -class TextCommandEditor final : public Window, public gcn::ActionListener +class TextCommandEditor final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index c31c099fb..f6f2ce06a 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -41,7 +41,7 @@ TextDialog::TextDialog(const std::string &restrict title, Window *const parent, const bool isPassword): Window(title, true, parent, "textdialog.xml"), - gcn::ActionListener(), + ActionListener(), mTextField(nullptr), mPasswordField(nullptr), // TRANSLATORS: text dialog button diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h index 58819de76..d82b15085 100644 --- a/src/gui/windows/textdialog.h +++ b/src/gui/windows/textdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; class PasswordField; @@ -36,7 +36,8 @@ class TextField; * * \ingroup GUI */ -class TextDialog final : public Window, public gcn::ActionListener +class TextDialog final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index c3a096161..6a9f9a8af 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -67,7 +67,7 @@ TradeWindow::TradeWindow(): // TRANSLATORS: trade window caption Window(_("Trade: You"), false, nullptr, "trade.xml"), - gcn::ActionListener(), + ActionListener(), gcn::SelectionListener(), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index da5c84df2..69ba64ed7 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/selectionlistener.hpp" #include @@ -43,7 +43,7 @@ class TextField; * \ingroup Interface */ class TradeWindow final : public Window, - private gcn::ActionListener, + private ActionListener, private gcn::SelectionListener { public: diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp index 76afb1539..791a25c05 100644 --- a/src/gui/windows/unregisterdialog.cpp +++ b/src/gui/windows/unregisterdialog.cpp @@ -45,7 +45,7 @@ UnRegisterDialog::UnRegisterDialog(LoginData *const data) : // TRANSLATORS: unregister dialog name Window(_("Unregister"), true, nullptr, "unregister.xml"), - gcn::ActionListener(), + ActionListener(), mLoginData(data), mPasswordField(new PasswordField(this, mLoginData->password)), // TRANSLATORS: unregister dialog. button. diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h index 806822171..b384a7041 100644 --- a/src/gui/windows/unregisterdialog.h +++ b/src/gui/windows/unregisterdialog.h @@ -25,7 +25,7 @@ #include "gui/widgets/window.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class Button; class LoginData; @@ -37,7 +37,8 @@ class WrongDataNoticeListener; * * \ingroup Interface */ -class UnRegisterDialog final : public Window, public gcn::ActionListener +class UnRegisterDialog final : public Window, + public ActionListener { public: /** diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index eab1bea1b..2e3294508 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -156,7 +156,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, const int updateType): // TRANSLATORS: updater window name Window(_("Updating..."), false, nullptr, "update.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index 5509168d4..affb7edda 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -30,7 +30,7 @@ #include "utils/mutex.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" #include @@ -69,7 +69,7 @@ struct UpdateFile final * \ingroup GUI */ class UpdaterWindow final : public Window, - public gcn::ActionListener, + public ActionListener, public LinkHandler, public gcn::KeyListener { diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index d60805983..8c6235130 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -30,7 +30,7 @@ #include -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" class BrowserBox; class Button; @@ -102,7 +102,7 @@ class OnlinePlayer final */ class WhoIsOnline final : public Window, public LinkHandler, - public gcn::ActionListener, + public ActionListener, public ConfigListener { public: diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index a3fd0fc73..7372345ef 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -82,7 +82,7 @@ class WorldListModel final : public gcn::ListModel WorldSelectDialog::WorldSelectDialog(Worlds worlds): // TRANSLATORS: world select dialog name Window(_("Select World"), false, nullptr, "world.xml"), - gcn::ActionListener(), + ActionListener(), gcn::KeyListener(), mWorldListModel(new WorldListModel(worlds)), mWorldList(new ListBox(this, mWorldListModel, "")), diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h index 0f3d857b2..9fe42cf13 100644 --- a/src/gui/windows/worldselectdialog.h +++ b/src/gui/windows/worldselectdialog.h @@ -27,7 +27,7 @@ #include "net/worldinfo.h" -#include "gui/base/actionlistener.hpp" +#include "listeners/actionlistener.h" #include "gui/base/keylistener.hpp" class Button; @@ -39,7 +39,8 @@ class WorldListModel; * * \ingroup Interface */ -class WorldSelectDialog final : public Window, public gcn::ActionListener, +class WorldSelectDialog final : public Window, + public ActionListener, public gcn::KeyListener { public: diff --git a/src/listeners/actionlistener.h b/src/listeners/actionlistener.h new file mode 100644 index 000000000..ee3154f80 --- /dev/null +++ b/src/listeners/actionlistener.h @@ -0,0 +1,109 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 LISTENERS_ACTIONLISTENER_HPP +#define LISTENERS_ACTIONLISTENER_HPP + +#include + +#include "gui/base/actionevent.hpp" + +/** + * Interface for listening for action events from widgets. + * + * @see Widget::addActionListener, Widget::removeActionListener, + * ActionEvent + * @author Olof Naessén + * @author Per Larsson + */ +class ActionListener +{ + public: + /** + * Destructor. + */ + virtual ~ActionListener() + { } + + /** + * Called when an action is recieved from a widget. It is used + * to be able to recieve a notification that an action has + * occured. + * + * @param actionEvent The event of the action. + * @since 0.6.0 + */ + virtual void action(const gcn::ActionEvent &actionEvent) = 0; + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of ActionListener, + * therefore its constructor is protected. + */ + ActionListener() + { } +}; + +#endif // end LISTENERS_ACTIONLISTENER_HPP diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 3e5db9169..c568012fc 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -60,7 +60,7 @@ namespace /** * Listener used for handling the overweigth message. */ - struct WeightListener final : public gcn::ActionListener + struct WeightListener final : public ActionListener { void action(const gcn::ActionEvent &event A_UNUSED) { @@ -71,7 +71,7 @@ namespace /** * Listener used for handling death message. */ - struct DeathListener final : public gcn::ActionListener + struct DeathListener final : public ActionListener { void action(const gcn::ActionEvent &event A_UNUSED) { diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 9457a31db..adecd591f 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -48,7 +48,7 @@ ConfirmDialog *confirmDlg = nullptr; */ namespace { - struct RequestTradeListener : public gcn::ActionListener + struct RequestTradeListener : public ActionListener { void action(const gcn::ActionEvent &event) { -- cgit v1.2.3-70-g09d2 From 580ce9af9e9a241aac083107b18c9c81e1c1da0d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 23:20:49 +0300 Subject: move deathlistener from base into listeners. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/basiccontainer.hpp | 3 +- src/gui/base/deathlistener.hpp | 109 ---------------------------------------- src/gui/base/widget.cpp | 3 +- src/gui/base/widget.hpp | 2 +- src/listeners/deathlistener.h | 106 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 113 insertions(+), 114 deletions(-) delete mode 100644 src/gui/base/deathlistener.hpp create mode 100644 src/listeners/deathlistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fccf99fb6..d68026c5d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -774,7 +774,7 @@ SET(SRCS gui/base/basiccontainer.hpp gui/base/cliprectangle.hpp gui/base/color.hpp - gui/base/deathlistener.hpp + listeners/deathlistener.h gui/base/event.hpp gui/base/exception.hpp gui/base/focushandler.hpp diff --git a/src/Makefile.am b/src/Makefile.am index 422b08586..7a74b3d17 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -161,7 +161,7 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/basiccontainer.hpp \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ - gui/base/deathlistener.hpp \ + listeners/deathlistener.h \ gui/base/event.hpp \ gui/base/exception.hpp \ gui/base/focushandler.hpp \ diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp index d6dd38b63..0fec2c0e7 100644 --- a/src/gui/base/basiccontainer.hpp +++ b/src/gui/base/basiccontainer.hpp @@ -67,9 +67,10 @@ #include #include -#include "gui/base/deathlistener.hpp" #include "gui/base/widget.hpp" +#include "listeners/deathlistener.h" + namespace gcn { /** diff --git a/src/gui/base/deathlistener.hpp b/src/gui/base/deathlistener.hpp deleted file mode 100644 index b325166c2..000000000 --- a/src/gui/base/deathlistener.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_DEATHLISTENER_HPP -#define GCN_DEATHLISTENER_HPP - -#include - -#include "gui/base/event.hpp" - -namespace gcn -{ - /** - * Interface for listening for death events from widgets. - * - * @see Widget::addDeathListener, Widget::removeDeathListener - * @author Olof Naessén - * @since 0.6.0 - */ - class DeathListener - { - public: - /** - * Destructor. - */ - virtual ~DeathListener() - { } - - /** - * Called when a widget dies. It is used to be able to recieve - * a notification when a death of a widget occurs. - * - * @param event The event of the death. - */ - virtual void death(const Event& event) = 0; - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of DeathListener, - * therefore its constructor is protected. - */ - DeathListener() - { } - }; -} // namespace gcn - -#endif // end GCN_DEATHLISTENER_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index c14914cc2..b9a98ff1c 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -70,7 +70,6 @@ #include "gui/base/actionevent.hpp" #include "listeners/actionlistener.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/deathlistener.hpp" #include "gui/base/event.hpp" #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" @@ -80,6 +79,8 @@ #include "gui/base/mouselistener.hpp" #include "gui/base/widgetlistener.hpp" +#include "listeners/deathlistener.h" + #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 1c05c2d03..b896ac1e9 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -74,12 +74,12 @@ #include "localconsts.h" class ActionListener; +class DeathListener; class Graphics; namespace gcn { class BasicContainer; - class DeathListener; class FocusHandler; class FocusListener; class Font; diff --git a/src/listeners/deathlistener.h b/src/listeners/deathlistener.h new file mode 100644 index 000000000..ad2eb5364 --- /dev/null +++ b/src/listeners/deathlistener.h @@ -0,0 +1,106 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 LISTENERS_DEATHLISTENER_HPP +#define LISTENERS_DEATHLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +/** + * Interface for listening for death events from widgets. + * + * @see Widget::addDeathListener, Widget::removeDeathListener + * @author Olof Naessén + * @since 0.6.0 + */ +class DeathListener +{ + public: + /** + * Destructor. + */ + virtual ~DeathListener() + { } + + /** + * Called when a widget dies. It is used to be able to recieve + * a notification when a death of a widget occurs. + * + * @param event The event of the death. + */ + virtual void death(const gcn::Event &event) = 0; + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of DeathListener, + * therefore its constructor is protected. + */ + DeathListener() + { } +}; + +#endif // LISTENERS_DEATHLISTENER_HPP -- cgit v1.2.3-70-g09d2 From 01d93aedcc4d1632ff5915c3989a502ec31cd978 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 23:40:05 +0300 Subject: move focuslistener from base into listeners. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/focushandler.cpp | 3 +- src/gui/base/focuslistener.hpp | 119 ---------------------------------------- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 4 +- src/gui/base/widgets/button.hpp | 5 +- src/gui/gui.cpp | 4 +- src/gui/gui.h | 9 +-- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 7 ++- src/gui/widgets/popuplist.cpp | 2 +- src/gui/widgets/popuplist.h | 5 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textfield.h | 5 +- src/listeners/focuslistener.h | 116 +++++++++++++++++++++++++++++++++++++++ 16 files changed, 146 insertions(+), 143 deletions(-) delete mode 100644 src/gui/base/focuslistener.hpp create mode 100644 src/listeners/focuslistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d68026c5d..324e65cac 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -778,7 +778,7 @@ SET(SRCS gui/base/event.hpp gui/base/exception.hpp gui/base/focushandler.hpp - gui/base/focuslistener.hpp + listeners/focuslistener.h gui/base/font.hpp gui/base/gui.hpp gui/base/input.hpp diff --git a/src/Makefile.am b/src/Makefile.am index 7a74b3d17..da16e98d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -165,7 +165,7 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/event.hpp \ gui/base/exception.hpp \ gui/base/focushandler.hpp \ - gui/base/focuslistener.hpp \ + listeners/focuslistener.h \ gui/base/font.hpp \ gui/base/graphics.hpp \ gui/base/gui.hpp \ diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp index 6984d1fcd..ff149bf99 100644 --- a/src/gui/base/focushandler.cpp +++ b/src/gui/base/focushandler.cpp @@ -67,10 +67,11 @@ #include "gui/base/focushandler.hpp" -#include "gui/base/focuslistener.hpp" #include "gui/base/exception.hpp" #include "gui/base/widget.hpp" +#include "listeners/focuslistener.h" + #include "debug.h" namespace gcn diff --git a/src/gui/base/focuslistener.hpp b/src/gui/base/focuslistener.hpp deleted file mode 100644 index f6a7da5ea..000000000 --- a/src/gui/base/focuslistener.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_FOCUSLISTENER_HPP -#define GCN_FOCUSLISTENER_HPP - -#include - -#include "gui/base/event.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for focus events from widgets. - * - * @see Widget::addFocusListener, Widget::removeFocusListener - * @author Olof Naessén - * @since 0.7.0 - */ - class FocusListener - { - public: - /** - * Destructor. - */ - virtual ~FocusListener() - { } - - /** - * Called when a widget gains focus. - * - * @param event Discribes the event. - */ - virtual void focusGained(const Event& event A_UNUSED) - { } - - /** - * Called when a widget loses focus. - * - * @param event Discribes the event. - */ - virtual void focusLost(const Event& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of FocusListener, - * therefore its constructor is protected. - */ - FocusListener() - { } - }; -} // namespace gcn - -#endif // end GCN_FOCUSLISTENER_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index b896ac1e9..a6dc2ed13 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -75,13 +75,13 @@ class ActionListener; class DeathListener; +class FocusListener; class Graphics; namespace gcn { class BasicContainer; class FocusHandler; - class FocusListener; class Font; class KeyInput; class KeyListener; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 3e699670a..82ff878a0 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -83,7 +83,7 @@ namespace gcn gcn::Widget(), gcn::MouseListener(), gcn::KeyListener(), - gcn::FocusListener(), + FocusListener(), mCaption(), mHasMouse(false), mKeyPressed(false), @@ -104,7 +104,7 @@ namespace gcn gcn::Widget(), gcn::MouseListener(), gcn::KeyListener(), - gcn::FocusListener(), + FocusListener(), mCaption(caption), mHasMouse(false), mKeyPressed(false), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index cd41a1b02..e2d6c0c8e 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -66,10 +66,11 @@ #include -#include "gui/base/focuslistener.hpp" +#include "listeners/focuslistener.h" #include "gui/base/keylistener.hpp" -#include "gui/base/mouseevent.hpp" #include "gui/base/mouselistener.hpp" + +#include "gui/base/mouseevent.hpp" #include "gui/base/widget.hpp" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 4da397a73..a398ca427 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -910,12 +910,12 @@ void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput) mFocusHandler->setDraggedWidget(nullptr); } -void Gui::addGlobalFocusListener(gcn::FocusListener* focusListener) +void Gui::addGlobalFocusListener(FocusListener* focusListener) { mFocusListeners.push_back(focusListener); } -void Gui::removeGlobalFocusListener(gcn::FocusListener* focusListener) +void Gui::removeGlobalFocusListener(FocusListener* focusListener) { mFocusListeners.remove(focusListener); } diff --git a/src/gui/gui.h b/src/gui/gui.h index 4737c62fb..544d9dd3d 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -24,9 +24,10 @@ #define GUI_GUI_H #include "gui/base/color.hpp" -#include "gui/base/focuslistener.hpp" #include "gui/base/gui.hpp" +#include "listeners/focuslistener.h" + #include "localconsts.h" class Graphics; @@ -151,9 +152,9 @@ class Gui final : public gcn::Gui int &restrict x, int &restrict y); - void addGlobalFocusListener(gcn::FocusListener* focusListener); + void addGlobalFocusListener(FocusListener* focusListener); - void removeGlobalFocusListener(gcn::FocusListener* focusListener); + void removeGlobalFocusListener(FocusListener* focusListener); void distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent); @@ -195,7 +196,7 @@ class Gui final : public gcn::Gui uint16_t mLastMouseRealX; uint16_t mLastMouseRealY; #endif - typedef std::list FocusListenerList; + typedef std::list FocusListenerList; typedef FocusListenerList::iterator FocusListenerIterator; FocusListenerList mFocusListeners; gcn::Color mForegroundColor; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 070afdbb5..0e9241f21 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -60,7 +60,7 @@ DropDown::DropDown(const Widget2 *const widget, gcn::BasicContainer(), gcn::KeyListener(), gcn::MouseListener(), - gcn::FocusListener(), + FocusListener(), gcn::SelectionListener(), Widget2(widget), mPopup(new PopupList(this, listModel, extended, modal)), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 0b6ada6dd..ca0743ae7 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -26,9 +26,10 @@ #include "gui/widgets/widget2.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/focuslistener.hpp" -#include "gui/base/keylistener.hpp" #include "gui/base/listmodel.hpp" + +#include "listeners/focuslistener.h" +#include "gui/base/keylistener.hpp" #include "gui/base/mouselistener.hpp" #include "gui/base/selectionlistener.hpp" @@ -54,7 +55,7 @@ class DropDown final : public ActionListener, public gcn::BasicContainer, public gcn::KeyListener, public gcn::MouseListener, - public gcn::FocusListener, + public FocusListener, public gcn::SelectionListener, public Widget2 { diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index f7f8afc66..b8e4dabb4 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -32,7 +32,7 @@ PopupList::PopupList(DropDown *const widget, gcn::ListModel *const listModel, bool extended, bool modal): Popup("PopupList", "popuplist.xml"), - gcn::FocusListener(), + FocusListener(), mListModel(listModel), mListBox(extended ? new ExtendedListBox( widget, listModel, "extendedlistbox.xml", 0) : diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index dfe93c0ae..454b5617c 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -23,7 +23,8 @@ #include "gui/widgets/popup.h" -#include "gui/base/focuslistener.hpp" +#include "listeners/focuslistener.h" + #include "gui/base/listmodel.hpp" #include "localconsts.h" @@ -33,7 +34,7 @@ class ListBox; class ScrollArea; class PopupList final : public Popup, - public gcn::FocusListener + public FocusListener { public: PopupList(DropDown *const widget, diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 692a5608e..22e9d42dd 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -57,7 +57,7 @@ TextField::TextField(const Widget2 *restrict const widget, const std::string &restrict eventId, const bool sendAlwaysEvents): gcn::TextField(text), - gcn::FocusListener(), + FocusListener(), Widget2(widget), mSendAlwaysEvents(sendAlwaysEvents), mCaretColor(&getThemeColor(Theme::CARET)), diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 80d022bb1..4545e9ff9 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -25,7 +25,8 @@ #include "gui/widgets/widget2.h" -#include "gui/base/focuslistener.hpp" +#include "listeners/focuslistener.h" + #include "gui/base/widgets/textfield.hpp" #include "localconsts.h" @@ -38,7 +39,7 @@ class PopupMenu; * \ingroup GUI */ class TextField : public gcn::TextField, - public gcn::FocusListener, + public FocusListener, public Widget2 { public: diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h new file mode 100644 index 000000000..1a6dd3fb2 --- /dev/null +++ b/src/listeners/focuslistener.h @@ -0,0 +1,116 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 LISTENERS_FOCUSLISTENER_HPP +#define LISTENERS_FOCUSLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for focus events from widgets. + * + * @see Widget::addFocusListener, Widget::removeFocusListener + * @author Olof Naessén + * @since 0.7.0 + */ +class FocusListener +{ + public: + /** + * Destructor. + */ + virtual ~FocusListener() + { } + + /** + * Called when a widget gains focus. + * + * @param event Discribes the event. + */ + virtual void focusGained(const gcn::Event &event A_UNUSED) + { } + + /** + * Called when a widget loses focus. + * + * @param event Discribes the event. + */ + virtual void focusLost(const gcn::Event &event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of FocusListener, + * therefore its constructor is protected. + */ + FocusListener() + { } +}; + +#endif // LISTENERS_FOCUSLISTENER_HPP -- cgit v1.2.3-70-g09d2 From 768523601ff80a23bf3e821484cc116c62498a38 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 15 Feb 2014 23:58:22 +0300 Subject: move keylistener from base into listeners. --- src/gui/base/gui.cpp | 5 +- src/gui/base/gui.hpp | 2 +- src/gui/base/keylistener.hpp | 119 ---------------------------------- src/gui/base/widget.cpp | 6 +- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 4 +- src/gui/base/widgets/button.hpp | 2 +- src/gui/base/widgets/checkbox.cpp | 4 +- src/gui/base/widgets/checkbox.hpp | 3 +- src/gui/base/widgets/listbox.cpp | 4 +- src/gui/base/widgets/listbox.hpp | 5 +- src/gui/base/widgets/radiobutton.cpp | 4 +- src/gui/base/widgets/radiobutton.hpp | 3 +- src/gui/base/widgets/slider.cpp | 4 +- src/gui/base/widgets/slider.hpp | 3 +- src/gui/base/widgets/textbox.cpp | 4 +- src/gui/base/widgets/textbox.hpp | 3 +- src/gui/base/widgets/textfield.cpp | 4 +- src/gui/base/widgets/textfield.hpp | 3 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 7 +- src/gui/widgets/guitable.cpp | 2 +- src/gui/widgets/guitable.h | 5 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 7 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 5 +- src/gui/widgets/tabs/setup_video.cpp | 2 +- src/gui/widgets/tabs/setup_video.h | 4 +- src/gui/windows/charcreatedialog.cpp | 2 +- src/gui/windows/charcreatedialog.h | 4 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/charselectdialog.h | 4 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/chatwindow.h | 4 +- src/gui/windows/editserverdialog.cpp | 2 +- src/gui/windows/editserverdialog.h | 4 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/itemamountwindow.cpp | 2 +- src/gui/windows/itemamountwindow.h | 4 +- src/gui/windows/logindialog.cpp | 2 +- src/gui/windows/logindialog.h | 4 +- src/gui/windows/quitdialog.cpp | 2 +- src/gui/windows/quitdialog.h | 4 +- src/gui/windows/registerdialog.cpp | 2 +- src/gui/windows/registerdialog.h | 4 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 7 +- src/gui/windows/updaterwindow.cpp | 2 +- src/gui/windows/updaterwindow.h | 4 +- src/gui/windows/worldselectdialog.cpp | 2 +- src/gui/windows/worldselectdialog.h | 4 +- src/listeners/keylistener.h | 119 ++++++++++++++++++++++++++++++++++ 54 files changed, 213 insertions(+), 203 deletions(-) delete mode 100644 src/gui/base/keylistener.hpp create mode 100644 src/listeners/keylistener.h (limited to 'src') diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index 73d6ff380..e85a17d97 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -72,11 +72,12 @@ #include "gui/base/focushandler.hpp" #include "gui/base/input.hpp" #include "gui/base/keyinput.hpp" -#include "gui/base/keylistener.hpp" #include "gui/base/mouseinput.hpp" -#include "gui/base/mouselistener.hpp" #include "gui/base/widget.hpp" +#include "listeners/keylistener.h" +#include "gui/base/mouselistener.hpp" + #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 28a231101..b1d13dcd7 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -72,12 +72,12 @@ #include "gui/base/mouseinput.hpp" class Graphics; +class KeyListener; namespace gcn { class FocusHandler; class Input; - class KeyListener; class Widget; // The following comment will appear in the doxygen main page. diff --git a/src/gui/base/keylistener.hpp b/src/gui/base/keylistener.hpp deleted file mode 100644 index 088a937a6..000000000 --- a/src/gui/base/keylistener.hpp +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEYLISTENER_HPP -#define GCN_KEYLISTENER_HPP - -#include "gui/base/keyevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - class Key; - - /** - * Interface for listening for key events from widgets. - * - * @see Widget::addKeyListener, Widget::removeKeyListener - */ - class KeyListener - { - public: - /** - * Destructor. - */ - virtual ~KeyListener() - { } - - /** - * Called if a key is pressed when the widget has keyboard focus. - * If a key is held down the widget will generate multiple key - * presses. - * - * @param keyEvent Discribes the event. - */ - virtual void keyPressed(KeyEvent& keyEvent A_UNUSED) - { } - - /** - * Called if a key is released when the widget has keyboard focus. - * - * @param keyEvent Discribes the event. - */ - virtual void keyReleased(KeyEvent& keyEvent A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of KeyListener, - * therefore its constructor is protected. - */ - KeyListener() - { } - }; -} // namespace gcn - -#endif // end GCN_KEYLISTENER_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index b9a98ff1c..c72a06e8b 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -74,12 +74,12 @@ #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/keyinput.hpp" -#include "gui/base/keylistener.hpp" #include "gui/base/mouseinput.hpp" -#include "gui/base/mouselistener.hpp" -#include "gui/base/widgetlistener.hpp" #include "listeners/deathlistener.h" +#include "listeners/keylistener.h" +#include "gui/base/mouselistener.hpp" +#include "gui/base/widgetlistener.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index a6dc2ed13..583ade076 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -77,6 +77,7 @@ class ActionListener; class DeathListener; class FocusListener; class Graphics; +class KeyListener; namespace gcn { @@ -84,7 +85,6 @@ namespace gcn class FocusHandler; class Font; class KeyInput; - class KeyListener; class MouseInput; class MouseListener; class WidgetListener; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 82ff878a0..4631ed80f 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -82,7 +82,7 @@ namespace gcn Button::Button() : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), FocusListener(), mCaption(), mHasMouse(false), @@ -103,7 +103,7 @@ namespace gcn Button::Button(const std::string& caption) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), FocusListener(), mCaption(caption), mHasMouse(false), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index e2d6c0c8e..779a75aa5 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -67,7 +67,7 @@ #include #include "listeners/focuslistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" #include "gui/base/mouseevent.hpp" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 615808a85..ceb59a1eb 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -81,7 +81,7 @@ namespace gcn CheckBox::CheckBox() : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mSelected(false), mCaption() { @@ -93,7 +93,7 @@ namespace gcn CheckBox::CheckBox(const std::string &caption, bool selected) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mSelected(selected), mCaption() { diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index c9b723879..4904a022f 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -66,8 +66,9 @@ #include -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" + #include "gui/base/widget.hpp" namespace gcn diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index dcf443c77..771f22f64 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -83,7 +83,7 @@ namespace gcn ListBox::ListBox() : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mSelected(-1), mListModel(nullptr), mWrappingEnabled(false), @@ -99,7 +99,7 @@ namespace gcn ListBox::ListBox(ListModel *listModel) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mSelected(-1), mListModel(listModel), mWrappingEnabled(false), diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index f2780f130..11983262f 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -66,11 +66,12 @@ #include -#include "gui/base/keylistener.hpp" #include "gui/base/listmodel.hpp" -#include "gui/base/mouselistener.hpp" #include "gui/base/widget.hpp" +#include "listeners/keylistener.h" +#include "gui/base/mouselistener.hpp" + namespace gcn { class SelectionListener; diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index 1e1da2622..f7145fd55 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -82,7 +82,7 @@ namespace gcn RadioButton::RadioButton() : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mSelected(false), mCaption(), mGroup() @@ -99,7 +99,7 @@ namespace gcn bool selected) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mSelected(false), mCaption(), mGroup() diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index 07e3d656a..98b562676 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -67,8 +67,9 @@ #include #include -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" + #include "gui/base/widget.hpp" namespace gcn diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index e9ab36e86..2a3fb8c24 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -79,7 +79,7 @@ namespace gcn Slider::Slider(const double scaleEnd) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mDragged(false), mValue(0), mStepLength(scaleEnd / 10), @@ -98,7 +98,7 @@ namespace gcn Slider::Slider(const double scaleStart, const double scaleEnd) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mDragged(false), mValue(scaleStart), mStepLength((scaleEnd - scaleStart) / 10), diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp index 32cdfefb9..fa047a739 100644 --- a/src/gui/base/widgets/slider.hpp +++ b/src/gui/base/widgets/slider.hpp @@ -64,8 +64,9 @@ #ifndef GCN_SLIDER_HPP #define GCN_SLIDER_HPP -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" + #include "gui/base/widget.hpp" namespace gcn diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 411fc7dd5..c146c4f08 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -81,7 +81,7 @@ namespace gcn TextBox::TextBox() : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mTextRows(), mCaretColumn(0), mCaretRow(0), @@ -99,7 +99,7 @@ namespace gcn TextBox::TextBox(const std::string& text) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mTextRows(), mCaretColumn(0), mCaretRow(0), diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 0a540a2c1..894616360 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -68,8 +68,9 @@ #include #include -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" + #include "gui/base/widget.hpp" namespace gcn diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 3349ebccb..178a012b7 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -80,7 +80,7 @@ namespace gcn TextField::TextField() : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mText(), mCaretPosition(0), mXScroll(0) @@ -94,7 +94,7 @@ namespace gcn TextField::TextField(const std::string& text) : gcn::Widget(), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mText(text), mCaretPosition(0), mXScroll(0) diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp index bc227eb55..56d60b7aa 100644 --- a/src/gui/base/widgets/textfield.hpp +++ b/src/gui/base/widgets/textfield.hpp @@ -64,8 +64,9 @@ #ifndef GCN_TEXTFIELD_HPP #define GCN_TEXTFIELD_HPP -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" + #include "gui/base/widget.hpp" #include diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 0e9241f21..e4e38aa90 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -58,7 +58,7 @@ DropDown::DropDown(const Widget2 *const widget, const std::string &eventId): ActionListener(), gcn::BasicContainer(), - gcn::KeyListener(), + KeyListener(), gcn::MouseListener(), FocusListener(), gcn::SelectionListener(), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index ca0743ae7..525ce83e3 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -28,13 +28,12 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/listmodel.hpp" +#include "listeners/actionlistener.h" #include "listeners/focuslistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" #include "gui/base/selectionlistener.hpp" -#include "listeners/actionlistener.h" - #include "localconsts.h" class Image; @@ -53,7 +52,7 @@ class Skin; */ class DropDown final : public ActionListener, public gcn::BasicContainer, - public gcn::KeyListener, + public KeyListener, public gcn::MouseListener, public FocusListener, public gcn::SelectionListener, diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index e2af7f16d..fff2416bf 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -97,7 +97,7 @@ GuiTable::GuiTable(const Widget2 *const widget, gcn::Widget(), Widget2(widget), gcn::MouseListener(), - gcn::KeyListener(), + KeyListener(), mModel(nullptr), mTopWidget(nullptr), mActionListeners(), diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 2154d0889..8d551de2b 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -28,8 +28,9 @@ #include "gui/widgets/tablemodel.h" #include "gui/widgets/widget2.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" + #include "gui/base/widget.hpp" #include @@ -48,7 +49,7 @@ class GuiTableActionListener; class GuiTable final : public gcn::Widget, public Widget2, public gcn::MouseListener, - public gcn::KeyListener, + public KeyListener, public TableModelListener { // so that the action listener can call distributeActionEvent diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 0913dcae3..4fa8a2705 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -160,7 +160,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget, const bool forceQuantity) : gcn::Widget(), Widget2(widget), - gcn::KeyListener(), + KeyListener(), gcn::MouseListener(), gcn::WidgetListener(), mInventory(inventory), diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index cfacb05c6..7757fa65c 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -25,11 +25,12 @@ #include "gui/widgets/widget2.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" -#include "gui/base/widget.hpp" #include "gui/base/widgetlistener.hpp" +#include "gui/base/widget.hpp" + #include #include "localconsts.h" @@ -51,7 +52,7 @@ namespace gcn */ class ItemContainer final : public gcn::Widget, public Widget2, - public gcn::KeyListener, + public KeyListener, public gcn::MouseListener, public gcn::WidgetListener { diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index d659cd6b6..8841560e2 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -37,7 +37,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : Widget2(widget), ActionListener(), gcn::BasicContainer(), - gcn::KeyListener(), + KeyListener(), gcn::MouseListener(), gcn::WidgetListener(), mSelectedTab(nullptr), diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index af7fe5429..03a9f6868 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -25,9 +25,10 @@ #include "gui/widgets/widget2.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/mouselistener.hpp" #include "gui/base/widgetlistener.hpp" + #include "gui/base/widgets/container.hpp" #include "listeners/actionlistener.h" @@ -42,7 +43,7 @@ class Tab; class TabbedArea final : public Widget2, public ActionListener, public gcn::BasicContainer, - public gcn::KeyListener, + public KeyListener, public gcn::MouseListener, public gcn::WidgetListener { diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index f35f75413..ffadc5d03 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -178,7 +178,7 @@ public: Setup_Video::Setup_Video(const Widget2 *const widget) : SetupTab(widget), - gcn::KeyListener(), + KeyListener(), mFullScreenEnabled(config.getBoolValue("screen")), mOpenGLEnabled(intToRenderType(config.getIntValue("opengl"))), mFps(config.getIntValue("fpslimit")), diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h index 25ecfabd6..facbcbce3 100644 --- a/src/gui/widgets/tabs/setup_video.h +++ b/src/gui/widgets/tabs/setup_video.h @@ -25,7 +25,7 @@ #include "gui/widgets/tabs/setuptab.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" class Button; class CheckBox; @@ -37,7 +37,7 @@ class OpenGLListModel; class Slider; class TextDialog; -class Setup_Video final : public SetupTab, public gcn::KeyListener +class Setup_Video final : public SetupTab, public KeyListener { public: explicit Setup_Video(const Widget2 *const widget); diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index e581cc2c9..4595709ca 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -64,7 +64,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, // TRANSLATORS: char create dialog name Window(_("New Character"), true, parent, "charcreate.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mCharSelectDialog(parent), mNameField(new TextField(this, "")), // TRANSLATORS: char create dialog label diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index 89e3c832a..c0e8e2928 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -28,7 +28,7 @@ #include "gui/windows/charselectdialog.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" class Label; class PlayerBox; @@ -43,7 +43,7 @@ class TextField; */ class CharCreateDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: /** diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 37e93938c..f5b522971 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -89,7 +89,7 @@ CharSelectDialog::CharSelectDialog(LoginData *const data): data->username.c_str(), data->lastLogin.c_str()), false, nullptr, "char.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mLoginData(data), // TRANSLATORS: char select dialog. button. mSwitchLoginButton(new Button(this, _("Switch Login"), "switch", this)), diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 66b2f933e..9f0e4d126 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -30,7 +30,7 @@ #include "net/charserverhandler.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" class Button; class CharacterDisplay; @@ -46,7 +46,7 @@ class TextDialog; */ class CharSelectDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: friend class CharDeleteConfirm; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 12ef73516..e62f797e3 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -203,7 +203,7 @@ ChatWindow::ChatWindow(): // TRANSLATORS: chat window name Window(_("Chat"), false, nullptr, "chat.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mItemLinkHandler(new ItemLinkHandler), mChatTabs(new TabbedArea(this)), mChatInput(new ChatInput(this)), diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index 6e4415728..cb7671058 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -30,7 +30,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include #include @@ -84,7 +84,7 @@ struct CHATLOG final */ class ChatWindow final : public Window, public ActionListener, - public gcn::KeyListener, + public KeyListener, public DepricatedListener, public ConfigListener { diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 0b065bb0c..ee375a86e 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -64,7 +64,7 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, // TRANSLATORS: edit server dialog name Window(_("Edit Server"), true, parent), ActionListener(), - gcn::KeyListener(), + KeyListener(), mServerAddressField(new TextField(this, std::string())), mPortField(new TextField(this, std::string())), mNameField(new TextField(this, std::string())), diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 5ef780ef0..bf36c216f 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -32,7 +32,7 @@ class ServerDialog; #include "net/serverinfo.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/listmodel.hpp" @@ -77,7 +77,7 @@ class TypeListModel : public gcn::ListModel */ class EditServerDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: EditServerDialog(ServerDialog *const parent, ServerInfo server, diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 25f1a0110..9e2c1a6ff 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -102,7 +102,7 @@ InventoryWindow::WindowList InventoryWindow::invInstances; InventoryWindow::InventoryWindow(Inventory *const inventory): Window("Inventory", false, nullptr, "inventory.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), gcn::SelectionListener(), InventoryListener(), mInventory(inventory), diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 0ff314fb8..066d0d6d5 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -30,7 +30,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include "gui/base/selectionlistener.hpp" class Button; @@ -52,7 +52,7 @@ class TextPopup; */ class InventoryWindow final : public Window, public ActionListener, - public gcn::KeyListener, + public KeyListener, public gcn::SelectionListener, public InventoryListener, public DepricatedListener diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index d35854375..4dd220093 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -139,7 +139,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, Item *const item, const int maxRange) : Window("", false, parent, "amount.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mItemAmountTextField(new IntTextField(this, 1)), mItemPriceTextField(nullptr), mGPLabel(nullptr), diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index 760555c6c..ac2eae8e1 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -25,8 +25,8 @@ #include "gui/widgets/window.h" -#include "gui/base/keylistener.hpp" #include "listeners/actionlistener.h" +#include "listeners/keylistener.h" class DropDown; class Icon; @@ -44,7 +44,7 @@ class Slider; */ class ItemAmountWindow final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: enum Usage diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index cc8d02471..609b58b57 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -144,7 +144,7 @@ LoginDialog::LoginDialog(LoginData *const data, std::string serverName, // TRANSLATORS: login dialog name Window(_("Login"), false, nullptr, "login.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mLoginData(data), mUserField(new TextField(this, mLoginData->username)), mPassField(new PasswordField(this, mLoginData->password)), diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index 77fb75dd5..70b16f537 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include @@ -46,7 +46,7 @@ class UpdateTypeModel; */ class LoginDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: /** diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 375ab415e..99890472b 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -50,7 +50,7 @@ QuitDialog::QuitDialog(QuitDialog **const pointerToMe): // TRANSLATORS: quit dialog name Window(_("Quit"), true, nullptr, "quit.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mOptions(), // TRANSLATORS: quit dialog button mLogoutQuit(new RadioButton(this, _("Quit"), "quitdialog")), diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h index d99ab72d8..0b81992f1 100644 --- a/src/gui/windows/quitdialog.h +++ b/src/gui/windows/quitdialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include @@ -40,7 +40,7 @@ class RadioButton; */ class QuitDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: /** diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 66a5ad187..fd5ab8f5a 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -64,7 +64,7 @@ RegisterDialog::RegisterDialog(LoginData *const data) : // TRANSLATORS: register dialog name Window(_("Register"), false, nullptr, "register.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mLoginData(data), mUserField(new TextField(this, mLoginData->username)), mPasswordField(new PasswordField(this, mLoginData->password)), diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h index fea74e776..93908c27c 100644 --- a/src/gui/windows/registerdialog.h +++ b/src/gui/windows/registerdialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" class Button; class LoginData; @@ -59,7 +59,7 @@ class WrongDataNoticeListener final : public ActionListener */ class RegisterDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: /** diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 1a02f95c6..a307b043e 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -245,7 +245,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, // TRANSLATORS: servers dialog name Window(_("Choose Your Server"), false, nullptr, "server.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), gcn::SelectionListener(), mMutex(), mDescription(new Label(this, std::string())), diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 3ea3b23a4..afcdf1643 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -32,10 +32,11 @@ #include "utils/mutex.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" -#include "gui/base/listmodel.hpp" +#include "listeners/keylistener.h" #include "gui/base/selectionlistener.hpp" +#include "gui/base/listmodel.hpp" + #include #include @@ -92,7 +93,7 @@ class ServersListModel final : public gcn::ListModel */ class ServerDialog final : public Window, public ActionListener, - public gcn::KeyListener, + public KeyListener, public gcn::SelectionListener { public: diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 2e3294508..b5339a202 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -157,7 +157,7 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, // TRANSLATORS: updater window name Window(_("Updating..."), false, nullptr, "update.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mDownloadStatus(UPDATE_NEWS), mUpdateHost(updateHost), mUpdatesDir(updatesDir), diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index affb7edda..d20f2aadc 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -31,7 +31,7 @@ #include "utils/mutex.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" #include #include @@ -71,7 +71,7 @@ struct UpdateFile final class UpdaterWindow final : public Window, public ActionListener, public LinkHandler, - public gcn::KeyListener + public KeyListener { public: /** diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 7372345ef..48be8df8a 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -83,7 +83,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): // TRANSLATORS: world select dialog name Window(_("Select World"), false, nullptr, "world.xml"), ActionListener(), - gcn::KeyListener(), + KeyListener(), mWorldListModel(new WorldListModel(worlds)), mWorldList(new ListBox(this, mWorldListModel, "")), // TRANSLATORS: world dialog button diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h index 9fe42cf13..5542d2360 100644 --- a/src/gui/windows/worldselectdialog.h +++ b/src/gui/windows/worldselectdialog.h @@ -28,7 +28,7 @@ #include "net/worldinfo.h" #include "listeners/actionlistener.h" -#include "gui/base/keylistener.hpp" +#include "listeners/keylistener.h" class Button; class ListBox; @@ -41,7 +41,7 @@ class WorldListModel; */ class WorldSelectDialog final : public Window, public ActionListener, - public gcn::KeyListener + public KeyListener { public: /** diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h new file mode 100644 index 000000000..e4cd42b67 --- /dev/null +++ b/src/listeners/keylistener.h @@ -0,0 +1,119 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_KEYLISTENER_HPP +#define GCN_KEYLISTENER_HPP + +#include "gui/base/keyevent.hpp" + +#include "localconsts.h" + +namespace gcn +{ + class Key; +} + +/** + * Interface for listening for key events from widgets. + * + * @see Widget::addKeyListener, Widget::removeKeyListener + */ +class KeyListener +{ + public: + /** + * Destructor. + */ + virtual ~KeyListener() + { } + + /** + * Called if a key is pressed when the widget has keyboard focus. + * If a key is held down the widget will generate multiple key + * presses. + * + * @param keyEvent Discribes the event. + */ + virtual void keyPressed(gcn::KeyEvent &keyEvent A_UNUSED) + { } + + /** + * Called if a key is released when the widget has keyboard focus. + * + * @param keyEvent Discribes the event. + */ + virtual void keyReleased(gcn::KeyEvent &keyEvent A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of KeyListener, + * therefore its constructor is protected. + */ + KeyListener() + { } +}; + +#endif // end GCN_KEYLISTENER_HPP -- cgit v1.2.3-70-g09d2 From 9093f12ebbfbdacb3df7a5f5fcdda422daa22754 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 00:12:40 +0300 Subject: move mouselistener from base into listeners. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/gui.cpp | 2 +- src/gui/base/mouselistener.hpp | 196 ---------------------------------- src/gui/base/widget.cpp | 2 +- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 4 +- src/gui/base/widgets/button.hpp | 2 +- src/gui/base/widgets/checkbox.cpp | 4 +- src/gui/base/widgets/checkbox.hpp | 2 +- src/gui/base/widgets/listbox.cpp | 4 +- src/gui/base/widgets/listbox.hpp | 2 +- src/gui/base/widgets/radiobutton.cpp | 4 +- src/gui/base/widgets/radiobutton.hpp | 2 +- src/gui/base/widgets/scrollarea.cpp | 6 +- src/gui/base/widgets/scrollarea.hpp | 2 +- src/gui/base/widgets/slider.cpp | 4 +- src/gui/base/widgets/slider.hpp | 2 +- src/gui/base/widgets/textbox.cpp | 4 +- src/gui/base/widgets/textbox.hpp | 2 +- src/gui/base/widgets/textfield.cpp | 4 +- src/gui/base/widgets/textfield.hpp | 2 +- src/gui/base/widgets/window.cpp | 4 +- src/gui/base/widgets/window.hpp | 3 +- src/gui/gui.cpp | 4 +- src/gui/viewport.cpp | 2 +- src/gui/viewport.h | 4 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/browserbox.h | 4 +- src/gui/widgets/characterdisplay.cpp | 2 +- src/gui/widgets/characterdisplay.h | 2 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 7 +- src/gui/widgets/guitable.cpp | 2 +- src/gui/widgets/guitable.h | 4 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 4 +- src/gui/widgets/linkhandler.h | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 5 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/shortcutcontainer.h | 4 +- src/gui/widgets/sliderlist.cpp | 2 +- src/gui/widgets/sliderlist.h | 4 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 4 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/tabs/tab.h | 5 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 2 +- src/listeners/mouselistener.h | 193 +++++++++++++++++++++++++++++++++ 53 files changed, 271 insertions(+), 270 deletions(-) delete mode 100644 src/gui/base/mouselistener.hpp create mode 100644 src/listeners/mouselistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 324e65cac..edfdec695 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -790,7 +790,7 @@ SET(SRCS gui/base/listmodel.hpp gui/base/mouseevent.hpp gui/base/mouseinput.hpp - gui/base/mouselistener.hpp + listeners/mouselistener.h gui/base/rectangle.hpp gui/base/selectionevent.hpp gui/base/selectionlistener.hpp diff --git a/src/Makefile.am b/src/Makefile.am index da16e98d7..f6787bcff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,7 +178,7 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/listmodel.hpp \ gui/base/mouseevent.hpp \ gui/base/mouseinput.hpp \ - gui/base/mouselistener.hpp \ + listeners/mouselistener.hpp \ gui/base/rectangle.hpp \ gui/base/selectionevent.hpp \ gui/base/selectionlistener.hpp \ diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index e85a17d97..f16048bbb 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -76,7 +76,7 @@ #include "gui/base/widget.hpp" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "render/graphics.h" diff --git a/src/gui/base/mouselistener.hpp b/src/gui/base/mouselistener.hpp deleted file mode 100644 index 32486e56f..000000000 --- a/src/gui/base/mouselistener.hpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_MOUSELISTENER_HPP -#define GCN_MOUSELISTENER_HPP - -#include "gui/base/mouseevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for mouse events from widgets. - * - * @see Widget::addMouseListener, Widget::removeMouseListener - * @since 0.1.0 - */ - class MouseListener - { - public: - /** - * Destructor. - */ - virtual ~MouseListener() - { } - - /** - * Called when the mouse has entered into the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseEntered(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has exited the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseExited(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button has been pressed on the widget area. - * - * NOTE: A mouse press is NOT equal to a mouse click. - * Use mouseClickMessage to check for mouse clicks. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mousePressed(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button has been released on the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseReleased(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when a mouse button is pressed and released (clicked) on - * the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseClicked(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse wheel has moved up on the widget area. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseWheelMovedUp(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse wheel has moved down on the widget area. - * - * @param mousEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseWheelMovedDown(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has moved in the widget area and no mouse button - * has been pressed (i.e no widget is being dragged). - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseMoved(MouseEvent& mouseEvent A_UNUSED) - { - } - - /** - * Called when the mouse has moved and the mouse has previously been - * pressed on the widget. - * - * @param mouseEvent Describes the event. - * @since 0.6.0 - */ - virtual void mouseDragged(MouseEvent& mouseEvent A_UNUSED) - { - } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of MouseListener, - * therefore its constructor is protected. - */ - MouseListener() - { } - }; -} // namespace gcn - -#endif // end GCN_MOUSELISTENER_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index c72a06e8b..b05a0d5b1 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -78,7 +78,7 @@ #include "listeners/deathlistener.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 583ade076..af04714f6 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -78,6 +78,7 @@ class DeathListener; class FocusListener; class Graphics; class KeyListener; +class MouseListener; namespace gcn { @@ -86,7 +87,6 @@ namespace gcn class Font; class KeyInput; class MouseInput; - class MouseListener; class WidgetListener; /** diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 4631ed80f..7f1aea668 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -81,7 +81,7 @@ namespace gcn { Button::Button() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), FocusListener(), mCaption(), @@ -102,7 +102,7 @@ namespace gcn Button::Button(const std::string& caption) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), FocusListener(), mCaption(caption), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index 779a75aa5..c81fec14f 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -68,7 +68,7 @@ #include "listeners/focuslistener.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/mouseevent.hpp" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index ceb59a1eb..5f2477b4d 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -80,7 +80,7 @@ namespace gcn CheckBox::CheckBox() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(false), mCaption() @@ -92,7 +92,7 @@ namespace gcn CheckBox::CheckBox(const std::string &caption, bool selected) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(selected), mCaption() diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index 4904a022f..c03187bba 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -67,7 +67,7 @@ #include #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 771f22f64..3ae4caa91 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -82,7 +82,7 @@ namespace gcn { ListBox::ListBox() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(-1), mListModel(nullptr), @@ -98,7 +98,7 @@ namespace gcn ListBox::ListBox(ListModel *listModel) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(-1), mListModel(listModel), diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index 11983262f..793aba840 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -70,7 +70,7 @@ #include "gui/base/widget.hpp" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" namespace gcn { diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index f7145fd55..e42773de1 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -81,7 +81,7 @@ namespace gcn RadioButton::RadioButton() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(false), mCaption(), @@ -98,7 +98,7 @@ namespace gcn const std::string &group, bool selected) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mSelected(false), mCaption(), diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index 98b562676..8a9a8b585 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -68,7 +68,7 @@ #include #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index 308cee473..ffcaffdb1 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -77,7 +77,7 @@ namespace gcn { ScrollArea::ScrollArea() : gcn::BasicContainer(), - gcn::MouseListener(), + MouseListener(), mVScroll(0), mHScroll(0), mScrollbarWidth(12), @@ -104,7 +104,7 @@ namespace gcn ScrollArea::ScrollArea(Widget *const content) : gcn::BasicContainer(), - gcn::MouseListener(), + MouseListener(), mVScroll(0), mHScroll(0), mScrollbarWidth(12), @@ -134,7 +134,7 @@ namespace gcn ScrollPolicy hPolicy, ScrollPolicy vPolicy) : gcn::BasicContainer(), - gcn::MouseListener(), + MouseListener(), mVScroll(0), mHScroll(0), mScrollbarWidth(12), diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp index e75390ec0..1d4c0dd54 100644 --- a/src/gui/base/widgets/scrollarea.hpp +++ b/src/gui/base/widgets/scrollarea.hpp @@ -67,7 +67,7 @@ #include #include "gui/base/basiccontainer.hpp" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" namespace gcn { diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index 2a3fb8c24..91c054e7d 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -78,7 +78,7 @@ namespace gcn { Slider::Slider(const double scaleEnd) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mDragged(false), mValue(0), @@ -97,7 +97,7 @@ namespace gcn Slider::Slider(const double scaleStart, const double scaleEnd) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mDragged(false), mValue(scaleStart), diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp index fa047a739..f77d3f5dd 100644 --- a/src/gui/base/widgets/slider.hpp +++ b/src/gui/base/widgets/slider.hpp @@ -65,7 +65,7 @@ #define GCN_SLIDER_HPP #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index c146c4f08..06d0e6379 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -80,7 +80,7 @@ namespace gcn { TextBox::TextBox() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mTextRows(), mCaretColumn(0), @@ -98,7 +98,7 @@ namespace gcn TextBox::TextBox(const std::string& text) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mTextRows(), mCaretColumn(0), diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 894616360..8fc788816 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -69,7 +69,7 @@ #include #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 178a012b7..df1b844d4 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -79,7 +79,7 @@ namespace gcn { TextField::TextField() : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mText(), mCaretPosition(0), @@ -93,7 +93,7 @@ namespace gcn TextField::TextField(const std::string& text) : gcn::Widget(), - gcn::MouseListener(), + MouseListener(), KeyListener(), mText(text), mCaretPosition(0), diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp index 56d60b7aa..099ed1356 100644 --- a/src/gui/base/widgets/textfield.hpp +++ b/src/gui/base/widgets/textfield.hpp @@ -65,7 +65,7 @@ #define GCN_TEXTFIELD_HPP #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 6373bcb63..02611f819 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -79,7 +79,7 @@ namespace gcn { Window::Window() : Container(), - gcn::MouseListener(), + MouseListener(), mCaption(), mAlignment(Graphics::CENTER), mPadding(2), @@ -96,7 +96,7 @@ namespace gcn Window::Window(const std::string& caption) : Container(), - gcn::MouseListener(), + MouseListener(), mCaption(caption), mAlignment(Graphics::CENTER), mPadding(2), diff --git a/src/gui/base/widgets/window.hpp b/src/gui/base/widgets/window.hpp index 9c7e6bcbf..030d57edc 100644 --- a/src/gui/base/widgets/window.hpp +++ b/src/gui/base/widgets/window.hpp @@ -66,7 +66,8 @@ #include -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" + #include "gui/base/widgets/container.hpp" namespace gcn diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index a398ca427..bced937c7 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -697,11 +697,11 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, mouseEvent.setX(x - widgetX); mouseEvent.setY(y - widgetY); - std::list mouseListeners + std::list mouseListeners = widget->_getMouseListeners(); // Send the event to all mouse listeners of the widget. - for (std::list::const_iterator + for (std::list::const_iterator it = mouseListeners.begin(); it != mouseListeners.end(); ++ it) { diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 2a91d1991..b3cafa104 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -51,7 +51,7 @@ extern MiniStatusWindow *miniStatusWindow; Viewport::Viewport() : WindowContainer(nullptr), - gcn::MouseListener(), + MouseListener(), mMap(nullptr), mScrollRadius(config.getIntValue("ScrollRadius")), mScrollLaziness(config.getIntValue("ScrollLaziness")), diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 9adaa6c18..6fd062c35 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -29,7 +29,7 @@ #include "gui/widgets/windowcontainer.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" class ActorSprite; class Button; @@ -60,7 +60,7 @@ const int walkingMouseDelay = 500; * coordinates. */ class Viewport final : public WindowContainer, - public gcn::MouseListener, + public MouseListener, public ConfigListener { public: diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 024dde9c8..cfbc0ec41 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -55,7 +55,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const std::string &skin) : gcn::Widget(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), mTextRows(), mTextRowLinksCount(), mLineParts(), diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 85ce9b96b..fa3b90963 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" #include @@ -104,7 +104,7 @@ class LinePart final */ class BrowserBox final : public gcn::Widget, public Widget2, - public gcn::MouseListener + public MouseListener { public: /** diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 5ae4e2f5b..54cb3b28d 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -40,7 +40,7 @@ CharacterDisplay::CharacterDisplay(const Widget2 *const widget, CharSelectDialog *const charSelectDialog) : Container(widget), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mCharacter(nullptr), mPlayerBox(new PlayerBox(nullptr)), diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index ebb0d46da..0352a91a0 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -38,7 +38,7 @@ class Label; class TextPopup; class CharacterDisplay final : public Container, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index e4e38aa90..efb3235a4 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -59,7 +59,7 @@ DropDown::DropDown(const Widget2 *const widget, ActionListener(), gcn::BasicContainer(), KeyListener(), - gcn::MouseListener(), + MouseListener(), FocusListener(), gcn::SelectionListener(), Widget2(widget), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 525ce83e3..7d645a478 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -31,7 +31,7 @@ #include "listeners/actionlistener.h" #include "listeners/focuslistener.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/selectionlistener.hpp" #include "localconsts.h" @@ -53,7 +53,7 @@ class Skin; class DropDown final : public ActionListener, public gcn::BasicContainer, public KeyListener, - public gcn::MouseListener, + public MouseListener, public FocusListener, public gcn::SelectionListener, public Widget2 diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 6101c20ae..c086cd463 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -36,7 +36,7 @@ namespace EmotePage::EmotePage(const Widget2 *const widget) : gcn::Widget(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mEmotes(ResourceManager::getInstance()->getImageSet( "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)), diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 9cd2867aa..c773d9a66 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -23,15 +23,16 @@ #include "gui/widgets/widget2.h" -#include "gui/base/mouselistener.hpp" -#include "gui/base/widget.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" +#include "gui/base/widget.hpp" + #include "localconsts.h" class EmotePage final : public gcn::Widget, public Widget2, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index fff2416bf..3d987ed63 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -96,7 +96,7 @@ GuiTable::GuiTable(const Widget2 *const widget, TableModel *const initial_model, const bool opacity) : gcn::Widget(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), KeyListener(), mModel(nullptr), mTopWidget(nullptr), diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 8d551de2b..a751cac59 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -29,7 +29,7 @@ #include "gui/widgets/widget2.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" @@ -48,7 +48,7 @@ class GuiTableActionListener; */ class GuiTable final : public gcn::Widget, public Widget2, - public gcn::MouseListener, + public MouseListener, public KeyListener, public TableModelListener { diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 4fa8a2705..40c87d272 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -161,7 +161,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget, gcn::Widget(), Widget2(widget), KeyListener(), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mInventory(inventory), mSelImg(Theme::getImageFromThemeXml("item_selection.xml", "")), diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 7757fa65c..77d7e1c28 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "gui/base/widget.hpp" @@ -53,7 +53,7 @@ namespace gcn class ItemContainer final : public gcn::Widget, public Widget2, public KeyListener, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h index f79f1bf50..2f3a6e53f 100644 --- a/src/gui/widgets/linkhandler.h +++ b/src/gui/widgets/linkhandler.h @@ -25,7 +25,7 @@ #include -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" /** * A simple interface to windows that need to handle links from BrowserBox diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index c1319737e..a4908c23b 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -34,7 +34,7 @@ Popup::Popup(const std::string &name, std::string skin) : Container(nullptr), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mPadding(3), mSkin(nullptr), diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index f0fd1b932..d09331136 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -26,7 +26,7 @@ #include "gui/widgets/container.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" class ImageCollection; @@ -45,7 +45,8 @@ class WindowContainer; * * \ingroup GUI */ -class Popup : public Container, public gcn::MouseListener, +class Popup : public Container, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index a3030b035..dcb7d1138 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -32,7 +32,7 @@ ShortcutContainer::ShortcutContainer() : gcn::Widget(), Widget2(), gcn::WidgetListener(), - gcn::MouseListener(), + MouseListener(), mBackgroundImg(nullptr), mMaxItems(0), mBoxWidth(1), diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 4d4ff2389..1d734de6a 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -25,7 +25,7 @@ #include "gui/widgets/widget2.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widget.hpp" #include "gui/base/widgetlistener.hpp" @@ -40,7 +40,7 @@ class ImageCollection; class ShortcutContainer : public gcn::Widget, public Widget2, public gcn::WidgetListener, - public gcn::MouseListener + public MouseListener { public: A_DELETE_COPY(ShortcutContainer) diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 0ae0890dc..d70977ff3 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -37,7 +37,7 @@ SliderList::SliderList(const Widget2 *const widget, gcn::ListModel *const listModel) : Container(widget), ActionListener(), - gcn::MouseListener(), + MouseListener(), mLabel(new Label(this)), mListModel(listModel), mPrevEventId(), diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 3d86f8735..144fa0cf1 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -22,9 +22,9 @@ #define GUI_WIDGETS_SLIDERLIST_H #include "gui/base/listmodel.hpp" -#include "gui/base/mouselistener.hpp" #include "listeners/actionlistener.h" +#include "listeners/mouselistener.h" #include "gui/widgets/container.h" @@ -35,7 +35,7 @@ class Label; class SliderList final : public Container, public ActionListener, - public gcn::MouseListener + public MouseListener { public: SliderList(const Widget2 *const widget, diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 8841560e2..2c431c452 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -38,7 +38,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : ActionListener(), gcn::BasicContainer(), KeyListener(), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mSelectedTab(nullptr), mTabContainer(new gcn::Container()), diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 03a9f6868..b8b075ade 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "listeners/keylistener.h" -#include "gui/base/mouselistener.hpp" +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "gui/base/widgets/container.hpp" @@ -44,7 +44,7 @@ class TabbedArea final : public Widget2, public ActionListener, public gcn::BasicContainer, public KeyListener, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index bba1ef7b6..877329cf8 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -46,7 +46,7 @@ Skin *Tab::tabImg[Tab::TAB_COUNT]; Tab::Tab(const Widget2 *const widget) : gcn::BasicContainer(), Widget2(widget), - gcn::MouseListener(), + MouseListener(), gcn::WidgetListener(), mLabel(new Label(this)), mTabbedArea(nullptr), diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 66f7521d9..a67025842 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -26,7 +26,8 @@ #include "gui/widgets/widget2.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/mouselistener.hpp" + +#include "listeners/mouselistener.h" #include "gui/base/widgetlistener.hpp" #include "localconsts.h" @@ -41,7 +42,7 @@ class TabbedArea; */ class Tab : public gcn::BasicContainer, public Widget2, - public gcn::MouseListener, + public MouseListener, public gcn::WidgetListener { public: diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 3ef3e73ce..aeef201e7 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -46,7 +46,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : Container(widget), ActionListener(), gcn::SelectionListener(), - gcn::MouseListener(), + MouseListener(), mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "") : nullptr), mPadding(mSkin ? mSkin->getPadding() : 1), diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index d7e16e7fa..0b613fce9 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -79,7 +79,7 @@ class WindowMenu final : public Container, public ConfigListener, public ActionListener, public gcn::SelectionListener, - public gcn::MouseListener + public MouseListener { public: explicit WindowMenu(const Widget2 *const widget); diff --git a/src/listeners/mouselistener.h b/src/listeners/mouselistener.h new file mode 100644 index 000000000..e95d2ca01 --- /dev/null +++ b/src/listeners/mouselistener.h @@ -0,0 +1,193 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_MOUSELISTENER_HPP +#define GCN_MOUSELISTENER_HPP + +#include "gui/base/mouseevent.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for mouse events from widgets. + * + * @see Widget::addMouseListener, Widget::removeMouseListener + * @since 0.1.0 + */ +class MouseListener +{ + public: + /** + * Destructor. + */ + virtual ~MouseListener() + { } + + /** + * Called when the mouse has entered into the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseEntered(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has exited the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseExited(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button has been pressed on the widget area. + * + * NOTE: A mouse press is NOT equal to a mouse click. + * Use mouseClickMessage to check for mouse clicks. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mousePressed(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button has been released on the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseReleased(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when a mouse button is pressed and released (clicked) on + * the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseClicked(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse wheel has moved up on the widget area. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseWheelMovedUp(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse wheel has moved down on the widget area. + * + * @param mousEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has moved in the widget area and no mouse button + * has been pressed (i.e no widget is being dragged). + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseMoved(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + /** + * Called when the mouse has moved and the mouse has previously been + * pressed on the widget. + * + * @param mouseEvent Describes the event. + * @since 0.6.0 + */ + virtual void mouseDragged(gcn::MouseEvent &mouseEvent A_UNUSED) + { + } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of MouseListener, + * therefore its constructor is protected. + */ + MouseListener() + { } +}; + +#endif // end GCN_MOUSELISTENER_HPP -- cgit v1.2.3-70-g09d2 From 9bca06b1c7c121f410766ad99b91075902ce24c7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 00:36:17 +0300 Subject: move selectionlistener from base into listeners. --- src/gui/base/selectionlistener.hpp | 117 ---------------------------------- src/gui/base/widgets/listbox.cpp | 2 +- src/gui/base/widgets/listbox.hpp | 4 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 12 ++-- src/gui/widgets/tabs/setup_colors.cpp | 2 +- src/gui/widgets/tabs/setup_colors.h | 4 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 4 +- src/gui/windows/buydialog.cpp | 6 +- src/gui/windows/buydialog.h | 4 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/selldialog.cpp | 4 +- src/gui/windows/selldialog.h | 4 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 4 +- src/gui/windows/shopwindow.cpp | 2 +- src/gui/windows/shopwindow.h | 4 +- src/gui/windows/tradewindow.cpp | 2 +- src/gui/windows/tradewindow.h | 4 +- src/listeners/selectionlistener.h | 114 +++++++++++++++++++++++++++++++++ 24 files changed, 152 insertions(+), 159 deletions(-) delete mode 100644 src/gui/base/selectionlistener.hpp create mode 100644 src/listeners/selectionlistener.h (limited to 'src') diff --git a/src/gui/base/selectionlistener.hpp b/src/gui/base/selectionlistener.hpp deleted file mode 100644 index b1a4d73ba..000000000 --- a/src/gui/base/selectionlistener.hpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SELECTIONLISTENER_HPP -#define GCN_SELECTIONLISTENER_HPP - -#include - -#include "gui/base/selectionevent.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for selection events from widgets. - * - * @see ListBox::addSelectionListener, - * ListBox::removeSelectionListener, - * DropDown::addSelectionListener, - * DropDown::removeSelectionListener - * @author Olof Naessén - * @since 0.8.0 - */ - class SelectionListener - { - public: - /** - * Destructor. - */ - virtual ~SelectionListener() - { } - - /** - * Called when the value of a selection has been changed in a Widget. - * It is used to be able to recieve a notification that a value has - * been changed. - * - * @param event The event of the value change. - * @since 0.8.0 - */ - virtual void valueChanged(const SelectionEvent& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of SelectionListener, - * therefore its constructor is protected. - */ - SelectionListener() - { } - }; -} // namespace gcn - -#endif // end GCN_SELECTIONLISTENER_HPP diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 3ae4caa91..7f46b4b10 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -72,7 +72,7 @@ #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouseinput.hpp" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index 793aba840..61c8486bb 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -72,10 +72,10 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" +class SelectionListener; + namespace gcn { - class SelectionListener; - /** * An implementation of a list box where an item can be selected. * diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index efb3235a4..1aed0dfe1 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -61,7 +61,7 @@ DropDown::DropDown(const Widget2 *const widget, KeyListener(), MouseListener(), FocusListener(), - gcn::SelectionListener(), + SelectionListener(), Widget2(widget), mPopup(new PopupList(this, listModel, extended, modal)), mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 7d645a478..692b341ca 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -32,7 +32,7 @@ #include "listeners/focuslistener.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "localconsts.h" @@ -55,7 +55,7 @@ class DropDown final : public ActionListener, public KeyListener, public MouseListener, public FocusListener, - public gcn::SelectionListener, + public SelectionListener, public Widget2 { public: diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 40c87d272..036cb6c1b 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -47,7 +47,7 @@ #include "resources/image.h" #include "gui/base/font.hpp" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 77d7e1c28..74ae72a23 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -39,11 +39,7 @@ class Image; class Inventory; class Item; class ItemPopup; - -namespace gcn -{ - class SelectionListener; -} +class SelectionListener; /** * An item container. Used to show items in inventory and trade dialog. @@ -116,14 +112,14 @@ class ItemContainer final : public gcn::Widget, * Adds a listener to the list that's notified each time a change to * the selection occurs. */ - void addSelectionListener(gcn::SelectionListener *listener) + void addSelectionListener(SelectionListener *listener) { mSelectionListeners.push_back(listener); } /** * Removes a listener from the list that's notified each time a change * to the selection occurs. */ - void removeSelectionListener(gcn::SelectionListener *listener) + void removeSelectionListener(SelectionListener *listener) { mSelectionListeners.remove(listener); } void setFilter(const int tag); @@ -192,7 +188,7 @@ class ItemContainer final : public gcn::Widget, gcn::Color mEquipedColor2; gcn::Color mUnEquipedColor; gcn::Color mUnEquipedColor2; - typedef std::list SelectionListenerList; + typedef std::list SelectionListenerList; typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; int mGridColumns; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 1094f5e29..fadea948a 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -47,7 +47,7 @@ const char *const Setup_Colors::rawmsg = Setup_Colors::Setup_Colors(const Widget2 *const widget) : SetupTab(widget), - gcn::SelectionListener(), + SelectionListener(), mColorBox(new ListBox(this, userPalette, "")), mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")), mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index 38f0f2687..0bcc9c7f0 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -24,7 +24,7 @@ #include "gui/widgets/tabs/setuptab.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include @@ -37,7 +37,7 @@ class TextField; class TextPreview; class Setup_Colors final : public SetupTab, - public gcn::SelectionListener + public SelectionListener { public: explicit Setup_Colors(const Widget2 *const widget); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index aeef201e7..631fe3437 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -45,7 +45,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : Container(widget), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), MouseListener(), mSkin(Theme::instance() ? Theme::instance()->load("windowmenu.xml", "") : nullptr), diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 0b613fce9..b472be579 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -29,7 +29,7 @@ #include "gui/widgets/button.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "localconsts.h" @@ -78,7 +78,7 @@ struct ButtonText final class WindowMenu final : public Container, public ConfigListener, public ActionListener, - public gcn::SelectionListener, + public SelectionListener, public MouseListener { public: diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 2d6d7d9db..def60b942 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -194,7 +194,7 @@ BuyDialog::BuyDialog() : // TRANSLATORS: buy dialog name Window(_("Create items"), false, nullptr, "buy.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(-2), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(), mSortModel(nullptr), mSortDropDown(nullptr) @@ -206,7 +206,7 @@ BuyDialog::BuyDialog(const int npcId) : // TRANSLATORS: buy dialog name Window(_("Buy"), false, nullptr, "buy.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(npcId), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(), mSortModel(nullptr), mSortDropDown(nullptr) @@ -218,7 +218,7 @@ BuyDialog::BuyDialog(std::string nick) : // TRANSLATORS: buy dialog name Window(_("Buy"), false, nullptr, "buy.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(-1), mMoney(0), mAmountItems(0), mMaxItems(0), mNick(nick), mSortModel(new SortListModelBuy), mSortDropDown(new DropDown(this, mSortModel, false, false, this, "sort")) diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index ef51c04b2..9e493b91e 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class DropDown; @@ -46,7 +46,7 @@ class Slider; */ class BuyDialog final : public Window, public ActionListener, - public gcn::SelectionListener + public SelectionListener { public: /** diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 9e2c1a6ff..7066a9c8e 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -103,7 +103,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): Window("Inventory", false, nullptr, "inventory.xml"), ActionListener(), KeyListener(), - gcn::SelectionListener(), + SelectionListener(), InventoryListener(), mInventory(inventory), mItems(new ItemContainer(this, mInventory)), diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 066d0d6d5..2d5ec6191 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -31,7 +31,7 @@ #include "listeners/actionlistener.h" #include "listeners/keylistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class DropDown; @@ -53,7 +53,7 @@ class TextPopup; class InventoryWindow final : public Window, public ActionListener, public KeyListener, - public gcn::SelectionListener, + public SelectionListener, public InventoryListener, public DepricatedListener { diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 888a2432d..9db7bda27 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -54,7 +54,7 @@ SellDialog::SellDialog(const int npcId) : // TRANSLATORS: sell dialog name Window(_("Sell"), false, nullptr, "sell.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(npcId), mMaxItems(0), mAmountItems(0), mNick("") { init(); @@ -64,7 +64,7 @@ SellDialog::SellDialog(const std::string &nick): // TRANSLATORS: sell dialog name Window(_("Sell"), false, nullptr, "sell.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mNpcId(-1), mMaxItems(0), mAmountItems(0), mNick(nick) { init(); diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h index c23112f8a..f1747ca7e 100644 --- a/src/gui/windows/selldialog.h +++ b/src/gui/windows/selldialog.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class Item; @@ -43,7 +43,7 @@ class Slider; */ class SellDialog final : public Window, private ActionListener, - private gcn::SelectionListener + private SelectionListener { public: /** diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index a307b043e..32e838ac3 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -246,7 +246,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, Window(_("Choose Your Server"), false, nullptr, "server.xml"), ActionListener(), KeyListener(), - gcn::SelectionListener(), + SelectionListener(), mMutex(), mDescription(new Label(this, std::string())), // TRANSLATORS: servers dialog button diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index afcdf1643..c01f8dd08 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -33,7 +33,7 @@ #include "listeners/actionlistener.h" #include "listeners/keylistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include "gui/base/listmodel.hpp" @@ -94,7 +94,7 @@ class ServersListModel final : public gcn::ListModel class ServerDialog final : public Window, public ActionListener, public KeyListener, - public gcn::SelectionListener + public SelectionListener { public: /** diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 1485f18c9..7e50e4c37 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -72,7 +72,7 @@ ShopWindow::ShopWindow(): // TRANSLATORS: shop window name Window(_("Personal Shop"), false, nullptr, "shop.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), // TRANSLATORS: shop window button mCloseButton(new Button(this, _("Close"), "close", this)), mBuyShopItems(new ShopItems), diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 606080986..9149b79cb 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" class Button; class CheckBox; @@ -44,7 +44,7 @@ class ShopListBox; */ class ShopWindow final : public Window, public ActionListener, - public gcn::SelectionListener + public SelectionListener { public: enum ShopMode diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 6a9f9a8af..a5b7f1a47 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -68,7 +68,7 @@ TradeWindow::TradeWindow(): // TRANSLATORS: trade window caption Window(_("Trade: You"), false, nullptr, "trade.xml"), ActionListener(), - gcn::SelectionListener(), + SelectionListener(), mMyInventory(new Inventory(Inventory::TRADE)), mPartnerInventory(new Inventory(Inventory::TRADE)), mMyItemContainer(new ItemContainer(this, mMyInventory.get())), diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index 69ba64ed7..c5e1d7e8f 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -26,7 +26,7 @@ #include "gui/widgets/window.h" #include "listeners/actionlistener.h" -#include "gui/base/selectionlistener.hpp" +#include "listeners/selectionlistener.h" #include @@ -44,7 +44,7 @@ class TextField; */ class TradeWindow final : public Window, private ActionListener, - private gcn::SelectionListener + private SelectionListener { public: /** diff --git a/src/listeners/selectionlistener.h b/src/listeners/selectionlistener.h new file mode 100644 index 000000000..e258440e6 --- /dev/null +++ b/src/listeners/selectionlistener.h @@ -0,0 +1,114 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GCN_SELECTIONLISTENER_HPP +#define GCN_SELECTIONLISTENER_HPP + +#include + +#include "gui/base/selectionevent.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for selection events from widgets. + * + * @see ListBox::addSelectionListener, + * ListBox::removeSelectionListener, + * DropDown::addSelectionListener, + * DropDown::removeSelectionListener + * @author Olof Naessén + * @since 0.8.0 + */ +class SelectionListener +{ + public: + /** + * Destructor. + */ + virtual ~SelectionListener() + { } + + /** + * Called when the value of a selection has been changed in a Widget. + * It is used to be able to recieve a notification that a value has + * been changed. + * + * @param event The event of the value change. + * @since 0.8.0 + */ + virtual void valueChanged(const gcn::SelectionEvent &event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of SelectionListener, + * therefore its constructor is protected. + */ + SelectionListener() + { } +}; + +#endif // end GCN_SELECTIONLISTENER_HPP -- cgit v1.2.3-70-g09d2 From c57791d0fc6833d2ec72a40400d9039030f7cc96 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 01:05:05 +0300 Subject: move widgetlistener from base into listeners. --- src/gui/base/widget.cpp | 2 +- src/gui/base/widget.hpp | 2 +- src/gui/base/widgetlistener.hpp | 143 ---------------------------------- src/gui/widgets/button.cpp | 10 +-- src/gui/widgets/button.h | 4 +- src/gui/widgets/characterdisplay.cpp | 2 +- src/gui/widgets/characterdisplay.h | 4 +- src/gui/widgets/desktop.cpp | 2 +- src/gui/widgets/desktop.h | 5 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 4 +- src/gui/widgets/flowcontainer.cpp | 2 +- src/gui/widgets/flowcontainer.h | 4 +- src/gui/widgets/horizontcontainer.cpp | 2 +- src/gui/widgets/horizontcontainer.h | 5 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 4 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/layouthelper.h | 4 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 4 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/progressbar.h | 5 +- src/gui/widgets/scrollarea.cpp | 4 +- src/gui/widgets/scrollarea.h | 5 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/shortcutcontainer.h | 4 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 4 +- src/gui/widgets/tabs/setuptab.cpp | 2 +- src/gui/widgets/tabs/setuptab.h | 4 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/tabs/tab.h | 4 +- src/gui/widgets/vertcontainer.cpp | 2 +- src/gui/widgets/vertcontainer.h | 5 +- src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 4 +- src/gui/widgets/window.cpp | 2 +- src/gui/widgets/window.h | 4 +- src/listeners/widgetlistener.h | 140 +++++++++++++++++++++++++++++++++ 40 files changed, 206 insertions(+), 204 deletions(-) delete mode 100644 src/gui/base/widgetlistener.hpp create mode 100644 src/listeners/widgetlistener.h (limited to 'src') diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index b05a0d5b1..6acf447d1 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -79,7 +79,7 @@ #include "listeners/deathlistener.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index af04714f6..ce32b14f3 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -79,6 +79,7 @@ class FocusListener; class Graphics; class KeyListener; class MouseListener; +class WidgetListener; namespace gcn { @@ -87,7 +88,6 @@ namespace gcn class Font; class KeyInput; class MouseInput; - class WidgetListener; /** * Abstract class for widgets of Guichan. It contains basic functions diff --git a/src/gui/base/widgetlistener.hpp b/src/gui/base/widgetlistener.hpp deleted file mode 100644 index 3dd74bb4d..000000000 --- a/src/gui/base/widgetlistener.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_WIDGETLISTENER_HPP -#define GCN_WIDGETLISTENER_HPP - -#include - -#include "gui/base/event.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * Interface for listening for events from widgets. When a widget's size, - * location or visibility changes, the relevant method of the listener is - * invoked. - * - * @see Widget::addWidgetListener, Widget::removeWidgetListener - * @author Olof Naessén - * @since 0.8.0 - */ - class WidgetListener - { - public: - /** - * Destructor. - */ - virtual ~WidgetListener() - { } - - /** - * Invoked when a widget changes its size. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetResized(const Event& event A_UNUSED) - { } - - /** - * Invoked when a widget is moved. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetMoved(const Event& event A_UNUSED) - { } - - /** - * Invoked when a widget is hidden, i.e it's set to be - * not visible. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetHidden(const Event& event A_UNUSED) - { } - - /** - * Invoked when a widget is shown, i.e it's set to be - * visible. - * - * @param event Describes the event. - * @since 0.8.0 - */ - virtual void widgetShown(const Event& event A_UNUSED) - { } - - protected: - /** - * Constructor. - * - * You should not be able to make an instance of WidgetListener, - * therefore its constructor is protected. - */ - WidgetListener() - { } - }; -} // namespace gcn - -#endif // end GCN_WIDGETLISTENER_HPP diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 7cbdff44d..ee984a18a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -50,7 +50,7 @@ Skin *Button::button[BUTTON_COUNT]; Button::Button(const Widget2 *const widget) : gcn::Button(), Widget2(widget), - gcn::WidgetListener(), + WidgetListener(), mDescription(), mVertexes2(new ImageCollection), mEnabledColor(getThemeColor(Theme::BUTTON)), @@ -84,7 +84,7 @@ Button::Button(const Widget2 *const widget, ActionListener *const listener) : gcn::Button(caption), Widget2(widget), - gcn::WidgetListener(), + WidgetListener(), mDescription(), mVertexes2(new ImageCollection), mEnabledColor(getThemeColor(Theme::BUTTON)), @@ -124,7 +124,7 @@ Button::Button(const Widget2 *const widget, ActionListener *const listener) : gcn::Button(caption), Widget2(widget), - gcn::WidgetListener(), + WidgetListener(), mDescription(), mVertexes2(new ImageCollection), mEnabledColor(getThemeColor(Theme::BUTTON)), @@ -164,7 +164,7 @@ Button::Button(const Widget2 *const widget, ActionListener *const listener) : gcn::Button(), Widget2(widget), - gcn::WidgetListener(), + WidgetListener(), mDescription(), mVertexes2(new ImageCollection), mEnabledColor(getThemeColor(Theme::BUTTON)), @@ -204,7 +204,7 @@ Button::Button(const Widget2 *const widget, ActionListener *const listener) : gcn::Button(caption), Widget2(widget), - gcn::WidgetListener(), + WidgetListener(), mDescription(), mVertexes2(new ImageCollection), mEnabledColor(getThemeColor(Theme::BUTTON)), diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index e80593f7f..8f79755a8 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "gui/base/widgets/button.hpp" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -44,7 +44,7 @@ const std::string BUTTON_PLAY = "buttonplay.png"; */ class Button final : public gcn::Button, public Widget2, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 54cb3b28d..21de10412 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -41,7 +41,7 @@ CharacterDisplay::CharacterDisplay(const Widget2 *const widget, CharSelectDialog *const charSelectDialog) : Container(widget), MouseListener(), - gcn::WidgetListener(), + WidgetListener(), mCharacter(nullptr), mPlayerBox(new PlayerBox(nullptr)), mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww")), diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index 0352a91a0..940dbe5c6 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -29,7 +29,7 @@ #include "net/charserverhandler.h" #include "net/net.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -39,7 +39,7 @@ class TextPopup; class CharacterDisplay final : public Container, public MouseListener, - public gcn::WidgetListener + public WidgetListener { public: CharacterDisplay(const Widget2 *const widget, diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index b46fe3289..5874ee441 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -35,7 +35,7 @@ Desktop::Desktop(const Widget2 *const widget) : Container(widget), - gcn::WidgetListener(), + WidgetListener(), mWallpaper(nullptr), mVersionLabel(nullptr), mSkin(nullptr), diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 6982ce525..9e49ceb59 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -45,7 +45,8 @@ class Skin; * * \ingroup GUI */ -class Desktop final : public Container, private gcn::WidgetListener +class Desktop final : public Container, + private WidgetListener { public: explicit Desktop(const Widget2 *const widget); diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index c086cd463..091d699a7 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -37,7 +37,7 @@ EmotePage::EmotePage(const Widget2 *const widget) : gcn::Widget(), Widget2(widget), MouseListener(), - gcn::WidgetListener(), + WidgetListener(), mEmotes(ResourceManager::getInstance()->getImageSet( "graphics/sprites/chatemotes.png", emoteWidth, emoteHeight)), mVertexes(new ImageCollection), diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index c773d9a66..afc950f79 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -24,7 +24,7 @@ #include "gui/widgets/widget2.h" #include "listeners/mouselistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "gui/base/widget.hpp" @@ -33,7 +33,7 @@ class EmotePage final : public gcn::Widget, public Widget2, public MouseListener, - public gcn::WidgetListener + public WidgetListener { public: explicit EmotePage(const Widget2 *const widget); diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index d39a7124a..bfcd704d3 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -26,7 +26,7 @@ FlowContainer::FlowContainer(const Widget2 *const widget, const int boxWidth, const int boxHeight) : Container(widget), - gcn::WidgetListener(), + WidgetListener(), mBoxWidth(boxWidth), mBoxHeight(boxHeight), mGridWidth(1), diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 1967258dd..e2773d34c 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -34,7 +34,7 @@ * \ingroup GUI */ class FlowContainer final : public Container, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index a4c95169a..77dff3232 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -26,7 +26,7 @@ HorizontContainer::HorizontContainer(const Widget2 *const widget, const int height, const int spacing) : Container(widget), - gcn::WidgetListener(), + WidgetListener(), mSpacing(spacing), mCount(0), mLastX(spacing) diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 517cb6fd9..eb1f8c5aa 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -33,7 +33,8 @@ * * This container places it's contents veritcally. */ -class HorizontContainer final : public Container, public gcn::WidgetListener +class HorizontContainer final : public Container, + public WidgetListener { public: HorizontContainer(const Widget2 *const widget, diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 036cb6c1b..84934911c 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -162,7 +162,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget, Widget2(widget), KeyListener(), MouseListener(), - gcn::WidgetListener(), + WidgetListener(), mInventory(inventory), mSelImg(Theme::getImageFromThemeXml("item_selection.xml", "")), mProtectedImg(Theme::getImageFromTheme("lock.png")), diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 74ae72a23..3d98d425b 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -27,7 +27,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "gui/base/widget.hpp" @@ -50,7 +50,7 @@ class ItemContainer final : public gcn::Widget, public Widget2, public KeyListener, public MouseListener, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index b0fb75adc..460810adf 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -25,7 +25,7 @@ #include "debug.h" LayoutHelper::LayoutHelper(gcn::Container *const container) : - gcn::WidgetListener(), + WidgetListener(), mLayout(), mContainer(container) { diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index 1a3a3a69f..bdd923560 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -25,14 +25,14 @@ #include "gui/widgets/layout.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" /** * A helper class for adding a layout to a Guichan container widget. The layout * will register itself as a widget listener and relayout the widgets in the * container dynamically on resize. */ -class LayoutHelper final : public gcn::WidgetListener +class LayoutHelper final : public WidgetListener { public: /** diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index a4908c23b..9d34beaa7 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -35,7 +35,7 @@ Popup::Popup(const std::string &name, std::string skin) : Container(nullptr), MouseListener(), - gcn::WidgetListener(), + WidgetListener(), mPadding(3), mSkin(nullptr), mPopupName(name), diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index d09331136..25998e21d 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -27,7 +27,7 @@ #include "gui/widgets/container.h" #include "listeners/mouselistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" class ImageCollection; class Skin; @@ -47,7 +47,7 @@ class WindowContainer; */ class Popup : public Container, public MouseListener, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 242b6ba6e..415962310 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -41,7 +41,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget, float progress, const std::string &skin, const std::string &skinFill): gcn::Widget(), Widget2(widget), - gcn::WidgetListener(), + WidgetListener(), mFillRect(), mSkin(nullptr), mProgress(progress), diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 022d86ab3..2835a7ffc 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -26,7 +26,8 @@ #include "gui/widgets/widget2.h" #include "gui/base/widget.hpp" -#include "gui/base/widgetlistener.hpp" + +#include "listeners/widgetlistener.h" #include @@ -42,7 +43,7 @@ class Skin; */ class ProgressBar final : public gcn::Widget, public Widget2, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 26add84c1..e9e850b1c 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -47,7 +47,7 @@ static std::string const buttonFiles[2] = ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : gcn::ScrollArea(), - gcn::WidgetListener(), + WidgetListener(), mX(0), mY(0), mClickX(0), @@ -69,7 +69,7 @@ ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : ScrollArea::ScrollArea(gcn::Widget *const widget, const bool opaque, const std::string &skin) : gcn::ScrollArea(widget), - gcn::WidgetListener(), + WidgetListener(), mX(0), mY(0), mClickX(0), diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index fe60399df..69f567b02 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -26,7 +26,8 @@ #include "gui/widgets/widget2.h" #include "gui/base/widgets/scrollarea.hpp" -#include "gui/base/widgetlistener.hpp" + +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -44,7 +45,7 @@ class ImageCollection; */ class ScrollArea final : public gcn::ScrollArea, public Widget2, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index dcb7d1138..8b3507b8e 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -31,7 +31,7 @@ float ShortcutContainer::mAlpha = 1.0; ShortcutContainer::ShortcutContainer() : gcn::Widget(), Widget2(), - gcn::WidgetListener(), + WidgetListener(), MouseListener(), mBackgroundImg(nullptr), mMaxItems(0), diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 1d734de6a..1db3e0482 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -27,7 +27,7 @@ #include "listeners/mouselistener.h" #include "gui/base/widget.hpp" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" class Image; class ImageCollection; @@ -39,7 +39,7 @@ class ImageCollection; */ class ShortcutContainer : public gcn::Widget, public Widget2, - public gcn::WidgetListener, + public WidgetListener, public MouseListener { public: diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 2c431c452..0bf6b8d11 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -39,7 +39,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : gcn::BasicContainer(), KeyListener(), MouseListener(), - gcn::WidgetListener(), + WidgetListener(), mSelectedTab(nullptr), mTabContainer(new gcn::Container()), mWidgetContainer(new gcn::Container()), diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index b8b075ade..27ed05b5e 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -27,7 +27,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "gui/base/widgets/container.hpp" @@ -45,7 +45,7 @@ class TabbedArea final : public Widget2, public gcn::BasicContainer, public KeyListener, public MouseListener, - public gcn::WidgetListener + public WidgetListener { public: /** diff --git a/src/gui/widgets/tabs/setuptab.cpp b/src/gui/widgets/tabs/setuptab.cpp index efead5a3c..6de77d7a0 100644 --- a/src/gui/widgets/tabs/setuptab.cpp +++ b/src/gui/widgets/tabs/setuptab.cpp @@ -27,7 +27,7 @@ SetupTab::SetupTab(const Widget2 *const widget) : Container(widget), ActionListener(), - gcn::WidgetListener(), + WidgetListener(), mName() { setOpaque(false); diff --git a/src/gui/widgets/tabs/setuptab.h b/src/gui/widgets/tabs/setuptab.h index 1621b0713..4d6049b6a 100644 --- a/src/gui/widgets/tabs/setuptab.h +++ b/src/gui/widgets/tabs/setuptab.h @@ -26,7 +26,7 @@ #include "gui/widgets/container.h" #include "listeners/actionlistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include @@ -37,7 +37,7 @@ */ class SetupTab : public Container, public ActionListener, - public gcn::WidgetListener + public WidgetListener { public: A_DELETE_COPY(SetupTab) diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 877329cf8..398802eb0 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -47,7 +47,7 @@ Tab::Tab(const Widget2 *const widget) : gcn::BasicContainer(), Widget2(widget), MouseListener(), - gcn::WidgetListener(), + WidgetListener(), mLabel(new Label(this)), mTabbedArea(nullptr), mTabColor(&getThemeColor(Theme::TAB)), diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index a67025842..ac10b7dc7 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -28,7 +28,7 @@ #include "gui/base/basiccontainer.hpp" #include "listeners/mouselistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -43,7 +43,7 @@ class TabbedArea; class Tab : public gcn::BasicContainer, public Widget2, public MouseListener, - public gcn::WidgetListener + public WidgetListener { public: explicit Tab(const Widget2 *const widget); diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index a91f20657..ed3d00219 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -27,7 +27,7 @@ VertContainer::VertContainer(const Widget2 *const widget, const int verticalItemSize, const bool resizable, const int leftSpacing) : Container(widget), - gcn::WidgetListener(), + WidgetListener(), mResizableWidgets(), mVerticalItemSize(verticalItemSize), mCount(0), diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index d194a00c3..34fcf3d45 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -24,7 +24,7 @@ #include "gui/widgets/container.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include @@ -35,7 +35,8 @@ * * This container places it's contents veritcally. */ -class VertContainer final : public Container, public gcn::WidgetListener +class VertContainer final : public Container, + public WidgetListener { public: VertContainer(const Widget2 *const widget, diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index ee8d6f719..17383780f 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -26,7 +26,7 @@ WidgetGroup::WidgetGroup(const Widget2 *const widget, const std::string &group, const int height, const int spacing) : Container(widget), - gcn::WidgetListener(), + WidgetListener(), ActionListener(), mSpacing(spacing), mCount(0), diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index e648a17e5..60ee2672f 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -24,12 +24,12 @@ #include "gui/widgets/container.h" #include "listeners/actionlistener.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "localconsts.h" class WidgetGroup : public Container, - public gcn::WidgetListener, + public WidgetListener, public ActionListener { public: diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 54ec3c859..1fc439abf 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -52,7 +52,7 @@ Window::Window(const std::string &caption, const bool modal, Window *const parent, std::string skin) : gcn::Window(caption), Widget2(), - gcn::WidgetListener(), + WidgetListener(), mSkin(nullptr), mDefaultX(0), mDefaultY(0), diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 68ce1a293..5ff5abe2b 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -27,7 +27,7 @@ #include "gui/widgets/widget2.h" -#include "gui/base/widgetlistener.hpp" +#include "listeners/widgetlistener.h" #include "gui/base/widgets/window.hpp" @@ -48,7 +48,7 @@ class WindowContainer; */ class Window : public gcn::Window, public Widget2, - private gcn::WidgetListener + private WidgetListener { public: /** diff --git a/src/listeners/widgetlistener.h b/src/listeners/widgetlistener.h new file mode 100644 index 000000000..d7d348cd0 --- /dev/null +++ b/src/listeners/widgetlistener.h @@ -0,0 +1,140 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 LISTENERS_WIDGETLISTENER_HPP +#define LISTENERS_WIDGETLISTENER_HPP + +#include + +#include "gui/base/event.hpp" + +#include "localconsts.h" + +/** + * Interface for listening for events from widgets. When a widget's size, + * location or visibility changes, the relevant method of the listener is + * invoked. + * + * @see Widget::addWidgetListener, Widget::removeWidgetListener + * @author Olof Naessén + * @since 0.8.0 + */ +class WidgetListener +{ + public: + /** + * Destructor. + */ + virtual ~WidgetListener() + { } + + /** + * Invoked when a widget changes its size. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetResized(const gcn::Event &event A_UNUSED) + { } + + /** + * Invoked when a widget is moved. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetMoved(const gcn::Event &event A_UNUSED) + { } + + /** + * Invoked when a widget is hidden, i.e it's set to be + * not visible. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetHidden(const gcn::Event &event A_UNUSED) + { } + + /** + * Invoked when a widget is shown, i.e it's set to be + * visible. + * + * @param event Describes the event. + * @since 0.8.0 + */ + virtual void widgetShown(const gcn::Event &event A_UNUSED) + { } + + protected: + /** + * Constructor. + * + * You should not be able to make an instance of WidgetListener, + * therefore its constructor is protected. + */ + WidgetListener() + { } +}; + +#endif // LISTENERS_WIDGETLISTENER_HPP -- cgit v1.2.3-70-g09d2 From 55758c8c9e87881a80272c906015cf4f837543a7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 01:29:28 +0300 Subject: fix files in make files. --- src/CMakeLists.txt | 6 +++--- src/Makefile.am | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index edfdec695..d5e0edfe7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -786,17 +786,17 @@ SET(SRCS gui/base/key.hpp gui/base/keyevent.hpp gui/base/keyinput.hpp - gui/base/keylistener.hpp + listeners/keylistener.h gui/base/listmodel.hpp gui/base/mouseevent.hpp gui/base/mouseinput.hpp listeners/mouselistener.h gui/base/rectangle.hpp gui/base/selectionevent.hpp - gui/base/selectionlistener.hpp + listeners/selectionlistener.h gui/base/sdl/sdlpixel.hpp gui/base/widget.hpp - gui/base/widgetlistener.hpp + listeners/widgetlistener.h gui/base/widgets/button.hpp gui/base/widgets/checkbox.hpp gui/base/widgets/container.hpp diff --git a/src/Makefile.am b/src/Makefile.am index f6787bcff..2456617da 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -174,17 +174,17 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/key.hpp \ gui/base/keyevent.hpp \ gui/base/keyinput.hpp \ - gui/base/keylistener.hpp \ + listeners/keylistener.h \ gui/base/listmodel.hpp \ gui/base/mouseevent.hpp \ gui/base/mouseinput.hpp \ - listeners/mouselistener.hpp \ + listeners/mouselistener.h \ gui/base/rectangle.hpp \ gui/base/selectionevent.hpp \ - gui/base/selectionlistener.hpp \ + listeners/selectionlistener.h \ gui/base/sdl/sdlpixel.hpp \ gui/base/widget.hpp \ - gui/base/widgetlistener.hpp \ + listeners/widgetlistener.h \ gui/base/widgets/button.hpp \ gui/base/widgets/checkbox.hpp \ gui/base/widgets/container.hpp \ -- cgit v1.2.3-70-g09d2 From 6f2f77681072c8ec71b0398649bcfd4de3083d28 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 01:44:40 +0300 Subject: fix make file again. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 2456617da..6f0dd30f4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -167,7 +167,7 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/focushandler.hpp \ listeners/focuslistener.h \ gui/base/font.hpp \ - gui/base/graphics.hpp \ + render/graphics.h \ gui/base/gui.hpp \ gui/base/input.hpp \ gui/base/inputevent.hpp \ -- cgit v1.2.3-70-g09d2 From 0d73f54f842a9690c65faedf094112017fd07430 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 12:22:47 +0300 Subject: move actionevent into events directory. --- src/CMakeLists.txt | 3 +- src/Makefile.am | 8 +- src/actionmanager.cpp | 4 +- src/being/localplayer.cpp | 2 +- src/being/localplayer.h | 2 +- src/client.cpp | 10 +-- src/client.h | 4 +- src/events/actionevent.h | 139 +++++++++++++++++++++++++++++++ src/gui/base/actionevent.cpp | 88 ------------------- src/gui/base/actionevent.hpp | 133 ----------------------------- src/gui/base/widget.cpp | 5 +- src/gui/popups/popupmenu.cpp | 4 +- src/gui/popups/popupmenu.h | 4 +- src/gui/widgets/characterviewnormal.cpp | 2 +- src/gui/widgets/characterviewnormal.h | 2 +- src/gui/widgets/characterviewsmall.cpp | 2 +- src/gui/widgets/characterviewsmall.h | 2 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/dropdown.h | 2 +- src/gui/widgets/guitable.cpp | 5 +- src/gui/widgets/itemlinkhandler.cpp | 2 +- src/gui/widgets/setupitem.cpp | 16 ++-- src/gui/widgets/setupitem.h | 16 ++-- src/gui/widgets/sliderlist.cpp | 2 +- src/gui/widgets/sliderlist.h | 2 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/tabbedarea.h | 2 +- src/gui/widgets/tabs/setup_colors.cpp | 2 +- src/gui/widgets/tabs/setup_colors.h | 2 +- src/gui/widgets/tabs/setup_input.cpp | 2 +- src/gui/widgets/tabs/setup_input.h | 2 +- src/gui/widgets/tabs/setup_joystick.cpp | 2 +- src/gui/widgets/tabs/setup_joystick.h | 2 +- src/gui/widgets/tabs/setup_relations.cpp | 2 +- src/gui/widgets/tabs/setup_relations.h | 2 +- src/gui/widgets/tabs/setup_theme.cpp | 2 +- src/gui/widgets/tabs/setup_theme.h | 2 +- src/gui/widgets/tabs/setup_video.cpp | 2 +- src/gui/widgets/tabs/setup_video.h | 2 +- src/gui/widgets/tabs/setuptabscroll.h | 2 +- src/gui/widgets/tabstrip.cpp | 2 +- src/gui/widgets/tabstrip.h | 2 +- src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 2 +- src/gui/windowmenu.cpp | 2 +- src/gui/windowmenu.h | 2 +- src/gui/windows/botcheckerwindow.cpp | 2 +- src/gui/windows/botcheckerwindow.h | 2 +- src/gui/windows/buydialog.cpp | 2 +- src/gui/windows/buydialog.h | 2 +- src/gui/windows/buyselldialog.cpp | 2 +- src/gui/windows/buyselldialog.h | 2 +- src/gui/windows/changeemaildialog.cpp | 2 +- src/gui/windows/changeemaildialog.h | 2 +- src/gui/windows/changepassworddialog.cpp | 2 +- src/gui/windows/changepassworddialog.h | 2 +- src/gui/windows/charcreatedialog.cpp | 4 +- src/gui/windows/charcreatedialog.h | 2 +- src/gui/windows/charselectdialog.cpp | 6 +- src/gui/windows/charselectdialog.h | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/chatwindow.h | 2 +- src/gui/windows/confirmdialog.cpp | 2 +- src/gui/windows/confirmdialog.h | 2 +- src/gui/windows/connectiondialog.cpp | 2 +- src/gui/windows/connectiondialog.h | 2 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/didyouknowwindow.h | 2 +- src/gui/windows/editdialog.cpp | 2 +- src/gui/windows/editdialog.h | 2 +- src/gui/windows/editserverdialog.cpp | 4 +- src/gui/windows/editserverdialog.h | 2 +- src/gui/windows/equipmentwindow.cpp | 2 +- src/gui/windows/equipmentwindow.h | 2 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/helpwindow.h | 2 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 2 +- src/gui/windows/itemamountwindow.cpp | 2 +- src/gui/windows/itemamountwindow.h | 2 +- src/gui/windows/killstats.cpp | 2 +- src/gui/windows/killstats.h | 2 +- src/gui/windows/logindialog.cpp | 8 +- src/gui/windows/logindialog.h | 2 +- src/gui/windows/npcdialog.cpp | 2 +- src/gui/windows/npcdialog.h | 2 +- src/gui/windows/npcpostdialog.cpp | 2 +- src/gui/windows/npcpostdialog.h | 2 +- src/gui/windows/okdialog.cpp | 2 +- src/gui/windows/okdialog.h | 2 +- src/gui/windows/outfitwindow.cpp | 2 +- src/gui/windows/outfitwindow.h | 2 +- src/gui/windows/questswindow.cpp | 2 +- src/gui/windows/questswindow.h | 2 +- src/gui/windows/quitdialog.cpp | 7 +- src/gui/windows/quitdialog.h | 2 +- src/gui/windows/registerdialog.cpp | 8 +- src/gui/windows/registerdialog.h | 4 +- src/gui/windows/selldialog.cpp | 2 +- src/gui/windows/selldialog.h | 2 +- src/gui/windows/serverdialog.cpp | 8 +- src/gui/windows/serverdialog.h | 2 +- src/gui/windows/setupwindow.cpp | 2 +- src/gui/windows/setupwindow.h | 2 +- src/gui/windows/shopwindow.cpp | 2 +- src/gui/windows/shopwindow.h | 2 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/skilldialog.h | 2 +- src/gui/windows/socialwindow.cpp | 8 +- src/gui/windows/socialwindow.h | 2 +- src/gui/windows/statuswindow.cpp | 6 +- src/gui/windows/statuswindow.h | 2 +- src/gui/windows/textcommandeditor.cpp | 2 +- src/gui/windows/textcommandeditor.h | 2 +- src/gui/windows/textdialog.cpp | 2 +- src/gui/windows/textdialog.h | 2 +- src/gui/windows/tradewindow.cpp | 2 +- src/gui/windows/tradewindow.h | 2 +- src/gui/windows/unregisterdialog.cpp | 2 +- src/gui/windows/unregisterdialog.h | 2 +- src/gui/windows/updaterwindow.cpp | 9 +- src/gui/windows/updaterwindow.h | 2 +- src/gui/windows/whoisonline.cpp | 2 +- src/gui/windows/whoisonline.h | 2 +- src/gui/windows/worldselectdialog.cpp | 6 +- src/gui/windows/worldselectdialog.h | 2 +- src/listeners/actionlistener.h | 4 +- src/net/ea/playerhandler.cpp | 4 +- src/net/ea/tradehandler.cpp | 2 +- 129 files changed, 320 insertions(+), 407 deletions(-) create mode 100644 src/events/actionevent.h delete mode 100644 src/gui/base/actionevent.cpp delete mode 100644 src/gui/base/actionevent.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5e0edfe7..99d36e1ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -769,7 +769,7 @@ SET(SRCS vector.h walklayer.cpp walklayer.h - gui/base/actionevent.hpp + events/actionevent.h listeners/actionlistener.h gui/base/basiccontainer.hpp gui/base/cliprectangle.hpp @@ -808,7 +808,6 @@ SET(SRCS gui/base/widgets/textbox.hpp gui/base/widgets/textfield.hpp gui/base/widgets/window.hpp - gui/base/actionevent.cpp gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp gui/base/color.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 6f0dd30f4..21c2fc0e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,15 +26,14 @@ manaplus_SOURCES = endif dyecmd_CXXFLAGS = -dyecmd_SOURCES = gui/base/actionevent.cpp \ - gui/base/cliprectangle.cpp \ +dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ gui/base/event.cpp \ gui/base/exception.cpp \ gui/base/font.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ - gui/base/actionevent.hpp \ + events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ gui/base/event.hpp \ @@ -156,7 +155,7 @@ manaplus_CXXFLAGS += -DUSE_SDL2 endif endif -manaplus_SOURCES += gui/base/actionevent.hpp \ +manaplus_SOURCES += events/actionevent.h \ listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ gui/base/cliprectangle.hpp \ @@ -196,7 +195,6 @@ manaplus_SOURCES += gui/base/actionevent.hpp \ gui/base/widgets/textbox.hpp \ gui/base/widgets/textfield.hpp \ gui/base/widgets/window.hpp \ - gui/base/actionevent.cpp \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 1c7dbce14..4b6d80981 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -234,12 +234,12 @@ impHandler0(ok) // Close the config window, cancelling changes if opened else if (setupWindow && setupWindow->isWindowVisible()) { - setupWindow->action(gcn::ActionEvent(nullptr, "cancel")); + setupWindow->action(ActionEvent(nullptr, "cancel")); return true; } else if (NpcDialog *const dialog = NpcDialog::getActive()) { - dialog->action(gcn::ActionEvent(nullptr, "ok")); + dialog->action(ActionEvent(nullptr, "ok")); return true; } return false; diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 86db69d8d..ea8218ee4 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -4385,7 +4385,7 @@ void LocalPlayer::setTestParticle(const std::string &fileName, } } -void AwayListener::action(const gcn::ActionEvent &event) +void AwayListener::action(const ActionEvent &event) { if (event.getId() == "ok" && player_node && player_node->getAway()) { diff --git a/src/being/localplayer.h b/src/being/localplayer.h index f43cfe0bb..ce501bcec 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -44,7 +44,7 @@ class OkDialog; class AwayListener final : public ActionListener { public: - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; }; /** diff --git a/src/client.cpp b/src/client.cpp index 3812fc9a9..0fac5b3f2 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -174,7 +174,7 @@ UserPalette *userPalette = nullptr; SoundManager soundManager; RenderType openGLMode = RENDER_SOFTWARE; -void ErrorListener::action(const gcn::ActionEvent &event) +void ErrorListener::action(const ActionEvent &event) { if (event.getId() == "yes") openBrowser(client->getSupportUrl()); @@ -196,7 +196,7 @@ extern "C" char const *_nl_locale_name_default(void); class AccountListener final : public ActionListener { public: - void action(const gcn::ActionEvent &) + void action(const ActionEvent &) { client->setState(STATE_CHAR_SELECT); } @@ -205,7 +205,7 @@ class AccountListener final : public ActionListener class LoginListener final : public ActionListener { public: - void action(const gcn::ActionEvent &) + void action(const ActionEvent &) { client->setState(STATE_PRE_LOGIN); } @@ -1351,7 +1351,7 @@ int Client::gameExec() if (mOptions.chooseDefault) { static_cast(mCurrentDialog) - ->action(gcn::ActionEvent(nullptr, "ok")); + ->action(ActionEvent(nullptr, "ok")); } } } @@ -1853,7 +1853,7 @@ void Client::optionChanged(const std::string &name) } } -void Client::action(const gcn::ActionEvent &event) +void Client::action(const ActionEvent &event) { std::string tab; const std::string &eventId = event.getId(); diff --git a/src/client.h b/src/client.h index aedad4569..0e6528ca3 100644 --- a/src/client.h +++ b/src/client.h @@ -60,7 +60,7 @@ extern int textures_count; class ErrorListener : public ActionListener { public: - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; }; extern std::string errorMessage; @@ -302,7 +302,7 @@ public: void optionChanged(const std::string &name) override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void initTradeFilter() const; diff --git a/src/events/actionevent.h b/src/events/actionevent.h new file mode 100644 index 000000000..77f945693 --- /dev/null +++ b/src/events/actionevent.h @@ -0,0 +1,139 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 EVENTS_ACTIONEVENT_HPP +#define EVENTS_ACTIONEVENT_HPP + +#include "gui/base/event.hpp" + +#include + +#include "localconsts.h" + +namespace GCN +{ + class Widget; +} + +/** + * Represents an action event. An action event is an event + * that can be fired by a widget whenever an action has occured. + * What exactly an action is is up to the widget that fires + * the action event. An example is a Button which fires an action + * event as soon as the Button is clicked, another example is + * TextField which fires an action event as soon as the enter + * key is pressed. + * + * Any object can listen for actions from widgets by implementing + * the ActionListener interface. + * + * If you have implement a widget of your own it's a good idea to + * let the widget fire action events whenever you feel an action + * has occured so action listeners of the widget can be informed + * of the state of the widget. + * + * @see Widget::addActionListener, Widget::removeActionListener, + * Widget::distributeActionEvent + * @author Olof Naessén + * @since 0.6.0 + */ +class ActionEvent final : public gcn::Event +{ + public: + /** + * Constructor. + * + * @param source The source widget of the event. + * @param id An identifier of the event. + */ + ActionEvent(gcn::Widget *const source, const std::string &id) : + gcn::Event(source), + mId(id) + { + } + + /** + * Destructor. + */ + virtual ~ActionEvent() + { } + + /** + * Gets the identifier of the event. An identifier can + * be used to distinguish from two actions from the same + * widget or to let many widgets fire the same widgets + * that should be treated equally. + * + * @return The identifier of the event. + */ + const std::string &getId() const A_WARN_UNUSED + { return mId; } + + protected: + /** + * Holds the identifier of the event. + */ + std::string mId; +}; + +#endif // EVENTS_ACTIONEVENT_HPP diff --git a/src/gui/base/actionevent.cpp b/src/gui/base/actionevent.cpp deleted file mode 100644 index 7fcc1ee84..000000000 --- a/src/gui/base/actionevent.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/actionevent.hpp" - -#include "debug.h" - -namespace gcn -{ - ActionEvent::ActionEvent(Widget *const source, const std::string &id) - :Event(source), - mId(id) - { - } - - ActionEvent::~ActionEvent() - { - } - - const std::string& ActionEvent::getId() const - { - return mId; - } -} // namespace gcn diff --git a/src/gui/base/actionevent.hpp b/src/gui/base/actionevent.hpp deleted file mode 100644 index 621499864..000000000 --- a/src/gui/base/actionevent.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_ACTIONEVENT_HPP -#define GCN_ACTIONEVENT_HPP - -#include "gui/base/event.hpp" - -#include - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Represents an action event. An action event is an event - * that can be fired by a widget whenever an action has occured. - * What exactly an action is is up to the widget that fires - * the action event. An example is a Button which fires an action - * event as soon as the Button is clicked, another example is - * TextField which fires an action event as soon as the enter - * key is pressed. - * - * Any object can listen for actions from widgets by implementing - * the ActionListener interface. - * - * If you have implement a widget of your own it's a good idea to - * let the widget fire action events whenever you feel an action - * has occured so action listeners of the widget can be informed - * of the state of the widget. - * - * @see Widget::addActionListener, Widget::removeActionListener, - * Widget::distributeActionEvent - * @author Olof Naessén - * @since 0.6.0 - */ - class ActionEvent final : public Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - * @param id An identifier of the event. - */ - ActionEvent(Widget *const source, const std::string &id); - - /** - * Destructor. - */ - virtual ~ActionEvent(); - - /** - * Gets the identifier of the event. An identifier can - * be used to distinguish from two actions from the same - * widget or to let many widgets fire the same widgets - * that should be treated equally. - * - * @return The identifier of the event. - */ - const std::string& getId() const A_WARN_UNUSED; - - protected: - /** - * Holds the identifier of the event. - */ - std::string mId; - }; -} // namespace gcn - -#endif // GCN_ACTIONEVENT_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index 6acf447d1..de133ac09 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -67,8 +67,8 @@ #include "gui/base/widget.hpp" -#include "gui/base/actionevent.hpp" -#include "listeners/actionlistener.h" +#include "events/actionevent.h" + #include "gui/base/basiccontainer.hpp" #include "gui/base/event.hpp" #include "gui/base/exception.hpp" @@ -76,6 +76,7 @@ #include "gui/base/keyinput.hpp" #include "gui/base/mouseinput.hpp" +#include "listeners/actionlistener.h" #include "listeners/deathlistener.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 343baba01..197a9f716 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -2859,7 +2859,7 @@ void RenameListener::setMapItem(MapItem *const mapItem) } } -void RenameListener::action(const gcn::ActionEvent &event) +void RenameListener::action(const ActionEvent &event) { if (event.getId() == "ok" && viewport && mDialog) { @@ -2893,7 +2893,7 @@ PlayerListener::PlayerListener() : { } -void PlayerListener::action(const gcn::ActionEvent &event) +void PlayerListener::action(const ActionEvent &event) { if (event.getId() == "ok" && !mNick.empty() && mDialog) { diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index a79dd3162..235c809ba 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -54,7 +54,7 @@ class RenameListener final : public ActionListener A_DELETE_COPY(RenameListener) - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void setMapItem(MapItem *const mapItem); @@ -74,7 +74,7 @@ class PlayerListener : public ActionListener A_DELETE_COPY(PlayerListener) - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void setNick(std::string name) { mNick = name; } diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp index 78c538b8c..75481268b 100644 --- a/src/gui/widgets/characterviewnormal.cpp +++ b/src/gui/widgets/characterviewnormal.cpp @@ -87,6 +87,6 @@ void CharacterViewNormal::resize() (*mCharacterEntries)[f]->setPosition((f - 5) * width, y); } -void CharacterViewNormal::action(const gcn::ActionEvent &event A_UNUSED) +void CharacterViewNormal::action(const ActionEvent &event A_UNUSED) { } diff --git a/src/gui/widgets/characterviewnormal.h b/src/gui/widgets/characterviewnormal.h index 50001a61d..4ef1500b0 100644 --- a/src/gui/widgets/characterviewnormal.h +++ b/src/gui/widgets/characterviewnormal.h @@ -40,7 +40,7 @@ class CharacterViewNormal final : public CharacterViewBase void resize() override; - void action(const gcn::ActionEvent &event A_UNUSED) override final; + void action(const ActionEvent &event A_UNUSED) override final; private: std::vector *mCharacterEntries; diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp index ce218646b..eda1e4a71 100644 --- a/src/gui/widgets/characterviewsmall.cpp +++ b/src/gui/widgets/characterviewsmall.cpp @@ -98,7 +98,7 @@ void CharacterViewSmall::resize() mNumber->setPosition(10, y2); } -void CharacterViewSmall::action(const gcn::ActionEvent &event) +void CharacterViewSmall::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "next") diff --git a/src/gui/widgets/characterviewsmall.h b/src/gui/widgets/characterviewsmall.h index 3a326134b..17a549718 100644 --- a/src/gui/widgets/characterviewsmall.h +++ b/src/gui/widgets/characterviewsmall.h @@ -39,7 +39,7 @@ class CharacterViewSmall final : public CharacterViewBase void resize() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: CharacterDisplay *mSelectedEntry; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 1aed0dfe1..bbba0cd99 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -505,7 +505,7 @@ gcn::ListModel *DropDown::getListModel() return mPopup->getListModel(); } -void DropDown::action(const gcn::ActionEvent &actionEvent A_UNUSED) +void DropDown::action(const ActionEvent &actionEvent A_UNUSED) { foldUp(); distributeActionEvent(); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 692b341ca..f3431459f 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -133,7 +133,7 @@ class DropDown final : public ActionListener, gcn::Rectangle getChildrenArea() override; - void action(const gcn::ActionEvent &actionEvent) override; + void action(const ActionEvent &actionEvent) override; void distributeValueChangedEvent(); diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 3d987ed63..dcb5431d5 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -49,7 +49,7 @@ public: ~GuiTableActionListener(); - void action(const gcn::ActionEvent& actionEvent) override final; + void action(const ActionEvent& actionEvent) override final; protected: GuiTable *mTable; @@ -84,8 +84,7 @@ GuiTableActionListener::~GuiTableActionListener() } } -void GuiTableActionListener::action(const gcn::ActionEvent - &actionEvent A_UNUSED) +void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED) { mTable->setSelected(mRow, mColumn); mTable->distributeActionEvent(); diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 96494ed0b..108444bb0 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -53,7 +53,7 @@ namespace A_DELETE_COPY(OpenUrlListener) - void action(const gcn::ActionEvent &event) override final + void action(const ActionEvent &event) override final { if (event.getId() == "yes") openBrowser(url); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 8453a9722..8b6cca5a7 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -154,7 +154,7 @@ std::string SetupItem::getActionEventId() const return mWidget->getActionEventId(); } -void SetupItem::action(const gcn::ActionEvent &event) +void SetupItem::action(const ActionEvent &event) { if (!mWidget) return; @@ -393,7 +393,7 @@ void SetupItemTextField::toWidget() mTextField->setText(mValue); } -void SetupItemTextField::action(const gcn::ActionEvent &event) +void SetupItemTextField::action(const ActionEvent &event) { if (!mTextField) return; @@ -529,7 +529,7 @@ void SetupItemIntTextField::toWidget() mTextField->setText(mValue); } -void SetupItemIntTextField::action(const gcn::ActionEvent &event) +void SetupItemIntTextField::action(const ActionEvent &event) { if (!mTextField) return; @@ -609,7 +609,7 @@ void SetupItemLabel::toWidget() { } -void SetupItemLabel::action(const gcn::ActionEvent &event A_UNUSED) +void SetupItemLabel::action(const ActionEvent &event A_UNUSED) { } @@ -799,7 +799,7 @@ void SetupItemSlider::toWidget() mSlider->setValue2(atof(mValue.c_str())); } -void SetupItemSlider::action(const gcn::ActionEvent &event A_UNUSED) +void SetupItemSlider::action(const ActionEvent &event A_UNUSED) { fromWidget(); if (mOnTheFly) @@ -954,7 +954,7 @@ void SetupItemSlider2::toWidget() updateLabel(); } -void SetupItemSlider2::action(const gcn::ActionEvent &event A_UNUSED) +void SetupItemSlider2::action(const ActionEvent &event A_UNUSED) { fromWidget(); updateLabel(); @@ -1086,7 +1086,7 @@ void SetupItemSliderList::toWidget() mSlider->setSelectedString(mValue); } -void SetupItemSliderList::action(const gcn::ActionEvent &event A_UNUSED) +void SetupItemSliderList::action(const ActionEvent &event A_UNUSED) { fromWidget(); if (mOnTheFly) @@ -1124,7 +1124,7 @@ void SetupItemSound::addMoreControls() mHorizont->add(mButton); } -void SetupItemSound::action(const gcn::ActionEvent &event) +void SetupItemSound::action(const ActionEvent &event) { if (event.getId() == mEventName + "_PLAY") { diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index dd5eda1d9..b5261e2f4 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -79,7 +79,7 @@ class SetupItem : public ActionListener, virtual std::string getActionEventId() const A_WARN_UNUSED; - virtual void action(const gcn::ActionEvent &event) override; + virtual void action(const ActionEvent &event) override; virtual void action(); @@ -210,7 +210,7 @@ class SetupItemTextField final : public SetupItem void toWidget() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void apply(const std::string &eventName) override final; @@ -265,7 +265,7 @@ class SetupItemIntTextField final : public SetupItem void toWidget() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void apply(const std::string &eventName) override final; @@ -297,7 +297,7 @@ class SetupItemLabel final : public SetupItem void toWidget() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void apply(const std::string &eventName) override final; @@ -377,7 +377,7 @@ class SetupItemSlider final : public SetupItem void toWidget() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void apply(const std::string &eventName) override final; @@ -433,7 +433,7 @@ class SetupItemSlider2 final : public SetupItem void toWidget() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void apply(const std::string &eventName) override final; @@ -470,7 +470,7 @@ class SetupItemSliderList : public SetupItem void toWidget() override; - virtual void action(const gcn::ActionEvent &event) override; + virtual void action(const ActionEvent &event) override; void apply(const std::string &eventName) override final; @@ -520,7 +520,7 @@ class SetupItemSound final : public SetupItemSliderList A_DELETE_COPY(SetupItemSound) - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void addMoreControls() override final; diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index d70977ff3..eee012120 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -138,7 +138,7 @@ void SliderList::updateLabel() mLabel->setPosition(buttonSpace + (space - labelWidth) / 2, labelY); } -void SliderList::action(const gcn::ActionEvent &event) +void SliderList::action(const ActionEvent &event) { if (!mListModel) return; diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 144fa0cf1..952b6c337 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -58,7 +58,7 @@ class SliderList final : public Container, void draw(Graphics *graphics) override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void setSelectedString(const std::string &str); diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 0bf6b8d11..500e821f5 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -558,7 +558,7 @@ void TabbedArea::adjustTabPositions() } } -void TabbedArea::action(const gcn::ActionEvent& actionEvent) +void TabbedArea::action(const ActionEvent& actionEvent) { gcn::Widget *const source = actionEvent.getSource(); Tab *const tab = dynamic_cast(source); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 27ed05b5e..ec4c02ce5 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -151,7 +151,7 @@ class TabbedArea final : public Widget2, */ void adjustTabPositions(); - void action(const gcn::ActionEvent& actionEvent) override final; + void action(const ActionEvent& actionEvent) override final; // Inherited from MouseListener diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index fadea948a..f7068b965 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -207,7 +207,7 @@ Setup_Colors::~Setup_Colors() } } -void Setup_Colors::action(const gcn::ActionEvent &event) +void Setup_Colors::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "slider_grad") diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index 0bcc9c7f0..55d5950c5 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -50,7 +50,7 @@ class Setup_Colors final : public SetupTab, void cancel() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void valueChanged(const gcn::SelectionEvent &event) override final; diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index b079974d5..ba02eb5a2 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -213,7 +213,7 @@ void Setup_Input::cancel() refreshKeys(); } -void Setup_Input::action(const gcn::ActionEvent &event) +void Setup_Input::action(const ActionEvent &event) { const std::string id = event.getId(); diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h index 135cb3339..43ec53b56 100644 --- a/src/gui/widgets/tabs/setup_input.h +++ b/src/gui/widgets/tabs/setup_input.h @@ -55,7 +55,7 @@ class Setup_Input final : public SetupTab void cancel() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Get an update on the assigned key. diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index 6f023a488..7f96ee468 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -102,7 +102,7 @@ Setup_Joystick::~Setup_Joystick() mNamesModel = nullptr; } -void Setup_Joystick::action(const gcn::ActionEvent &event) +void Setup_Joystick::action(const ActionEvent &event) { const gcn::Widget *const source = event.getSource(); if (source == mJoystickEnabled) diff --git a/src/gui/widgets/tabs/setup_joystick.h b/src/gui/widgets/tabs/setup_joystick.h index 5c7b764ec..ac6caef24 100644 --- a/src/gui/widgets/tabs/setup_joystick.h +++ b/src/gui/widgets/tabs/setup_joystick.h @@ -44,7 +44,7 @@ class Setup_Joystick final : public SetupTab void cancel() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void setTempEnabled(const bool sel); diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 89d1f5beb..d23ac565c 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -370,7 +370,7 @@ void Setup_Relations::cancel() { } -void Setup_Relations::action(const gcn::ActionEvent &event) +void Setup_Relations::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == ACTION_TABLE) diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h index c9d8e50a3..55da0bedc 100644 --- a/src/gui/widgets/tabs/setup_relations.h +++ b/src/gui/widgets/tabs/setup_relations.h @@ -56,7 +56,7 @@ public: void reset(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void updatedPlayer(const std::string &name); diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index d7cc4b4df..fd70b9158 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -433,7 +433,7 @@ void Setup_Theme::updateInfo() mInfoButton->setEnabled(!mThemeInfo.empty()); } -void Setup_Theme::action(const gcn::ActionEvent &event) +void Setup_Theme::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == ACTION_THEME) diff --git a/src/gui/widgets/tabs/setup_theme.h b/src/gui/widgets/tabs/setup_theme.h index a7f3ad101..5e8fe7c2a 100644 --- a/src/gui/widgets/tabs/setup_theme.h +++ b/src/gui/widgets/tabs/setup_theme.h @@ -46,7 +46,7 @@ class Setup_Theme final : public SetupTab void cancel() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void updateInfo(); diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index ffadc5d03..589b08e5e 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -445,7 +445,7 @@ void Setup_Video::cancel() config.setValue("noframe", mNoFrame); } -void Setup_Video::action(const gcn::ActionEvent &event) +void Setup_Video::action(const ActionEvent &event) { const std::string &id = event.getId(); diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h index facbcbce3..b385d0358 100644 --- a/src/gui/widgets/tabs/setup_video.h +++ b/src/gui/widgets/tabs/setup_video.h @@ -50,7 +50,7 @@ class Setup_Video final : public SetupTab, public KeyListener void cancel() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: bool mFullScreenEnabled; diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h index fb7de574d..779826e5a 100644 --- a/src/gui/widgets/tabs/setuptabscroll.h +++ b/src/gui/widgets/tabs/setuptabscroll.h @@ -56,7 +56,7 @@ class SetupTabScroll : public SetupTab virtual void externalUnloaded() override; - virtual void action(const gcn::ActionEvent &event A_UNUSED) + virtual void action(const ActionEvent &event A_UNUSED) override final { } diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index 24c33c614..ca31e393d 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -48,7 +48,7 @@ gcn::Widget *TabStrip::createWidget(const std::string &text) const return widget; } -void TabStrip::action(const gcn::ActionEvent &event) +void TabStrip::action(const ActionEvent &event) { WidgetGroup::action(event); if (event.getSource()) diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index 3e954aec5..2e5ccfe34 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -40,7 +40,7 @@ class TabStrip final : public WidgetGroup gcn::Widget *createWidget(const std::string &name) const override final A_WARN_UNUSED; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; }; #endif // GUI_WIDGETS_TABSTRIP_H diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 17383780f..56da2d492 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -57,7 +57,7 @@ void WidgetGroup::addButton(const std::string &restrict text, } } -void WidgetGroup::action(const gcn::ActionEvent &event) +void WidgetGroup::action(const ActionEvent &event) { for (ActionListenerIterator iter = mActionListeners.begin(); iter != mActionListeners.end(); ++iter) diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 60ee2672f..835738a6f 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -40,7 +40,7 @@ class WidgetGroup : public Container, virtual void addButton(const std::string &restrict text, const std::string &restrict tag); - void action(const gcn::ActionEvent &event) override; + void action(const ActionEvent &event) override; virtual void add(gcn::Widget *const widget, const int spacing); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 631fe3437..e04eb210f 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -213,7 +213,7 @@ WindowMenu::~WindowMenu() } } -void WindowMenu::action(const gcn::ActionEvent &event) +void WindowMenu::action(const ActionEvent &event) { const std::string &eventId = event.getId(); diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index b472be579..9375eb15d 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -88,7 +88,7 @@ class WindowMenu final : public Container, ~WindowMenu(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index 20ade8ae4..e04174962 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -377,7 +377,7 @@ void BotCheckerWindow::slowLogic() BLOCK_END("BotCheckerWindow::slowLogic") } -void BotCheckerWindow::action(const gcn::ActionEvent &event) +void BotCheckerWindow::action(const ActionEvent &event) { if (event.getId() == "reset") { diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h index 3db396321..25fd550fb 100644 --- a/src/gui/windows/botcheckerwindow.h +++ b/src/gui/windows/botcheckerwindow.h @@ -61,7 +61,7 @@ class BotCheckerWindow final : public Window, */ ~BotCheckerWindow(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void update(); diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index def60b942..0027b695e 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -388,7 +388,7 @@ void BuyDialog::sort() } } -void BuyDialog::action(const gcn::ActionEvent &event) +void BuyDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "quit") diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 9e493b91e..f3ba80c45 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -98,7 +98,7 @@ class BuyDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Returns the number of items in the shop inventory. diff --git a/src/gui/windows/buyselldialog.cpp b/src/gui/windows/buyselldialog.cpp index 5a1914040..92f6503bb 100644 --- a/src/gui/windows/buyselldialog.cpp +++ b/src/gui/windows/buyselldialog.cpp @@ -119,7 +119,7 @@ void BuySellDialog::setVisible(bool visible) } } -void BuySellDialog::action(const gcn::ActionEvent &event) +void BuySellDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "Buy") diff --git a/src/gui/windows/buyselldialog.h b/src/gui/windows/buyselldialog.h index 84bac0cac..a89ff0bea 100644 --- a/src/gui/windows/buyselldialog.h +++ b/src/gui/windows/buyselldialog.h @@ -59,7 +59,7 @@ class BuySellDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Returns true if any instances exist. diff --git a/src/gui/windows/changeemaildialog.cpp b/src/gui/windows/changeemaildialog.cpp index 3ed9ff213..b8f9c1fd2 100644 --- a/src/gui/windows/changeemaildialog.cpp +++ b/src/gui/windows/changeemaildialog.cpp @@ -109,7 +109,7 @@ ChangeEmailDialog::~ChangeEmailDialog() mWrongDataNoticeListener = nullptr; } -void ChangeEmailDialog::action(const gcn::ActionEvent &event) +void ChangeEmailDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "cancel") diff --git a/src/gui/windows/changeemaildialog.h b/src/gui/windows/changeemaildialog.h index cdbd371d1..d2928025d 100644 --- a/src/gui/windows/changeemaildialog.h +++ b/src/gui/windows/changeemaildialog.h @@ -58,7 +58,7 @@ class ChangeEmailDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * This is used to pass the pointer to where the new email should be diff --git a/src/gui/windows/changepassworddialog.cpp b/src/gui/windows/changepassworddialog.cpp index 24823cddc..05c7a9309 100644 --- a/src/gui/windows/changepassworddialog.cpp +++ b/src/gui/windows/changepassworddialog.cpp @@ -88,7 +88,7 @@ ChangePasswordDialog::~ChangePasswordDialog() mWrongDataNoticeListener = nullptr; } -void ChangePasswordDialog::action(const gcn::ActionEvent &event) +void ChangePasswordDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "cancel") diff --git a/src/gui/windows/changepassworddialog.h b/src/gui/windows/changepassworddialog.h index ac7d35308..adbaf109a 100644 --- a/src/gui/windows/changepassworddialog.h +++ b/src/gui/windows/changepassworddialog.h @@ -58,7 +58,7 @@ class ChangePasswordDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: TextField *mOldPassField; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 4595709ca..23be4eacf 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -318,7 +318,7 @@ CharCreateDialog::~CharCreateDialog() Net::getCharServerHandler()->setCharCreateDialog(nullptr); } -void CharCreateDialog::action(const gcn::ActionEvent &event) +void CharCreateDialog::action(const ActionEvent &event) { const std::string id = event.getId(); if (id == "create") @@ -671,7 +671,7 @@ void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) { case Input::KEY_GUI_CANCEL: keyEvent.consume(); - action(gcn::ActionEvent(mCancelButton, + action(ActionEvent(mCancelButton, mCancelButton->getActionEventId())); break; diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index c0e8e2928..d98860566 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -58,7 +58,7 @@ class CharCreateDialog final : public Window, */ ~CharCreateDialog(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Unlocks the dialog, enabling the create character button again. diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index f5b522971..5d447c717 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -70,7 +70,7 @@ class CharDeleteConfirm final : public ConfirmDialog A_DELETE_COPY(CharDeleteConfirm) - void action(const gcn::ActionEvent &event) + void action(const ActionEvent &event) { if (event.getId() == "yes" && mMaster) mMaster->askPasswordForDeletion(mIndex); @@ -205,7 +205,7 @@ void CharSelectDialog::postInit() requestFocus(); } -void CharSelectDialog::action(const gcn::ActionEvent &event) +void CharSelectDialog::action(const ActionEvent &event) { // Check if a button of a character was pressed const gcn::Widget *const sourceParent = event.getSource()->getParent(); @@ -322,7 +322,7 @@ void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) { case Input::KEY_GUI_CANCEL: keyEvent.consume(); - action(gcn::ActionEvent(mSwitchLoginButton, + action(ActionEvent(mSwitchLoginButton, mSwitchLoginButton->getActionEventId())); break; diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 9f0e4d126..6c6759932 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -61,7 +61,7 @@ class CharSelectDialog final : public Window, ~CharSelectDialog(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void keyPressed(gcn::KeyEvent &keyEvent) override final; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index e62f797e3..28f58aaa9 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -514,7 +514,7 @@ void ChatWindow::defaultTab() mChatTabs->setSelectedTabByIndex(static_cast(0)); } -void ChatWindow::action(const gcn::ActionEvent &event) +void ChatWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "chatinput") diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index cb7671058..e18eef7b2 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -139,7 +139,7 @@ class ChatWindow final : public Window, /** * Performs action. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Request focus for typing chat message. diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 950c6eada..499538388 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -107,7 +107,7 @@ void ConfirmDialog::postInit() yesButton->requestFocus(); } -void ConfirmDialog::action(const gcn::ActionEvent &event) +void ConfirmDialog::action(const ActionEvent &event) { setActionEventId(event.getId()); distributeActionEvent(); diff --git a/src/gui/windows/confirmdialog.h b/src/gui/windows/confirmdialog.h index a123dae71..0d9f25d38 100644 --- a/src/gui/windows/confirmdialog.h +++ b/src/gui/windows/confirmdialog.h @@ -58,7 +58,7 @@ class ConfirmDialog : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override; + void action(const ActionEvent &event) override; void postInit() override final; diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp index a50747958..0d0633ff8 100644 --- a/src/gui/windows/connectiondialog.cpp +++ b/src/gui/windows/connectiondialog.cpp @@ -60,7 +60,7 @@ void ConnectionDialog::postInit() setVisible(true); } -void ConnectionDialog::action(const gcn::ActionEvent &) +void ConnectionDialog::action(const ActionEvent &) { logger->log1("Cancel pressed"); client->setState(mCancelState); diff --git a/src/gui/windows/connectiondialog.h b/src/gui/windows/connectiondialog.h index b27aa892e..059d4bd6d 100644 --- a/src/gui/windows/connectiondialog.h +++ b/src/gui/windows/connectiondialog.h @@ -56,7 +56,7 @@ class ConnectionDialog final : public Window, * Called when the user presses Cancel. Restores the global state to * the previous one. */ - void action(const gcn::ActionEvent &) override; + void action(const ActionEvent &) override; void draw(Graphics *graphics) override; diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index d393a7dd5..cb2fdec95 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -102,7 +102,7 @@ void DidYouKnowWindow::postInit() widgetResized(gcn::Event(nullptr)); } -void DidYouKnowWindow::action(const gcn::ActionEvent &event) +void DidYouKnowWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "close") diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h index ff4599657..4f88b3f1c 100644 --- a/src/gui/windows/didyouknowwindow.h +++ b/src/gui/windows/didyouknowwindow.h @@ -53,7 +53,7 @@ class DidYouKnowWindow final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Handles link action. diff --git a/src/gui/windows/editdialog.cpp b/src/gui/windows/editdialog.cpp index 3f087b803..55102acdb 100644 --- a/src/gui/windows/editdialog.cpp +++ b/src/gui/windows/editdialog.cpp @@ -65,7 +65,7 @@ void EditDialog::postInit() okButton->requestFocus(); } -void EditDialog::action(const gcn::ActionEvent &event) +void EditDialog::action(const ActionEvent &event) { // Proxy button events to our listeners FOR_EACH (ActionListenerIterator, i, mActionListeners) diff --git a/src/gui/windows/editdialog.h b/src/gui/windows/editdialog.h index f37369a89..b3bfe1f45 100644 --- a/src/gui/windows/editdialog.h +++ b/src/gui/windows/editdialog.h @@ -59,7 +59,7 @@ class EditDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; std::string getMsg() const A_WARN_UNUSED { return mTextField->getText(); } diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index ee375a86e..d8301f5ce 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -198,7 +198,7 @@ void EditServerDialog::postInit() mNameField->requestFocus(); } -void EditServerDialog::action(const gcn::ActionEvent &event) +void EditServerDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); @@ -299,6 +299,6 @@ void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent) else if (actionId == static_cast(Input::KEY_GUI_SELECT) || actionId == static_cast(Input::KEY_GUI_SELECT2)) { - action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); + action(ActionEvent(nullptr, mOkButton->getActionEventId())); } } diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index bf36c216f..55c200934 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -92,7 +92,7 @@ class EditServerDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void keyPressed(gcn::KeyEvent &keyEvent) override final; diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 3f7f19948..68ef56826 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -257,7 +257,7 @@ void EquipmentWindow::draw(Graphics *graphics) BLOCK_END("EquipmentWindow::draw") } -void EquipmentWindow::action(const gcn::ActionEvent &event) +void EquipmentWindow::action(const ActionEvent &event) { if (!mEquipment) return; diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index 7ce8e6409..bade666ad 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -84,7 +84,7 @@ class EquipmentWindow final : public Window, */ void draw(Graphics *graphics) override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void mousePressed(gcn::MouseEvent& mouseEvent) override final; diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 288c38138..53e82335e 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -90,7 +90,7 @@ HelpWindow::HelpWindow() : widgetResized(gcn::Event(nullptr)); } -void HelpWindow::action(const gcn::ActionEvent &event) +void HelpWindow::action(const ActionEvent &event) { if (event.getId() == "DYK") { diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h index ae7d68c7c..d8b873408 100644 --- a/src/gui/windows/helpwindow.h +++ b/src/gui/windows/helpwindow.h @@ -59,7 +59,7 @@ class HelpWindow final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Handles link action. diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 7066a9c8e..509b085b5 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -335,7 +335,7 @@ void InventoryWindow::storeSortOrder() } } -void InventoryWindow::action(const gcn::ActionEvent &event) +void InventoryWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "outfit") diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 2d5ec6191..4babbc264 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -77,7 +77,7 @@ class InventoryWindow final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Returns the selected item. diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 4dd220093..40ca481b0 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -339,7 +339,7 @@ void ItemAmountWindow::resetAmount() mItemAmountTextField->setValue(1); } -void ItemAmountWindow::action(const gcn::ActionEvent &event) +void ItemAmountWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "cancel") diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index ac2eae8e1..46e20353e 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -65,7 +65,7 @@ class ItemAmountWindow final : public Window, /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Sets default amount value. diff --git a/src/gui/windows/killstats.cpp b/src/gui/windows/killstats.cpp index dec951458..710875a3c 100644 --- a/src/gui/windows/killstats.cpp +++ b/src/gui/windows/killstats.cpp @@ -156,7 +156,7 @@ KillStats::~KillStats() { } -void KillStats::action(const gcn::ActionEvent &event) +void KillStats::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "reset") diff --git a/src/gui/windows/killstats.h b/src/gui/windows/killstats.h index 2dcc41b97..486ec9135 100644 --- a/src/gui/windows/killstats.h +++ b/src/gui/windows/killstats.h @@ -51,7 +51,7 @@ class KillStats final : public Window, /** * Stuff. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void gainXp(int Xp); diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 609b58b57..44a19346f 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -63,7 +63,7 @@ namespace A_DELETE_COPY(OpenUrlListener) - void action(const gcn::ActionEvent &event) override final + void action(const ActionEvent &event) override final { if (event.getId() == "yes") openBrowser(url); @@ -276,7 +276,7 @@ LoginDialog::~LoginDialog() mUpdateListModel = nullptr; } -void LoginDialog::action(const gcn::ActionEvent &event) +void LoginDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "login" && canSubmit()) @@ -330,12 +330,12 @@ void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) &keyEvent)->getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { - action(gcn::ActionEvent(nullptr, mServerButton->getActionEventId())); + action(ActionEvent(nullptr, mServerButton->getActionEventId())); } else if (actionId == static_cast(Input::KEY_GUI_SELECT) || actionId == static_cast(Input::KEY_GUI_SELECT2)) { - action(gcn::ActionEvent(nullptr, mLoginButton->getActionEventId())); + action(ActionEvent(nullptr, mLoginButton->getActionEventId())); } else { diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index 70b16f537..fee21f307 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -66,7 +66,7 @@ class LoginDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Called when a key is pressed in one of the text fields. diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 6e33422b2..4ee8f3b29 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -295,7 +295,7 @@ void NpcDialog::showCloseButton() buildLayout(); } -void NpcDialog::action(const gcn::ActionEvent &event) +void NpcDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "ok") diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index e9ad99242..1fdd4a444 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -77,7 +77,7 @@ class NpcDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Sets the text shows in the dialog. diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp index 1666d1bd6..587f94ab2 100644 --- a/src/gui/windows/npcpostdialog.cpp +++ b/src/gui/windows/npcpostdialog.cpp @@ -98,7 +98,7 @@ NpcPostDialog::~NpcPostDialog() instances.remove(this); } -void NpcPostDialog::action(const gcn::ActionEvent &event) +void NpcPostDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "send") diff --git a/src/gui/windows/npcpostdialog.h b/src/gui/windows/npcpostdialog.h index 6ce070808..5396aad6e 100644 --- a/src/gui/windows/npcpostdialog.h +++ b/src/gui/windows/npcpostdialog.h @@ -48,7 +48,7 @@ class NpcPostDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void setVisible(bool visible) override final; diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index eb22d6c87..b9f26da20 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -84,7 +84,7 @@ OkDialog::OkDialog(const std::string &restrict title, soundManager.playGuiSound(SOUND_ERROR); } -void OkDialog::action(const gcn::ActionEvent &event) +void OkDialog::action(const ActionEvent &event) { setActionEventId(event.getId()); distributeActionEvent(); diff --git a/src/gui/windows/okdialog.h b/src/gui/windows/okdialog.h index 6809bee1a..b8236dfbc 100644 --- a/src/gui/windows/okdialog.h +++ b/src/gui/windows/okdialog.h @@ -63,7 +63,7 @@ class OkDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: TextBox *mTextBox; diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 2d59c6a43..6fbb34390 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -225,7 +225,7 @@ void OutfitWindow::save() const serverConfig.setValue("OutfitAwayIndex", mAwayOutfit); } -void OutfitWindow::action(const gcn::ActionEvent &event) +void OutfitWindow::action(const ActionEvent &event) { const std::string eventId = event.getId(); if (eventId == "next") diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 4c3b5951c..f27852a8c 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -50,7 +50,7 @@ class OutfitWindow final : public Window, */ ~OutfitWindow(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void draw(Graphics *graphics) override final; diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index c37bc860c..681949145 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -318,7 +318,7 @@ void QuestsWindow::loadEffect(const int var, const XmlNodePtr node) mAllEffects.push_back(effect); } -void QuestsWindow::action(const gcn::ActionEvent &event) +void QuestsWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "select") diff --git a/src/gui/windows/questswindow.h b/src/gui/windows/questswindow.h index fdb2c98aa..9000fcaa9 100644 --- a/src/gui/windows/questswindow.h +++ b/src/gui/windows/questswindow.h @@ -57,7 +57,7 @@ class QuestsWindow final : public Window, ~QuestsWindow(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void updateQuest(const int var, const int val); diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 99890472b..2c264f232 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -147,7 +147,7 @@ void QuitDialog::placeOption(ContainerPlacer &placer, mOptions.push_back(option); } -void QuitDialog::action(const gcn::ActionEvent &event) +void QuitDialog::action(const ActionEvent &event) { soundManager.playGuiSound(SOUND_HIDE_WINDOW); if (event.getId() == "ok") @@ -211,11 +211,10 @@ void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) { case Input::KEY_GUI_SELECT: case Input::KEY_GUI_SELECT2: - action(gcn::ActionEvent(nullptr, mOkButton->getActionEventId())); + action(ActionEvent(nullptr, mOkButton->getActionEventId())); break; case Input::KEY_GUI_CANCEL: - action(gcn::ActionEvent(nullptr, - mCancelButton->getActionEventId())); + action(ActionEvent(nullptr, mCancelButton->getActionEventId())); break; case Input::KEY_GUI_UP: dir = -1; diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h index 0b81992f1..5f0824ff4 100644 --- a/src/gui/windows/quitdialog.h +++ b/src/gui/windows/quitdialog.h @@ -62,7 +62,7 @@ class QuitDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void keyPressed(gcn::KeyEvent &keyEvent) override final; diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index fd5ab8f5a..a89b09d5b 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -54,7 +54,7 @@ void WrongDataNoticeListener::setTarget(TextField *const textField) mTarget = textField; } -void WrongDataNoticeListener::action(const gcn::ActionEvent &event) +void WrongDataNoticeListener::action(const ActionEvent &event) { if (event.getId() == "ok" && mTarget) mTarget->requestFocus(); @@ -172,7 +172,7 @@ RegisterDialog::~RegisterDialog() mWrongDataNoticeListener = nullptr; } -void RegisterDialog::action(const gcn::ActionEvent &event) +void RegisterDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "cancel") @@ -292,12 +292,12 @@ void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) &keyEvent)->getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { - action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); + action(ActionEvent(nullptr, mCancelButton->getActionEventId())); } else if (actionId == static_cast(Input::KEY_GUI_SELECT) || actionId == static_cast(Input::KEY_GUI_SELECT2)) { - action(gcn::ActionEvent(nullptr, mRegisterButton->getActionEventId())); + action(ActionEvent(nullptr, mRegisterButton->getActionEventId())); } else { diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h index 93908c27c..766f4b6b1 100644 --- a/src/gui/windows/registerdialog.h +++ b/src/gui/windows/registerdialog.h @@ -47,7 +47,7 @@ class WrongDataNoticeListener final : public ActionListener void setTarget(TextField *const textField); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: TextField *mTarget; }; @@ -82,7 +82,7 @@ class RegisterDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override; + void action(const ActionEvent &event) override; /** * Called when a key is pressed in one of the text fields. diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 9db7bda27..1917f7693 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -185,7 +185,7 @@ void SellDialog::addItem(const int id, const unsigned char color, } -void SellDialog::action(const gcn::ActionEvent &event) +void SellDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h index f1747ca7e..5d1065c16 100644 --- a/src/gui/windows/selldialog.h +++ b/src/gui/windows/selldialog.h @@ -80,7 +80,7 @@ class SellDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Updates labels according to selected item. diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 32e838ac3..8d42d83e9 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -404,7 +404,7 @@ void ServerDialog::connectToSelectedServer() client->setState(STATE_CONNECT_SERVER); } -void ServerDialog::action(const gcn::ActionEvent &event) +void ServerDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "connect") @@ -456,7 +456,7 @@ void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) case Input::KEY_GUI_SELECT: case Input::KEY_GUI_SELECT2: keyEvent.consume(); - action(gcn::ActionEvent(nullptr, + action(ActionEvent(nullptr, mConnectButton->getActionEventId())); return; @@ -510,8 +510,8 @@ void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) if (mouseEvent.getClickCount() == 2 && mouseEvent.getSource() == mServersList) { - action(gcn::ActionEvent(mConnectButton, - mConnectButton->getActionEventId())); + action(ActionEvent(mConnectButton, + mConnectButton->getActionEventId())); } } diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index c01f8dd08..4e711d732 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -116,7 +116,7 @@ class ServerDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void keyPressed(gcn::KeyEvent &keyEvent) override final; diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 85e4938ef..710702f5e 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -160,7 +160,7 @@ SetupWindow::~SetupWindow() mButtons.clear(); } -void SetupWindow::action(const gcn::ActionEvent &event) +void SetupWindow::action(const ActionEvent &event) { if (Game::instance()) Game::instance()->resetAdjustLevel(); diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index c65f1cfea..27e44b243 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -52,7 +52,7 @@ class SetupWindow final : public Window, void postInit() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void setInGame(const bool inGame); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 7e50e4c37..04258998a 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -205,7 +205,7 @@ ShopWindow::~ShopWindow() instances.remove(this); } -void ShopWindow::action(const gcn::ActionEvent &event) +void ShopWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "close") diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index 9149b79cb..a93e0d475 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -72,7 +72,7 @@ class ShopWindow final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Updates the labels according to the selected item. diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index f2af65c3c..12c6e76d8 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -321,7 +321,7 @@ SkillDialog::~SkillDialog() clearSkills(); } -void SkillDialog::action(const gcn::ActionEvent &event) +void SkillDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "inc") diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index d58aa5cca..2bedef2b0 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -58,7 +58,7 @@ class SkillDialog final : public Window, /** * Called when receiving actions from widget. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Update the given skill's display diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 8b5fdf95c..72590ab60 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -208,7 +208,7 @@ public: mScroll = nullptr; } - void action(const gcn::ActionEvent &event) override final + void action(const ActionEvent &event) override final { const std::string &eventId = event.getId(); if (eventId == "do invite") @@ -343,7 +343,7 @@ public: mScroll = nullptr; } - void action(const gcn::ActionEvent &event A_UNUSED) override final + void action(const ActionEvent &event A_UNUSED) override final { } @@ -411,7 +411,7 @@ public: mScroll = nullptr; } - void action(const gcn::ActionEvent &event) override final + void action(const ActionEvent &event) override final { const std::string &eventId = event.getId(); if (eventId == "do invite") @@ -1482,7 +1482,7 @@ bool SocialWindow::removeTab(Party *const party) return true; } -void SocialWindow::action(const gcn::ActionEvent &event) +void SocialWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 84c713787..08497c5c8 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -68,7 +68,7 @@ public: bool removeTab(Party *const party); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void showGuildInvite(const std::string &restrict guildName, const int guildId, diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index a95eb807c..1279961e6 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -129,7 +129,7 @@ class ChangeDisplay final : public AttrDisplay, ActionListener void setPointsNeeded(const int needed); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: int mNeeded; @@ -746,7 +746,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar, bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_OFF)); } -void StatusWindow::action(const gcn::ActionEvent &event) +void StatusWindow::action(const ActionEvent &event) { if (!chatWindow) return; @@ -873,7 +873,7 @@ void ChangeDisplay::setPointsNeeded(const int needed) update(); } -void ChangeDisplay::action(const gcn::ActionEvent &event) +void ChangeDisplay::action(const ActionEvent &event) { if (Net::getPlayerHandler()->canCorrectAttributes() && event.getSource() == mDec) diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h index 31e1dda69..3b171a25e 100644 --- a/src/gui/windows/statuswindow.h +++ b/src/gui/windows/statuswindow.h @@ -83,7 +83,7 @@ class StatusWindow final : public Window, const int id, const bool percent = true); - void action(const gcn::ActionEvent &event) override; + void action(const ActionEvent &event) override; void clearAttributes(); diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 72796b6b9..98b9cae60 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -314,7 +314,7 @@ TextCommandEditor::~TextCommandEditor() mMagicSchoolModel = nullptr; } -void TextCommandEditor::action(const gcn::ActionEvent &event) +void TextCommandEditor::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "magic") diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h index 7b3921618..3b5e239cd 100644 --- a/src/gui/windows/textcommandeditor.h +++ b/src/gui/windows/textcommandeditor.h @@ -56,7 +56,7 @@ class TextCommandEditor final : public Window, void postInit() override final; - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void scheduleDelete() override final; diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index f6f2ce06a..c4ff71eb7 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -104,7 +104,7 @@ TextDialog::~TextDialog() instances--; } -void TextDialog::action(const gcn::ActionEvent &event) +void TextDialog::action(const ActionEvent &event) { if (event.getId() == "CANCEL") setActionEventId("~" + getActionEventId()); diff --git a/src/gui/windows/textdialog.h b/src/gui/windows/textdialog.h index d82b15085..8e69e8a3d 100644 --- a/src/gui/windows/textdialog.h +++ b/src/gui/windows/textdialog.h @@ -59,7 +59,7 @@ public: /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Get the text in the textfield diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index a5b7f1a47..2a3b1c7b5 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -318,7 +318,7 @@ void TradeWindow::setStatus(const Status s) mOkButton->setEnabled((s != PROPOSING && s != ACCEPTED)); } -void TradeWindow::action(const gcn::ActionEvent &event) +void TradeWindow::action(const ActionEvent &event) { if (!inventoryWindow) return; diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index c5e1d7e8f..6839b2f30 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -114,7 +114,7 @@ class TradeWindow final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; /** * Closes the Trade Window, as well as telling the server that the diff --git a/src/gui/windows/unregisterdialog.cpp b/src/gui/windows/unregisterdialog.cpp index 791a25c05..3326ca2bb 100644 --- a/src/gui/windows/unregisterdialog.cpp +++ b/src/gui/windows/unregisterdialog.cpp @@ -101,7 +101,7 @@ UnRegisterDialog::~UnRegisterDialog() mWrongDataNoticeListener = nullptr; } -void UnRegisterDialog::action(const gcn::ActionEvent &event) +void UnRegisterDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "cancel") diff --git a/src/gui/windows/unregisterdialog.h b/src/gui/windows/unregisterdialog.h index b384a7041..206c05413 100644 --- a/src/gui/windows/unregisterdialog.h +++ b/src/gui/windows/unregisterdialog.h @@ -57,7 +57,7 @@ class UnRegisterDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; private: LoginData *mLoginData; diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index b5339a202..9df4fdc57 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -270,7 +270,7 @@ void UpdaterWindow::enable() client->setState(STATE_LOAD_DATA); } -void UpdaterWindow::action(const gcn::ActionEvent &event) +void UpdaterWindow::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "cancel") @@ -295,7 +295,7 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) const int actionId = static_cast(&keyEvent)->getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { - action(gcn::ActionEvent(nullptr, mCancelButton->getActionEventId())); + action(ActionEvent(nullptr, mCancelButton->getActionEventId())); client->setState(STATE_LOGIN); } else if (actionId == static_cast(Input::KEY_GUI_SELECT) @@ -304,12 +304,11 @@ void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) if (mDownloadStatus == UPDATE_COMPLETE || mDownloadStatus == UPDATE_ERROR) { - action(gcn::ActionEvent(nullptr, mPlayButton->getActionEventId())); + action(ActionEvent(nullptr, mPlayButton->getActionEventId())); } else { - action(gcn::ActionEvent(nullptr, - mCancelButton->getActionEventId())); + action(ActionEvent(nullptr, mCancelButton->getActionEventId())); } } } diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index d20f2aadc..879a9eac3 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -119,7 +119,7 @@ class UpdaterWindow final : public Window, void loadPatch(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void keyPressed(gcn::KeyEvent &keyEvent) override final; diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index fd54076ed..0d65eff35 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -683,7 +683,7 @@ void WhoIsOnline::slowLogic() BLOCK_END("WhoIsOnline::slowLogic") } -void WhoIsOnline::action(const gcn::ActionEvent &event) +void WhoIsOnline::action(const ActionEvent &event) { if (event.getId() == "update") { diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 8c6235130..af0d14f7b 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -134,7 +134,7 @@ public: void slowLogic(); - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void widgetResized(const gcn::Event &event) override final; diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 48be8df8a..5d81e249e 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -134,7 +134,7 @@ WorldSelectDialog::~WorldSelectDialog() mWorldListModel = nullptr; } -void WorldSelectDialog::action(const gcn::ActionEvent &event) +void WorldSelectDialog::action(const ActionEvent &event) { const std::string &eventId = event.getId(); if (eventId == "world") @@ -160,12 +160,12 @@ void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { - action(gcn::ActionEvent(nullptr, + action(ActionEvent(nullptr, mChangeLoginButton->getActionEventId())); } else if (actionId == static_cast(Input::KEY_GUI_SELECT) || actionId == static_cast(Input::KEY_GUI_SELECT2)) { - action(gcn::ActionEvent(nullptr, mChooseWorld->getActionEventId())); + action(ActionEvent(nullptr, mChooseWorld->getActionEventId())); } } diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h index 5542d2360..9315317bf 100644 --- a/src/gui/windows/worldselectdialog.h +++ b/src/gui/windows/worldselectdialog.h @@ -63,7 +63,7 @@ class WorldSelectDialog final : public Window, /** * Called when receiving actions from the widgets. */ - void action(const gcn::ActionEvent &event) override final; + void action(const ActionEvent &event) override final; void keyPressed(gcn::KeyEvent &keyEvent) override final; diff --git a/src/listeners/actionlistener.h b/src/listeners/actionlistener.h index ee3154f80..b22e5abc6 100644 --- a/src/listeners/actionlistener.h +++ b/src/listeners/actionlistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/actionevent.hpp" +#include "events/actionevent.h" /** * Interface for listening for action events from widgets. @@ -93,7 +93,7 @@ class ActionListener * @param actionEvent The event of the action. * @since 0.6.0 */ - virtual void action(const gcn::ActionEvent &actionEvent) = 0; + virtual void action(const ActionEvent &actionEvent) = 0; protected: /** diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index c568012fc..28f16735c 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -62,7 +62,7 @@ namespace */ struct WeightListener final : public ActionListener { - void action(const gcn::ActionEvent &event A_UNUSED) + void action(const ActionEvent &event A_UNUSED) { weightNotice = nullptr; } @@ -73,7 +73,7 @@ namespace */ struct DeathListener final : public ActionListener { - void action(const gcn::ActionEvent &event A_UNUSED) + void action(const ActionEvent &event A_UNUSED) { if (Net::getPlayerHandler()) Net::getPlayerHandler()->respawn(); diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index adecd591f..4cb424fc9 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -50,7 +50,7 @@ namespace { struct RequestTradeListener : public ActionListener { - void action(const gcn::ActionEvent &event) + void action(const ActionEvent &event) { confirmDlg = nullptr; const std::string &eventId = event.getId(); -- cgit v1.2.3-70-g09d2 From 3ae82048ca8636ce03e71bdd4c11f60594cfc698 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 12:47:15 +0300 Subject: move event into events directory. --- src/CMakeLists.txt | 3 +- src/Makefile.am | 6 +- src/events/actionevent.h | 6 +- src/events/event.h | 117 +++++++++++++++++++++++++++++ src/gui/base/event.cpp | 87 --------------------- src/gui/base/event.hpp | 113 ---------------------------- src/gui/base/focushandler.hpp | 2 +- src/gui/base/inputevent.hpp | 2 +- src/gui/base/selectionevent.hpp | 2 +- src/gui/base/widget.cpp | 2 +- src/gui/focushandler.cpp | 2 +- src/gui/focushandler.h | 2 +- src/gui/gui.cpp | 2 +- src/gui/gui.h | 2 +- src/gui/widgets/button.cpp | 4 +- src/gui/widgets/button.h | 4 +- src/gui/widgets/characterdisplay.cpp | 2 +- src/gui/widgets/characterdisplay.h | 2 +- src/gui/widgets/desktop.cpp | 2 +- src/gui/widgets/desktop.h | 2 +- src/gui/widgets/dropshortcutcontainer.cpp | 2 +- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emotepage.cpp | 4 +- src/gui/widgets/emotepage.h | 4 +- src/gui/widgets/emoteshortcutcontainer.cpp | 2 +- src/gui/widgets/emoteshortcutcontainer.h | 2 +- src/gui/widgets/flowcontainer.cpp | 4 +- src/gui/widgets/flowcontainer.h | 2 +- src/gui/widgets/horizontcontainer.cpp | 2 +- src/gui/widgets/horizontcontainer.h | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/itemcontainer.h | 2 +- src/gui/widgets/itemshortcutcontainer.cpp | 2 +- src/gui/widgets/itemshortcutcontainer.h | 2 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/layouthelper.h | 2 +- src/gui/widgets/popup.cpp | 4 +- src/gui/widgets/popup.h | 4 +- src/gui/widgets/popuplist.cpp | 6 +- src/gui/widgets/popuplist.h | 6 +- src/gui/widgets/progressbar.cpp | 4 +- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/scrollarea.cpp | 4 +- src/gui/widgets/scrollarea.h | 4 +- src/gui/widgets/shortcutcontainer.cpp | 4 +- src/gui/widgets/shortcutcontainer.h | 4 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.h | 2 +- src/gui/widgets/tabbedarea.cpp | 8 +- src/gui/widgets/tabbedarea.h | 4 +- src/gui/widgets/tabs/setuptabscroll.cpp | 2 +- src/gui/widgets/tabs/setuptabscroll.h | 2 +- src/gui/widgets/tabs/tab.cpp | 4 +- src/gui/widgets/tabs/tab.h | 4 +- src/gui/widgets/textfield.cpp | 4 +- src/gui/widgets/textfield.h | 4 +- src/gui/widgets/vertcontainer.cpp | 2 +- src/gui/widgets/vertcontainer.h | 2 +- src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 2 +- src/gui/widgets/window.cpp | 8 +- src/gui/widgets/window.h | 6 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/charselectdialog.h | 2 +- src/gui/windows/chatwindow.cpp | 4 +- src/gui/windows/chatwindow.h | 2 +- src/gui/windows/debugwindow.cpp | 2 +- src/gui/windows/debugwindow.h | 2 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/emotewindow.cpp | 4 +- src/gui/windows/emotewindow.h | 4 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 6 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/setupwindow.cpp | 4 +- src/gui/windows/setupwindow.h | 2 +- src/gui/windows/shortcutwindow.cpp | 4 +- src/gui/windows/shortcutwindow.h | 4 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/skilldialog.h | 2 +- src/gui/windows/socialwindow.cpp | 4 +- src/gui/windows/socialwindow.h | 2 +- src/gui/windows/whoisonline.cpp | 4 +- src/gui/windows/whoisonline.h | 2 +- src/listeners/deathlistener.h | 4 +- src/listeners/focuslistener.h | 6 +- src/listeners/widgetlistener.h | 10 +-- 87 files changed, 252 insertions(+), 338 deletions(-) create mode 100644 src/events/event.h delete mode 100644 src/gui/base/event.cpp delete mode 100644 src/gui/base/event.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 99d36e1ec..2a79f5839 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -775,7 +775,7 @@ SET(SRCS gui/base/cliprectangle.hpp gui/base/color.hpp listeners/deathlistener.h - gui/base/event.hpp + events/event.h gui/base/exception.hpp gui/base/focushandler.hpp listeners/focuslistener.h @@ -811,7 +811,6 @@ SET(SRCS gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp gui/base/color.cpp - gui/base/event.cpp gui/base/exception.cpp gui/base/focushandler.cpp gui/base/font.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 21c2fc0e9..8a731c17f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,6 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/event.cpp \ gui/base/exception.cpp \ gui/base/font.cpp \ gui/base/rectangle.cpp \ @@ -36,7 +35,7 @@ dyecmd_SOURCES = gui/base/cliprectangle.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ - gui/base/event.hpp \ + events/event.h \ gui/base/exception.hpp \ gui/base/font.hpp \ gui/base/rectangle.hpp \ @@ -161,7 +160,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ listeners/deathlistener.h \ - gui/base/event.hpp \ + events/event.h \ gui/base/exception.hpp \ gui/base/focushandler.hpp \ listeners/focuslistener.h \ @@ -198,7 +197,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/event.cpp \ gui/base/exception.cpp \ gui/base/focushandler.cpp \ gui/base/font.cpp \ diff --git a/src/events/actionevent.h b/src/events/actionevent.h index 77f945693..70ed0f398 100644 --- a/src/events/actionevent.h +++ b/src/events/actionevent.h @@ -64,7 +64,7 @@ #ifndef EVENTS_ACTIONEVENT_HPP #define EVENTS_ACTIONEVENT_HPP -#include "gui/base/event.hpp" +#include "events/event.h" #include @@ -97,7 +97,7 @@ namespace GCN * @author Olof Naessén * @since 0.6.0 */ -class ActionEvent final : public gcn::Event +class ActionEvent final : public Event { public: /** @@ -107,7 +107,7 @@ class ActionEvent final : public gcn::Event * @param id An identifier of the event. */ ActionEvent(gcn::Widget *const source, const std::string &id) : - gcn::Event(source), + Event(source), mId(id) { } diff --git a/src/events/event.h b/src/events/event.h new file mode 100644 index 000000000..d62dd672b --- /dev/null +++ b/src/events/event.h @@ -0,0 +1,117 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 EVENTS_EVENT_HPP +#define EVENTS_EVENT_HPP + +#include "localconsts.h" + +namespace gcn +{ + class Widget; +} + +/** + * Base class for all events. All events in Guichan should + * inherit from this class. + * + * @author Olof Naessén + * @since 0.6.0 + */ +class Event +{ + public: + /** + * Constructor. + * + * @param source The source widget of the event. + */ + explicit Event(gcn::Widget *const source) : + mSource(source) + { } + + A_DELETE_COPY(Event) + + /** + * Destructor. + */ + virtual ~Event() + { } + + /** + * Gets the source widget of the event. The function + * is used to tell which widget fired an event. + * + * @return The source widget of the event. + */ + gcn::Widget* getSource() const A_WARN_UNUSED + { return mSource; } + + protected: + /** + * Holds the source widget of the event. + */ + gcn::Widget* mSource; +}; + +#endif // EVENTS_EVENT_HPP diff --git a/src/gui/base/event.cpp b/src/gui/base/event.cpp deleted file mode 100644 index 359b780bf..000000000 --- a/src/gui/base/event.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/event.hpp" - -#include "debug.h" - -namespace gcn -{ - Event::Event(Widget *const source) : - mSource(source) - { - } - - Event::~Event() - { - } - - Widget* Event::getSource() const - { - return mSource; - } -} // namespace gcn diff --git a/src/gui/base/event.hpp b/src/gui/base/event.hpp deleted file mode 100644 index 2a1f4ca4b..000000000 --- a/src/gui/base/event.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_EVENT_HPP -#define GCN_EVENT_HPP - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Base class for all events. All events in Guichan should - * inherit from this class. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - */ - explicit Event(Widget *const source); - - A_DELETE_COPY(Event) - - /** - * Destructor. - */ - virtual ~Event(); - - /** - * Gets the source widget of the event. The function - * is used to tell which widget fired an event. - * - * @return The source widget of the event. - */ - Widget* getSource() const A_WARN_UNUSED; - - protected: - /** - * Holds the source widget of the event. - */ - Widget* mSource; - }; -} // namespace gcn - -#endif // end GCN_EVENT_HPP diff --git a/src/gui/base/focushandler.hpp b/src/gui/base/focushandler.hpp index aab3f2464..a5c1b14a1 100644 --- a/src/gui/base/focushandler.hpp +++ b/src/gui/base/focushandler.hpp @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" namespace gcn { diff --git a/src/gui/base/inputevent.hpp b/src/gui/base/inputevent.hpp index 166edf038..fab68e2a4 100644 --- a/src/gui/base/inputevent.hpp +++ b/src/gui/base/inputevent.hpp @@ -64,7 +64,7 @@ #ifndef GCN_INPUTEVENT_HPP #define GCN_INPUTEVENT_HPP -#include "gui/base/event.hpp" +#include "events/event.h" namespace gcn { diff --git a/src/gui/base/selectionevent.hpp b/src/gui/base/selectionevent.hpp index 543b3a9ad..5d05f015c 100644 --- a/src/gui/base/selectionevent.hpp +++ b/src/gui/base/selectionevent.hpp @@ -64,7 +64,7 @@ #ifndef GCN_SELECTIONEVENT_HPP #define GCN_SELECTIONEVENT_HPP -#include "gui/base/event.hpp" +#include "events/event.h" #include "localconsts.h" diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index de133ac09..6083fb35a 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -70,7 +70,7 @@ #include "events/actionevent.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/event.hpp" +#include "events/event.h" #include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/keyinput.hpp" diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index cd780e12d..04cb3f555 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -103,7 +103,7 @@ void FocusHandler::checkForWindow() const } } -void FocusHandler::distributeFocusGainedEvent(const gcn::Event &focusEvent) +void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) { if (gui) gui->distributeGlobalFocusGainedEvent(focusEvent); diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index b051fe300..0e07625b7 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -71,7 +71,7 @@ class FocusHandler final : public gcn::FocusHandler void tabPrevious() override final; - void distributeFocusGainedEvent(const gcn::Event &focusEvent) + void distributeFocusGainedEvent(const Event &focusEvent) override final; private: diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index bced937c7..5d72c9dcb 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -920,7 +920,7 @@ void Gui::removeGlobalFocusListener(FocusListener* focusListener) mFocusListeners.remove(focusListener); } -void Gui::distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent) +void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent) { for (FocusListenerIterator iter = mFocusListeners.begin(); iter != mFocusListeners.end(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 544d9dd3d..1ec73e42f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -156,7 +156,7 @@ class Gui final : public gcn::Gui void removeGlobalFocusListener(FocusListener* focusListener); - void distributeGlobalFocusGainedEvent(const gcn::Event &focusEvent); + void distributeGlobalFocusGainedEvent(const Event &focusEvent); void removeDragged(gcn::Widget *widget); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index ee984a18a..5478d8164 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -546,12 +546,12 @@ void Button::mouseReleased(gcn::MouseEvent& mouseEvent) } } -void Button::widgetResized(const gcn::Event &event A_UNUSED) +void Button::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void Button::widgetMoved(const gcn::Event &event A_UNUSED) +void Button::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 8f79755a8..7fd7e4a9a 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -132,9 +132,9 @@ class Button final : public gcn::Button, void setPressed(bool b) { mPressed = b; } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; void loadImage(const std::string &imageName); diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 21de10412..3f4a672f0 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -110,7 +110,7 @@ void CharacterDisplay::update() distributeResizedEvent(); } -void CharacterDisplay::widgetHidden(const gcn::Event &event A_UNUSED) +void CharacterDisplay::widgetHidden(const Event &event A_UNUSED) { mPopup->setVisible(false); } diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index 940dbe5c6..84a288ab0 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -73,7 +73,7 @@ class CharacterDisplay final : public Container, void setSelect(bool b) { mPlayerBox->setSelected(b); } - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 5874ee441..8e0496fea 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -98,7 +98,7 @@ void Desktop::reloadWallpaper() setBestFittingWallpaper(); } -void Desktop::widgetResized(const gcn::Event &event A_UNUSED) +void Desktop::widgetResized(const Event &event A_UNUSED) { setBestFittingWallpaper(); } diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index 9e49ceb59..ad07b0ff8 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -60,7 +60,7 @@ class Desktop final : public Container, */ void reloadWallpaper(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void draw(Graphics *graphics) override final; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 9b37682fe..4b991bc34 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -308,7 +308,7 @@ void DropShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mItemPopup->setVisible(false); } -void DropShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void DropShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 6b7a9f151..26cbdffa7 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -67,7 +67,7 @@ class DropShortcutContainer final : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 091d699a7..e255afc30 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -139,12 +139,12 @@ void EmotePage::resetAction() mSelectedIndex = -1; } -void EmotePage::widgetResized(const gcn::Event &event A_UNUSED) +void EmotePage::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void EmotePage::widgetMoved(const gcn::Event &event A_UNUSED) +void EmotePage::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index afc950f79..cb6fd8711 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -48,9 +48,9 @@ class EmotePage final : public gcn::Widget, int getIndexFromGrid(const int x, const int y) const; - void widgetResized(const gcn::Event &event A_UNUSED) override final; + void widgetResized(const Event &event A_UNUSED) override final; - void widgetMoved(const gcn::Event &event A_UNUSED) override final; + void widgetMoved(const Event &event A_UNUSED) override final; void resetAction(); diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index dc25d9e5c..d00f01495 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -232,7 +232,7 @@ void EmoteShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mEmotePopup->setVisible(false); } -void EmoteShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void EmoteShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mEmotePopup) mEmotePopup->setVisible(false); diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index 62999207e..37ebe0cf9 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -74,7 +74,7 @@ class EmoteShortcutContainer final : public ShortcutContainer void mouseExited(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void setWidget2(const Widget2 *const widget) override final; diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index bfcd704d3..1c5961140 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -39,7 +39,7 @@ FlowContainer::FlowContainer(const Widget2 *const widget, mBoxHeight = 1; } -void FlowContainer::widgetResized(const gcn::Event &event A_UNUSED) +void FlowContainer::widgetResized(const Event &event A_UNUSED) { if (getWidth() < mBoxWidth) { @@ -92,5 +92,5 @@ void FlowContainer::add(gcn::Widget *widget) Container::add(widget); widget->setSize(mBoxWidth, mBoxHeight); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index e2773d34c..a425e8465 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -55,7 +55,7 @@ class FlowContainer final : public Container, * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; int getBoxWidth() const A_WARN_UNUSED { return mBoxWidth; } diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index 77dff3232..b2fddfcae 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -58,6 +58,6 @@ void HorizontContainer::clear() mCount = 0; } -void HorizontContainer::widgetResized(const gcn::Event &event A_UNUSED) +void HorizontContainer::widgetResized(const Event &event A_UNUSED) { } diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index eb1f8c5aa..4f652df64 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -48,7 +48,7 @@ class HorizontContainer final : public Container, void clear() override; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; protected: int mSpacing; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 84934911c..2c9e9b731 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -618,7 +618,7 @@ void ItemContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mItemPopup->setVisible(false); } -void ItemContainer::widgetResized(const gcn::Event &event A_UNUSED) +void ItemContainer::widgetResized(const Event &event A_UNUSED) { mGridColumns = std::max(1, mDimension.width / mBoxWidth); adjustHeight(); diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 3d98d425b..ecb7b658e 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -96,7 +96,7 @@ class ItemContainer final : public gcn::Widget, void mouseExited(gcn::MouseEvent &event) override final; // WidgetListener - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; /** * Returns the selected item. diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 2438050d9..ef4d8ebfa 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -467,7 +467,7 @@ void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mSpellPopup->setVisible(false); } -void ItemShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void ItemShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index c2dbe93a3..5efda0433 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -68,7 +68,7 @@ class ItemShortcutContainer final : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 460810adf..066cabaf8 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -61,7 +61,7 @@ void LayoutHelper::reflowLayout(int w, int h) mContainer->setSize(w, h); } -void LayoutHelper::widgetResized(const gcn::Event &event A_UNUSED) +void LayoutHelper::widgetResized(const Event &event A_UNUSED) { const gcn::Rectangle area = mContainer->getChildrenArea(); int w = area.width; diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index bdd923560..d5a94e656 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -78,7 +78,7 @@ class LayoutHelper final : public WidgetListener /** * Called whenever the managed container changes size. */ - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; private: Layout mLayout; /**< Layout handler */ diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 9d34beaa7..7036968ad 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -244,12 +244,12 @@ void Popup::hide() mRedraw = true; } -void Popup::widgetResized(const gcn::Event &event A_UNUSED) +void Popup::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void Popup::widgetMoved(const gcn::Event &event A_UNUSED) +void Popup::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 25998e21d..e467783ef 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -164,9 +164,9 @@ class Popup : public Container, void hide(); - void widgetResized(const gcn::Event &event) override; + void widgetResized(const Event &event) override; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; bool isPopupVisible() const { return mVisible; } diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index b8e4dabb4..37dd6b1ec 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -90,7 +90,7 @@ void PopupList::show(int x, int y) requestModalFocus(); } -void PopupList::widgetResized(const gcn::Event &event) +void PopupList::widgetResized(const Event &event) { Popup::widgetResized(event); adjustSize(); @@ -154,7 +154,7 @@ void PopupList::mouseReleased(gcn::MouseEvent& mouseEvent) releaseModalFocus(); } -void PopupList::focusGained(const gcn::Event& event) +void PopupList::focusGained(const Event& event) { const gcn::Widget *const source = event.getSource(); if (!mVisible || source == this || source == mListBox @@ -170,7 +170,7 @@ void PopupList::focusGained(const gcn::Event& event) releaseModalFocus(); } -void PopupList::focusLost(const gcn::Event& event A_UNUSED) +void PopupList::focusLost(const Event& event A_UNUSED) { if (mDropDown) mDropDown->updateSelection(); diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index 454b5617c..31308fff8 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -49,7 +49,7 @@ class PopupList final : public Popup, void show(int x, int y); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void setSelected(int selected); @@ -62,9 +62,9 @@ class PopupList final : public Popup, void adjustSize(); - void focusGained(const gcn::Event& event A_UNUSED) override final; + void focusGained(const Event& event A_UNUSED) override final; - void focusLost(const gcn::Event& event A_UNUSED) override final; + void focusLost(const Event& event A_UNUSED) override final; void mousePressed(gcn::MouseEvent& mouseEvent) override final; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 415962310..b120e4289 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -283,12 +283,12 @@ void ProgressBar::render(Graphics *graphics) } } -void ProgressBar::widgetResized(const gcn::Event &event A_UNUSED) +void ProgressBar::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void ProgressBar::widgetMoved(const gcn::Event &event A_UNUSED) +void ProgressBar::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 2835a7ffc..86e314e16 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -132,9 +132,9 @@ class ProgressBar final : public gcn::Widget, */ void render(Graphics *graphics); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; void setPadding(unsigned int padding) { mPadding = padding; } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index e9e850b1c..73ff82be0 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -667,7 +667,7 @@ void ScrollArea::mouseExited(gcn::MouseEvent& event A_UNUSED) mHasMouse = false; } -void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED) +void ScrollArea::widgetResized(const Event &event A_UNUSED) { mRedraw = true; const unsigned int frameSize = 2 * mFrameSize; @@ -679,7 +679,7 @@ void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED) } } -void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED) +void ScrollArea::widgetMoved(const Event& event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 69f567b02..7bf7e811c 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -124,9 +124,9 @@ class ScrollArea final : public gcn::ScrollArea, void mouseDragged(gcn::MouseEvent &event) override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; gcn::Rectangle getVerticalBarDimension() const; diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 8b3507b8e..767a32974 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -53,7 +53,7 @@ ShortcutContainer::~ShortcutContainer() mVertexes = nullptr; } -void ShortcutContainer::widgetResized(const gcn::Event &event A_UNUSED) +void ShortcutContainer::widgetResized(const Event &event A_UNUSED) { mGridWidth = mDimension.width / mBoxWidth; @@ -116,7 +116,7 @@ void ShortcutContainer::drawBackground(Graphics *g) } } -void ShortcutContainer::widgetMoved(const gcn::Event& event A_UNUSED) +void ShortcutContainer::widgetMoved(const Event& event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 1db3e0482..2c237f513 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -59,9 +59,9 @@ class ShortcutContainer : public gcn::Widget, * Invoked when a widget changes its size. This is used to determine * the new height of the container. */ - virtual void widgetResized(const gcn::Event &event) override final; + virtual void widgetResized(const Event &event) override final; - virtual void widgetMoved(const gcn::Event& event) override final; + virtual void widgetMoved(const Event& event) override final; /** * Handles mouse when dragged. diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 696b0fbb4..ee76ee5dd 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -314,7 +314,7 @@ void SpellShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) mSpellPopup->setVisible(false); } -void SpellShortcutContainer::widgetHidden(const gcn::Event &event A_UNUSED) +void SpellShortcutContainer::widgetHidden(const Event &event A_UNUSED) { if (mSpellPopup) mSpellPopup->setVisible(false); diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index 3115e47fe..b5968dfe5 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -67,7 +67,7 @@ class SpellShortcutContainer final : public ShortcutContainer */ void mouseReleased(gcn::MouseEvent &event) override final; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; void mouseExited(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 500e821f5..2fe4f1332 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -72,7 +72,7 @@ TabbedArea::TabbedArea(const Widget2 *const widget) : void TabbedArea::postInit() { - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } TabbedArea::~TabbedArea() @@ -365,7 +365,7 @@ void TabbedArea::setSelectedTab(Tab *const tab) if (newTab) newTab->setCurrent(); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } int TabbedArea::getSelectedTabIndex() const @@ -392,7 +392,7 @@ void TabbedArea::setSelectedTabByName(const std::string &name) } } -void TabbedArea::widgetResized(const gcn::Event &event A_UNUSED) +void TabbedArea::widgetResized(const Event &event A_UNUSED) { adjustSize(); @@ -716,7 +716,7 @@ void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) } } -void TabbedArea::death(const gcn::Event &event) +void TabbedArea::death(const Event &event) { Tab *const tab = dynamic_cast(event.getSource()); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index ec4c02ce5..d517c9a51 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -142,7 +142,7 @@ class TabbedArea final : public Widget2, void setSelectedTabByName(const std::string &name); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; /* void moveLeft(Tab *tab); @@ -184,7 +184,7 @@ class TabbedArea final : public Widget2, void setDimension(const gcn::Rectangle &dimension); - void death(const gcn::Event &event); + void death(const Event &event); void setResizeHeight(bool b) { mResizeHeight = b; } diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp index 659ef5824..9a37ced42 100644 --- a/src/gui/widgets/tabs/setuptabscroll.cpp +++ b/src/gui/widgets/tabs/setuptabscroll.cpp @@ -146,7 +146,7 @@ void SetupTabScroll::externalUnloaded() } } -void SetupTabScroll::widgetResized(const gcn::Event &event A_UNUSED) +void SetupTabScroll::widgetResized(const Event &event A_UNUSED) { mScroll->setWidth(getWidth() - 12); mScroll->setHeight(getHeight() - 12 - 12); diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h index 779826e5a..f7aa628c9 100644 --- a/src/gui/widgets/tabs/setuptabscroll.h +++ b/src/gui/widgets/tabs/setuptabscroll.h @@ -63,7 +63,7 @@ class SetupTabScroll : public SetupTab int getPreferredFirstItemSize() const A_WARN_UNUSED { return mPreferredFirstItemSize; } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void reread(const std::string &name); diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 398802eb0..db5ddf6b4 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -254,12 +254,12 @@ void Tab::draw(Graphics *graphics) BLOCK_END("Tab::draw") } -void Tab::widgetResized(const gcn::Event &event A_UNUSED) +void Tab::widgetResized(const Event &event A_UNUSED) { mRedraw = true; } -void Tab::widgetMoved(const gcn::Event &event A_UNUSED) +void Tab::widgetMoved(const Event &event A_UNUSED) { mRedraw = true; } diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index ac10b7dc7..e979c71b8 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -130,9 +130,9 @@ class Tab : public gcn::BasicContainer, int getFlash() const A_WARN_UNUSED { return mFlash; } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; void setLabelFont(gcn::Font *const font); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 22e9d42dd..58facecb8 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -760,7 +760,7 @@ void TextField::mousePressed(gcn::MouseEvent &mouseEvent) } } -void TextField::focusGained(const gcn::Event &event A_UNUSED) +void TextField::focusGained(const Event &event A_UNUSED) { #ifdef ANDROID if (!client->isKeyboardVisible()) @@ -768,6 +768,6 @@ void TextField::focusGained(const gcn::Event &event A_UNUSED) #endif } -void TextField::focusLost(const gcn::Event &event A_UNUSED) +void TextField::focusLost(const Event &event A_UNUSED) { } diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 4545e9ff9..42f76985c 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -124,9 +124,9 @@ class TextField : public gcn::TextField, void handleCopy() const; - void focusGained(const gcn::Event &event) override final; + void focusGained(const Event &event) override final; - void focusLost(const gcn::Event &event) override; + void focusLost(const Event &event) override; void moveCaretBack(); diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index ed3d00219..e38ebb9af 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -79,7 +79,7 @@ void VertContainer::clear() mResizableWidgets.clear(); } -void VertContainer::widgetResized(const gcn::Event &event A_UNUSED) +void VertContainer::widgetResized(const Event &event A_UNUSED) { FOR_EACH (std::vector::const_iterator, it, mResizableWidgets) (*it)->setWidth(getWidth()); diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 34fcf3d45..1d396efc9 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -52,7 +52,7 @@ class VertContainer final : public Container, void clear(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; private: std::vector mResizableWidgets; diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 56da2d492..3957fab30 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -84,6 +84,6 @@ void WidgetGroup::clear() mCount = 0; } -void WidgetGroup::widgetResized(const gcn::Event &event A_UNUSED) +void WidgetGroup::widgetResized(const Event &event A_UNUSED) { } diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 835738a6f..b26d88d15 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -47,7 +47,7 @@ class WidgetGroup : public Container, virtual void clear(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; virtual Widget *createWidget(const std::string &name) const A_WARN_UNUSED = 0; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 1fc439abf..54c18bd52 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -490,7 +490,7 @@ void Window::setResizable(const bool r) } } -void Window::widgetResized(const gcn::Event &event A_UNUSED) +void Window::widgetResized(const Event &event A_UNUSED) { const gcn::Rectangle area = getChildrenArea(); @@ -554,12 +554,12 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED) mRedraw = true; } -void Window::widgetMoved(const gcn::Event& event A_UNUSED) +void Window::widgetMoved(const Event& event A_UNUSED) { mRedraw = true; } -void Window::widgetHidden(const gcn::Event &event A_UNUSED) +void Window::widgetHidden(const Event &event A_UNUSED) { if (gui) gui->setCursorType(Cursor::CURSOR_POINTER); @@ -1085,7 +1085,7 @@ void Window::adjustSizeToScreen() if (mDimension.height > screenHeight) mDimension.height = screenHeight; if (oldWidth != mDimension.width || oldHeight != mDimension.height) - widgetResized(gcn::Event(this)); + widgetResized(Event(this)); } int Window::getResizeHandles(const gcn::MouseEvent &event) diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 5ff5abe2b..0c3b69880 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -114,14 +114,14 @@ class Window : public gcn::Window, /** * Called whenever the widget changes size. */ - virtual void widgetResized(const gcn::Event &event) override; + virtual void widgetResized(const Event &event) override; - virtual void widgetMoved(const gcn::Event& event) override; + virtual void widgetMoved(const Event& event) override; /** * Called whenever the widget is hidden. */ - virtual void widgetHidden(const gcn::Event &event) override; + virtual void widgetHidden(const Event &event) override; /** * Sets whether or not the window has a close button. diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 5d447c717..793315067 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -563,7 +563,7 @@ void CharSelectDialog::close() Window::close(); } -void CharSelectDialog::widgetResized(const gcn::Event &event) +void CharSelectDialog::widgetResized(const Event &event) { Window::widgetResized(event); if (mCharacterView) diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 6c6759932..e2b9c1ba8 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -86,7 +86,7 @@ class CharSelectDialog final : public Window, void close() override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void updateState(); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 28f58aaa9..40b4b9400 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -97,7 +97,7 @@ class ChatInput final : public TextField * Called if the chat input loses focus. It will set itself to * invisible as result. */ - void focusLost(const gcn::Event &event) + void focusLost(const Event &event) { TextField::focusLost(event); if (mFocusGaining || !config.getBoolValue("protectChatFocus")) @@ -441,7 +441,7 @@ void ChatWindow::adjustTabSize() mChatTabs->adjustSize(); } -void ChatWindow::widgetResized(const gcn::Event &event) +void ChatWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index e18eef7b2..f8458bd32 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -286,7 +286,7 @@ class ChatWindow final : public Window, void unHideWindow(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void addGlobalMessage(const std::string &line); diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 7cc074086..7e68aa6d8 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -147,7 +147,7 @@ void DebugWindow::draw(Graphics *g) BLOCK_END("DebugWindow::draw") } -void DebugWindow::widgetResized(const gcn::Event &event) +void DebugWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h index 83d6676da..aa7bdfe6c 100644 --- a/src/gui/windows/debugwindow.h +++ b/src/gui/windows/debugwindow.h @@ -151,7 +151,7 @@ class DebugWindow final : public Window void setPing(int pingTime); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; #ifdef USE_PROFILER void logicChildren(); diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index cb2fdec95..89b1eda26 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -99,7 +99,7 @@ DidYouKnowWindow::DidYouKnowWindow() : void DidYouKnowWindow::postInit() { - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } void DidYouKnowWindow::action(const ActionEvent &event) diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index 2d2fdbd26..5f3aa1bb1 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -214,7 +214,7 @@ void EmoteWindow::addListeners(ActionListener *const listener) mFontPage->addActionListener(listener); } -void EmoteWindow::widgetResized(const gcn::Event &event) +void EmoteWindow::widgetResized(const Event &event) { Window::widgetResized(event); const int pad2 = mPadding * 2; @@ -229,7 +229,7 @@ void EmoteWindow::widgetResized(const gcn::Event &event) mEmotePage->widgetResized(event); } -void EmoteWindow::widgetMoved(const gcn::Event &event) +void EmoteWindow::widgetMoved(const Event &event) { Window::widgetMoved(event); mEmotePage->widgetResized(event); diff --git a/src/gui/windows/emotewindow.h b/src/gui/windows/emotewindow.h index 2ddc64886..37a5c015f 100644 --- a/src/gui/windows/emotewindow.h +++ b/src/gui/windows/emotewindow.h @@ -61,9 +61,9 @@ class EmoteWindow final : public Window void addListeners(ActionListener *const listener); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; - void widgetMoved(const gcn::Event &event) override final; + void widgetMoved(const Event &event) override final; private: TabbedArea *mTabs; diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 53e82335e..9738378ea 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -87,7 +87,7 @@ HelpWindow::HelpWindow() : loadWindowState(); loadTags(); enableVisibleSound(true); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); } void HelpWindow::action(const ActionEvent &event) diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 509b085b5..2412b524b 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -295,7 +295,7 @@ void InventoryWindow::postInit() slotsChanged(mInventory); mItems->setSortType(mSortDropDown->getSelected()); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); if (!isMainInventory()) setVisible(true); } @@ -459,7 +459,7 @@ void InventoryWindow::unselectItem() mItems->selectNone(); } -void InventoryWindow::widgetHidden(const gcn::Event &event) +void InventoryWindow::widgetHidden(const Event &event) { Window::widgetHidden(event); mItems->hidePopup(); @@ -812,7 +812,7 @@ bool InventoryWindow::isAnyInputFocused() return false; } -void InventoryWindow::widgetResized(const gcn::Event &event) +void InventoryWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 4babbc264..cd5172c03 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -92,7 +92,7 @@ class InventoryWindow final : public Window, /** * Handles closing of the window */ - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; /** * Handles the mouse clicks. @@ -145,7 +145,7 @@ class InventoryWindow final : public Window, bool isInputFocused() const A_WARN_UNUSED; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void mouseMoved(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 710702f5e..a996d776b 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -149,7 +149,7 @@ void SetupWindow::postInit() center(); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); setInGame(false); enableVisibleSound(true); } @@ -260,7 +260,7 @@ void SetupWindow::setVisible(bool visible) Window::setVisible(visible); } -void SetupWindow::widgetResized(const gcn::Event &event) +void SetupWindow::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/setupwindow.h b/src/gui/windows/setupwindow.h index 27e44b243..38b3eb206 100644 --- a/src/gui/windows/setupwindow.h +++ b/src/gui/windows/setupwindow.h @@ -71,7 +71,7 @@ class SetupWindow final : public Window, void setVisible(bool visible) override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; private: void unloadModTab(); diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 96ec8c93c..7916ce8e4 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -176,7 +176,7 @@ int ShortcutWindow::getTabIndex() const return mTabs->getSelectedTabIndex(); } -void ShortcutWindow::widgetHidden(const gcn::Event &event) +void ShortcutWindow::widgetHidden(const Event &event) { if (mItems) mItems->widgetHidden(event); @@ -226,7 +226,7 @@ void ShortcutWindow::mouseDragged(gcn::MouseEvent &event) } } -void ShortcutWindow::widgetMoved(const gcn::Event& event) +void ShortcutWindow::widgetMoved(const Event& event) { Window::widgetMoved(event); if (mItems) diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h index f4c417c94..707a0a1d7 100644 --- a/src/gui/windows/shortcutwindow.h +++ b/src/gui/windows/shortcutwindow.h @@ -60,9 +60,9 @@ class ShortcutWindow final : public Window int getTabIndex() const A_WARN_UNUSED; - void widgetHidden(const gcn::Event &event) override final; + void widgetHidden(const Event &event) override final; - void widgetMoved(const gcn::Event& event) override final; + void widgetMoved(const Event& event) override final; void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 12c6e76d8..deeffb9a0 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -617,7 +617,7 @@ SkillInfo* SkillDialog::getSkillByItem(const int itemId) const return nullptr; } -void SkillDialog::widgetResized(const gcn::Event &event) +void SkillDialog::widgetResized(const Event &event) { Window::widgetResized(event); diff --git a/src/gui/windows/skilldialog.h b/src/gui/windows/skilldialog.h index 2bedef2b0..3bf64df9b 100644 --- a/src/gui/windows/skilldialog.h +++ b/src/gui/windows/skilldialog.h @@ -88,7 +88,7 @@ class SkillDialog final : public Window, bool hasSkills() const A_WARN_UNUSED { return !mSkills.empty(); } - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void useItem(const int itemId) const; diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 72590ab60..4df0ab6f1 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -1336,7 +1336,7 @@ void SocialWindow::postInit() place(0, 1, mCountLabel); place(0, 2, mTabs, 4, 4); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); loadWindowState(); @@ -1863,7 +1863,7 @@ void SocialWindow::updateParty() } } -void SocialWindow::widgetResized(const gcn::Event &event) +void SocialWindow::widgetResized(const Event &event) { Window::widgetResized(event); if (mTabs) diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index 08497c5c8..fc93aed4f 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -123,7 +123,7 @@ public: void updatePickupFilter(); - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; void setCounter(const SocialTab *const tab, const std::string &str); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 0d65eff35..201a5e11e 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -133,7 +133,7 @@ void WhoIsOnline::postInit() download(); - widgetResized(gcn::Event(nullptr)); + widgetResized(Event(nullptr)); config.addListener("updateOnlineList", this); config.addListener("groupFriends", this); mGroupFriends = config.getBoolValue("groupFriends"); @@ -715,7 +715,7 @@ void WhoIsOnline::action(const ActionEvent &event) } } -void WhoIsOnline::widgetResized(const gcn::Event &event) +void WhoIsOnline::widgetResized(const Event &event) { Window::widgetResized(event); updateSize(); diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index af0d14f7b..99eeb1911 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -136,7 +136,7 @@ public: void action(const ActionEvent &event) override final; - void widgetResized(const gcn::Event &event) override final; + void widgetResized(const Event &event) override final; const std::set &getOnlinePlayers() const A_WARN_UNUSED { return mOnlinePlayers; } diff --git a/src/listeners/deathlistener.h b/src/listeners/deathlistener.h index ad2eb5364..beefe1746 100644 --- a/src/listeners/deathlistener.h +++ b/src/listeners/deathlistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" /** * Interface for listening for death events from widgets. @@ -90,7 +90,7 @@ class DeathListener * * @param event The event of the death. */ - virtual void death(const gcn::Event &event) = 0; + virtual void death(const Event &event) = 0; protected: /** diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h index 1a6dd3fb2..c910f833e 100644 --- a/src/listeners/focuslistener.h +++ b/src/listeners/focuslistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" #include "localconsts.h" @@ -91,7 +91,7 @@ class FocusListener * * @param event Discribes the event. */ - virtual void focusGained(const gcn::Event &event A_UNUSED) + virtual void focusGained(const Event &event A_UNUSED) { } /** @@ -99,7 +99,7 @@ class FocusListener * * @param event Discribes the event. */ - virtual void focusLost(const gcn::Event &event A_UNUSED) + virtual void focusLost(const Event &event A_UNUSED) { } protected: diff --git a/src/listeners/widgetlistener.h b/src/listeners/widgetlistener.h index d7d348cd0..16d9e1f15 100644 --- a/src/listeners/widgetlistener.h +++ b/src/listeners/widgetlistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/event.hpp" +#include "events/event.h" #include "localconsts.h" @@ -94,7 +94,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetResized(const gcn::Event &event A_UNUSED) + virtual void widgetResized(const Event &event A_UNUSED) { } /** @@ -103,7 +103,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetMoved(const gcn::Event &event A_UNUSED) + virtual void widgetMoved(const Event &event A_UNUSED) { } /** @@ -113,7 +113,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetHidden(const gcn::Event &event A_UNUSED) + virtual void widgetHidden(const Event &event A_UNUSED) { } /** @@ -123,7 +123,7 @@ class WidgetListener * @param event Describes the event. * @since 0.8.0 */ - virtual void widgetShown(const gcn::Event &event A_UNUSED) + virtual void widgetShown(const Event &event A_UNUSED) { } protected: -- cgit v1.2.3-70-g09d2 From 9ca8495acdebb975a7b0777e11d7c599e61c0185 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 13:16:49 +0300 Subject: move inputevent into events directory. --- src/CMakeLists.txt | 3 +- src/Makefile.am | 3 +- src/events/inputguievent.h | 187 ++++++++++++++++++++++++++++++++++++++++++++ src/gui/base/inputevent.cpp | 117 --------------------------- src/gui/base/inputevent.hpp | 177 ----------------------------------------- src/gui/base/keyevent.cpp | 10 +-- src/gui/base/keyevent.hpp | 4 +- src/gui/base/mouseevent.cpp | 10 +-- src/gui/base/mouseevent.hpp | 4 +- 9 files changed, 203 insertions(+), 312 deletions(-) create mode 100644 src/events/inputguievent.h delete mode 100644 src/gui/base/inputevent.cpp delete mode 100644 src/gui/base/inputevent.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a79f5839..9c82f792b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -782,7 +782,7 @@ SET(SRCS gui/base/font.hpp gui/base/gui.hpp gui/base/input.hpp - gui/base/inputevent.hpp + events/inputguievent.h gui/base/key.hpp gui/base/keyevent.hpp gui/base/keyinput.hpp @@ -815,7 +815,6 @@ SET(SRCS gui/base/focushandler.cpp gui/base/font.cpp gui/base/gui.cpp - gui/base/inputevent.cpp gui/base/key.cpp gui/base/keyevent.cpp gui/base/keyinput.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 8a731c17f..94a671dfc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -168,7 +168,7 @@ manaplus_SOURCES += events/actionevent.h \ render/graphics.h \ gui/base/gui.hpp \ gui/base/input.hpp \ - gui/base/inputevent.hpp \ + events/inputguievent.h \ gui/base/key.hpp \ gui/base/keyevent.hpp \ gui/base/keyinput.hpp \ @@ -201,7 +201,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/focushandler.cpp \ gui/base/font.cpp \ gui/base/gui.cpp \ - gui/base/inputevent.cpp \ gui/base/key.cpp \ gui/base/keyevent.cpp \ gui/base/keyinput.cpp \ diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h new file mode 100644 index 000000000..a2aefc35f --- /dev/null +++ b/src/events/inputguievent.h @@ -0,0 +1,187 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 EVENTS_INPUTEVENT_HPP +#define EVENTS_INPUTEVENT_HPP + +#include "events/event.h" + +/** + * Base class for all events concerning input. + * + * @author Olof Naessén + * @since 0.6.0 + */ +class InputGuiEvent: public Event +{ + public: + /** + * Constructor. + * + * @param source The source widget of the event. + * @param isShiftPressed True if shift is pressed, false otherwise. + * @param isControlPressed True if control is pressed, false otherwise. + * @param isAltPressed True if alt is pressed, false otherwise. + * @param isMetaPressed True if meta is pressed, false otherwise. + */ + InputGuiEvent(gcn::Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed) : + Event(source), + mShiftPressed(shiftPressed), + mControlPressed(controlPressed), + mAltPressed(altPressed), + mMetaPressed(metaPressed), + mIsConsumed(false) + { } + + /** + * Checks if shift is pressed. + * + * @return True if shift was pressed at the same time as the key, + * false otherwise. + */ + bool isShiftPressed() const A_WARN_UNUSED + { return mShiftPressed; } + + /** + * Checks if control is pressed. + * + * @return True if control was pressed at the same time as the key, + * false otherwise. + */ + bool isControlPressed() const A_WARN_UNUSED + { return mControlPressed; } + + /** + * Checks if alt is pressed. + * + * @return True if alt was pressed at the same time as the key, + * false otherwise. + */ + bool isAltPressed() const A_WARN_UNUSED + { return mAltPressed; } + + /** + * Checks whether meta is pressed. + * + * @return True if meta was pressed at the same time as the key, + * false otherwise. + */ + bool isMetaPressed() const A_WARN_UNUSED + { return mMetaPressed; } + + /** + * Marks the event as consumed. Input event listeners may discard + * consumed input or act on consumed input. An example of a widget + * that discards consumed input is the ScrollArea widget that + * discards consumed mouse wheel events so the ScrollArea will not + * scroll if for instance a Slider's value inside the ScrollArea was + * changed with the mouse wheel. + * + * @see isConsumed + */ + void consume() + { mIsConsumed = true; } + + /** + * Checks if the input event is consumed. + * + * @return True if the input event is consumed, + * false otherwise. + * @see consume + */ + bool isConsumed() const A_WARN_UNUSED + { return mIsConsumed; } + + protected: + /** + * True if shift is pressed, false otherwise. + */ + bool mShiftPressed; + + /** + * True if control is pressed, false otherwise. + */ + bool mControlPressed; + + /** + * True if alt is pressed, false otherwise. + */ + bool mAltPressed; + + /** + * True if meta is pressed, false otherwise. + */ + bool mMetaPressed; + + /** + * True if the input event is consumed, + * false otherwise. + */ + bool mIsConsumed; +}; + +#endif // EVENTS_INPUTEVENT_HPP diff --git a/src/gui/base/inputevent.cpp b/src/gui/base/inputevent.cpp deleted file mode 100644 index 3251a102f..000000000 --- a/src/gui/base/inputevent.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/inputevent.hpp" - -#include "debug.h" - -namespace gcn -{ - InputEvent::InputEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed) - :Event(source), - mShiftPressed(shiftPressed), - mControlPressed(controlPressed), - mAltPressed(altPressed), - mMetaPressed(metaPressed), - mIsConsumed(false) - { - } - - bool InputEvent::isShiftPressed() const - { - return mShiftPressed; - } - - bool InputEvent::isControlPressed() const - { - return mControlPressed; - } - - bool InputEvent::isAltPressed() const - { - return mAltPressed; - } - - bool InputEvent::isMetaPressed() const - { - return mMetaPressed; - } - - void InputEvent::consume() - { - mIsConsumed = true; - } - - bool InputEvent::isConsumed() const - { - return mIsConsumed; - } -} // namespace gcn diff --git a/src/gui/base/inputevent.hpp b/src/gui/base/inputevent.hpp deleted file mode 100644 index fab68e2a4..000000000 --- a/src/gui/base/inputevent.hpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_INPUTEVENT_HPP -#define GCN_INPUTEVENT_HPP - -#include "events/event.h" - -namespace gcn -{ - /** - * Base class for all events concerning input. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class InputEvent: public Event - { - public: - /** - * Constructor. - * - * @param source The source widget of the event. - * @param isShiftPressed True if shift is pressed, false otherwise. - * @param isControlPressed True if control is pressed, false otherwise. - * @param isAltPressed True if alt is pressed, false otherwise. - * @param isMetaPressed True if meta is pressed, false otherwise. - */ - InputEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed); - - /** - * Checks if shift is pressed. - * - * @return True if shift was pressed at the same time as the key, - * false otherwise. - */ - bool isShiftPressed() const A_WARN_UNUSED; - - /** - * Checks if control is pressed. - * - * @return True if control was pressed at the same time as the key, - * false otherwise. - */ - bool isControlPressed() const A_WARN_UNUSED; - - /** - * Checks if alt is pressed. - * - * @return True if alt was pressed at the same time as the key, - * false otherwise. - */ - bool isAltPressed() const A_WARN_UNUSED; - - /** - * Checks whether meta is pressed. - * - * @return True if meta was pressed at the same time as the key, - * false otherwise. - */ - bool isMetaPressed() const A_WARN_UNUSED; - - /** - * Marks the event as consumed. Input event listeners may discard - * consumed input or act on consumed input. An example of a widget - * that discards consumed input is the ScrollArea widget that - * discards consumed mouse wheel events so the ScrollArea will not - * scroll if for instance a Slider's value inside the ScrollArea was - * changed with the mouse wheel. - * - * @see isConsumed - */ - void consume(); - - /** - * Checks if the input event is consumed. - * - * @return True if the input event is consumed, - * false otherwise. - * @see consume - */ - bool isConsumed() const A_WARN_UNUSED; - - protected: - /** - * True if shift is pressed, false otherwise. - */ - bool mShiftPressed; - - /** - * True if control is pressed, false otherwise. - */ - bool mControlPressed; - - /** - * True if alt is pressed, false otherwise. - */ - bool mAltPressed; - - /** - * True if meta is pressed, false otherwise. - */ - bool mMetaPressed; - - /** - * True if the input event is consumed, - * false otherwise. - */ - bool mIsConsumed; - }; -} // namespace gcn - -#endif // end GCN_INPUTEVENT_HPP diff --git a/src/gui/base/keyevent.cpp b/src/gui/base/keyevent.cpp index 35c4f06a5..d8d954bf3 100644 --- a/src/gui/base/keyevent.cpp +++ b/src/gui/base/keyevent.cpp @@ -79,11 +79,11 @@ namespace gcn const unsigned int type, const bool numericPad, const Key& key) : - InputEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), + InputGuiEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), mIsNumericPad(numericPad), mKey(key) diff --git a/src/gui/base/keyevent.hpp b/src/gui/base/keyevent.hpp index 4f2fa05a3..dd2b5f296 100644 --- a/src/gui/base/keyevent.hpp +++ b/src/gui/base/keyevent.hpp @@ -64,7 +64,7 @@ #ifndef GCN_KEYEVENT_HPP #define GCN_KEYEVENT_HPP -#include "gui/base/inputevent.hpp" +#include "events/inputguievent.h" #include "gui/base/key.hpp" namespace gcn @@ -74,7 +74,7 @@ namespace gcn /** * Represents a key event. */ - class KeyEvent: public InputEvent + class KeyEvent: public InputGuiEvent { public: /** diff --git a/src/gui/base/mouseevent.cpp b/src/gui/base/mouseevent.cpp index 653974a83..9577059cc 100644 --- a/src/gui/base/mouseevent.cpp +++ b/src/gui/base/mouseevent.cpp @@ -81,11 +81,11 @@ namespace gcn const int x, const int y, const int clickCount) : - InputEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), + InputGuiEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), mType(type), mButton(button), mX(x), diff --git a/src/gui/base/mouseevent.hpp b/src/gui/base/mouseevent.hpp index 93c1fc0a7..2853d01bf 100644 --- a/src/gui/base/mouseevent.hpp +++ b/src/gui/base/mouseevent.hpp @@ -64,7 +64,7 @@ #ifndef GCN_MOUSEEVENT_HPP #define GCN_MOUSEEVENT_HPP -#include "gui/base/inputevent.hpp" +#include "events/inputguievent.h" namespace gcn { @@ -77,7 +77,7 @@ namespace gcn * @author Olof Naessén * @since 0.6.0 */ - class MouseEvent: public InputEvent + class MouseEvent: public InputGuiEvent { public: /** -- cgit v1.2.3-70-g09d2 From 9e3f92a3914e28ce01331d7df7d03c31244a843b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 13:30:46 +0300 Subject: move keyevent into events directory. --- src/CMakeLists.txt | 5 +- src/Makefile.am | 3 - src/events/keyevent.h | 192 ++++++++++++++++++++++++++++++++++ src/gui/base/gui.hpp | 2 +- src/gui/base/keyevent.cpp | 111 -------------------- src/gui/base/keyevent.hpp | 157 --------------------------- src/gui/gui.cpp | 3 +- src/gui/widgets/button.cpp | 7 +- src/gui/widgets/button.h | 4 +- src/gui/widgets/checkbox.cpp | 5 +- src/gui/widgets/checkbox.h | 2 +- src/gui/widgets/dropdown.cpp | 5 +- src/gui/widgets/dropdown.h | 2 +- src/gui/widgets/guitable.cpp | 5 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/inttextfield.cpp | 5 +- src/gui/widgets/inttextfield.h | 2 +- src/gui/widgets/itemcontainer.cpp | 4 +- src/gui/widgets/itemcontainer.h | 4 +- src/gui/widgets/listbox.cpp | 5 +- src/gui/widgets/listbox.h | 2 +- src/gui/widgets/radiobutton.cpp | 5 +- src/gui/widgets/radiobutton.h | 2 +- src/gui/widgets/slider.cpp | 5 +- src/gui/widgets/slider.h | 2 +- src/gui/widgets/tabbedarea.cpp | 5 +- src/gui/widgets/tabbedarea.h | 2 +- src/gui/widgets/textbox.cpp | 5 +- src/gui/widgets/textbox.h | 2 +- src/gui/widgets/textfield.cpp | 4 +- src/gui/widgets/textfield.h | 2 +- src/gui/windows/charcreatedialog.cpp | 5 +- src/gui/windows/charcreatedialog.h | 2 +- src/gui/windows/charselectdialog.cpp | 5 +- src/gui/windows/charselectdialog.h | 2 +- src/gui/windows/chatwindow.cpp | 5 +- src/gui/windows/chatwindow.h | 2 +- src/gui/windows/editserverdialog.cpp | 5 +- src/gui/windows/editserverdialog.h | 2 +- src/gui/windows/inventorywindow.cpp | 7 +- src/gui/windows/inventorywindow.h | 4 +- src/gui/windows/itemamountwindow.cpp | 2 +- src/gui/windows/itemamountwindow.h | 2 +- src/gui/windows/logindialog.cpp | 5 +- src/gui/windows/logindialog.h | 2 +- src/gui/windows/quitdialog.cpp | 5 +- src/gui/windows/quitdialog.h | 2 +- src/gui/windows/registerdialog.cpp | 5 +- src/gui/windows/registerdialog.h | 2 +- src/gui/windows/serverdialog.cpp | 5 +- src/gui/windows/serverdialog.h | 2 +- src/gui/windows/updaterwindow.cpp | 5 +- src/gui/windows/updaterwindow.h | 2 +- src/gui/windows/worldselectdialog.cpp | 5 +- src/gui/windows/worldselectdialog.h | 2 +- src/input/keyevent.cpp | 47 --------- src/input/keyevent.h | 66 ------------ src/listeners/keylistener.h | 6 +- 58 files changed, 296 insertions(+), 469 deletions(-) create mode 100644 src/events/keyevent.h delete mode 100644 src/gui/base/keyevent.cpp delete mode 100644 src/gui/base/keyevent.hpp delete mode 100644 src/input/keyevent.cpp delete mode 100644 src/input/keyevent.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9c82f792b..1714b01c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -667,8 +667,6 @@ SET(SRCS input/keyboardconfig.h input/keyboarddata.h input/keydata.h - input/keyevent.cpp - input/keyevent.h input/keyinput.cpp input/keyinput.h input/multitouchmanager.cpp @@ -784,7 +782,7 @@ SET(SRCS gui/base/input.hpp events/inputguievent.h gui/base/key.hpp - gui/base/keyevent.hpp + events/keyevent.h gui/base/keyinput.hpp listeners/keylistener.h gui/base/listmodel.hpp @@ -816,7 +814,6 @@ SET(SRCS gui/base/font.cpp gui/base/gui.cpp gui/base/key.cpp - gui/base/keyevent.cpp gui/base/keyinput.cpp gui/base/mouseevent.cpp gui/base/mouseinput.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 94a671dfc..268344f2d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -202,7 +202,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/font.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ - gui/base/keyevent.cpp \ gui/base/keyinput.cpp \ gui/base/mouseevent.cpp \ gui/base/mouseinput.cpp \ @@ -787,8 +786,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ input/keyboardconfig.h \ input/keyboarddata.h \ input/keydata.h \ - input/keyevent.cpp \ - input/keyevent.h \ input/keyinput.cpp \ input/keyinput.h \ input/multitouchmanager.cpp \ diff --git a/src/events/keyevent.h b/src/events/keyevent.h new file mode 100644 index 000000000..ec5b5489a --- /dev/null +++ b/src/events/keyevent.h @@ -0,0 +1,192 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 EVENTS_KEYEVENT_HPP +#define EVENTS_KEYEVENT_HPP + +#include "events/inputguievent.h" +#include "gui/base/key.hpp" + +namespace gcn +{ + class Widget; +} + +/** + * Represents a key event. + */ +class KeyEvent: public InputGuiEvent +{ + public: + /** + * Key event types. + */ + enum + { + PRESSED = 0, + RELEASED + }; + + /** + * Constructor. + * + * @param source The source widget of the event. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. + * @param type The type of the event. A value from KeyEventType. + * @param numericPad True if the event occured on the numeric pad, + * false otherwise. + * @param key The key of the event. + */ + KeyEvent(gcn::Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const int actionId, + const gcn::Key &key) : + InputGuiEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), + mKey(key), +#ifdef USE_SDL2 + mText(), +#endif + mType(type), + mActionId(actionId), + mIsNumericPad(numericPad) + { } + + /** + * Destructor. + */ + virtual ~KeyEvent() + { } + + /** + * Gets the type of the event. + * + * @return The type of the event. + */ + unsigned int getType() const A_WARN_UNUSED + { return mType; } + + /** + * Checks if the key event occured on the numeric pad. + * + * @return True if key event occured on the numeric pad, + * false otherwise. + * + */ + bool isNumericPad() const A_WARN_UNUSED + { return mIsNumericPad; } + + /** + * Gets the key of the event. + * + * @return The key of the event. + */ + const gcn::Key &getKey() const A_WARN_UNUSED + { return mKey; } + + int getActionId() const A_WARN_UNUSED + { return mActionId; } + +#ifdef USE_SDL2 + void setText(const std::string &text) + { mText = text; } + + std::string getText() const + { return mText; } +#endif + + protected: + /** + * Holds the key of the key event. + */ + gcn::Key mKey; + +#ifdef USE_SDL2 + std::string mText; +#endif + + /** + * Holds the type of the key event. + */ + unsigned int mType; + + int mActionId; + + /** + * True if the numeric pad was used, false otherwise. + */ + bool mIsNumericPad; +}; + +#endif // EVENTS_KEYEVENT_HPP diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index b1d13dcd7..5198b066a 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -67,7 +67,7 @@ #include #include -#include "gui/base/keyevent.hpp" +#include "events/keyevent.h" #include "gui/base/mouseevent.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/keyevent.cpp b/src/gui/base/keyevent.cpp deleted file mode 100644 index d8d954bf3..000000000 --- a/src/gui/base/keyevent.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/keyevent.hpp" - -#include "debug.h" - -namespace gcn -{ - KeyEvent::KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const Key& key) : - InputGuiEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), - mType(type), - mIsNumericPad(numericPad), - mKey(key) - { - } - - KeyEvent::~KeyEvent() - { - } - - unsigned int KeyEvent::getType() const - { - return mType; - } - - bool KeyEvent::isNumericPad() const - { - return mIsNumericPad; - } - - const Key& KeyEvent::getKey() const - { - return mKey; - } -} // namespace gcn diff --git a/src/gui/base/keyevent.hpp b/src/gui/base/keyevent.hpp deleted file mode 100644 index dd2b5f296..000000000 --- a/src/gui/base/keyevent.hpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEYEVENT_HPP -#define GCN_KEYEVENT_HPP - -#include "events/inputguievent.h" -#include "gui/base/key.hpp" - -namespace gcn -{ - class Widget; - - /** - * Represents a key event. - */ - class KeyEvent: public InputGuiEvent - { - public: - /** - * Key event types. - */ - enum - { - PRESSED = 0, - RELEASED - }; - - /** - * Constructor. - * - * @param source The source widget of the event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. - * @param type The type of the event. A value from KeyEventType. - * @param numericPad True if the event occured on the numeric pad, - * false otherwise. - * @param key The key of the event. - */ - KeyEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const Key& key); - - /** - * Destructor. - */ - virtual ~KeyEvent(); - - /** - * Gets the type of the event. - * - * @return The type of the event. - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Checks if the key event occured on the numeric pad. - * - * @return True if key event occured on the numeric pad, - * false otherwise. - * - */ - bool isNumericPad() const A_WARN_UNUSED; - - /** - * Gets the key of the event. - * - * @return The key of the event. - */ - const Key& getKey() const A_WARN_UNUSED; - - protected: - /** - * Holds the type of the key event. - */ - unsigned int mType; - - /** - * True if the numeric pad was used, false otherwise. - */ - bool mIsNumericPad; - - /** - * Holds the key of the key event. - */ - Key mKey; - }; -} // namespace gcn - -#endif // end GCN_KEYEVENT_HPP diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 5d72c9dcb..7708183e5 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -39,8 +39,9 @@ #include "dragdrop.h" #include "touchmanager.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "input/keyinput.h" #include "resources/cursor.h" diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 5478d8164..10088d5f4 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "graphicsvertexes.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/imageset.h" @@ -589,7 +590,7 @@ void Button::setCaption(const std::string& caption) mCaption = caption; } -void Button::keyPressed(gcn::KeyEvent& keyEvent) +void Button::keyPressed(KeyEvent& keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); @@ -600,7 +601,7 @@ void Button::keyPressed(gcn::KeyEvent& keyEvent) } } -void Button::keyReleased(gcn::KeyEvent& keyEvent) +void Button::keyReleased(KeyEvent& keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 7fd7e4a9a..5dc89ea4d 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -144,9 +144,9 @@ class Button final : public gcn::Button, void setCaption(const std::string& caption); - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; - void keyReleased(gcn::KeyEvent &keyEvent) override final; + void keyReleased(KeyEvent &keyEvent) override final; bool isPressed2() const A_WARN_UNUSED; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 0721e29f6..2514f30d3 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/image.h" @@ -181,7 +182,7 @@ void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED) mHasMouse = false; } -void CheckBox::keyPressed(gcn::KeyEvent& keyEvent) +void CheckBox::keyPressed(KeyEvent& keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 8e5958c92..2d1502552 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -81,7 +81,7 @@ class CheckBox final : public gcn::CheckBox, */ void mouseExited(gcn::MouseEvent& event) override final; - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void adjustSize(); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index bbba0cd99..db3393b46 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/extendedlistmodel.h" #include "gui/widgets/popuplist.h" @@ -309,7 +310,7 @@ void DropDown::drawButton(Graphics *graphics) } } -void DropDown::keyPressed(gcn::KeyEvent& keyEvent) +void DropDown::keyPressed(KeyEvent& keyEvent) { if (keyEvent.isConsumed()) return; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index f3431459f..58942bdb5 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -89,7 +89,7 @@ class DropDown final : public ActionListener, // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; // Inherited from MouseListener diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index dcb5431d5..1d3dc0c55 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -24,7 +24,8 @@ #include "client.h" -#include "input/keyevent.h" +#include "events/keyevent.h" + #include "input/keydata.h" #include "utils/dtor.h" @@ -418,7 +419,7 @@ gcn::Rectangle GuiTable::getChildrenArea() } // -- KeyListener notifications -void GuiTable::keyPressed(gcn::KeyEvent& keyEvent) +void GuiTable::keyPressed(KeyEvent& keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index a751cac59..766f7a3de 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -125,7 +125,7 @@ public: void _setFocusHandler(gcn::FocusHandler* focusHandler) override final; // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; /** * Sets the table to be opaque, that is sets the table diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index e50bd232b..8e3713522 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -26,8 +26,9 @@ #include "gui/sdlinput.h" #endif +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "utils/stringutils.h" #include "debug.h" @@ -49,7 +50,7 @@ IntTextField::IntTextField(const Widget2 *const widget, const int def, setWidth(width); } -void IntTextField::keyPressed(gcn::KeyEvent &event) +void IntTextField::keyPressed(KeyEvent &event) { const int action = static_cast(&event)->getActionId(); diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index 3493cf52b..2e4e68083 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -68,7 +68,7 @@ class IntTextField final : public TextField /** * Responds to key presses. */ - void keyPressed(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; private: int mMin; /**< Minimum value */ diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 2c9e9b731..b2fa6a47e 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -386,11 +386,11 @@ void ItemContainer::hidePopup() mItemPopup->setVisible(false); } -void ItemContainer::keyPressed(gcn::KeyEvent &event A_UNUSED) +void ItemContainer::keyPressed(KeyEvent &event A_UNUSED) { } -void ItemContainer::keyReleased(gcn::KeyEvent &event A_UNUSED) +void ItemContainer::keyReleased(KeyEvent &event A_UNUSED) { } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index ecb7b658e..bc1bee695 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -85,8 +85,8 @@ class ItemContainer final : public gcn::Widget, void draw(Graphics *graphics) override final; // KeyListener - void keyPressed(gcn::KeyEvent &event) override final; - void keyReleased(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; + void keyReleased(KeyEvent &event) override final; // MouseListener void mousePressed(gcn::MouseEvent &event) override final; diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index e71907f37..bd685632f 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/gui.h" @@ -174,7 +175,7 @@ void ListBox::draw(Graphics *graphics) BLOCK_END("ListBox::draw") } -void ListBox::keyPressed(gcn::KeyEvent &keyEvent) +void ListBox::keyPressed(KeyEvent &keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT) diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 459aea2e3..883814456 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -67,7 +67,7 @@ class ListBox : public gcn::ListBox, // Inherited from KeyListener - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; // Inherited from MouseListener diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 092841dcf..75ea4819a 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/image.h" @@ -177,7 +178,7 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) mHasMouse = false; } -void RadioButton::keyPressed(gcn::KeyEvent& keyEvent) +void RadioButton::keyPressed(KeyEvent& keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); if (action == Input::KEY_GUI_SELECT) diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index ff6f5aafd..9802fb5fd 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -74,7 +74,7 @@ class RadioButton final : public gcn::RadioButton, */ void mouseExited(gcn::MouseEvent& event) override final; - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void updateAlpha(); diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 8eb27824d..4513ca167 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "graphicsvertexes.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "resources/image.h" @@ -340,7 +341,7 @@ void Slider::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) mouseEvent.consume(); } -void Slider::keyPressed(gcn::KeyEvent& keyEvent) +void Slider::keyPressed(KeyEvent& keyEvent) { const int action = static_cast(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index c59e0c47f..38c149560 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -85,7 +85,7 @@ class Slider final : public gcn::Slider, void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) override final; - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void setValue2(const double value); diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 2fe4f1332..bc41ba824 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -22,8 +22,9 @@ #include "gui/widgets/tabbedarea.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/button.h" #include "gui/widgets/scrollarea.h" @@ -683,7 +684,7 @@ void TabbedArea::setDimension(const gcn::Rectangle &dimension) adjustSize(); } -void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent) +void TabbedArea::keyPressed(KeyEvent& keyEvent) { if (mBlockSwitching || keyEvent.isConsumed() || !isFocused()) return; diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index d517c9a51..de470e89d 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -171,7 +171,7 @@ class TabbedArea final : public Widget2, bool getFollowDownScroll() const A_WARN_UNUSED { return mFollowDownScroll; } - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void setBlockSwitching(const bool b) { mBlockSwitching = b; } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 6bd301b32..8130469b7 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -22,8 +22,9 @@ #include "gui/widgets/textbox.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/base/font.hpp" @@ -165,7 +166,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) gcn::TextBox::setText(wrappedStream.str()); } -void TextBox::keyPressed(gcn::KeyEvent& keyEvent) +void TextBox::keyPressed(KeyEvent& keyEvent) { const gcn::Key &key = keyEvent.getKey(); const int action = static_cast(&keyEvent)->getActionId(); diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index d8841cfeb..6b0429483 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -60,7 +60,7 @@ class TextBox final : public gcn::TextBox, int getMinWidth() const A_WARN_UNUSED { return mMinWidth; } - void keyPressed(gcn::KeyEvent& keyEvent) override final; + void keyPressed(KeyEvent& keyEvent) override final; void draw(Graphics* graphics) override final; diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 58facecb8..81a69e472 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -26,7 +26,7 @@ #include "input/inputmanager.h" -#include "input/keyevent.h" +#include "events/keyevent.h" #include "gui/sdlinput.h" @@ -198,7 +198,7 @@ int TextField::getValue() const return value; } -void TextField::keyPressed(gcn::KeyEvent &keyEvent) +void TextField::keyPressed(KeyEvent &keyEvent) { const int val = keyEvent.getKey().getValue(); #ifdef USE_SDL2 diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 42f76985c..71285bd64 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -90,7 +90,7 @@ class TextField : public gcn::TextField, /** * Processes one keypress. */ - void keyPressed(gcn::KeyEvent &keyEvent) override; + void keyPressed(KeyEvent &keyEvent) override; /** * Set the minimum value for a range diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 23be4eacf..0d324439b 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -24,8 +24,9 @@ #include "main.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/okdialog.h" @@ -664,7 +665,7 @@ void CharCreateDialog::updatePlayer() } } -void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) +void CharCreateDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast(&keyEvent)->getActionId(); switch (actionId) diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index d98860566..123d826f2 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -76,7 +76,7 @@ class CharCreateDialog final : public Window, void updatePlayer(); - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: int getDistributedPoints() const A_WARN_UNUSED; diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 793315067..b18e6df5b 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -26,8 +26,9 @@ #include "configuration.h" #include "units.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/charcreatedialog.h" #include "gui/windows/confirmdialog.h" @@ -315,7 +316,7 @@ void CharSelectDialog::use(const int selected) } } -void CharSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) +void CharSelectDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast(&keyEvent)->getActionId(); switch (actionId) diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index e2b9c1ba8..348811ee3 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -63,7 +63,7 @@ class CharSelectDialog final : public Window, void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; enum SelectAction { diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 40b4b9400..11551b5cb 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -35,8 +35,9 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" +#include "events/keyevent.h" + #include "input/inputmanager.h" -#include "input/keyevent.h" #include "gui/sdlfont.h" #include "gui/sdlinput.h" @@ -836,7 +837,7 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) temp = str; \ break -void ChatWindow::keyPressed(gcn::KeyEvent &event) +void ChatWindow::keyPressed(KeyEvent &event) { const int key = event.getKey().getValue(); const int actionId = static_cast(&event)->getActionId(); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index f8458bd32..e664e63ce 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -169,7 +169,7 @@ class ChatWindow final : public Window, void localChatInput(const std::string &msg) const; /** Called when key is pressed */ - void keyPressed(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; /** Set the chat input as the given text. */ void setInputText(const std::string &text); diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index d8301f5ce..82c255863 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -21,8 +21,9 @@ #include "gui/windows/editserverdialog.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/okdialog.h" #include "gui/windows/serverdialog.h" @@ -284,7 +285,7 @@ void EditServerDialog::action(const ActionEvent &event) } } -void EditServerDialog::keyPressed(gcn::KeyEvent &keyEvent) +void EditServerDialog::keyPressed(KeyEvent &keyEvent) { if (keyEvent.isConsumed()) return; diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 55c200934..8907a2846 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -94,7 +94,7 @@ class EditServerDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: TextField *mServerAddressField; diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 2412b524b..24b5cdab3 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -28,8 +28,9 @@ #include "being/playerinfo.h" +#include "events/keyevent.h" + #include "input/inputmanager.h" -#include "input/keyevent.h" #include "gui/viewport.h" @@ -612,7 +613,7 @@ void InventoryWindow::mouseExited(gcn::MouseEvent &event A_UNUSED) mTextPopup->hide(); } -void InventoryWindow::keyPressed(gcn::KeyEvent &event) +void InventoryWindow::keyPressed(KeyEvent &event) { if (static_cast(&event)->getActionId() == static_cast(Input::KEY_GUI_MOD)) @@ -621,7 +622,7 @@ void InventoryWindow::keyPressed(gcn::KeyEvent &event) } } -void InventoryWindow::keyReleased(gcn::KeyEvent &event) +void InventoryWindow::keyReleased(KeyEvent &event) { if (static_cast(&event)->getActionId() == static_cast(Input::KEY_GUI_MOD)) diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index cd5172c03..03f64b562 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -102,12 +102,12 @@ class InventoryWindow final : public Window, /** * Handles the key presses. */ - void keyPressed(gcn::KeyEvent &event) override final; + void keyPressed(KeyEvent &event) override final; /** * Handles the key releases. */ - void keyReleased(gcn::KeyEvent &event) override final; + void keyReleased(KeyEvent &event) override final; /** * Updates labels to currently selected item. diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 40ca481b0..2158c4dd9 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -435,7 +435,7 @@ void ItemAmountWindow::close() scheduleDelete(); } -void ItemAmountWindow::keyReleased(gcn::KeyEvent &keyEvent A_UNUSED) +void ItemAmountWindow::keyReleased(KeyEvent &keyEvent A_UNUSED) { mItemAmountSlide->setValue2(mItemAmountTextField->getValue()); } diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index 46e20353e..76d53eeeb 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -82,7 +82,7 @@ class ItemAmountWindow final : public Window, */ void close(); - void keyReleased(gcn::KeyEvent &keyEvent) override final; + void keyReleased(KeyEvent &keyEvent) override final; /** * Creates the dialog, or bypass it if there aren't enough items. diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 44a19346f..f9988a0c3 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "configuration.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/confirmdialog.h" @@ -318,7 +319,7 @@ void LoginDialog::action(const ActionEvent &event) } } -void LoginDialog::keyPressed(gcn::KeyEvent &keyEvent) +void LoginDialog::keyPressed(KeyEvent &keyEvent) { if (keyEvent.isConsumed()) { diff --git a/src/gui/windows/logindialog.h b/src/gui/windows/logindialog.h index fee21f307..7150b62c1 100644 --- a/src/gui/windows/logindialog.h +++ b/src/gui/windows/logindialog.h @@ -71,7 +71,7 @@ class LoginDialog final : public Window, /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; void close() override final; diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index 2c264f232..c47fb1f0e 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -28,8 +28,9 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/viewport.h" @@ -202,7 +203,7 @@ void QuitDialog::action(const ActionEvent &event) scheduleDelete(); } -void QuitDialog::keyPressed(gcn::KeyEvent &keyEvent) +void QuitDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast(&keyEvent)->getActionId(); int dir = 0; diff --git a/src/gui/windows/quitdialog.h b/src/gui/windows/quitdialog.h index 5f0824ff4..8ce60d06c 100644 --- a/src/gui/windows/quitdialog.h +++ b/src/gui/windows/quitdialog.h @@ -64,7 +64,7 @@ class QuitDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: void placeOption(ContainerPlacer &placer, diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index a89b09d5b..530a33758 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/windows/okdialog.h" @@ -281,7 +282,7 @@ void RegisterDialog::action(const ActionEvent &event) } } -void RegisterDialog::keyPressed(gcn::KeyEvent &keyEvent) +void RegisterDialog::keyPressed(KeyEvent &keyEvent) { if (keyEvent.isConsumed()) { diff --git a/src/gui/windows/registerdialog.h b/src/gui/windows/registerdialog.h index 766f4b6b1..1d5b5e48b 100644 --- a/src/gui/windows/registerdialog.h +++ b/src/gui/windows/registerdialog.h @@ -87,7 +87,7 @@ class RegisterDialog final : public Window, /** * Called when a key is pressed in one of the text fields. */ - void keyPressed(gcn::KeyEvent &keyEvent) override; + void keyPressed(KeyEvent &keyEvent) override; void close() override; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 8d42d83e9..6d61b3eb2 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -27,8 +27,9 @@ #include "configuration.h" #include "main.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/sdlfont.h" @@ -444,7 +445,7 @@ void ServerDialog::action(const ActionEvent &event) } } -void ServerDialog::keyPressed(gcn::KeyEvent &keyEvent) +void ServerDialog::keyPressed(KeyEvent &keyEvent) { switch (static_cast(&keyEvent)->getActionId()) { diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 4e711d732..d14360b88 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -118,7 +118,7 @@ class ServerDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; /** * Called when the selected value changed in the servers list box. diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 9df4fdc57..12a5cb0c4 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -25,8 +25,9 @@ #include "client.h" #include "configuration.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -290,7 +291,7 @@ void UpdaterWindow::action(const ActionEvent &event) } } -void UpdaterWindow::keyPressed(gcn::KeyEvent &keyEvent) +void UpdaterWindow::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast(&keyEvent)->getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index 879a9eac3..ffd5b3103 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -121,7 +121,7 @@ class UpdaterWindow final : public Window, void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; void logic() override final; diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 5d81e249e..03545bcc4 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -24,8 +24,9 @@ #include "client.h" +#include "events/keyevent.h" + #include "input/keydata.h" -#include "input/keyevent.h" #include "gui/widgets/button.h" #include "gui/widgets/layout.h" @@ -153,7 +154,7 @@ void WorldSelectDialog::action(const ActionEvent &event) } } -void WorldSelectDialog::keyPressed(gcn::KeyEvent &keyEvent) +void WorldSelectDialog::keyPressed(KeyEvent &keyEvent) { const int actionId = static_cast( &keyEvent)->getActionId(); diff --git a/src/gui/windows/worldselectdialog.h b/src/gui/windows/worldselectdialog.h index 9315317bf..9d06ac25e 100644 --- a/src/gui/windows/worldselectdialog.h +++ b/src/gui/windows/worldselectdialog.h @@ -65,7 +65,7 @@ class WorldSelectDialog final : public Window, */ void action(const ActionEvent &event) override final; - void keyPressed(gcn::KeyEvent &keyEvent) override final; + void keyPressed(KeyEvent &keyEvent) override final; private: WorldListModel *mWorldListModel; diff --git a/src/input/keyevent.cpp b/src/input/keyevent.cpp deleted file mode 100644 index 5695cd99b..000000000 --- a/src/input/keyevent.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "input/keyevent.h" - -#include "debug.h" - -KeyEvent::KeyEvent(gcn::Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const int actionId, - const gcn::Key& key) : - gcn::KeyEvent(source, shiftPressed, controlPressed, altPressed, - metaPressed, type, numericPad, key), -#ifdef USE_SDL2 - mActionId(actionId), - mText() -#else - mActionId(actionId) -#endif -{ -} - -KeyEvent::~KeyEvent() -{ -} diff --git a/src/input/keyevent.h b/src/input/keyevent.h deleted file mode 100644 index 3637d720c..000000000 --- a/src/input/keyevent.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef INPUT_KEYEVENT_H -#define INPUT_KEYEVENT_H - -#include "gui/base/key.hpp" -#include "gui/base/keyevent.hpp" - -#include - -#include "localconsts.h" - -class KeyEvent final : public gcn::KeyEvent -{ - public: - KeyEvent(gcn::Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const int actionId, - const gcn::Key& key); - - A_DELETE_COPY(KeyEvent) - - ~KeyEvent(); - - int getActionId() const A_WARN_UNUSED - { return mActionId; } - -#ifdef USE_SDL2 - void setText(const std::string &text) - { mText = text; } - - std::string getText() const - { return mText; } -#endif - - protected: - int mActionId; -#ifdef USE_SDL2 - std::string mText; -#endif -}; - -#endif // INPUT_KEYEVENT_H diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h index e4cd42b67..2d4a74b9e 100644 --- a/src/listeners/keylistener.h +++ b/src/listeners/keylistener.h @@ -64,7 +64,7 @@ #ifndef GCN_KEYLISTENER_HPP #define GCN_KEYLISTENER_HPP -#include "gui/base/keyevent.hpp" +#include "events/keyevent.h" #include "localconsts.h" @@ -94,7 +94,7 @@ class KeyListener * * @param keyEvent Discribes the event. */ - virtual void keyPressed(gcn::KeyEvent &keyEvent A_UNUSED) + virtual void keyPressed(KeyEvent &keyEvent A_UNUSED) { } /** @@ -102,7 +102,7 @@ class KeyListener * * @param keyEvent Discribes the event. */ - virtual void keyReleased(gcn::KeyEvent &keyEvent A_UNUSED) + virtual void keyReleased(KeyEvent &keyEvent A_UNUSED) { } protected: -- cgit v1.2.3-70-g09d2 From f880384018ee23efdc5cc072789e176208956a06 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 13:56:14 +0300 Subject: Remove useless casts with KeyEvent. --- src/gui/widgets/button.cpp | 4 ++-- src/gui/widgets/checkbox.cpp | 2 +- src/gui/widgets/dropdown.cpp | 2 +- src/gui/widgets/guitable.cpp | 2 +- src/gui/widgets/inttextfield.cpp | 4 ++-- src/gui/widgets/listbox.cpp | 2 +- src/gui/widgets/radiobutton.cpp | 2 +- src/gui/widgets/slider.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 2 +- src/gui/widgets/textbox.cpp | 2 +- src/gui/widgets/textfield.cpp | 4 ++-- src/gui/windows/charcreatedialog.cpp | 2 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/editserverdialog.cpp | 3 +-- src/gui/windows/inventorywindow.cpp | 10 ++-------- src/gui/windows/logindialog.cpp | 3 +-- src/gui/windows/quitdialog.cpp | 2 +- src/gui/windows/registerdialog.cpp | 3 +-- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/updaterwindow.cpp | 2 +- src/gui/windows/worldselectdialog.cpp | 3 +-- 22 files changed, 26 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 10088d5f4..fecf551b2 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -592,7 +592,7 @@ void Button::setCaption(const std::string& caption) void Button::keyPressed(KeyEvent& keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (action == Input::KEY_GUI_SELECT) { @@ -603,7 +603,7 @@ void Button::keyPressed(KeyEvent& keyEvent) void Button::keyReleased(KeyEvent& keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (action == Input::KEY_GUI_SELECT && mKeyPressed) { diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 2514f30d3..20310c4bc 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -184,7 +184,7 @@ void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED) void CheckBox::keyPressed(KeyEvent& keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (action == Input::KEY_GUI_SELECT) { diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index db3393b46..9e3bca2fa 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -315,7 +315,7 @@ void DropDown::keyPressed(KeyEvent& keyEvent) if (keyEvent.isConsumed()) return; - const int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); switch (actionId) { case Input::KEY_GUI_SELECT: diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 1d3dc0c55..bca93e7c2 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -421,7 +421,7 @@ gcn::Rectangle GuiTable::getChildrenArea() // -- KeyListener notifications void GuiTable::keyPressed(KeyEvent& keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (action == Input::KEY_GUI_SELECT) { diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index 8e3713522..e693526f0 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -52,7 +52,7 @@ IntTextField::IntTextField(const Widget2 *const widget, const int def, void IntTextField::keyPressed(KeyEvent &event) { - const int action = static_cast(&event)->getActionId(); + const int action = event.getActionId(); if (action == Input::KEY_GUI_DELETE || action == Input::KEY_GUI_BACKSPACE) { @@ -68,7 +68,7 @@ void IntTextField::keyPressed(KeyEvent &event) if (val != Key::TEXTINPUT) return; - const std::string str = static_cast(&event)->getText(); + const std::string str = event->getText(); if (str.empty()) return; const size_t sz = str.size(); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index bd685632f..1e97b6e8a 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -177,7 +177,7 @@ void ListBox::draw(Graphics *graphics) void ListBox::keyPressed(KeyEvent &keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (action == Input::KEY_GUI_SELECT) { distributeActionEvent(); diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 75ea4819a..afcd98d67 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -180,7 +180,7 @@ void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) void RadioButton::keyPressed(KeyEvent& keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (action == Input::KEY_GUI_SELECT) { setSelected(true); diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 4513ca167..8cc454c10 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -343,7 +343,7 @@ void Slider::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) void Slider::keyPressed(KeyEvent& keyEvent) { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (getOrientation() == HORIZONTAL) { diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index bc41ba824..6a5febea6 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -689,7 +689,7 @@ void TabbedArea::keyPressed(KeyEvent& keyEvent) if (mBlockSwitching || keyEvent.isConsumed() || !isFocused()) return; - const int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); if (actionId == Input::KEY_GUI_LEFT) { diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 8130469b7..ecdc0e4d0 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -169,7 +169,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) void TextBox::keyPressed(KeyEvent& keyEvent) { const gcn::Key &key = keyEvent.getKey(); - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); switch (action) { diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 81a69e472..aa554b30f 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -204,7 +204,7 @@ void TextField::keyPressed(KeyEvent &keyEvent) #ifdef USE_SDL2 if (val == Key::TEXTINPUT) { - std::string str = static_cast(&keyEvent)->getText(); + std::string str = keyEvent->getText(); mText.insert(mCaretPosition, str); mCaretPosition += str.size(); keyEvent.consume(); @@ -293,7 +293,7 @@ void TextField::keyPressed(KeyEvent &keyEvent) } else { - const int action = static_cast(&keyEvent)->getActionId(); + const int action = keyEvent.getActionId(); if (!inputManager.isActionActive(static_cast( Input::KEY_GUI_CTRL))) { diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 0d324439b..a3fdcde3a 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -667,7 +667,7 @@ void CharCreateDialog::updatePlayer() void CharCreateDialog::keyPressed(KeyEvent &keyEvent) { - const int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); switch (actionId) { case Input::KEY_GUI_CANCEL: diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index b18e6df5b..7c6e387a4 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -318,7 +318,7 @@ void CharSelectDialog::use(const int selected) void CharSelectDialog::keyPressed(KeyEvent &keyEvent) { - const int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); switch (actionId) { case Input::KEY_GUI_CANCEL: diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 11551b5cb..1e71c50ae 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -840,7 +840,7 @@ void ChatWindow::mouseDragged(gcn::MouseEvent &event) void ChatWindow::keyPressed(KeyEvent &event) { const int key = event.getKey().getValue(); - const int actionId = static_cast(&event)->getActionId(); + const int actionId = event.getActionId(); if (actionId == static_cast(Input::KEY_GUI_DOWN)) { if (mCurHist != mHistory.end()) diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 82c255863..2286a9b36 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -290,8 +290,7 @@ void EditServerDialog::keyPressed(KeyEvent &keyEvent) if (keyEvent.isConsumed()) return; - const int actionId = static_cast( - &keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 24b5cdab3..a1eb83e7a 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -615,20 +615,14 @@ void InventoryWindow::mouseExited(gcn::MouseEvent &event A_UNUSED) void InventoryWindow::keyPressed(KeyEvent &event) { - if (static_cast(&event)->getActionId() - == static_cast(Input::KEY_GUI_MOD)) - { + if (event.getActionId() == static_cast(Input::KEY_GUI_MOD)) mSplit = true; - } } void InventoryWindow::keyReleased(KeyEvent &event) { - if (static_cast(&event)->getActionId() - == static_cast(Input::KEY_GUI_MOD)) - { + if (event.getActionId() == static_cast(Input::KEY_GUI_MOD)) mSplit = false; - } } void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED) diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index f9988a0c3..bfa20af62 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -327,8 +327,7 @@ void LoginDialog::keyPressed(KeyEvent &keyEvent) return; } - const int actionId = static_cast( - &keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { action(ActionEvent(nullptr, mServerButton->getActionEventId())); diff --git a/src/gui/windows/quitdialog.cpp b/src/gui/windows/quitdialog.cpp index c47fb1f0e..98aa70c70 100644 --- a/src/gui/windows/quitdialog.cpp +++ b/src/gui/windows/quitdialog.cpp @@ -205,7 +205,7 @@ void QuitDialog::action(const ActionEvent &event) void QuitDialog::keyPressed(KeyEvent &keyEvent) { - const int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); int dir = 0; switch (actionId) diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 530a33758..50344f223 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -289,8 +289,7 @@ void RegisterDialog::keyPressed(KeyEvent &keyEvent) mRegisterButton->setEnabled(canSubmit()); return; } - const int actionId = static_cast( - &keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { action(ActionEvent(nullptr, mCancelButton->getActionEventId())); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 6d61b3eb2..c4bd7c79f 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -447,7 +447,7 @@ void ServerDialog::action(const ActionEvent &event) void ServerDialog::keyPressed(KeyEvent &keyEvent) { - switch (static_cast(&keyEvent)->getActionId()) + switch (keyEvent.getActionId()) { case Input::KEY_GUI_CANCEL: keyEvent.consume(); diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 12a5cb0c4..109858a07 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -293,7 +293,7 @@ void UpdaterWindow::action(const ActionEvent &event) void UpdaterWindow::keyPressed(KeyEvent &keyEvent) { - const int actionId = static_cast(&keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { action(ActionEvent(nullptr, mCancelButton->getActionEventId())); diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 03545bcc4..0d861b85c 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -156,8 +156,7 @@ void WorldSelectDialog::action(const ActionEvent &event) void WorldSelectDialog::keyPressed(KeyEvent &keyEvent) { - const int actionId = static_cast( - &keyEvent)->getActionId(); + const int actionId = keyEvent.getActionId(); if (actionId == static_cast(Input::KEY_GUI_CANCEL)) { -- cgit v1.2.3-70-g09d2 From 8406b00588070266ae8af2bf25776f2fa716af69 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 14:22:57 +0300 Subject: move mouseevent into events directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/actionmanager.cpp | 2 +- src/gui/base/gui.hpp | 3 +- src/gui/base/mouseevent.cpp | 121 ---------------- src/gui/base/mouseevent.hpp | 217 ----------------------------- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/button.hpp | 3 +- src/gui/gui.cpp | 23 +-- src/gui/popups/itempopup.cpp | 2 +- src/gui/popups/itempopup.h | 2 +- src/gui/popups/popupmenu.cpp | 2 +- src/gui/popups/popupmenu.h | 2 +- src/gui/popups/spellpopup.cpp | 2 +- src/gui/popups/spellpopup.h | 2 +- src/gui/popups/textpopup.cpp | 2 +- src/gui/popups/textpopup.h | 2 +- src/gui/viewport.cpp | 20 +-- src/gui/viewport.h | 8 +- src/gui/widgets/avatarlistbox.cpp | 10 +- src/gui/widgets/avatarlistbox.h | 4 +- src/gui/widgets/browserbox.cpp | 4 +- src/gui/widgets/browserbox.h | 4 +- src/gui/widgets/button.cpp | 4 +- src/gui/widgets/button.h | 2 +- src/gui/widgets/characterdisplay.cpp | 6 +- src/gui/widgets/characterdisplay.h | 6 +- src/gui/widgets/checkbox.cpp | 4 +- src/gui/widgets/checkbox.h | 4 +- src/gui/widgets/dropdown.cpp | 16 +-- src/gui/widgets/dropdown.h | 10 +- src/gui/widgets/dropshortcutcontainer.cpp | 18 +-- src/gui/widgets/dropshortcutcontainer.h | 10 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 2 +- src/gui/widgets/emoteshortcutcontainer.cpp | 12 +- src/gui/widgets/emoteshortcutcontainer.h | 10 +- src/gui/widgets/guitable.cpp | 12 +- src/gui/widgets/guitable.h | 8 +- src/gui/widgets/itemcontainer.cpp | 12 +- src/gui/widgets/itemcontainer.h | 10 +- src/gui/widgets/itemlinkhandler.cpp | 3 +- src/gui/widgets/itemlinkhandler.h | 2 +- src/gui/widgets/itemshortcutcontainer.cpp | 18 +-- src/gui/widgets/itemshortcutcontainer.h | 10 +- src/gui/widgets/linkhandler.h | 2 +- src/gui/widgets/listbox.cpp | 16 +-- src/gui/widgets/listbox.h | 12 +- src/gui/widgets/mouseevent.h | 48 ------- src/gui/widgets/playerbox.cpp | 4 +- src/gui/widgets/playerbox.h | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 2 +- src/gui/widgets/popuplist.cpp | 4 +- src/gui/widgets/popuplist.h | 4 +- src/gui/widgets/radiobutton.cpp | 4 +- src/gui/widgets/radiobutton.h | 4 +- src/gui/widgets/scrollarea.cpp | 16 +-- src/gui/widgets/scrollarea.h | 12 +- src/gui/widgets/shoplistbox.cpp | 8 +- src/gui/widgets/shoplistbox.h | 6 +- src/gui/widgets/shortcutcontainer.h | 6 +- src/gui/widgets/slider.cpp | 14 +- src/gui/widgets/slider.h | 12 +- src/gui/widgets/sliderlist.cpp | 4 +- src/gui/widgets/sliderlist.h | 4 +- src/gui/widgets/spellshortcutcontainer.cpp | 22 +-- src/gui/widgets/spellshortcutcontainer.h | 10 +- src/gui/widgets/tabbedarea.cpp | 4 +- src/gui/widgets/tabbedarea.h | 2 +- src/gui/widgets/tabs/tab.cpp | 4 +- src/gui/widgets/tabs/tab.h | 4 +- src/gui/widgets/textfield.cpp | 4 +- src/gui/widgets/textfield.h | 2 +- src/gui/widgets/window.cpp | 22 +-- src/gui/widgets/window.h | 18 +-- src/gui/windowmenu.cpp | 8 +- src/gui/windowmenu.h | 6 +- src/gui/windows/chatwindow.cpp | 14 +- src/gui/windows/chatwindow.h | 10 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/didyouknowwindow.h | 2 +- src/gui/windows/equipmentwindow.cpp | 12 +- src/gui/windows/equipmentwindow.h | 8 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/helpwindow.h | 2 +- src/gui/windows/inventorywindow.cpp | 18 +-- src/gui/windows/inventorywindow.h | 6 +- src/gui/windows/itemamountwindow.cpp | 4 +- src/gui/windows/itemamountwindow.h | 4 +- src/gui/windows/minimap.cpp | 10 +- src/gui/windows/minimap.h | 6 +- src/gui/windows/ministatuswindow.cpp | 8 +- src/gui/windows/ministatuswindow.h | 6 +- src/gui/windows/npcdialog.cpp | 4 +- src/gui/windows/npcdialog.h | 2 +- src/gui/windows/outfitwindow.cpp | 12 +- src/gui/windows/outfitwindow.h | 6 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 2 +- src/gui/windows/shortcutwindow.cpp | 6 +- src/gui/windows/shortcutwindow.h | 4 +- src/gui/windows/skilldialog.cpp | 16 +-- src/gui/windows/socialwindow.cpp | 2 +- src/gui/windows/updaterwindow.cpp | 2 +- src/gui/windows/updaterwindow.h | 2 +- src/gui/windows/whoisonline.cpp | 6 +- src/gui/windows/whoisonline.h | 2 +- src/listeners/mouselistener.h | 20 +-- 109 files changed, 367 insertions(+), 754 deletions(-) delete mode 100644 src/gui/base/mouseevent.cpp delete mode 100644 src/gui/base/mouseevent.hpp delete mode 100644 src/gui/widgets/mouseevent.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1714b01c5..e3bf7ae5c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -176,7 +176,6 @@ SET(SRCS gui/widgets/linkhandler.h gui/widgets/listbox.cpp gui/widgets/listbox.h - gui/widgets/mouseevent.h gui/widgets/namesmodel.cpp gui/widgets/namesmodel.h gui/widgets/passwordfield.cpp @@ -786,7 +785,7 @@ SET(SRCS gui/base/keyinput.hpp listeners/keylistener.h gui/base/listmodel.hpp - gui/base/mouseevent.hpp + events/mouseevent.h gui/base/mouseinput.hpp listeners/mouselistener.h gui/base/rectangle.hpp @@ -815,7 +814,6 @@ SET(SRCS gui/base/gui.cpp gui/base/key.cpp gui/base/keyinput.cpp - gui/base/mouseevent.cpp gui/base/mouseinput.cpp gui/base/rectangle.cpp gui/base/selectionevent.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 268344f2d..3b199ba44 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -174,7 +174,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/keyinput.hpp \ listeners/keylistener.h \ gui/base/listmodel.hpp \ - gui/base/mouseevent.hpp \ + events/mouseevent.h \ gui/base/mouseinput.hpp \ listeners/mouselistener.h \ gui/base/rectangle.hpp \ @@ -203,7 +203,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/gui.cpp \ gui/base/key.cpp \ gui/base/keyinput.cpp \ - gui/base/mouseevent.cpp \ gui/base/mouseinput.cpp \ gui/base/rectangle.cpp \ gui/base/selectionevent.cpp \ @@ -293,7 +292,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/linkhandler.h \ gui/widgets/listbox.cpp \ gui/widgets/listbox.h \ - gui/widgets/mouseevent.h \ gui/widgets/namesmodel.cpp \ gui/widgets/namesmodel.h \ gui/widgets/passwordfield.cpp \ diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 4b6d80981..5b02e4aba 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -219,7 +219,7 @@ impHandler0(mouseClick) int mouseX, mouseY; Gui::getMouseState(&mouseX, &mouseY); - guiInput->simulateMouseClick(mouseX, mouseY, gcn::MouseEvent::RIGHT); + guiInput->simulateMouseClick(mouseX, mouseY, MouseEvent::RIGHT); return true; } diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 5198b066a..b853a4210 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -68,7 +68,8 @@ #include #include "events/keyevent.h" -#include "gui/base/mouseevent.hpp" +#include "events/mouseevent.h" + #include "gui/base/mouseinput.hpp" class Graphics; diff --git a/src/gui/base/mouseevent.cpp b/src/gui/base/mouseevent.cpp deleted file mode 100644 index 9577059cc..000000000 --- a/src/gui/base/mouseevent.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/mouseevent.hpp" - -#include "debug.h" - -namespace gcn -{ - MouseEvent::MouseEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const unsigned int button, - const int x, - const int y, - const int clickCount) : - InputGuiEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), - mType(type), - mButton(button), - mX(x), - mY(y), - mClickCount(clickCount) - { - } - - unsigned int MouseEvent::getButton() const - { - return mButton; - } - - int MouseEvent::getX() const - { - return mX; - } - - int MouseEvent::getY() const - { - return mY; - } - - int MouseEvent::getClickCount() const - { - return mClickCount; - } - - unsigned int MouseEvent::getType() const - { - return mType; - } -} // namespace gcn diff --git a/src/gui/base/mouseevent.hpp b/src/gui/base/mouseevent.hpp deleted file mode 100644 index 2853d01bf..000000000 --- a/src/gui/base/mouseevent.hpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_MOUSEEVENT_HPP -#define GCN_MOUSEEVENT_HPP - -#include "events/inputguievent.h" - -namespace gcn -{ - class Gui; - class Widget; - - /** - * Represents a mouse event. - * - * @author Olof Naessén - * @since 0.6.0 - */ - class MouseEvent: public InputGuiEvent - { - public: - /** - * Constructor. - * - * @param source The source widget of the mouse event. - * @param shiftPressed True if shift is pressed, false otherwise. - * @param controlPressed True if control is pressed, false otherwise. - * @param altPressed True if alt is pressed, false otherwise. - * @param metaPressed True if meta is pressed, false otherwise. - * @param type The type of the mouse event. - * @param button The button of the mouse event. - * @param x The x coordinate of the event relative to the source widget. - * @param y The y coordinate of the event relative the source widget. - * @param clickCount The number of clicks generated with the same button. - * It's set to zero if another button is used. - */ - MouseEvent(Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const unsigned int button, - const int x, - const int y, - const int clickCount); - - /** - * Gets the button of the mouse event. - * - * @return The button of the mouse event. - */ - unsigned int getButton() const A_WARN_UNUSED; - - /** - * Gets the x coordinate of the mouse event. - * The coordinate relative to widget the mouse listener - * receiving the events have registered to. - * - * @return The x coordinate of the mouse event. - * @see Widget::addMouseListener, Widget::removeMouseListener - */ - int getX() const A_WARN_UNUSED; - - /** - * Gets the y coordinate of the mouse event. - * The coordinate relative to widget the mouse listener - * receiving the events have registered to. - * - * @return The y coordinate of the mouse event. - * @see Widget::addMouseListener, Widget::removeMouseListener - */ - int getY() const A_WARN_UNUSED; - - /** - * Gets the number of clicks generated with the same button. - * It's set to zero if another button is used. - * - * @return The number of clicks generated with the same button. - */ - int getClickCount() const A_WARN_UNUSED; - - /** - * Gets the type of the event. - * - * @return The type of the event. - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Mouse event types. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP, - CLICKED, - ENTERED, - EXITED, - DRAGGED - }; - - /** - * Mouse button types. - */ - enum - { - EMPTY = 0, - LEFT, - RIGHT, - MIDDLE - }; - - protected: - /** - * Holds the type of the mouse event. - */ - unsigned int mType; - - /** - * Holds the button of the mouse event. - */ - unsigned int mButton; - - /** - * Holds the x-coordinate of the mouse event. - */ - int mX; - - /** - * Holds the y-coordinate of the mouse event. - */ - int mY; - - /** - * The number of clicks generated with the same button. - * It's set to zero if another button is used. - */ - int mClickCount; - - /** - * Gui is a friend of this class in order to be able to manipulate - * the protected member variables of this class and at the same time - * keep the MouseEvent class as const as possible. Gui needs to - * update the x och y coordinates for the coordinates to be relative - * to widget the mouse listener receiving the events have registered - * to. - */ - friend class Gui; - }; -} // namespace gcn - -#endif // GCN_MOUSEEVENT_HPP diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 7f1aea668..8cf49da4b 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -70,9 +70,10 @@ #include "gui/base/exception.hpp" #include "gui/base/font.hpp" #include "gui/base/key.hpp" -#include "gui/base/mouseevent.hpp" #include "gui/base/mouseinput.hpp" +#include "events/mouseevent.h" + #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index c81fec14f..6fee7f3b3 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -70,7 +70,8 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/mouseevent.hpp" +#include "events/mouseevent.h" + #include "gui/base/widget.hpp" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 7708183e5..649e547d7 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -31,7 +31,8 @@ #include "gui/theme.h" #include "gui/viewport.h" -#include "gui/widgets/mouseevent.h" +#include "events/mouseevent.h" + #include "gui/widgets/window.h" #include "client.h" @@ -708,32 +709,32 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, { switch (mouseEvent.getType()) { - case gcn::MouseEvent::ENTERED: + case MouseEvent::ENTERED: (*it)->mouseEntered(mouseEvent); break; - case gcn::MouseEvent::EXITED: + case MouseEvent::EXITED: (*it)->mouseExited(mouseEvent); break; - case gcn::MouseEvent::MOVED: + case MouseEvent::MOVED: (*it)->mouseMoved(mouseEvent); break; - case gcn::MouseEvent::PRESSED: + case MouseEvent::PRESSED: (*it)->mousePressed(mouseEvent); break; - case gcn::MouseEvent::RELEASED: + case MouseEvent::RELEASED: case 100: // manual hack for release on target after drag (*it)->mouseReleased(mouseEvent); break; - case gcn::MouseEvent::WHEEL_MOVED_UP: + case MouseEvent::WHEEL_MOVED_UP: (*it)->mouseWheelMovedUp(mouseEvent); break; - case gcn::MouseEvent::WHEEL_MOVED_DOWN: + case MouseEvent::WHEEL_MOVED_DOWN: (*it)->mouseWheelMovedDown(mouseEvent); break; - case gcn::MouseEvent::DRAGGED: + case MouseEvent::DRAGGED: (*it)->mouseDragged(mouseEvent); break; - case gcn::MouseEvent::CLICKED: + case MouseEvent::CLICKED: (*it)->mouseClicked(mouseEvent); break; default: @@ -749,7 +750,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, widget = parent; parent = swap->getParent(); - if (type == gcn::MouseEvent::RELEASED) + if (type == MouseEvent::RELEASED) dragDrop.clear(); // If a non modal focused widget has been reach diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index 07c950706..f7939b666 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -265,7 +265,7 @@ void ItemPopup::setLabelColor(Label *label, const ItemType type) const } #undef caseSetColor -void ItemPopup::mouseMoved(gcn::MouseEvent &event) +void ItemPopup::mouseMoved(MouseEvent &event) { Popup::mouseMoved(event); diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h index ac4683938..714e0305c 100644 --- a/src/gui/popups/itempopup.h +++ b/src/gui/popups/itempopup.h @@ -60,7 +60,7 @@ class ItemPopup final : public Popup void setItem(const Item *const item, const bool showImage = false); - void mouseMoved(gcn::MouseEvent &mouseEvent) override final; + void mouseMoved(MouseEvent &mouseEvent) override final; private: Label *mItemName; diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 197a9f716..45551d165 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -839,7 +839,7 @@ void PopupMenu::showChangePos(const int x, const int y) } void PopupMenu::handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) + MouseEvent *event A_UNUSED) { Being *being = nullptr; if (actorManager) diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 235c809ba..1ebb0dd89 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -187,7 +187,7 @@ class PopupMenu final : public Popup, public LinkHandler * Handles link action. */ void handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) override final; + MouseEvent *event A_UNUSED) override final; void clear(); diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index df25739f2..cc55fef57 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -109,7 +109,7 @@ void SpellPopup::view(const int x, const int y) requestMoveToTop(); } -void SpellPopup::mouseMoved(gcn::MouseEvent &event) +void SpellPopup::mouseMoved(MouseEvent &event) { Popup::mouseMoved(event); diff --git a/src/gui/popups/spellpopup.h b/src/gui/popups/spellpopup.h index c8123a4ce..152dfb306 100644 --- a/src/gui/popups/spellpopup.h +++ b/src/gui/popups/spellpopup.h @@ -60,7 +60,7 @@ class SpellPopup final : public Popup */ void view(const int x, const int y); - void mouseMoved(gcn::MouseEvent &mouseEvent) override final; + void mouseMoved(MouseEvent &mouseEvent) override final; private: Label *mItemName; diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 14f31f84f..245bf58b0 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -100,7 +100,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1, requestMoveToTop(); } -void TextPopup::mouseMoved(gcn::MouseEvent &event) +void TextPopup::mouseMoved(MouseEvent &event) { Popup::mouseMoved(event); diff --git a/src/gui/popups/textpopup.h b/src/gui/popups/textpopup.h index 131921b7b..eb29cba61 100644 --- a/src/gui/popups/textpopup.h +++ b/src/gui/popups/textpopup.h @@ -72,7 +72,7 @@ class TextPopup final : public Popup void show(const int x, const int y, const std::string &str1, const std::string &str2, const std::string &str3); - void mouseMoved(gcn::MouseEvent &mouseEvent) override final; + void mouseMoved(MouseEvent &mouseEvent) override final; private: Label *mText[TEXTPOPUPCOUNT]; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index b3cafa104..c3da988b7 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -280,13 +280,13 @@ void Viewport::_followMouse() if (mPlayerFollowMouse && (button & SDL_BUTTON(1))) { // We create a mouse event and send it to mouseDragged. - gcn::MouseEvent mouseEvent(nullptr, + MouseEvent mouseEvent(nullptr, 0, false, false, false, - gcn::MouseEvent::DRAGGED, - gcn::MouseEvent::LEFT, + MouseEvent::DRAGGED, + MouseEvent::LEFT, mMouseX, mMouseY, 0); @@ -385,7 +385,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, #endif } -void Viewport::mousePressed(gcn::MouseEvent &event) +void Viewport::mousePressed(MouseEvent &event) { if (event.getSource() != this) return; @@ -406,7 +406,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) const int pixelY = eventY + mPixelViewY; // Right click might open a popup - if (eventButton == gcn::MouseEvent::RIGHT) + if (eventButton == MouseEvent::RIGHT) { mPlayerFollowMouse = false; if (mHoverBeing) @@ -460,7 +460,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) } // Left click can cause different actions - if (eventButton == gcn::MouseEvent::LEFT) + if (eventButton == MouseEvent::LEFT) { // Interact with some being if (mHoverBeing) @@ -532,7 +532,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) _followMouse(); } } - else if (eventButton == gcn::MouseEvent::MIDDLE) + else if (eventButton == MouseEvent::MIDDLE) { mPlayerFollowMouse = false; validateSpeed(); @@ -548,7 +548,7 @@ void Viewport::mousePressed(gcn::MouseEvent &event) } } -void Viewport::mouseDragged(gcn::MouseEvent &event) +void Viewport::mouseDragged(MouseEvent &event) { if (!mMap || !player_node) return; @@ -685,7 +685,7 @@ void Viewport::mouseDragged(gcn::MouseEvent &event) } } -void Viewport::mouseReleased(gcn::MouseEvent &event A_UNUSED) +void Viewport::mouseReleased(MouseEvent &event A_UNUSED) { mPlayerFollowMouse = false; // Only useful for eAthena but doesn't hurt under ManaServ @@ -838,7 +838,7 @@ void Viewport::optionChanged(const std::string &name) mMouseDirectionMove = config.getBoolValue("mouseDirectionMove"); } -void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED) +void Viewport::mouseMoved(MouseEvent &event A_UNUSED) { // Check if we are on the map if (!mMap || !player_node || !actorManager) diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 6fd062c35..2b297de37 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -103,22 +103,22 @@ class Viewport final : public WindowContainer, /** * Handles mouse press on map. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; /** * Handles mouse move on map */ - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; /** * Handles mouse button release on map. */ - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; /** * Handles mouse move on map. */ - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; /** * Shows a popup for an item. diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 9a1aa40ab..8e4d9e483 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -310,7 +310,7 @@ void AvatarListBox::draw(Graphics *graphics) BLOCK_END("AvatarListBox::draw") } -void AvatarListBox::mousePressed(gcn::MouseEvent &event) +void AvatarListBox::mousePressed(MouseEvent &event) { if (!actorManager || !player_node || !viewport || !getFont()->getHeight()) @@ -334,7 +334,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) return; const unsigned int eventButton = event.getButton(); - if (eventButton == gcn::MouseEvent::LEFT) + if (eventButton == MouseEvent::LEFT) { if (ava->getType() == AVATAR_PLAYER) { @@ -348,7 +348,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) player_node->navigateTo(ava->getX(), ava->getY()); } } - else if (eventButton == gcn::MouseEvent::RIGHT) + else if (eventButton == MouseEvent::RIGHT) { switch (ava->getType()) { @@ -407,7 +407,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } } } - else if (eventButton == gcn::MouseEvent::MIDDLE) + else if (eventButton == MouseEvent::MIDDLE) { if (ava->getType() == AVATAR_PLAYER && chatWindow) { @@ -419,7 +419,7 @@ void AvatarListBox::mousePressed(gcn::MouseEvent &event) } } -void AvatarListBox::mouseReleased(gcn::MouseEvent &event A_UNUSED) +void AvatarListBox::mouseReleased(MouseEvent &event A_UNUSED) { } diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index ec384368c..d0449231b 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -55,9 +55,9 @@ public: */ void draw(Graphics *gcnGraphics) override final; - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; - void mouseReleased(gcn::MouseEvent &event A_UNUSED) override final; + void mouseReleased(MouseEvent &event A_UNUSED) override final; void optionChanged(const std::string &value) override final; diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index cfbc0ec41..c158171c0 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -423,7 +423,7 @@ struct MouseOverLink int mX, mY; }; -void BrowserBox::mousePressed(gcn::MouseEvent &event) +void BrowserBox::mousePressed(MouseEvent &event) { if (!mLinkHandler) return; @@ -438,7 +438,7 @@ void BrowserBox::mousePressed(gcn::MouseEvent &event) } } -void BrowserBox::mouseMoved(gcn::MouseEvent &event) +void BrowserBox::mouseMoved(MouseEvent &event) { const LinkIterator i = std::find_if(mLinks.begin(), mLinks.end(), MouseOverLink(event.getX(), event.getY())); diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index fa3b90963..f1c1aa1f6 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -158,9 +158,9 @@ class BrowserBox final : public gcn::Widget, /** * Handles mouse actions. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; /** * Draws the browser box. diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index fecf551b2..8bc3d7540 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -525,9 +525,9 @@ void Button::draw(Graphics *graphics) BLOCK_END("Button::draw") } -void Button::mouseReleased(gcn::MouseEvent& mouseEvent) +void Button::mouseReleased(MouseEvent& mouseEvent) { - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) + if (mouseEvent.getButton() == MouseEvent::LEFT) { if (mStick) mPressed = !mPressed; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 5dc89ea4d..a9722f6a2 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -109,7 +109,7 @@ class Button final : public gcn::Button, */ static void updateAlpha(); - void mouseReleased(gcn::MouseEvent& mouseEvent) override final; + void mouseReleased(MouseEvent& mouseEvent) override final; void setDescription(std::string text) { mDescription = text; } diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index 3f4a672f0..bdd740874 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -115,12 +115,12 @@ void CharacterDisplay::widgetHidden(const Event &event A_UNUSED) mPopup->setVisible(false); } -void CharacterDisplay::mouseExited(gcn::MouseEvent &event A_UNUSED) +void CharacterDisplay::mouseExited(MouseEvent &event A_UNUSED) { mPopup->setVisible(false); } -void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED) +void CharacterDisplay::mouseMoved(MouseEvent &event A_UNUSED) { if (!gui) return; @@ -142,7 +142,7 @@ void CharacterDisplay::mouseMoved(gcn::MouseEvent &event A_UNUSED) } } -void CharacterDisplay::mousePressed(gcn::MouseEvent &event) +void CharacterDisplay::mousePressed(MouseEvent &event) { if (event.getClickCount() == 2) distributeActionEvent(); diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index 84a288ab0..8571363c3 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -75,11 +75,11 @@ class CharacterDisplay final : public Container, void widgetHidden(const Event &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; private: void update(); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 20310c4bc..9b67b0359 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -172,12 +172,12 @@ void CheckBox::drawBox(Graphics *const graphics) } } -void CheckBox::mouseEntered(gcn::MouseEvent& event A_UNUSED) +void CheckBox::mouseEntered(MouseEvent& event A_UNUSED) { mHasMouse = true; } -void CheckBox::mouseExited(gcn::MouseEvent& event A_UNUSED) +void CheckBox::mouseExited(MouseEvent& event A_UNUSED) { mHasMouse = false; } diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 2d1502552..3b0830cee 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -74,12 +74,12 @@ class CheckBox final : public gcn::CheckBox, /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event) override final; + void mouseEntered(MouseEvent& event) override final; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event) override final; + void mouseExited(MouseEvent& event) override final; void keyPressed(KeyEvent& keyEvent) override final; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 9e3bca2fa..aca82cef4 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -357,10 +357,10 @@ void DropDown::hideDrop(bool event) mPopup->setVisible(false); } -void DropDown::mousePressed(gcn::MouseEvent& mouseEvent) +void DropDown::mousePressed(MouseEvent& mouseEvent) { // If we have a mouse press on the widget. - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT + if (mouseEvent.getButton() == MouseEvent::LEFT && !mDroppedDown && mouseEvent.getSource() == this) { mPushed = true; @@ -374,7 +374,7 @@ void DropDown::mousePressed(gcn::MouseEvent& mouseEvent) } } -void DropDown::mouseReleased(gcn::MouseEvent &mouseEvent) +void DropDown::mouseReleased(MouseEvent &mouseEvent) { if (mIsDragged) mPushed = false; @@ -385,12 +385,12 @@ void DropDown::mouseReleased(gcn::MouseEvent &mouseEvent) // Released outside of widget. Can happen when we have modal // input focus. if ((0 > y || y >= mDimension.height || x < 0 || x >= mDimension.width) - && button == gcn::MouseEvent::LEFT) + && button == MouseEvent::LEFT) { if (mIsDragged) foldUp(); } - else if (button == gcn::MouseEvent::LEFT) + else if (button == MouseEvent::LEFT) { mPushed = false; } @@ -398,19 +398,19 @@ void DropDown::mouseReleased(gcn::MouseEvent &mouseEvent) mIsDragged = false; } -void DropDown::mouseDragged(gcn::MouseEvent &mouseEvent) +void DropDown::mouseDragged(MouseEvent &mouseEvent) { mIsDragged = true; mouseEvent.consume(); } -void DropDown::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) +void DropDown::mouseWheelMovedUp(MouseEvent& mouseEvent) { setSelected(getSelected() - 1); mouseEvent.consume(); } -void DropDown::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) +void DropDown::mouseWheelMovedDown(MouseEvent& mouseEvent) { setSelected(getSelected() + 1); mouseEvent.consume(); diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 58942bdb5..dd38a1730 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -93,15 +93,15 @@ class DropDown final : public ActionListener, // Inherited from MouseListener - void mousePressed(gcn::MouseEvent& mouseEvent) override final; + void mousePressed(MouseEvent& mouseEvent) override final; - void mouseReleased(gcn::MouseEvent& mouseEvent) override final; + void mouseReleased(MouseEvent& mouseEvent) override final; - void mouseDragged(gcn::MouseEvent& mouseEvent) override final; + void mouseDragged(MouseEvent& mouseEvent) override final; - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedUp(MouseEvent& mouseEvent) override final; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedDown(MouseEvent& mouseEvent) override final; void setSelectedString(const std::string &str); diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 4b991bc34..693245c2f 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -157,12 +157,12 @@ void DropShortcutContainer::draw(Graphics *graphics) BLOCK_END("DropShortcutContainer::draw") } -void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event) +void DropShortcutContainer::mouseDragged(MouseEvent &event) { if (!dropShortcut) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (dragDrop.isEmpty() && mItemClicked) { @@ -196,7 +196,7 @@ void DropShortcutContainer::mouseDragged(gcn::MouseEvent &event) } } -void DropShortcutContainer::mousePressed(gcn::MouseEvent &event) +void DropShortcutContainer::mousePressed(MouseEvent &event) { if (!dropShortcut || !inventoryWindow) return; @@ -207,7 +207,7 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event) return; const int eventButton = event.getButton(); - if (eventButton == gcn::MouseEvent::LEFT) + if (eventButton == MouseEvent::LEFT) { if (dropShortcut->getItem(index) > 0) { @@ -223,7 +223,7 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event) } } } - else if (eventButton == gcn::MouseEvent::RIGHT) + else if (eventButton == MouseEvent::RIGHT) { const Inventory *const inv = PlayerInfo::getInventory(); if (!inv) @@ -237,12 +237,12 @@ void DropShortcutContainer::mousePressed(gcn::MouseEvent &event) } } -void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event) +void DropShortcutContainer::mouseReleased(MouseEvent &event) { if (!dropShortcut) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (dropShortcut->isItemSelected()) dropShortcut->setItemSelected(-1); @@ -269,7 +269,7 @@ void DropShortcutContainer::mouseReleased(gcn::MouseEvent &event) } // Show ItemTooltip -void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event) +void DropShortcutContainer::mouseMoved(MouseEvent &event) { if (!dropShortcut) return; @@ -302,7 +302,7 @@ void DropShortcutContainer::mouseMoved(gcn::MouseEvent &event) } } -void DropShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) +void DropShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 26cbdffa7..9880f526d 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -55,23 +55,23 @@ class DropShortcutContainer final : public ShortcutContainer /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; void widgetHidden(const Event &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; void setWidget2(const Widget2 *const widget) override final; diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index e255afc30..6456913a9 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -116,7 +116,7 @@ void EmotePage::draw(Graphics *graphics) BLOCK_END("EmotePage::draw") } -void EmotePage::mousePressed(gcn::MouseEvent &mouseEvent) +void EmotePage::mousePressed(MouseEvent &mouseEvent) { mSelectedIndex = getIndexFromGrid(mouseEvent.getX(), mouseEvent.getY()); distributeActionEvent(); diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index cb6fd8711..74f93e8d3 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -44,7 +44,7 @@ class EmotePage final : public gcn::Widget, void draw(Graphics *graphics) override final; - void mousePressed(gcn::MouseEvent &mouseEvent) override final; + void mousePressed(MouseEvent &mouseEvent) override final; int getIndexFromGrid(const int x, const int y) const; diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index d00f01495..38c76060b 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -148,11 +148,11 @@ void EmoteShortcutContainer::draw(Graphics *graphics) BLOCK_END("EmoteShortcutContainer::draw") } -void EmoteShortcutContainer::mouseDragged(gcn::MouseEvent &event A_UNUSED) +void EmoteShortcutContainer::mouseDragged(MouseEvent &event A_UNUSED) { } -void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event) +void EmoteShortcutContainer::mousePressed(MouseEvent &event) { if (!emoteShortcut) return; @@ -174,12 +174,12 @@ void EmoteShortcutContainer::mousePressed(gcn::MouseEvent &event) } } -void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event) +void EmoteShortcutContainer::mouseReleased(MouseEvent &event) { if (!emoteShortcut) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { const int index = getIndexFromGrid(event.getX(), event.getY()); @@ -206,7 +206,7 @@ void EmoteShortcutContainer::mouseReleased(gcn::MouseEvent &event) } } -void EmoteShortcutContainer::mouseMoved(gcn::MouseEvent &event) +void EmoteShortcutContainer::mouseMoved(MouseEvent &event) { if (!emoteShortcut || !mEmotePopup) return; @@ -226,7 +226,7 @@ void EmoteShortcutContainer::mouseMoved(gcn::MouseEvent &event) } } -void EmoteShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) +void EmoteShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (mEmotePopup) mEmotePopup->setVisible(false); diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index 37ebe0cf9..ed6b4c8b3 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -58,21 +58,21 @@ class EmoteShortcutContainer final : public ShortcutContainer /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; void widgetHidden(const Event &event) override final; diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index bca93e7c2..5873ef4ce 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -463,12 +463,12 @@ void GuiTable::keyPressed(KeyEvent& keyEvent) } // -- MouseListener notifications -void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) +void GuiTable::mousePressed(MouseEvent& mouseEvent) { if (!mModel || !mSelectable) return; - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) + if (mouseEvent.getButton() == MouseEvent::LEFT) { const int row = getRowForY(mouseEvent.getY()); const int column = getColumnForX(mouseEvent.getX()); @@ -484,7 +484,7 @@ void GuiTable::mousePressed(gcn::MouseEvent& mouseEvent) } } -void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) +void GuiTable::mouseWheelMovedUp(MouseEvent& mouseEvent) { if (isFocused()) { @@ -495,7 +495,7 @@ void GuiTable::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) } } -void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) +void GuiTable::mouseWheelMovedDown(MouseEvent& mouseEvent) { if (isFocused()) { @@ -504,9 +504,9 @@ void GuiTable::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) } } -void GuiTable::mouseDragged(gcn::MouseEvent& mouseEvent) +void GuiTable::mouseDragged(MouseEvent& mouseEvent) { - if (mouseEvent.getButton() != gcn::MouseEvent::LEFT) + if (mouseEvent.getButton() != MouseEvent::LEFT) return; // Make table selection update on drag diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 766f7a3de..da367dd94 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -146,13 +146,13 @@ public: { return mOpaque; } // Inherited from MouseListener - void mousePressed(gcn::MouseEvent& mouseEvent) override final; + void mousePressed(MouseEvent& mouseEvent) override final; - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedUp(MouseEvent& mouseEvent) override final; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedDown(MouseEvent& mouseEvent) override final; - void mouseDragged(gcn::MouseEvent& mouseEvent) override final; + void mouseDragged(MouseEvent& mouseEvent) override final; // Constraints inherited from TableModelListener void modelUpdated(const bool completed) override final; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index b2fa6a47e..27a00798e 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -394,7 +394,7 @@ void ItemContainer::keyReleased(KeyEvent &event A_UNUSED) { } -void ItemContainer::mousePressed(gcn::MouseEvent &event) +void ItemContainer::mousePressed(MouseEvent &event) { if (!mInventory) return; @@ -402,7 +402,7 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event) const int button = event.getButton(); mClicks = event.getClickCount(); - if (button == gcn::MouseEvent::LEFT || button == gcn::MouseEvent::RIGHT) + if (button == MouseEvent::LEFT || button == MouseEvent::RIGHT) { const int index = getSlotIndex(event.getX(), event.getY()); if (index == Inventory::NO_SLOT_INDEX) @@ -468,13 +468,13 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event) } } -void ItemContainer::mouseDragged(gcn::MouseEvent &event A_UNUSED) +void ItemContainer::mouseDragged(MouseEvent &event A_UNUSED) { if (mSelectionStatus != SEL_NONE) mSelectionStatus = SEL_DRAGGING; } -void ItemContainer::mouseReleased(gcn::MouseEvent &event) +void ItemContainer::mouseReleased(MouseEvent &event) { if (mClicks == 2) return; @@ -594,7 +594,7 @@ void ItemContainer::mouseReleased(gcn::MouseEvent &event) } } -void ItemContainer::mouseMoved(gcn::MouseEvent &event) +void ItemContainer::mouseMoved(MouseEvent &event) { if (!mInventory) return; @@ -613,7 +613,7 @@ void ItemContainer::mouseMoved(gcn::MouseEvent &event) } } -void ItemContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) +void ItemContainer::mouseExited(MouseEvent &event A_UNUSED) { mItemPopup->setVisible(false); } diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index bc1bee695..4f530320d 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -89,11 +89,11 @@ class ItemContainer final : public gcn::Widget, void keyReleased(KeyEvent &event) override final; // MouseListener - void mousePressed(gcn::MouseEvent &event) override final; - void mouseDragged(gcn::MouseEvent &event) override final; - void mouseReleased(gcn::MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; // WidgetListener void widgetResized(const Event &event) override final; diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 108444bb0..deb3b4451 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -75,8 +75,7 @@ ItemLinkHandler::~ItemLinkHandler() mItemPopup = nullptr; } -void ItemLinkHandler::handleLink(const std::string &link, - gcn::MouseEvent *event) +void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) { if (strStartWith(link, "http://") || strStartWith(link, "https://")) { diff --git a/src/gui/widgets/itemlinkhandler.h b/src/gui/widgets/itemlinkhandler.h index 4e55a8f72..39e811721 100644 --- a/src/gui/widgets/itemlinkhandler.h +++ b/src/gui/widgets/itemlinkhandler.h @@ -39,7 +39,7 @@ class ItemLinkHandler final : public LinkHandler ~ItemLinkHandler(); void handleLink(const std::string &link, - gcn::MouseEvent *event) override final; + MouseEvent *event) override final; private: ItemPopup *mItemPopup; diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index ef4d8ebfa..984803a99 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -233,13 +233,13 @@ void ItemShortcutContainer::draw(Graphics *graphics) BLOCK_END("ItemShortcutContainer::draw") } -void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) +void ItemShortcutContainer::mouseDragged(MouseEvent &event) { ItemShortcut *const selShortcut = itemShortcut[mNumber]; if (!selShortcut) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (dragDrop.isEmpty() && mItemClicked) { @@ -321,7 +321,7 @@ void ItemShortcutContainer::mouseDragged(gcn::MouseEvent &event) } } -void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) +void ItemShortcutContainer::mousePressed(MouseEvent &event) { ItemShortcut *const selShortcut = itemShortcut[mNumber]; if (!selShortcut) @@ -332,7 +332,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) if (index == -1) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { // Stores the selected item if theirs one. if (selShortcut->isItemSelected() && inventoryWindow && @@ -350,7 +350,7 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) mItemClicked = true; } } - else if (event.getButton() == gcn::MouseEvent::RIGHT) + else if (event.getButton() == MouseEvent::RIGHT) { if (viewport && selShortcut) { @@ -360,13 +360,13 @@ void ItemShortcutContainer::mousePressed(gcn::MouseEvent &event) } } -void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) +void ItemShortcutContainer::mouseReleased(MouseEvent &event) { ItemShortcut *const selShortcut = itemShortcut[mNumber]; if (!selShortcut) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (selShortcut->isItemSelected()) selShortcut->setItemSelected(-1); @@ -402,7 +402,7 @@ void ItemShortcutContainer::mouseReleased(gcn::MouseEvent &event) } } -void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) +void ItemShortcutContainer::mouseMoved(MouseEvent &event) { const ItemShortcut *const selShortcut = itemShortcut[mNumber]; if (!selShortcut) @@ -459,7 +459,7 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event) } // Hide ItemTooltip -void ItemShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) +void ItemShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index 5efda0433..f01c2779c 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -56,23 +56,23 @@ class ItemShortcutContainer final : public ShortcutContainer /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; void widgetHidden(const Event &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; void setWidget2(const Widget2 *const widget); diff --git a/src/gui/widgets/linkhandler.h b/src/gui/widgets/linkhandler.h index 2f3a6e53f..b373162a3 100644 --- a/src/gui/widgets/linkhandler.h +++ b/src/gui/widgets/linkhandler.h @@ -38,7 +38,7 @@ class LinkHandler { } virtual void handleLink(const std::string &link, - gcn::MouseEvent *event) = 0; + MouseEvent *event) = 0; }; #endif // GUI_WIDGETS_LINKHANDLER_H diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 1e97b6e8a..52ff775be 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -214,20 +214,20 @@ void ListBox::keyPressed(KeyEvent &keyEvent) // Don't do anything on scrollwheel. ScrollArea will deal with that. -void ListBox::mouseWheelMovedUp(gcn::MouseEvent &mouseEvent A_UNUSED) +void ListBox::mouseWheelMovedUp(MouseEvent &mouseEvent A_UNUSED) { } -void ListBox::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED) +void ListBox::mouseWheelMovedDown(MouseEvent &mouseEvent A_UNUSED) { } -void ListBox::mousePressed(gcn::MouseEvent &event) +void ListBox::mousePressed(MouseEvent &event) { mPressedIndex = getSelectionByMouse(event.getY()); } -void ListBox::mouseReleased(gcn::MouseEvent &event) +void ListBox::mouseReleased(MouseEvent &event) { if (mPressedIndex != getSelectionByMouse(event.getY())) return; @@ -262,18 +262,18 @@ void ListBox::mouseReleased(gcn::MouseEvent &event) mPressedIndex = -2; } -void ListBox::mouseReleased1(const gcn::MouseEvent &mouseEvent) +void ListBox::mouseReleased1(const MouseEvent &mouseEvent) { - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) + if (mouseEvent.getButton() == MouseEvent::LEFT) { setSelected(std::max(0, getSelectionByMouse(mouseEvent.getY()))); distributeActionEvent(); } } -void ListBox::mouseDragged(gcn::MouseEvent &event) +void ListBox::mouseDragged(MouseEvent &event) { - if (event.getButton() != gcn::MouseEvent::LEFT || getRowHeight() == 0) + if (event.getButton() != MouseEvent::LEFT || getRowHeight() == 0) return; // Make list selection update on drag, but guard against negative y diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 883814456..adf266f7e 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -71,17 +71,17 @@ class ListBox : public gcn::ListBox, // Inherited from MouseListener - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedUp(MouseEvent& mouseEvent) override final; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedDown(MouseEvent& mouseEvent) override final; - void mousePressed(gcn::MouseEvent &event) override; + void mousePressed(MouseEvent &event) override; - void mouseReleased(gcn::MouseEvent &event) override; + void mouseReleased(MouseEvent &event) override; - void mouseReleased1(const gcn::MouseEvent &event); + void mouseReleased1(const MouseEvent &event); - void mouseDragged(gcn::MouseEvent &event) override; + void mouseDragged(MouseEvent &event) override; void refocus(); diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h deleted file mode 100644 index d98a70130..000000000 --- a/src/gui/widgets/mouseevent.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_MOUSEEVENT_H -#define GUI_WIDGETS_MOUSEEVENT_H - -#include "gui/base/mouseevent.hpp" -#include "gui/base/widget.hpp" - -class MouseEvent final : public gcn::MouseEvent -{ - public: - MouseEvent(gcn::Widget* source, bool shiftPressed, - bool controlPressed, bool altPressed, - bool metaPressed, unsigned int type, unsigned int button, - int x, int y, int clickCount) : - gcn::MouseEvent(source, shiftPressed, controlPressed, - altPressed, metaPressed, type, button, x, y, - clickCount) - { - } - - void setX(int n) - { mX = n; } - - void setY(int n) - { mY = n; } -}; - -#endif // GUI_WIDGETS_MOUSEEVENT_H diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 0639fe1b0..3bcb8476e 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -147,10 +147,10 @@ void PlayerBox::drawFrame(Graphics *graphics) BLOCK_END("PlayerBox::drawFrame") } -void PlayerBox::mouseReleased(gcn::MouseEvent& event) +void PlayerBox::mouseReleased(MouseEvent& event) { ScrollArea::mouseReleased(event); - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (!mActionEventId.empty()) distributeActionEvent(); diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 9671715b0..30d79ff2f 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -84,7 +84,7 @@ class PlayerBox final : public Widget2, void setSelected(bool b) { mSelected = b; } - void mouseReleased(gcn::MouseEvent& event) override final; + void mouseReleased(MouseEvent& event) override final; private: Being *mBeing; diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 7036968ad..a61ba5275 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -231,7 +231,7 @@ void Popup::position(const int x, const int y) mRedraw = true; } -void Popup::mouseMoved(gcn::MouseEvent &event A_UNUSED) +void Popup::mouseMoved(MouseEvent &event A_UNUSED) { if (viewport) viewport->hideBeingPopup(); diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index e467783ef..d64bc4b3f 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -88,7 +88,7 @@ class Popup : public Container, */ void setLocationRelativeTo(const gcn::Widget *const widget); - void mouseMoved(gcn::MouseEvent &event) override; + void mouseMoved(MouseEvent &event) override; /** * Sets the minimum width of the popup. diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index 37dd6b1ec..62bc2f448 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -129,13 +129,13 @@ void PopupList::adjustSize() mListBox->setWidth(width); } -void PopupList::mousePressed(gcn::MouseEvent& mouseEvent) +void PopupList::mousePressed(MouseEvent& mouseEvent) { mPressedIndex = mListBox->getSelectionByMouse( mouseEvent.getY() + mPadding); } -void PopupList::mouseReleased(gcn::MouseEvent& mouseEvent) +void PopupList::mouseReleased(MouseEvent& mouseEvent) { if (mPressedIndex != mListBox->getSelectionByMouse( mouseEvent.getY() + mPadding)) diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index 31308fff8..45f52d3b3 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -66,9 +66,9 @@ class PopupList final : public Popup, void focusLost(const Event& event A_UNUSED) override final; - void mousePressed(gcn::MouseEvent& mouseEvent) override final; + void mousePressed(MouseEvent& mouseEvent) override final; - void mouseReleased(gcn::MouseEvent& mouseEvent) override final; + void mouseReleased(MouseEvent& mouseEvent) override final; private: gcn::ListModel *mListModel; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index afcd98d67..2fec7a9f6 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -168,12 +168,12 @@ void RadioButton::draw(Graphics* graphics) BLOCK_END("RadioButton::draw") } -void RadioButton::mouseEntered(gcn::MouseEvent& event A_UNUSED) +void RadioButton::mouseEntered(MouseEvent& event A_UNUSED) { mHasMouse = true; } -void RadioButton::mouseExited(gcn::MouseEvent& event A_UNUSED) +void RadioButton::mouseExited(MouseEvent& event A_UNUSED) { mHasMouse = false; } diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 9802fb5fd..6c33447c4 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -67,12 +67,12 @@ class RadioButton final : public gcn::RadioButton, /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event) override final; + void mouseEntered(MouseEvent& event) override final; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event) override final; + void mouseExited(MouseEvent& event) override final; void keyPressed(KeyEvent& keyEvent) override final; diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 73ff82be0..0ee2c3357 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -651,18 +651,18 @@ void ScrollArea::calcHMarker(Graphics *const graphics) } } -void ScrollArea::mouseMoved(gcn::MouseEvent& event) +void ScrollArea::mouseMoved(MouseEvent& event) { mX = event.getX(); mY = event.getY(); } -void ScrollArea::mouseEntered(gcn::MouseEvent& event A_UNUSED) +void ScrollArea::mouseEntered(MouseEvent& event A_UNUSED) { mHasMouse = true; } -void ScrollArea::mouseExited(gcn::MouseEvent& event A_UNUSED) +void ScrollArea::mouseExited(MouseEvent& event A_UNUSED) { mHasMouse = false; } @@ -684,7 +684,7 @@ void ScrollArea::widgetMoved(const Event& event A_UNUSED) mRedraw = true; } -void ScrollArea::mousePressed(gcn::MouseEvent& event) +void ScrollArea::mousePressed(MouseEvent& event) { const int x = event.getX(); const int y = event.getY(); @@ -754,16 +754,16 @@ void ScrollArea::mousePressed(gcn::MouseEvent& event) } } - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { mClickX = event.getX(); mClickY = event.getY(); } } -void ScrollArea::mouseReleased(gcn::MouseEvent& event) +void ScrollArea::mouseReleased(MouseEvent& event) { - if (event.getButton() == gcn::MouseEvent::LEFT && mClickX && mClickY) + if (event.getButton() == MouseEvent::LEFT && mClickX && mClickY) { if (!event.isConsumed()) { @@ -822,7 +822,7 @@ void ScrollArea::mouseReleased(gcn::MouseEvent& event) mRedraw = true; } -void ScrollArea::mouseDragged(gcn::MouseEvent &event) +void ScrollArea::mouseDragged(MouseEvent &event) { if (mIsVerticalMarkerDragged) { diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 7bf7e811c..3f6195271 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -106,23 +106,23 @@ class ScrollArea final : public gcn::ScrollArea, /** * Called when the mouse moves in the widget area. */ - void mouseMoved(gcn::MouseEvent& event) override final; + void mouseMoved(MouseEvent& event) override final; /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event) override final; + void mouseEntered(MouseEvent& event) override final; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event) override final; + void mouseExited(MouseEvent& event) override final; - void mousePressed(gcn::MouseEvent& event) override final; + void mousePressed(MouseEvent& event) override final; - void mouseReleased(gcn::MouseEvent& event) override final; + void mouseReleased(MouseEvent& event) override final; - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; void widgetResized(const Event &event) override final; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 8f45abeb3..f364aaf46 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -189,7 +189,7 @@ void ShopListBox::setPriceCheck(const bool check) mPriceCheck = check; } -void ShopListBox::mouseMoved(gcn::MouseEvent &event) +void ShopListBox::mouseMoved(MouseEvent &event) { if (!mItemPopup || !mRowHeight) return; @@ -221,10 +221,10 @@ void ShopListBox::mouseMoved(gcn::MouseEvent &event) } } -void ShopListBox::mouseReleased(gcn::MouseEvent& mouseEvent) +void ShopListBox::mouseReleased(MouseEvent& mouseEvent) { ListBox::mouseReleased(mouseEvent); - if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) + if (mouseEvent.getButton() == MouseEvent::RIGHT) { setSelected(std::max(0, getSelectionByMouse(mouseEvent.getY()))); @@ -236,7 +236,7 @@ void ShopListBox::mouseReleased(gcn::MouseEvent& mouseEvent) } } -void ShopListBox::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) +void ShopListBox::mouseExited(MouseEvent& mouseEvent A_UNUSED) { if (!mItemPopup) return; diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 509af8393..1cf628cca 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -74,11 +74,11 @@ class ShopListBox final : public ListBox */ void setPriceCheck(const bool check); - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseReleased(gcn::MouseEvent& mouseEvent) override final; + void mouseReleased(MouseEvent& mouseEvent) override final; - void mouseExited(gcn::MouseEvent& mouseEvent) override final; + void mouseExited(MouseEvent& mouseEvent) override final; void setProtectItems(bool p) { mProtectItems = p; } diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 2c237f513..e7ec2ff62 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -66,21 +66,21 @@ class ShortcutContainer : public gcn::Widget, /** * Handles mouse when dragged. */ - virtual void mouseDragged(gcn::MouseEvent &event A_UNUSED) override + virtual void mouseDragged(MouseEvent &event A_UNUSED) override { } /** * Handles mouse when pressed. */ - virtual void mousePressed(gcn::MouseEvent &event A_UNUSED) override + virtual void mousePressed(MouseEvent &event A_UNUSED) override { } /** * Handles mouse release. */ - virtual void mouseReleased(gcn::MouseEvent &event A_UNUSED) override + virtual void mouseReleased(MouseEvent &event A_UNUSED) override { } diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 8cc454c10..02ebc2ccb 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -272,21 +272,21 @@ void Slider::draw(Graphics *graphics) BLOCK_END("Slider::draw") } -void Slider::mouseEntered(gcn::MouseEvent& event A_UNUSED) +void Slider::mouseEntered(MouseEvent& event A_UNUSED) { mHasMouse = true; mRedraw = true; } -void Slider::mouseExited(gcn::MouseEvent& event A_UNUSED) +void Slider::mouseExited(MouseEvent& event A_UNUSED) { mHasMouse = false; mRedraw = true; } -void Slider::mousePressed(gcn::MouseEvent &mouseEvent) +void Slider::mousePressed(MouseEvent &mouseEvent) { - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT + if (mouseEvent.getButton() == MouseEvent::LEFT && mouseEvent.getX() >= 0 && mouseEvent.getX() <= getWidth() && mouseEvent.getY() >= 0 @@ -307,7 +307,7 @@ void Slider::mousePressed(gcn::MouseEvent &mouseEvent) } } -void Slider::mouseDragged(gcn::MouseEvent &mouseEvent) +void Slider::mouseDragged(MouseEvent &mouseEvent) { if (getOrientation() == HORIZONTAL) { @@ -325,7 +325,7 @@ void Slider::mouseDragged(gcn::MouseEvent &mouseEvent) mouseEvent.consume(); } -void Slider::mouseWheelMovedUp(gcn::MouseEvent &mouseEvent) +void Slider::mouseWheelMovedUp(MouseEvent &mouseEvent) { setValue2(getValue() + getStepLength()); distributeActionEvent(); @@ -333,7 +333,7 @@ void Slider::mouseWheelMovedUp(gcn::MouseEvent &mouseEvent) mouseEvent.consume(); } -void Slider::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) +void Slider::mouseWheelMovedDown(MouseEvent &mouseEvent) { setValue2(getValue() - getStepLength()); distributeActionEvent(); diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 38c149560..2d4853539 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -70,20 +70,20 @@ class Slider final : public gcn::Slider, /** * Called when the mouse enteres the widget area. */ - void mouseEntered(gcn::MouseEvent& event) override final; + void mouseEntered(MouseEvent& event) override final; /** * Called when the mouse leaves the widget area. */ - void mouseExited(gcn::MouseEvent& event) override final; + void mouseExited(MouseEvent& event) override final; - void mousePressed(gcn::MouseEvent &mouseEvent) override final; + void mousePressed(MouseEvent &mouseEvent) override final; - void mouseDragged(gcn::MouseEvent &mouseEvent) override final; + void mouseDragged(MouseEvent &mouseEvent) override final; - void mouseWheelMovedUp(gcn::MouseEvent &mouseEvent) override final; + void mouseWheelMovedUp(MouseEvent &mouseEvent) override final; - void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent) override final; + void mouseWheelMovedDown(MouseEvent &mouseEvent) override final; void keyPressed(KeyEvent& keyEvent) override final; diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index eee012120..988db85dd 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -80,13 +80,13 @@ void SliderList::updateAlpha() Button::updateAlpha(); } -void SliderList::mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) +void SliderList::mouseWheelMovedUp(MouseEvent& mouseEvent) { setSelected(mSelectedIndex - 1); mouseEvent.consume(); } -void SliderList::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) +void SliderList::mouseWheelMovedDown(MouseEvent& mouseEvent) { setSelected(mSelectedIndex + 1); mouseEvent.consume(); diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 952b6c337..785ada74b 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -50,9 +50,9 @@ class SliderList final : public Container, void updateAlpha(); - void mouseWheelMovedUp(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedUp(MouseEvent& mouseEvent) override final; - void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) override final; + void mouseWheelMovedDown(MouseEvent& mouseEvent) override final; void resize(); diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index ee76ee5dd..511360b91 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -146,9 +146,9 @@ void SpellShortcutContainer::draw(Graphics *graphics) BLOCK_END("SpellShortcutContainer::draw") } -void SpellShortcutContainer::mouseDragged(gcn::MouseEvent &event) +void SpellShortcutContainer::mouseDragged(MouseEvent &event) { - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (dragDrop.isEmpty() && mSpellClicked) { @@ -177,7 +177,7 @@ void SpellShortcutContainer::mouseDragged(gcn::MouseEvent &event) } } -void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event) +void SpellShortcutContainer::mousePressed(MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); @@ -185,16 +185,16 @@ void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event) return; const unsigned int eventButton = event.getButton(); - if (eventButton == gcn::MouseEvent::LEFT) + if (eventButton == MouseEvent::LEFT) { const int itemId = getItemByIndex(index); if (itemId > 0) mSpellClicked = true; } - else if (eventButton == gcn::MouseEvent::RIGHT) + else if (eventButton == MouseEvent::RIGHT) { } - else if (eventButton == gcn::MouseEvent::MIDDLE) + else if (eventButton == MouseEvent::MIDDLE) { if (!spellShortcut || !spellManager) return; @@ -204,7 +204,7 @@ void SpellShortcutContainer::mousePressed(gcn::MouseEvent &event) } } -void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) +void SpellShortcutContainer::mouseReleased(MouseEvent &event) { if (!spellShortcut || !spellManager) return; @@ -220,7 +220,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) const int itemId = getItemByIndex(index); const unsigned int eventButton = event.getButton(); - if (eventButton == gcn::MouseEvent::LEFT) + if (eventButton == MouseEvent::LEFT) { mSpellClicked = false; @@ -272,7 +272,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) } } } - else if (eventButton == gcn::MouseEvent::RIGHT) + else if (eventButton == MouseEvent::RIGHT) { TextCommand *spell = nullptr; if (itemId >= 0) @@ -284,7 +284,7 @@ void SpellShortcutContainer::mouseReleased(gcn::MouseEvent &event) } // Show ItemTooltip -void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event) +void SpellShortcutContainer::mouseMoved(MouseEvent &event) { if (!mSpellPopup || !spellShortcut || !spellManager) return; @@ -308,7 +308,7 @@ void SpellShortcutContainer::mouseMoved(gcn::MouseEvent &event) } } -void SpellShortcutContainer::mouseExited(gcn::MouseEvent &event A_UNUSED) +void SpellShortcutContainer::mouseExited(MouseEvent &event A_UNUSED) { if (mSpellPopup) mSpellPopup->setVisible(false); diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index b5968dfe5..d8f5d22b4 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -55,23 +55,23 @@ class SpellShortcutContainer final : public ShortcutContainer /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; /** * Handles mouse release. */ - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; void widgetHidden(const Event &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; void setWidget2(const Widget2 *const widget) override final; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 6a5febea6..83df191d1 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -324,12 +324,12 @@ void TabbedArea::logic() BLOCK_END("TabbedArea::logic") } -void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent) +void TabbedArea::mousePressed(MouseEvent &mouseEvent) { if (mouseEvent.isConsumed()) return; - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) + if (mouseEvent.getButton() == MouseEvent::LEFT) { gcn::Widget *const widget = mTabContainer->getWidgetAt( mouseEvent.getX(), mouseEvent.getY()); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index de470e89d..2fb894f6f 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -155,7 +155,7 @@ class TabbedArea final : public Widget2, // Inherited from MouseListener - void mousePressed(gcn::MouseEvent &mouseEvent) override final; + void mousePressed(MouseEvent &mouseEvent) override final; void enableScrollButtons(const bool enable); diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index db5ddf6b4..a85b7927b 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -327,12 +327,12 @@ const std::string &Tab::getCaption() const return mLabel->getCaption(); } -void Tab::mouseEntered(gcn::MouseEvent& mouseEvent A_UNUSED) +void Tab::mouseEntered(MouseEvent& mouseEvent A_UNUSED) { mHasMouse = true; } -void Tab::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) +void Tab::mouseExited(MouseEvent& mouseEvent A_UNUSED) { mHasMouse = false; } diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index e979c71b8..d22c6bea5 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -149,9 +149,9 @@ class Tab : public gcn::BasicContainer, const std::string &getCaption() const A_WARN_UNUSED; - void mouseEntered(gcn::MouseEvent &mouseEvent) override final; + void mouseEntered(MouseEvent &mouseEvent) override final; - void mouseExited(gcn::MouseEvent &mouseEvent) override final; + void mouseExited(MouseEvent &mouseEvent) override final; void setImage(Image *const image); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index aa554b30f..0d01df51d 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -726,13 +726,13 @@ void TextField::fontChanged() fixScroll(); } -void TextField::mousePressed(gcn::MouseEvent &mouseEvent) +void TextField::mousePressed(MouseEvent &mouseEvent) { #ifdef ANDROID if (!client->isKeyboardVisible()) inputManager.executeAction(Input::KEY_SHOW_KEYBOARD); #endif - if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) + if (mouseEvent.getButton() == MouseEvent::RIGHT) { if (viewport) { diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index 71285bd64..ed08de2fa 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -118,7 +118,7 @@ class TextField : public gcn::TextField, void setCaretPosition(unsigned int position); - void mousePressed(gcn::MouseEvent &mouseEvent) override final; + void mousePressed(MouseEvent &mouseEvent) override final; void handlePaste(); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 54c18bd52..e9e1ed71e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -631,7 +631,7 @@ void Window::setVisible(const bool visible, const bool forceSticky) soundManager.playGuiSound(SOUND_SHOW_WINDOW); if (gui) { - gcn::MouseEvent *const event = reinterpret_cast( + MouseEvent *const event = reinterpret_cast( gui->createMouseEvent(this)); if (event) { @@ -658,12 +658,12 @@ void Window::scheduleDelete() windowContainer->scheduleDelete(this); } -void Window::mousePressed(gcn::MouseEvent &event) +void Window::mousePressed(MouseEvent &event) { // Let Guichan move window to top and figure out title bar drag gcn::Window::mousePressed(event); - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { const int x = event.getX(); const int y = event.getY(); @@ -701,7 +701,7 @@ void Window::close() setVisible(false); } -void Window::mouseReleased(gcn::MouseEvent &event A_UNUSED) +void Window::mouseReleased(MouseEvent &event A_UNUSED) { if (mGrip && mouseResize) { @@ -714,18 +714,18 @@ void Window::mouseReleased(gcn::MouseEvent &event A_UNUSED) mMoved = false; } -void Window::mouseEntered(gcn::MouseEvent &event) +void Window::mouseEntered(MouseEvent &event) { updateResizeHandler(event); } -void Window::mouseExited(gcn::MouseEvent &event A_UNUSED) +void Window::mouseExited(MouseEvent &event A_UNUSED) { if (mGrip && !mouseResize && gui) gui->setCursorType(Cursor::CURSOR_POINTER); } -void Window::updateResizeHandler(gcn::MouseEvent &event) +void Window::updateResizeHandler(MouseEvent &event) { if (!gui) return; @@ -760,7 +760,7 @@ void Window::updateResizeHandler(gcn::MouseEvent &event) } } -void Window::mouseMoved(gcn::MouseEvent &event) +void Window::mouseMoved(MouseEvent &event) { updateResizeHandler(event); if (viewport) @@ -772,7 +772,7 @@ bool Window::canMove() const return !mStickyButtonLock || !mSticky; } -void Window::mouseDragged(gcn::MouseEvent &event) +void Window::mouseDragged(MouseEvent &event) { if (canMove()) { @@ -1088,7 +1088,7 @@ void Window::adjustSizeToScreen() widgetResized(Event(this)); } -int Window::getResizeHandles(const gcn::MouseEvent &event) +int Window::getResizeHandles(const MouseEvent &event) { if (event.getX() < 0 || event.getY() < 0) return 0; @@ -1125,7 +1125,7 @@ int Window::getResizeHandles(const gcn::MouseEvent &event) return resizeHandles; } -bool Window::isResizeAllowed(const gcn::MouseEvent &event) const +bool Window::isResizeAllowed(const MouseEvent &event) const { const int y = event.getY(); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 0c3b69880..a5b6be83c 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -257,35 +257,35 @@ class Window : public gcn::Window, /** * Starts window resizing when appropriate. */ - void mousePressed(gcn::MouseEvent &event) override; + void mousePressed(MouseEvent &event) override; /** * Implements window resizing and makes sure the window is not * dragged/resized outside of the screen. */ - void mouseDragged(gcn::MouseEvent &event) override; + void mouseDragged(MouseEvent &event) override; /** * Implements custom cursor image changing context, based on mouse * relative position. */ - void mouseMoved(gcn::MouseEvent &event) override; + void mouseMoved(MouseEvent &event) override; /** * When the mouse button has been let go, this ensures that the mouse * custom cursor is restored back to it's standard image. */ - void mouseReleased(gcn::MouseEvent &event) override; + void mouseReleased(MouseEvent &event) override; /** * When the mouse leaves the window this ensures that the custom cursor * is restored back to it's standard image. */ - void mouseExited(gcn::MouseEvent &event) override; + void mouseExited(MouseEvent &event) override; - void mouseEntered(gcn::MouseEvent &event) override; + void mouseEntered(MouseEvent &event) override; - void updateResizeHandler(gcn::MouseEvent &event); + void updateResizeHandler(MouseEvent &event); /** * Sets the name of the window. This is not the window title. @@ -410,7 +410,7 @@ class Window : public gcn::Window, gcn::Rectangle getWindowArea() const A_WARN_UNUSED; - bool isResizeAllowed(const gcn::MouseEvent &event) const A_WARN_UNUSED; + bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; void setCaptionFont(gcn::Font *font) { mCaptionFont = font; } @@ -474,7 +474,7 @@ class Window : public gcn::Window, * * @see ResizeHandles */ - int getResizeHandles(const gcn::MouseEvent &event) A_WARN_UNUSED; + int getResizeHandles(const MouseEvent &event) A_WARN_UNUSED; Image *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index e04eb210f..4417f18a6 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -248,12 +248,12 @@ void WindowMenu::addButton(const char *const text, mButtonTexts.push_back(new ButtonText(description, key)); } -void WindowMenu::mousePressed(gcn::MouseEvent &event) +void WindowMenu::mousePressed(MouseEvent &event) { if (!viewport) return; - if (!mSmallWindow && event.getButton() == gcn::MouseEvent::RIGHT) + if (!mSmallWindow && event.getButton() == MouseEvent::RIGHT) { Button *const btn = dynamic_cast(event.getSource()); if (!btn) @@ -266,7 +266,7 @@ void WindowMenu::mousePressed(gcn::MouseEvent &event) } } -void WindowMenu::mouseMoved(gcn::MouseEvent &event) +void WindowMenu::mouseMoved(MouseEvent &event) { mHaveMouse = true; @@ -305,7 +305,7 @@ void WindowMenu::mouseMoved(gcn::MouseEvent &event) } } -void WindowMenu::mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) +void WindowMenu::mouseExited(MouseEvent& mouseEvent A_UNUSED) { mHaveMouse = false; if (!mTextPopup) diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 9375eb15d..1f2d8adb2 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -90,11 +90,11 @@ class WindowMenu final : public Container, void action(const ActionEvent &event) override final; - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) override final; + void mouseExited(MouseEvent& mouseEvent A_UNUSED) override final; std::map &getButtonNames() A_WARN_UNUSED { return mButtonNames; } diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 1e71c50ae..cbff544fc 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -771,12 +771,12 @@ void ChatWindow::scroll(const int amount) const tab->scroll(amount); } -void ChatWindow::mousePressed(gcn::MouseEvent &event) +void ChatWindow::mousePressed(MouseEvent &event) { if (event.isConsumed()) return; - if (event.getButton() == gcn::MouseEvent::RIGHT) + if (event.getButton() == MouseEvent::RIGHT) { if (viewport) { @@ -805,7 +805,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event) if (event.isConsumed()) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { const ChatTab *const tab = getFocused(); if (tab) @@ -816,7 +816,7 @@ void ChatWindow::mousePressed(gcn::MouseEvent &event) mDragOffsetY = event.getY(); } -void ChatWindow::mouseDragged(gcn::MouseEvent &event) +void ChatWindow::mouseDragged(MouseEvent &event) { Window::mouseDragged(event); @@ -1885,19 +1885,19 @@ void ChatWindow::optionChanged(const std::string &name) parseGlobalsFilter(); } -void ChatWindow::mouseMoved(gcn::MouseEvent &event) +void ChatWindow::mouseMoved(MouseEvent &event) { mHaveMouse = true; Window::mouseMoved(event); } -void ChatWindow::mouseEntered(gcn::MouseEvent& mouseEvent) +void ChatWindow::mouseEntered(MouseEvent& mouseEvent) { mHaveMouse = true; Window::mouseEntered(mouseEvent); } -void ChatWindow::mouseExited(gcn::MouseEvent& mouseEvent) +void ChatWindow::mouseExited(MouseEvent& mouseEvent) { updateVisibility(); Window::mouseExited(mouseEvent); diff --git a/src/gui/windows/chatwindow.h b/src/gui/windows/chatwindow.h index e664e63ce..2ec4e6bec 100644 --- a/src/gui/windows/chatwindow.h +++ b/src/gui/windows/chatwindow.h @@ -186,12 +186,12 @@ class ChatWindow final : public Window, /** * Handles mouse when dragged. */ - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; /** * Handles mouse when pressed. */ - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; void processEvent(const Channels channel, const DepricatedEvent &event) override final; @@ -274,11 +274,11 @@ class ChatWindow final : public Window, void optionChanged(const std::string &name) override final; - void mouseEntered(gcn::MouseEvent& mouseEvent) override final; + void mouseEntered(MouseEvent& mouseEvent) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent& mouseEvent A_UNUSED) override final; + void mouseExited(MouseEvent& mouseEvent A_UNUSED) override final; void draw(Graphics* graphics) override final; diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 89b1eda26..9b3ba857c 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -129,7 +129,7 @@ void DidYouKnowWindow::action(const ActionEvent &event) } void DidYouKnowWindow::handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) + MouseEvent *event A_UNUSED) { if (strStartWith(link, "http://") || strStartWith(link, "https://")) openBrowser(link); diff --git a/src/gui/windows/didyouknowwindow.h b/src/gui/windows/didyouknowwindow.h index 4f88b3f1c..fd539e360 100644 --- a/src/gui/windows/didyouknowwindow.h +++ b/src/gui/windows/didyouknowwindow.h @@ -59,7 +59,7 @@ class DidYouKnowWindow final : public Window, * Handles link action. */ void handleLink(const std::string &link, - gcn::MouseEvent *event) override final; + MouseEvent *event) override final; void loadData(int num = 0); diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 68ef56826..5caf30df1 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -291,7 +291,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const return nullptr; } -void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) +void EquipmentWindow::mousePressed(MouseEvent& mouseEvent) { if (!mEquipment) { @@ -302,7 +302,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) const int x = mouseEvent.getX(); const int y = mouseEvent.getY(); - if (mouseEvent.getButton() == gcn::MouseEvent::LEFT) + if (mouseEvent.getButton() == MouseEvent::LEFT) { if (mForing) { @@ -337,7 +337,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) return; } } - else if (mouseEvent.getButton() == gcn::MouseEvent::RIGHT) + else if (mouseEvent.getButton() == MouseEvent::RIGHT) { if (Item *const item = getItem(x, y)) { @@ -362,7 +362,7 @@ void EquipmentWindow::mousePressed(gcn::MouseEvent& mouseEvent) Window::mousePressed(mouseEvent); } -void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent) +void EquipmentWindow::mouseReleased(MouseEvent &mouseEvent) { Window::mouseReleased(mouseEvent); const DragDropSource src = dragDrop.getSource(); @@ -417,7 +417,7 @@ void EquipmentWindow::mouseReleased(gcn::MouseEvent &mouseEvent) } // Show ItemTooltip -void EquipmentWindow::mouseMoved(gcn::MouseEvent &event) +void EquipmentWindow::mouseMoved(MouseEvent &event) { Window::mouseMoved(event); @@ -441,7 +441,7 @@ void EquipmentWindow::mouseMoved(gcn::MouseEvent &event) } // Hide ItemTooltip -void EquipmentWindow::mouseExited(gcn::MouseEvent &event A_UNUSED) +void EquipmentWindow::mouseExited(MouseEvent &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index bade666ad..c9ca12bbd 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -86,7 +86,7 @@ class EquipmentWindow final : public Window, void action(const ActionEvent &event) override final; - void mousePressed(gcn::MouseEvent& mouseEvent) override final; + void mousePressed(MouseEvent& mouseEvent) override final; const Item* getEquipment(const int i) const A_WARN_UNUSED { return mEquipment ? mEquipment->getEquipment(i) : nullptr; } @@ -97,11 +97,11 @@ class EquipmentWindow final : public Window, void resetBeing(const Being *const being); - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; void recalcSize(); diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 9738378ea..95bea6e00 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -104,7 +104,7 @@ void HelpWindow::action(const ActionEvent &event) } void HelpWindow::handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) + MouseEvent *event A_UNUSED) { if (!strStartWith(link, "http://") && !strStartWith(link, "https://")) { diff --git a/src/gui/windows/helpwindow.h b/src/gui/windows/helpwindow.h index d8b873408..4290c99f9 100644 --- a/src/gui/windows/helpwindow.h +++ b/src/gui/windows/helpwindow.h @@ -65,7 +65,7 @@ class HelpWindow final : public Window, * Handles link action. */ void handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) override final; + MouseEvent *event A_UNUSED) override final; /** * Loads help in the dialog. diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index a1eb83e7a..09368e2ad 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -466,7 +466,7 @@ void InventoryWindow::widgetHidden(const Event &event) mItems->hidePopup(); } -void InventoryWindow::mouseClicked(gcn::MouseEvent &event) +void InventoryWindow::mouseClicked(MouseEvent &event) { Window::mouseClicked(event); @@ -482,7 +482,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) && inputManager.isActionActive(static_cast( Input::KEY_STOP_ATTACK))); - if (!mod && !mod2 && event.getButton() == gcn::MouseEvent::RIGHT) + if (!mod && !mod2 && event.getButton() == MouseEvent::RIGHT) { Item *const item = mItems->getSelectedItem(); @@ -502,8 +502,8 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) if (!mInventory) return; - if (event.getButton() == gcn::MouseEvent::LEFT - || event.getButton() == gcn::MouseEvent::RIGHT) + if (event.getButton() == MouseEvent::LEFT + || event.getButton() == MouseEvent::RIGHT) { Item *const item = mItems->getSelectedItem(); @@ -514,7 +514,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { if (mInventory->isMainInventory()) { - if (event.getButton() == gcn::MouseEvent::RIGHT) + if (event.getButton() == MouseEvent::RIGHT) { ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd, inventoryWindow, item); @@ -528,7 +528,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) } else { - if (event.getButton() == gcn::MouseEvent::RIGHT) + if (event.getButton() == MouseEvent::RIGHT) { ItemAmountWindow::showWindow(ItemAmountWindow::StoreRemove, inventoryWindow, item); @@ -545,7 +545,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) { if (PlayerInfo::isItemProtected(item->getId())) return; - if (event.getButton() == gcn::MouseEvent::RIGHT) + if (event.getButton() == MouseEvent::RIGHT) { ItemAmountWindow::showWindow(ItemAmountWindow::TradeAdd, tradeWindow, item); @@ -589,7 +589,7 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) } } -void InventoryWindow::mouseMoved(gcn::MouseEvent &event) +void InventoryWindow::mouseMoved(MouseEvent &event) { Window::mouseMoved(event); const gcn::Widget *const src = event.getSource(); @@ -608,7 +608,7 @@ void InventoryWindow::mouseMoved(gcn::MouseEvent &event) } } -void InventoryWindow::mouseExited(gcn::MouseEvent &event A_UNUSED) +void InventoryWindow::mouseExited(MouseEvent &event A_UNUSED) { mTextPopup->hide(); } diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 03f64b562..96d9d04fb 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -97,7 +97,7 @@ class InventoryWindow final : public Window, /** * Handles the mouse clicks. */ - void mouseClicked(gcn::MouseEvent &event) override final; + void mouseClicked(MouseEvent &event) override final; /** * Handles the key presses. @@ -147,9 +147,9 @@ class InventoryWindow final : public Window, void widgetResized(const Event &event) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; void setVisible(bool visible) override final; diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 2158c4dd9..6b7d10173 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -313,7 +313,7 @@ ItemAmountWindow::~ItemAmountWindow() } // Show ItemTooltip -void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event) +void ItemAmountWindow::mouseMoved(MouseEvent &event) { Window::mouseMoved(event); @@ -328,7 +328,7 @@ void ItemAmountWindow::mouseMoved(gcn::MouseEvent &event) } // Hide ItemTooltip -void ItemAmountWindow::mouseExited(gcn::MouseEvent &event A_UNUSED) +void ItemAmountWindow::mouseExited(MouseEvent &event A_UNUSED) { if (mItemPopup) mItemPopup->setVisible(false); diff --git a/src/gui/windows/itemamountwindow.h b/src/gui/windows/itemamountwindow.h index 76d53eeeb..cf721ee30 100644 --- a/src/gui/windows/itemamountwindow.h +++ b/src/gui/windows/itemamountwindow.h @@ -73,9 +73,9 @@ class ItemAmountWindow final : public Window, void resetAmount(); // MouseListener - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; /** * Schedules the Item Amount window for deletion. diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 691506753..0f0938e20 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -434,14 +434,14 @@ void Minimap::draw(Graphics *graphics) BLOCK_END("Minimap::draw") } -void Minimap::mouseReleased(gcn::MouseEvent &event) +void Minimap::mouseReleased(MouseEvent &event) { Window::mouseReleased(event); if (!player_node || !viewport) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { int x = event.getX(); int y = event.getY(); @@ -449,7 +449,7 @@ void Minimap::mouseReleased(gcn::MouseEvent &event) player_node->navigateTo(x, y); } - else if (event.getButton() == gcn::MouseEvent::RIGHT) + else if (event.getButton() == MouseEvent::RIGHT) { int x = event.getX(); int y = event.getY(); @@ -458,7 +458,7 @@ void Minimap::mouseReleased(gcn::MouseEvent &event) } } -void Minimap::mouseMoved(gcn::MouseEvent &event) +void Minimap::mouseMoved(MouseEvent &event) { Window::mouseMoved(event); const int x = event.getX(); @@ -467,7 +467,7 @@ void Minimap::mouseMoved(gcn::MouseEvent &event) mTextPopup->show(x + rect.x, y + rect.y, mCaption); } -void Minimap::mouseExited(gcn::MouseEvent &event) +void Minimap::mouseExited(MouseEvent &event) { Window::mouseExited(event); mTextPopup->hide(); diff --git a/src/gui/windows/minimap.h b/src/gui/windows/minimap.h index 661412c57..d99aea13d 100644 --- a/src/gui/windows/minimap.h +++ b/src/gui/windows/minimap.h @@ -62,11 +62,11 @@ class Minimap final : public Window, public ConfigListener */ void draw(Graphics *graphics) override final; - void mouseMoved(gcn::MouseEvent &event) override final; + void mouseMoved(MouseEvent &event) override final; - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; void screenToMap(int &x, int &y); diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 3513bb2ff..b8f2fd7ea 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -315,7 +315,7 @@ void MiniStatusWindow::draw(Graphics *graphics) BLOCK_END("MiniStatusWindow::draw") } -void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) +void MiniStatusWindow::mouseMoved(MouseEvent &event) { Popup::mouseMoved(event); @@ -433,12 +433,12 @@ void MiniStatusWindow::mouseMoved(gcn::MouseEvent &event) } } -void MiniStatusWindow::mousePressed(gcn::MouseEvent &event) +void MiniStatusWindow::mousePressed(MouseEvent &event) { if (!viewport) return; - if (event.getButton() == gcn::MouseEvent::RIGHT) + if (event.getButton() == MouseEvent::RIGHT) { const ProgressBar *const bar = dynamic_cast( event.getSource()); @@ -452,7 +452,7 @@ void MiniStatusWindow::mousePressed(gcn::MouseEvent &event) } } -void MiniStatusWindow::mouseExited(gcn::MouseEvent &event) +void MiniStatusWindow::mouseExited(MouseEvent &event) { Popup::mouseExited(event); diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index 5fccae02e..bb1991c19 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -71,11 +71,11 @@ class MiniStatusWindow final : public Popup, void draw(Graphics *graphics) override final; - void mouseMoved(gcn::MouseEvent &mouseEvent) override final; + void mouseMoved(MouseEvent &mouseEvent) override final; - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; - void mouseExited(gcn::MouseEvent &event) override final; + void mouseExited(MouseEvent &event) override final; void showBar(const std::string &name, const bool visible); diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index 4ee8f3b29..a883406e7 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -965,10 +965,10 @@ void NpcDialog::clearDialogs() mNpcDialogs.clear(); } -void NpcDialog::mousePressed(gcn::MouseEvent &event) +void NpcDialog::mousePressed(MouseEvent &event) { Window::mousePressed(event); - if (event.getButton() == gcn::MouseEvent::RIGHT + if (event.getButton() == MouseEvent::RIGHT && event.getSource() == mTextBox) { if (viewport) diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index 1fdd4a444..b7b036659 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -210,7 +210,7 @@ class NpcDialog final : public Window, void clearRows(); - void mousePressed(gcn::MouseEvent &event); + void mousePressed(MouseEvent &event); int isCloseState() const { return mActionState == NPC_ACTION_CLOSE; } diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 6fbb34390..d1413cc0a 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -366,9 +366,9 @@ void OutfitWindow::draw(Graphics *graphics) BLOCK_END("OutfitWindow::draw") } -void OutfitWindow::mouseDragged(gcn::MouseEvent &event) +void OutfitWindow::mouseDragged(MouseEvent &event) { - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (dragDrop.isEmpty() && mItemClicked) { @@ -409,12 +409,12 @@ void OutfitWindow::mouseDragged(gcn::MouseEvent &event) Window::mouseDragged(event); } -void OutfitWindow::mousePressed(gcn::MouseEvent &event) +void OutfitWindow::mousePressed(MouseEvent &event) { const int index = getIndexFromGrid(event.getX(), event.getY()); if (index == -1) { - if (event.getButton() == gcn::MouseEvent::RIGHT && viewport) + if (event.getButton() == MouseEvent::RIGHT && viewport) { viewport->showOutfitsPopup(); event.consume(); @@ -446,9 +446,9 @@ void OutfitWindow::mousePressed(gcn::MouseEvent &event) Window::mousePressed(event); } -void OutfitWindow::mouseReleased(gcn::MouseEvent &event) +void OutfitWindow::mouseReleased(MouseEvent &event) { - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (mCurrentOutfit < 0 || mCurrentOutfit >= static_cast(OUTFITS_COUNT)) diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index f27852a8c..909b84a41 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -54,11 +54,11 @@ class OutfitWindow final : public Window, void draw(Graphics *graphics) override final; - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; - void mouseReleased(gcn::MouseEvent &event) override final; + void mouseReleased(MouseEvent &event) override final; void load(const bool oldConfig = false); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index c4bd7c79f..4ad0e8360 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -506,7 +506,7 @@ void ServerDialog::valueChanged(const gcn::SelectionEvent &) mDeleteButton->setEnabled(true); } -void ServerDialog::mouseClicked(gcn::MouseEvent &mouseEvent) +void ServerDialog::mouseClicked(MouseEvent &mouseEvent) { if (mouseEvent.getClickCount() == 2 && mouseEvent.getSource() == mServersList) diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index d14360b88..41ef8bcf1 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -125,7 +125,7 @@ class ServerDialog final : public Window, */ void valueChanged(const gcn::SelectionEvent &event) override final; - void mouseClicked(gcn::MouseEvent &mouseEvent) override final; + void mouseClicked(MouseEvent &mouseEvent) override final; void logic() override final; diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 7916ce8e4..50bc6fcd1 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -195,21 +195,21 @@ void ShortcutWindow::widgetHidden(const Event &event) } } -void ShortcutWindow::mousePressed(gcn::MouseEvent &event) +void ShortcutWindow::mousePressed(MouseEvent &event) { Window::mousePressed(event); if (event.isConsumed()) return; - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { mDragOffsetX = event.getX(); mDragOffsetY = event.getY(); } } -void ShortcutWindow::mouseDragged(gcn::MouseEvent &event) +void ShortcutWindow::mouseDragged(MouseEvent &event) { Window::mouseDragged(event); diff --git a/src/gui/windows/shortcutwindow.h b/src/gui/windows/shortcutwindow.h index 707a0a1d7..5e36e68d7 100644 --- a/src/gui/windows/shortcutwindow.h +++ b/src/gui/windows/shortcutwindow.h @@ -64,9 +64,9 @@ class ShortcutWindow final : public Window void widgetMoved(const Event& event) override final; - void mousePressed(gcn::MouseEvent &event) override final; + void mousePressed(MouseEvent &event) override final; - void mouseDragged(gcn::MouseEvent &event) override final; + void mouseDragged(MouseEvent &event) override final; void nextTab(); diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index deeffb9a0..8ec8486e3 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -157,7 +157,7 @@ class SkillListBox final : public ListBox unsigned int getRowHeight() const override { return mRowHeight; } - const SkillInfo *getSkillByEvent(const gcn::MouseEvent &event) const + const SkillInfo *getSkillByEvent(const MouseEvent &event) const { const int y = (event.getY() + mPadding) / getRowHeight(); if (!mModel || y >= mModel->getNumberOfElements()) @@ -168,7 +168,7 @@ class SkillListBox final : public ListBox return skill; } - void mouseMoved(gcn::MouseEvent &event) override + void mouseMoved(MouseEvent &event) override { ListBox::mouseMoved(event); if (!viewport || !dragDrop.isEmpty()) @@ -182,9 +182,9 @@ class SkillListBox final : public ListBox skill->data->dispName, skill->data->description); } - void mouseDragged(gcn::MouseEvent &event) + void mouseDragged(MouseEvent &event) { - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { if (dragDrop.isEmpty()) { @@ -206,10 +206,10 @@ class SkillListBox final : public ListBox } } - void mousePressed(gcn::MouseEvent &event) + void mousePressed(MouseEvent &event) { ListBox::mousePressed(event); - if (event.getButton() == gcn::MouseEvent::LEFT) + if (event.getButton() == MouseEvent::LEFT) { const SkillInfo *const skill = getSkillByEvent(event); if (!skill) @@ -218,12 +218,12 @@ class SkillListBox final : public ListBox } } - void mouseReleased(gcn::MouseEvent &event) + void mouseReleased(MouseEvent &event) { ListBox::mouseReleased(event); } - void mouseExited(gcn::MouseEvent &event A_UNUSED) override + void mouseExited(MouseEvent &event A_UNUSED) override { mPopup->hide(); } diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 4df0ab6f1..704bf0ca6 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -1242,7 +1242,7 @@ public: A_DELETE_COPY(CreatePopup) void handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) override final + MouseEvent *event A_UNUSED) override final { if (link == "guild" && socialWindow) { diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 109858a07..8e31939ff 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -971,7 +971,7 @@ unsigned long UpdaterWindow::getFileHash(const std::string &filePath) } void UpdaterWindow::handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) + MouseEvent *event A_UNUSED) { if (strStartWith(link, "http://") || strStartWith(link, "https://")) openBrowser(link); diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h index ffd5b3103..79d764752 100644 --- a/src/gui/windows/updaterwindow.h +++ b/src/gui/windows/updaterwindow.h @@ -126,7 +126,7 @@ class UpdaterWindow final : public Window, void logic() override final; void handleLink(const std::string &link, - gcn::MouseEvent *event A_UNUSED) override final; + MouseEvent *event A_UNUSED) override final; void loadFile(std::string file); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 201a5e11e..1af21866d 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -159,9 +159,9 @@ WhoIsOnline::~WhoIsOnline() mOnlineNicks.clear(); } -void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event) +void WhoIsOnline::handleLink(const std::string& link, MouseEvent *event) { - if (!event || event->getButton() == gcn::MouseEvent::LEFT) + if (!event || event->getButton() == MouseEvent::LEFT) { if (chatWindow) { @@ -177,7 +177,7 @@ void WhoIsOnline::handleLink(const std::string& link, gcn::MouseEvent *event) } } } - else if (event->getButton() == gcn::MouseEvent::RIGHT) + else if (event->getButton() == MouseEvent::RIGHT) { if (player_node && link == player_node->getName()) return; diff --git a/src/gui/windows/whoisonline.h b/src/gui/windows/whoisonline.h index 99eeb1911..bc04c8066 100644 --- a/src/gui/windows/whoisonline.h +++ b/src/gui/windows/whoisonline.h @@ -128,7 +128,7 @@ public: void loadList(std::vector &list); void handleLink(const std::string& link, - gcn::MouseEvent *event) override final; + MouseEvent *event) override final; void logic() override final; diff --git a/src/listeners/mouselistener.h b/src/listeners/mouselistener.h index e95d2ca01..d294e4dd6 100644 --- a/src/listeners/mouselistener.h +++ b/src/listeners/mouselistener.h @@ -64,7 +64,7 @@ #ifndef GCN_MOUSELISTENER_HPP #define GCN_MOUSELISTENER_HPP -#include "gui/base/mouseevent.hpp" +#include "events/mouseevent.h" #include "localconsts.h" @@ -89,7 +89,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseEntered(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseEntered(MouseEvent &mouseEvent A_UNUSED) { } @@ -99,7 +99,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseExited(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseExited(MouseEvent &mouseEvent A_UNUSED) { } @@ -112,7 +112,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mousePressed(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mousePressed(MouseEvent &mouseEvent A_UNUSED) { } @@ -122,7 +122,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseReleased(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseReleased(MouseEvent &mouseEvent A_UNUSED) { } @@ -133,7 +133,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseClicked(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseClicked(MouseEvent &mouseEvent A_UNUSED) { } @@ -143,7 +143,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseWheelMovedUp(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseWheelMovedUp(MouseEvent &mouseEvent A_UNUSED) { } @@ -153,7 +153,7 @@ class MouseListener * @param mousEvent Describes the event. * @since 0.6.0 */ - virtual void mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseWheelMovedDown(MouseEvent &mouseEvent A_UNUSED) { } @@ -164,7 +164,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseMoved(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseMoved(MouseEvent &mouseEvent A_UNUSED) { } @@ -175,7 +175,7 @@ class MouseListener * @param mouseEvent Describes the event. * @since 0.6.0 */ - virtual void mouseDragged(gcn::MouseEvent &mouseEvent A_UNUSED) + virtual void mouseDragged(MouseEvent &mouseEvent A_UNUSED) { } -- cgit v1.2.3-70-g09d2 From 36c98f4e483ec0a9fc831d8a5938b7a3a72c1a9b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 15:03:00 +0300 Subject: Remove cast for MouseEvent and improve MouseEvent. --- src/events/mouseevent.h | 240 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 src/events/mouseevent.h (limited to 'src') diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h new file mode 100644 index 000000000..9284822ba --- /dev/null +++ b/src/events/mouseevent.h @@ -0,0 +1,240 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 EVENTS_MOUSEEVENT_HPP +#define EVENTS_MOUSEEVENT_HPP + +#include "events/inputguievent.h" + +namespace gcn +{ + class Gui; + class Widget; +} + +/** + * Represents a mouse event. + * + * @author Olof Naessén + * @since 0.6.0 + */ +class MouseEvent: public InputGuiEvent +{ + public: + /** + * Constructor. + * + * @param source The source widget of the mouse event. + * @param shiftPressed True if shift is pressed, false otherwise. + * @param controlPressed True if control is pressed, false otherwise. + * @param altPressed True if alt is pressed, false otherwise. + * @param metaPressed True if meta is pressed, false otherwise. + * @param type The type of the mouse event. + * @param button The button of the mouse event. + * @param x The x coordinate of the event relative to the source widget. + * @param y The y coordinate of the event relative the source widget. + * @param clickCount The number of clicks generated with the same button. + * It's set to zero if another button is used. + */ + MouseEvent(gcn::Widget *const source, + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const unsigned int button, + const int x, + const int y, + const int clickCount) : + InputGuiEvent(source, + shiftPressed, + controlPressed, + altPressed, + metaPressed), + mType(type), + mButton(button), + mX(x), + mY(y), + mClickCount(clickCount) + { + } + + /** + * Gets the button of the mouse event. + * + * @return The button of the mouse event. + */ + unsigned int getButton() const A_WARN_UNUSED + { return mButton; } + + /** + * Gets the x coordinate of the mouse event. + * The coordinate relative to widget the mouse listener + * receiving the events have registered to. + * + * @return The x coordinate of the mouse event. + * @see Widget::addMouseListener, Widget::removeMouseListener + */ + int getX() const A_WARN_UNUSED + { return mX; } + + /** + * Gets the y coordinate of the mouse event. + * The coordinate relative to widget the mouse listener + * receiving the events have registered to. + * + * @return The y coordinate of the mouse event. + * @see Widget::addMouseListener, Widget::removeMouseListener + */ + int getY() const A_WARN_UNUSED + { return mY; } + + /** + * Gets the number of clicks generated with the same button. + * It's set to zero if another button is used. + * + * @return The number of clicks generated with the same button. + */ + int getClickCount() const A_WARN_UNUSED + { return mClickCount; } + + /** + * Gets the type of the event. + * + * @return The type of the event. + */ + unsigned int getType() const A_WARN_UNUSED + { return mType; } + + void setX(int n) + { mX = n; } + + void setY(int n) + { mY = n; } + + /** + * Mouse event types. + */ + enum + { + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP, + CLICKED, + ENTERED, + EXITED, + DRAGGED + }; + + /** + * Mouse button types. + */ + enum + { + EMPTY = 0, + LEFT, + RIGHT, + MIDDLE + }; + + protected: + /** + * Holds the type of the mouse event. + */ + unsigned int mType; + + /** + * Holds the button of the mouse event. + */ + unsigned int mButton; + + /** + * Holds the x-coordinate of the mouse event. + */ + int mX; + + /** + * Holds the y-coordinate of the mouse event. + */ + int mY; + + /** + * The number of clicks generated with the same button. + * It's set to zero if another button is used. + */ + int mClickCount; + + /** + * Gui is a friend of this class in order to be able to manipulate + * the protected member variables of this class and at the same time + * keep the MouseEvent class as const as possible. Gui needs to + * update the x och y coordinates for the coordinates to be relative + * to widget the mouse listener receiving the events have registered + * to. + */ + friend class gcn::Gui; +}; + +#endif // EVENTS_MOUSEEVENT_HPP -- cgit v1.2.3-70-g09d2 From a9a838708956e001461c6d835d228aad8ce30902 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 15:18:59 +0300 Subject: move selectionevent into events directory. --- src/CMakeLists.txt | 3 +- src/Makefile.am | 3 +- src/events/selectionevent.h | 101 ++++++++++++++++++++++++++++++++++ src/gui/base/selectionevent.cpp | 82 --------------------------- src/gui/base/selectionevent.hpp | 98 --------------------------------- src/gui/widgets/dropdown.cpp | 4 +- src/gui/widgets/dropdown.h | 2 +- src/gui/widgets/itemcontainer.cpp | 2 +- src/gui/widgets/tabs/setup_colors.cpp | 2 +- src/gui/widgets/tabs/setup_colors.h | 2 +- src/gui/windows/buydialog.cpp | 2 +- src/gui/windows/buydialog.h | 2 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/inventorywindow.h | 2 +- src/gui/windows/selldialog.cpp | 2 +- src/gui/windows/selldialog.h | 2 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/serverdialog.h | 2 +- src/gui/windows/shopwindow.cpp | 2 +- src/gui/windows/shopwindow.h | 2 +- src/gui/windows/tradewindow.cpp | 2 +- src/gui/windows/tradewindow.h | 2 +- src/listeners/selectionlistener.h | 4 +- 23 files changed, 123 insertions(+), 204 deletions(-) create mode 100644 src/events/selectionevent.h delete mode 100644 src/gui/base/selectionevent.cpp delete mode 100644 src/gui/base/selectionevent.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e3bf7ae5c..3b6d15922 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -789,7 +789,7 @@ SET(SRCS gui/base/mouseinput.hpp listeners/mouselistener.h gui/base/rectangle.hpp - gui/base/selectionevent.hpp + events/selectionevent.h listeners/selectionlistener.h gui/base/sdl/sdlpixel.hpp gui/base/widget.hpp @@ -816,7 +816,6 @@ SET(SRCS gui/base/keyinput.cpp gui/base/mouseinput.cpp gui/base/rectangle.cpp - gui/base/selectionevent.cpp gui/base/widget.cpp gui/base/widgets/button.cpp gui/base/widgets/checkbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 3b199ba44..3cdad0f60 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -178,7 +178,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/mouseinput.hpp \ listeners/mouselistener.h \ gui/base/rectangle.hpp \ - gui/base/selectionevent.hpp \ + events/selectionevent.h \ listeners/selectionlistener.h \ gui/base/sdl/sdlpixel.hpp \ gui/base/widget.hpp \ @@ -205,7 +205,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/keyinput.cpp \ gui/base/mouseinput.cpp \ gui/base/rectangle.cpp \ - gui/base/selectionevent.cpp \ gui/base/widget.cpp \ gui/base/widgets/button.cpp \ gui/base/widgets/checkbox.cpp \ diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h new file mode 100644 index 000000000..fc030cab0 --- /dev/null +++ b/src/events/selectionevent.h @@ -0,0 +1,101 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 EVENTS_SELECTIONEVENT_HPP +#define EVENTS_SELECTIONEVENT_HPP + +#include "events/event.h" + +#include "localconsts.h" + +namespace gcn +{ + class Widget; +} + +/** + * Represents a selection event. + * + * @author Olof Naessén + * @since 0.8.0 + */ +class SelectionEvent final: public Event +{ + public: + /** + * Constructor. + * + * @param source source The widget of the selection event. + */ + explicit SelectionEvent(gcn::Widget *const source) : + Event(source) + { } + + /** + * Destructor. + */ + virtual ~SelectionEvent() + { } +}; + +#endif // EVENTS_SELECTIONEVENT_HPP diff --git a/src/gui/base/selectionevent.cpp b/src/gui/base/selectionevent.cpp deleted file mode 100644 index 04318be06..000000000 --- a/src/gui/base/selectionevent.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/selectionevent.hpp" - -#include "debug.h" - -namespace gcn -{ - SelectionEvent::SelectionEvent(Widget *const source) : - Event(source) - { - } - - SelectionEvent::~SelectionEvent() - { - } -} // namespace gcn diff --git a/src/gui/base/selectionevent.hpp b/src/gui/base/selectionevent.hpp deleted file mode 100644 index 5d05f015c..000000000 --- a/src/gui/base/selectionevent.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SELECTIONEVENT_HPP -#define GCN_SELECTIONEVENT_HPP - -#include "events/event.h" - -#include "localconsts.h" - -namespace gcn -{ - class Widget; - - /** - * Represents a selection event. - * - * @author Olof Naessén - * @since 0.8.0 - */ - class SelectionEvent final: public Event - { - public: - /** - * Constructor. - * - * @param source source The widget of the selection event. - */ - explicit SelectionEvent(Widget *const source); - - /** - * Destructor. - */ - virtual ~SelectionEvent(); - }; -} // namespace gcn - -#endif // end GCN_SELECTIONEVENT_HPP diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index aca82cef4..225ea11bb 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -524,7 +524,7 @@ gcn::Rectangle DropDown::getChildrenArea() return gcn::Rectangle(); } -void DropDown::valueChanged(const gcn::SelectionEvent& event A_UNUSED) +void DropDown::valueChanged(const SelectionEvent& event A_UNUSED) { } @@ -552,7 +552,7 @@ void DropDown::distributeValueChangedEvent() iter != mSelectionListeners.end(); ++iter) { - gcn::SelectionEvent event(this); + SelectionEvent event(this); (*iter)->valueChanged(event); } } diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index dd38a1730..8f42bfc65 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -107,7 +107,7 @@ class DropDown final : public ActionListener, std::string getSelectedString() const A_WARN_UNUSED; - void valueChanged(const gcn::SelectionEvent& event) override final; + void valueChanged(const SelectionEvent& event) override final; void updateSelection(); diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 27a00798e..4608534b1 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -374,7 +374,7 @@ void ItemContainer::distributeValueChangedEvent() { if (*i) { - gcn::SelectionEvent event(this); + SelectionEvent event(this); (*i)->valueChanged(event); } } diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index f7068b965..1a2bdfeae 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -244,7 +244,7 @@ void Setup_Colors::action(const ActionEvent &event) } } -void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED) +void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) { if (!userPalette) return; diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index 55d5950c5..8864db7db 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -52,7 +52,7 @@ class Setup_Colors final : public SetupTab, void action(const ActionEvent &event) override final; - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; private: static const char *const rawmsg; diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 0027b695e..19a46b9b8 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -482,7 +482,7 @@ void BuyDialog::action(const ActionEvent &event) } } -void BuyDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED) +void BuyDialog::valueChanged(const SelectionEvent &event A_UNUSED) { // Reset amount of items and update labels mAmountItems = 1; diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index f3ba80c45..500f378ef 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -108,7 +108,7 @@ class BuyDialog final : public Window, /** * Updates the labels according to the selected item. */ - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; /** * Updates the state of buttons and labels. diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 09368e2ad..3eb10e0e8 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -625,7 +625,7 @@ void InventoryWindow::keyReleased(KeyEvent &event) mSplit = false; } -void InventoryWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED) +void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED) { if (!mInventory || !mInventory->isMainInventory()) return; diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 96d9d04fb..6a6999034 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -112,7 +112,7 @@ class InventoryWindow final : public Window, /** * Updates labels to currently selected item. */ - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; /** * Sets whether the split button should be shown. diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 1917f7693..aad3619ba 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -309,7 +309,7 @@ void SellDialog::action(const ActionEvent &event) } } -void SellDialog::valueChanged(const gcn::SelectionEvent &event A_UNUSED) +void SellDialog::valueChanged(const SelectionEvent &event A_UNUSED) { // Reset amount of items and update labels mAmountItems = 1; diff --git a/src/gui/windows/selldialog.h b/src/gui/windows/selldialog.h index 5d1065c16..bd270919e 100644 --- a/src/gui/windows/selldialog.h +++ b/src/gui/windows/selldialog.h @@ -87,7 +87,7 @@ class SellDialog final : public Window, * * @see SelectionListener::selectionChanged */ - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; /** * Gives Player's Money amount diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 4ad0e8360..ce5c3c815 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -495,7 +495,7 @@ void ServerDialog::keyPressed(KeyEvent &keyEvent) mServersList->keyPressed(keyEvent); } -void ServerDialog::valueChanged(const gcn::SelectionEvent &) +void ServerDialog::valueChanged(const SelectionEvent &) { const int index = mServersList->getSelected(); if (index == -1) diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 41ef8bcf1..112c8001d 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -123,7 +123,7 @@ class ServerDialog final : public Window, /** * Called when the selected value changed in the servers list box. */ - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; void mouseClicked(MouseEvent &mouseEvent) override final; diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 04258998a..9e55af797 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -307,7 +307,7 @@ void ShopWindow::startTrade() mTradeNick.clear(); } -void ShopWindow::valueChanged(const gcn::SelectionEvent &event A_UNUSED) +void ShopWindow::valueChanged(const SelectionEvent &event A_UNUSED) { updateButtonsAndLabels(); } diff --git a/src/gui/windows/shopwindow.h b/src/gui/windows/shopwindow.h index a93e0d475..76971364b 100644 --- a/src/gui/windows/shopwindow.h +++ b/src/gui/windows/shopwindow.h @@ -77,7 +77,7 @@ class ShopWindow final : public Window, /** * Updates the labels according to the selected item. */ - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; /** * Updates the state of buttons and labels. diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 2a3b1c7b5..1793fc2fb 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -268,7 +268,7 @@ void TradeWindow::tradeItem(const Item *const item, const int quantity, Net::getTradeHandler()->addItem(item, quantity); } -void TradeWindow::valueChanged(const gcn::SelectionEvent &event) +void TradeWindow::valueChanged(const SelectionEvent &event) { if (!mMyItemContainer || !mPartnerItemContainer) return; diff --git a/src/gui/windows/tradewindow.h b/src/gui/windows/tradewindow.h index 6839b2f30..9704c1e80 100644 --- a/src/gui/windows/tradewindow.h +++ b/src/gui/windows/tradewindow.h @@ -109,7 +109,7 @@ class TradeWindow final : public Window, * Updates the labels and makes sure only one item is selected in * either my inventory or partner inventory. */ - void valueChanged(const gcn::SelectionEvent &event) override final; + void valueChanged(const SelectionEvent &event) override final; /** * Called when receiving actions from the widgets. diff --git a/src/listeners/selectionlistener.h b/src/listeners/selectionlistener.h index e258440e6..d3be0f0eb 100644 --- a/src/listeners/selectionlistener.h +++ b/src/listeners/selectionlistener.h @@ -66,7 +66,7 @@ #include -#include "gui/base/selectionevent.hpp" +#include "events/selectionevent.h" #include "localconsts.h" @@ -97,7 +97,7 @@ class SelectionListener * @param event The event of the value change. * @since 0.8.0 */ - virtual void valueChanged(const gcn::SelectionEvent &event A_UNUSED) + virtual void valueChanged(const SelectionEvent &event A_UNUSED) { } protected: -- cgit v1.2.3-70-g09d2 From 374005f4a84fd447fb6679a138b37c780d6e8b5d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 16:10:41 +0300 Subject: fix make file. --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3cdad0f60..98d843fbd 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -170,7 +170,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/input.hpp \ events/inputguievent.h \ gui/base/key.hpp \ - gui/base/keyevent.hpp \ + events/keyevent.h \ gui/base/keyinput.hpp \ listeners/keylistener.h \ gui/base/listmodel.hpp \ -- cgit v1.2.3-70-g09d2 From b3a0b3dc161face77bfd13791655c79343aab3a8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 16:46:23 +0300 Subject: Move inputevent into events directory. --- src/CMakeLists.txt | 3 +-- src/Makefile.am | 3 +-- src/actionmanager.cpp | 3 ++- src/events/inputevent.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++ src/input/inputevent.cpp | 29 ------------------------- src/input/inputevent.h | 51 ------------------------------------------- src/input/inputmanager.h | 3 ++- src/input/joystick.h | 2 +- src/input/keyboardconfig.h | 2 +- src/input/keydata.h | 2 +- 10 files changed, 63 insertions(+), 89 deletions(-) create mode 100644 src/events/inputevent.h delete mode 100644 src/input/inputevent.cpp delete mode 100644 src/input/inputevent.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b6d15922..3dd27b230 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -658,8 +658,7 @@ SET(SRCS textcommand.h input/inputmanager.cpp input/inputmanager.h - input/inputevent.cpp - input/inputevent.h + events/inputevent.h input/joystick.cpp input/joystick.h input/keyboardconfig.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 98d843fbd..90f09b6f7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -773,8 +773,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ spellshortcut.h \ textcommand.cpp \ textcommand.h \ - input/inputevent.cpp \ - input/inputevent.h \ + events/inputevent.h \ input/inputmanager.cpp \ input/inputmanager.h \ input/joystick.cpp \ diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 5b02e4aba..473e6cbc7 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -31,7 +31,8 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" -#include "input/inputevent.h" +#include "events/inputevent.h" + #include "input/inputmanager.h" #include "gui/sdlinput.h" diff --git a/src/events/inputevent.h b/src/events/inputevent.h new file mode 100644 index 000000000..2d8a36796 --- /dev/null +++ b/src/events/inputevent.h @@ -0,0 +1,54 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef EVENTS_INPUTEVENT_H +#define EVENTS_INPUTEVENT_H + +#include +#include + +#include "localconsts.h" + +typedef std::vector KeysVector; +typedef KeysVector::iterator KeysVectorIter; +typedef KeysVector::const_iterator KeysVectorCIter; + +typedef std::map KeyToActionMap; +typedef KeyToActionMap::iterator KeyToActionMapIter; + +typedef std::map KeyToIdMap; +typedef KeyToIdMap::iterator KeyToIdMapIter; + +typedef std::map KeyTimeMap; +typedef KeyTimeMap::iterator KeyTimeMapIter; + +struct InputEvent final +{ + InputEvent(const int action0, const int mask0) : + action(action0), + mask(mask0) + { } + + int action; + + int mask; +}; + +#endif // EVENTS_INPUTEVENT_H diff --git a/src/input/inputevent.cpp b/src/input/inputevent.cpp deleted file mode 100644 index b87e4fe0a..000000000 --- a/src/input/inputevent.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "input/inputevent.h" - -#include "debug.h" - -InputEvent::InputEvent(const int action0, const int mask0) : - action(action0), - mask(mask0) -{ -} diff --git a/src/input/inputevent.h b/src/input/inputevent.h deleted file mode 100644 index 61f80c8e2..000000000 --- a/src/input/inputevent.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef INPUT_INPUTEVENT_H -#define INPUT_INPUTEVENT_H - -#include -#include - -#include "localconsts.h" - -typedef std::vector KeysVector; -typedef KeysVector::iterator KeysVectorIter; -typedef KeysVector::const_iterator KeysVectorCIter; - -typedef std::map KeyToActionMap; -typedef KeyToActionMap::iterator KeyToActionMapIter; - -typedef std::map KeyToIdMap; -typedef KeyToIdMap::iterator KeyToIdMapIter; - -typedef std::map KeyTimeMap; -typedef KeyTimeMap::iterator KeyTimeMapIter; - -struct InputEvent final -{ - InputEvent(const int action0, const int mask0); - - int action; - - int mask; -}; - -#endif // INPUT_INPUTEVENT_H diff --git a/src/input/inputmanager.h b/src/input/inputmanager.h index 630b52948..fcd1252c0 100644 --- a/src/input/inputmanager.h +++ b/src/input/inputmanager.h @@ -21,7 +21,8 @@ #ifndef INPUT_INPUTMANAGER_H #define INPUT_INPUTMANAGER_H -#include "input/inputevent.h" +#include "events/inputevent.h" + #include "input/keydata.h" #include diff --git a/src/input/joystick.h b/src/input/joystick.h index 06823ca27..8693d0d75 100644 --- a/src/input/joystick.h +++ b/src/input/joystick.h @@ -23,7 +23,7 @@ #ifndef INPUT_JOYSTICK_H #define INPUT_JOYSTICK_H -#include "input/inputevent.h" +#include "events/inputevent.h" #include diff --git a/src/input/keyboardconfig.h b/src/input/keyboardconfig.h index 7f7102964..425a0c70c 100644 --- a/src/input/keyboardconfig.h +++ b/src/input/keyboardconfig.h @@ -27,7 +27,7 @@ #include "sdlshared.h" -#include "input/inputevent.h" +#include "events/inputevent.h" #include diff --git a/src/input/keydata.h b/src/input/keydata.h index 2ceb957c5..62517b64b 100644 --- a/src/input/keydata.h +++ b/src/input/keydata.h @@ -23,7 +23,7 @@ #ifndef INPUT_KEYDATA_H #define INPUT_KEYDATA_H -#include "input/inputevent.h" +#include "events/inputevent.h" #include -- cgit v1.2.3-70-g09d2 From 70b8ee71b559e968ad1b5c740703910f79351c5f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 17:07:21 +0300 Subject: move actorspritelistener into listeners directory. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/being/actorsprite.cpp | 3 ++- src/being/actorspritelistener.h | 44 ------------------------------------- src/being/localplayer.h | 2 +- src/listeners/actorspritelistener.h | 44 +++++++++++++++++++++++++++++++++++++ 6 files changed, 49 insertions(+), 48 deletions(-) delete mode 100644 src/being/actorspritelistener.h create mode 100644 src/listeners/actorspritelistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3dd27b230..4060c28b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -576,7 +576,7 @@ SET(SRCS being/actor.h being/actorsprite.cpp being/actorsprite.h - being/actorspritelistener.h + listeners/actorspritelistener.h actormanager.cpp actormanager.h animatedsprite.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 90f09b6f7..aa8edd335 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -693,7 +693,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being/actor.h \ being/actorsprite.cpp \ being/actorsprite.h \ - being/actorspritelistener.h \ + listeners/actorspritelistener.h \ actormanager.cpp \ actormanager.h \ animatedsprite.cpp \ diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 1426e481e..a74f4f477 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -25,11 +25,12 @@ #include "imagesprite.h" #include "statuseffect.h" -#include "being/actorspritelistener.h" #include "being/localplayer.h" #include "gui/theme.h" +#include "listeners/actorspritelistener.h" + #include "resources/resourcemanager.h" #include "utils/checkutils.h" diff --git a/src/being/actorspritelistener.h b/src/being/actorspritelistener.h deleted file mode 100644 index c89495c85..000000000 --- a/src/being/actorspritelistener.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef BEING_ACTORSPRITELISTENER_H -#define BEING_ACTORSPRITELISTENER_H - -class ActorSprite; - -class ActorSpriteListener -{ - public: - /** - * Destructor. - */ - virtual ~ActorSpriteListener() - { } - - /** - * Called when the ActorSprite has been destroyed. The listener will - * have to be registered first. - * @param actorSprite the ActorSprite being destroyed. - */ - virtual void actorSpriteDestroyed(const ActorSprite &actorSprite) = 0; -}; - -#endif // BEING_ACTORSPRITELISTENER_H diff --git a/src/being/localplayer.h b/src/being/localplayer.h index ce501bcec..5664b03b6 100644 --- a/src/being/localplayer.h +++ b/src/being/localplayer.h @@ -25,12 +25,12 @@ #include "listeners/depricatedlistener.h" -#include "being/actorspritelistener.h" #include "being/being.h" #include "gui/userpalette.h" #include "listeners/actionlistener.h" +#include "listeners/actorspritelistener.h" #include diff --git a/src/listeners/actorspritelistener.h b/src/listeners/actorspritelistener.h new file mode 100644 index 000000000..7b4d89b44 --- /dev/null +++ b/src/listeners/actorspritelistener.h @@ -0,0 +1,44 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LISTENERS_ACTORSPRITELISTENER_H +#define LISTENERS_ACTORSPRITELISTENER_H + +class ActorSprite; + +class ActorSpriteListener +{ + public: + /** + * Destructor. + */ + virtual ~ActorSpriteListener() + { } + + /** + * Called when the ActorSprite has been destroyed. The listener will + * have to be registered first. + * @param actorSprite the ActorSprite being destroyed. + */ + virtual void actorSpriteDestroyed(const ActorSprite &actorSprite) = 0; +}; + +#endif // LISTENERS_ACTORSPRITELISTENER_H -- cgit v1.2.3-70-g09d2 From 07e8275965ccb989e3bcc288e2440bffcbca4a8e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 17:14:00 +0300 Subject: move playerrelationlistener into listeners directory. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/being/playerrelations.h | 2 +- src/being/playerrelationslistener.h | 43 --------------------------------- src/gui/windows/socialwindow.h | 3 +-- src/listeners/playerrelationslistener.h | 43 +++++++++++++++++++++++++++++++++ 6 files changed, 47 insertions(+), 48 deletions(-) delete mode 100644 src/being/playerrelationslistener.h create mode 100644 src/listeners/playerrelationslistener.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4060c28b8..5e2385332 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -720,7 +720,7 @@ SET(SRCS being/playerinfo.h being/playerrelations.cpp being/playerrelations.h - being/playerrelationslistener.h + listeners/playerrelationslistener.h position.cpp position.h properties.h diff --git a/src/Makefile.am b/src/Makefile.am index aa8edd335..ca18b42a0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -835,7 +835,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ being/playerinfo.h \ being/playerrelations.cpp \ being/playerrelations.h \ - being/playerrelationslistener.h \ + listeners/playerrelationslistener.h \ position.cpp \ position.h \ properties.h \ diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h index 360930879..cddec5f10 100644 --- a/src/being/playerrelations.h +++ b/src/being/playerrelations.h @@ -25,7 +25,7 @@ #include "utils/stringvector.h" -#include "being/playerrelationslistener.h" +#include "listeners/playerrelationslistener.h" #include #include diff --git a/src/being/playerrelationslistener.h b/src/being/playerrelationslistener.h deleted file mode 100644 index 983f731e4..000000000 --- a/src/being/playerrelationslistener.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef BEING_PLAYERRELATIONSLISTENER_H -#define BEING_PLAYERRELATIONSLISTENER_H - -#include - -class PlayerRelationsListener -{ - public: - virtual ~PlayerRelationsListener() - { } - - virtual void updatedPlayer(const std::string &name) = 0; - - virtual void updateAll() = 0; - - protected: - PlayerRelationsListener() - { } -}; - -#endif // BEING_PLAYERRELATIONSLISTENER_H diff --git a/src/gui/windows/socialwindow.h b/src/gui/windows/socialwindow.h index fc93aed4f..57fbd5be5 100644 --- a/src/gui/windows/socialwindow.h +++ b/src/gui/windows/socialwindow.h @@ -24,9 +24,8 @@ #include "gui/widgets/window.h" -#include "being/playerrelationslistener.h" - #include "listeners/actionlistener.h" +#include "listeners/playerrelationslistener.h" #include #include diff --git a/src/listeners/playerrelationslistener.h b/src/listeners/playerrelationslistener.h new file mode 100644 index 000000000..b95f18c33 --- /dev/null +++ b/src/listeners/playerrelationslistener.h @@ -0,0 +1,43 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef LISTERNERS_PLAYERRELATIONSLISTENER_H +#define LISTERNERS_PLAYERRELATIONSLISTENER_H + +#include + +class PlayerRelationsListener +{ + public: + virtual ~PlayerRelationsListener() + { } + + virtual void updatedPlayer(const std::string &name) = 0; + + virtual void updateAll() = 0; + + protected: + PlayerRelationsListener() + { } +}; + +#endif // LISTERNERS_PLAYERRELATIONSLISTENER_H -- cgit v1.2.3-70-g09d2 From 82ac4641828ec7387863bb18cf4493190c4cc68f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 21:28:08 +0300 Subject: Remove Exception class. --- src/CMakeLists.txt | 2 - src/Makefile.am | 4 - src/gui/base/basiccontainer.cpp | 10 +- src/gui/base/exception.cpp | 120 ---------------------- src/gui/base/exception.hpp | 196 ------------------------------------ src/gui/base/focushandler.cpp | 9 +- src/gui/base/gui.cpp | 7 +- src/gui/base/widget.cpp | 26 +---- src/gui/base/widgets/button.cpp | 1 - src/gui/base/widgets/container.cpp | 1 - src/gui/base/widgets/label.cpp | 1 - src/gui/base/widgets/scrollarea.cpp | 9 +- src/gui/base/widgets/window.cpp | 1 - src/gui/gui.cpp | 69 ++----------- src/gui/sdlfont.cpp | 8 +- src/gui/sdlinput.cpp | 10 +- src/gui/widgets/popup.cpp | 8 +- src/gui/widgets/window.cpp | 7 +- src/input/inputmanager.cpp | 29 ++---- 19 files changed, 38 insertions(+), 480 deletions(-) delete mode 100644 src/gui/base/exception.cpp delete mode 100644 src/gui/base/exception.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5e2385332..41f99a646 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -772,7 +772,6 @@ SET(SRCS gui/base/color.hpp listeners/deathlistener.h events/event.h - gui/base/exception.hpp gui/base/focushandler.hpp listeners/focuslistener.h gui/base/font.hpp @@ -807,7 +806,6 @@ SET(SRCS gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp gui/base/color.cpp - gui/base/exception.cpp gui/base/focushandler.cpp gui/base/font.cpp gui/base/gui.cpp diff --git a/src/Makefile.am b/src/Makefile.am index ca18b42a0..c60b782a7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,6 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/exception.cpp \ gui/base/font.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ @@ -36,7 +35,6 @@ dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ events/event.h \ - gui/base/exception.hpp \ gui/base/font.hpp \ gui/base/rectangle.hpp \ gui/base/widget.hpp @@ -161,7 +159,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/color.hpp \ listeners/deathlistener.h \ events/event.h \ - gui/base/exception.hpp \ gui/base/focushandler.hpp \ listeners/focuslistener.h \ gui/base/font.hpp \ @@ -197,7 +194,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/exception.cpp \ gui/base/focushandler.cpp \ gui/base/font.cpp \ gui/base/gui.cpp \ diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 7a937fb42..4a745dc63 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -69,7 +69,6 @@ #include -#include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/mouseinput.hpp" @@ -96,8 +95,6 @@ namespace gcn return; } } - - throw GCN_EXCEPTION("There is no such widget in this container."); } void BasicContainer::moveToBottom(Widget* widget) @@ -106,11 +103,10 @@ namespace gcn iter = std::find(mWidgets.begin(), mWidgets.end(), widget); if (iter == mWidgets.end()) - throw GCN_EXCEPTION("There is no such widget in this container."); + return; mWidgets.erase(iter); mWidgets.insert(mWidgets.begin(), widget); -// mWidgets.push_front(widget); } void BasicContainer::death(const Event& event) @@ -119,7 +115,7 @@ namespace gcn iter = std::find(mWidgets.begin(), mWidgets.end(), event.getSource()); if (iter == mWidgets.end()) - throw GCN_EXCEPTION("There is no such widget in this container."); + return; mWidgets.erase(iter); } @@ -260,8 +256,6 @@ namespace gcn return; } } - - throw GCN_EXCEPTION("There is no such widget in this container."); } void BasicContainer::clear() diff --git a/src/gui/base/exception.cpp b/src/gui/base/exception.cpp deleted file mode 100644 index 998db928d..000000000 --- a/src/gui/base/exception.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/exception.hpp" - -#include "debug.h" - -namespace gcn -{ - Exception::Exception() - : mFunction("?"), - mMessage(""), - mFilename("?"), - mLine(0) - { - } - - Exception::Exception(const std::string& message) - : mFunction("?"), - mMessage(message), - mFilename("?"), - mLine(0) - { - } - - Exception::Exception(const std::string& message, - const std::string& function, - const std::string& filename, - const unsigned int line) - : mFunction(function), - mMessage(message), - mFilename(filename), - mLine(line) - { - } - - const std::string& Exception::getFunction() const - { - return mFunction; - } - - const std::string& Exception::getMessage() const - { - return mMessage; - } - - const std::string& Exception::getFilename() const - { - return mFilename; - } - - unsigned int Exception::getLine() const - { - return mLine; - } -} // namespace gcn diff --git a/src/gui/base/exception.hpp b/src/gui/base/exception.hpp deleted file mode 100644 index a60152c96..000000000 --- a/src/gui/base/exception.hpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_EXCEPTION_HPP -#define GCN_EXCEPTION_HPP - -#include - -#include "localconsts.h" - -#ifndef __FUNCTION__ -#define __FUNCTION__ "?" -#endif - -/* - * A macro used to create a standard exception object. - * What it basicly does is that it creates a new exception - * and automatically sets the filename and line number where - * the exception occured by using other compiler macros. - */ -#define GCN_EXCEPTION(mess) gcn::Exception(mess, \ - __FUNCTION__, \ - __FILE__, \ - __LINE__) - -namespace gcn -{ - - /** - * An exception containing a message, a file and a line number - * where the exception occured. Guichan will only throw exceptions - * of this class. - * - * You can use this class for your own exceptions that has - * something to do with a GUI exception. A nifty feature of the - * excpetion class is that it can tell you from which line and - * file it was thrown. To make things easier when throwing - * exceptions there exists a macro for creating exceptions - * which automatically sets the filename and line number. - * - * EXAMPLE: @code - * throw GCN_EXCEPTION("my error message"); - * @endcode - */ - class Exception final - { - public: - /** - * Constructor. - */ - Exception(); - - /** - * Constructor. - * - * @param message The error message of the exception. - */ - explicit Exception(const std::string& message); - - /** - * Constructor. - * - * NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead. - * This constructor merely exists for the GCN_EXCEPTION macro to - * use. - * - * @param message The error message of the exception. - * @param function The function name where the exception occured. - * @param filename The name of the file where the exception occured. - * @param line The line number in the source code where the exception - * occured. - */ - Exception(const std::string& message, - const std::string& function, - const std::string& filename, - const unsigned int line); - - /** - * Gets the function name where the exception occured. - * - * @return The function name where the exception occured. - */ - const std::string& getFunction() const A_WARN_UNUSED; - - /** - * Gets the error message of the exception. - * - * @return The error message of the exception. - */ - const std::string& getMessage() const A_WARN_UNUSED; - - /** - * Gets the filename where the exception occured. - * - * @return The filename where the exception occured. - */ - const std::string& getFilename() const A_WARN_UNUSED; - - /** - * Gets the line number where the exception occured. - * - * @return The line number where the exception occured. - */ - unsigned int getLine() const A_WARN_UNUSED; - - protected: - /** - * Holds the name of the function name where the - * exception occured. - */ - std::string mFunction; - - /** - * Holds the error message of the exception. - */ - std::string mMessage; - - /** - * Holds the filename where the exception occured. - */ - std::string mFilename; - - /** - * Holds the line number where the exception occured. - */ - unsigned int mLine; - }; -} // namespace gcn - -#endif // end GCN_EXCEPTION_HPP - -/* - * "Final Fantasy XI is the BEST!... It's even better then water!" - * - Astrolite - * I believe it's WoW now days. - */ diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp index ff149bf99..3c6978e70 100644 --- a/src/gui/base/focushandler.cpp +++ b/src/gui/base/focushandler.cpp @@ -67,7 +67,6 @@ #include "gui/base/focushandler.hpp" -#include "gui/base/exception.hpp" #include "gui/base/widget.hpp" #include "listeners/focuslistener.h" @@ -106,7 +105,7 @@ namespace gcn } if (toBeFocusedIndex < 0) - throw GCN_EXCEPTION("Trying to focus a none existing widget."); + return; Widget *const oldFocused = mFocusedWidget; @@ -128,10 +127,9 @@ namespace gcn void FocusHandler::requestModalFocus(Widget* widget) { if (mModalFocusedWidget && mModalFocusedWidget != widget) - throw GCN_EXCEPTION("Another widget already has modal focus."); + return; mModalFocusedWidget = widget; - if (mFocusedWidget && !mFocusedWidget->isModalFocused()) focusNone(); } @@ -141,8 +139,7 @@ namespace gcn if (mModalMouseInputFocusedWidget && mModalMouseInputFocusedWidget != widget) { - throw GCN_EXCEPTION("Another widget already has " - "modal input focus."); + return; } mModalMouseInputFocusedWidget = widget; diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index f16048bbb..e6fc79856 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -68,7 +68,6 @@ #include "gui/base/gui.hpp" #include "gui/base/basiccontainer.hpp" -#include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/input.hpp" #include "gui/base/keyinput.hpp" @@ -532,7 +531,7 @@ namespace gcn (*it)->mouseClicked(mouseEvent); break; default: - throw GCN_EXCEPTION("Unknown mouse event type."); + break; } } @@ -608,7 +607,7 @@ namespace gcn (*it)->keyReleased(keyEvent); break; default: - throw GCN_EXCEPTION("Unknown key event type."); + break; } } } @@ -641,7 +640,7 @@ namespace gcn (*it)->keyReleased(keyEvent); break; default: - throw GCN_EXCEPTION("Unknown key event type."); + break; } if (keyEvent.isConsumed()) diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index 6083fb35a..e0f33d498 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -71,7 +71,6 @@ #include "gui/base/basiccontainer.hpp" #include "events/event.h" -#include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/keyinput.hpp" #include "gui/base/mouseinput.hpp" @@ -276,10 +275,7 @@ namespace gcn void Widget::requestFocus() { if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } + return; if (isFocusable()) mFocusHandler->requestFocus(this); @@ -521,10 +517,7 @@ namespace gcn void Widget::requestModalFocus() { if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } + return; mFocusHandler->requestModalFocus(this); } @@ -532,10 +525,7 @@ namespace gcn void Widget::requestModalMouseInputFocus() { if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } + return; mFocusHandler->requestModalMouseInputFocus(this); } @@ -559,10 +549,7 @@ namespace gcn bool Widget::isModalFocused() const { if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } + return false; if (mParent) { @@ -576,10 +563,7 @@ namespace gcn bool Widget::isModalMouseInputFocused() const { if (!mFocusHandler) - { - throw GCN_EXCEPTION("No focushandler set (did you add " - "the widget to the gui?)."); - } + return false; if (mParent) { diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 8cf49da4b..1276b82b2 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -67,7 +67,6 @@ #include "gui/base/widgets/button.hpp" -#include "gui/base/exception.hpp" #include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp index d72f2a682..6026b920d 100644 --- a/src/gui/base/widgets/container.cpp +++ b/src/gui/base/widgets/container.cpp @@ -67,7 +67,6 @@ #include "gui/base/widgets/container.hpp" -#include "gui/base/exception.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index f4576d908..c23666eac 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -67,7 +67,6 @@ #include "gui/base/widgets/label.hpp" -#include "gui/base/exception.hpp" #include "gui/base/font.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index ffcaffdb1..f76226bc5 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -67,7 +67,6 @@ #include "gui/base/widgets/scrollarea.hpp" -#include "gui/base/exception.hpp" #include "render/graphics.h" @@ -300,8 +299,6 @@ namespace gcn { if (width > 0) mScrollbarWidth = width; - else - throw GCN_EXCEPTION("Width should be greater then 0."); } int ScrollArea::getScrollbarWidth() const @@ -446,7 +443,7 @@ namespace gcn break; default: - throw GCN_EXCEPTION("Horizontal scroll policy invalid."); + break; } switch (mVPolicy) @@ -471,7 +468,7 @@ namespace gcn } break; default: - throw GCN_EXCEPTION("Vertical scroll policy invalid."); + break; } } @@ -491,7 +488,7 @@ namespace gcn { const Widget *const content = getContent(); if (widget != content) - throw GCN_EXCEPTION("Widget not content widget"); + return; BasicContainer::showWidgetPart(widget, area); diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 02611f819..9207fe449 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -67,7 +67,6 @@ #include "gui/base/widgets/window.hpp" -#include "gui/base/exception.hpp" #include "gui/base/font.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 649e547d7..08794d478 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -53,8 +53,6 @@ #include "utils/langs.h" #include "utils/timer.h" -#include "gui/base/exception.hpp" - #include "debug.h" // Guichan stuff @@ -162,16 +160,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("font"); - try - { - mGuiFont = new SDLFont(fontFile, fontSize); - } - catch (const gcn::Exception &e) - { - logger->error(std::string("Unable to load '").append(fontFile) - .append("': ").append(e.getMessage())); - } - + mGuiFont = new SDLFont(fontFile, fontSize); // Set particle font fontFile = config.getValue("particleFont", ""); @@ -190,65 +179,28 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("particleFont"); - try - { - mInfoParticleFont = new SDLFont( - fontFile, fontSize, TTF_STYLE_BOLD); - } - catch (const gcn::Exception &e) - { - logger->error(std::string("Unable to load '").append(fontFile) - .append("': ").append(e.getMessage())); - } - + mInfoParticleFont = new SDLFont(fontFile, fontSize, TTF_STYLE_BOLD); // Set bold font fontFile = config.getValue("boldFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("boldFont"); - try - { - boldFont = new SDLFont(fontFile, fontSize); - } - catch (const gcn::Exception &e) - { - logger->error(std::string("Unable to load '").append(fontFile) - .append("': ").append(e.getMessage())); - } - + boldFont = new SDLFont(fontFile, fontSize); // Set help font fontFile = config.getValue("helpFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("helpFont"); - try - { - mHelpFont = new SDLFont(fontFile, fontSize); - } - catch (const gcn::Exception &e) - { - logger->error(std::string("Unable to load '").append(fontFile) - .append("': ").append(e.getMessage())); - } - + mHelpFont = new SDLFont(fontFile, fontSize); // Set secure font fontFile = config.getValue("secureFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("secureFont"); - try - { - mSecureFont = new SDLFont(fontFile, fontSize); - } - catch (const gcn::Exception &e) - { - logger->error(std::string("Unable to load '").append(fontFile) - .append("': ").append(e.getMessage())); - } - + mSecureFont = new SDLFont(fontFile, fontSize); // Set npc font const int npcFontSize = config.getIntValue("npcfontSize"); @@ -268,15 +220,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("npcFont"); - try - { - mNpcFont = new SDLFont(fontFile, npcFontSize); - } - catch (const gcn::Exception &e) - { - logger->error(std::string("Unable to load '").append(fontFile) - .append("': ").append(e.getMessage())); - } + mNpcFont = new SDLFont(fontFile, npcFontSize); gcn::Widget::setGlobalFont(mGuiFont); @@ -853,7 +797,6 @@ void Gui::handleMouseInput() handleMouseWheelMovedUp(mouseInput); break; default: - throw GCN_EXCEPTION("Unknown mouse input type."); break; } } diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp index bed4a9f31..95a3df390 100644 --- a/src/gui/sdlfont.cpp +++ b/src/gui/sdlfont.cpp @@ -39,8 +39,6 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/base/exception.hpp" - #include "debug.h" const unsigned int CACHE_SIZE = 256; @@ -350,7 +348,7 @@ SDLFont::SDLFont(std::string filename, mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE; if (TTF_Init() == -1) { - throw GCN_EXCEPTION("Unable to initialize SDL_ttf: " + + logger->error("Unable to initialize SDL_ttf: " + std::string(TTF_GetError())); } } @@ -373,8 +371,8 @@ SDLFont::SDLFont(std::string filename, mFont = openFont(fixDirSeparators(backFile).c_str(), size); if (!mFont) { - throw GCN_EXCEPTION("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); + logger->error("SDLSDLFont::SDLSDLFont: " + + std::string(TTF_GetError())); } } diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index c81f11802..661be07c5 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -90,8 +90,6 @@ #include #include -#include "gui/base/exception.hpp" - SDLInput::SDLInput() : mKeyInputQueue(), mMouseInputQueue(), @@ -108,9 +106,7 @@ bool SDLInput::isKeyQueueEmpty() KeyInput SDLInput::dequeueKeyInput2() { if (mKeyInputQueue.empty()) - { - throw GCN_EXCEPTION("The queue is empty."); - } + return KeyInput(); KeyInput keyInput = mKeyInputQueue.front(); mKeyInputQueue.pop(); @@ -128,7 +124,7 @@ gcn::MouseInput SDLInput::dequeueMouseInput() gcn::MouseInput mouseInput; if (mMouseInputQueue.empty()) - throw GCN_EXCEPTION("The queue is empty."); + return MouseInput(); mouseInput = mMouseInputQueue.front(); mMouseInputQueue.pop(); @@ -141,7 +137,7 @@ MouseInput SDLInput::dequeueMouseInput2() MouseInput mouseInput; if (mMouseInputQueue.empty()) - throw GCN_EXCEPTION("The queue is empty."); + return MouseInput(); mouseInput = mMouseInputQueue.front(); mMouseInputQueue.pop(); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index a61ba5275..178695891 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -27,8 +27,6 @@ #include "gui/viewport.h" -#include "gui/base/exception.hpp" - #include "debug.h" Popup::Popup(const std::string &name, @@ -48,9 +46,6 @@ Popup::Popup(const std::string &name, { logger->log("Popup::Popup(\"%s\")", name.c_str()); - if (!windowContainer) - throw GCN_EXCEPTION("Popup::Popup(): no windowContainer set"); - addWidgetListener(this); if (skin == "") @@ -67,7 +62,8 @@ Popup::Popup(const std::string &name, } } - windowContainer->add(this); + if (windowContainer) + windowContainer->add(this); // Popups are invisible by default setVisible(false); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index e9e1ed71e..c250e79a1 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -37,7 +37,6 @@ #include "resources/cursor.h" #include "resources/image.h" -#include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/font.hpp" @@ -92,9 +91,6 @@ Window::Window(const std::string &caption, const bool modal, { logger->log("Window::Window(\"%s\")", caption.c_str()); - if (!windowContainer) - throw GCN_EXCEPTION("Window::Window(): no windowContainer set"); - windowInstances++; setFrameSize(0); @@ -142,7 +138,8 @@ Window::Window(const std::string &caption, const bool modal, } // Add this window to the window container - windowContainer->add(this); + if (windowContainer) + windowContainer->add(this); if (mModal) { diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 7243bbf97..46494532a 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -51,7 +51,6 @@ #include "utils/timer.h" -#include "gui/base/exception.hpp" #include "gui/base/focushandler.hpp" #include @@ -549,18 +548,10 @@ bool InputManager::handleEvent(const SDL_Event &event) if (quitDialog || TextDialog::isActive() || NpcPostDialog::isActive()) { - try - { - if (guiInput) - guiInput->pushInput(event); - if (gui) - gui->handleInput(); - } - catch(const gcn::Exception &e) - { - const char *const err = e.getMessage().c_str(); - logger->log("Warning: guichan input exception: %s", err); - } + if (guiInput) + guiInput->pushInput(event); + if (gui) + gui->handleInput(); return true; } break; @@ -605,16 +596,8 @@ bool InputManager::handleEvent(const SDL_Event &event) break; } - try - { - if (guiInput) - guiInput->pushInput(event); - } - catch(const gcn::Exception &e) - { - const char *const err = e.getMessage().c_str(); - logger->log("Warning: guichan input exception: %s", err); - } + if (guiInput) + guiInput->pushInput(event); if (gui) { const bool res = gui->handleInput(); -- cgit v1.2.3-70-g09d2 From 6e6c5b2ba399e0ed364ada843c4c759ee54de219 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 22:17:22 +0300 Subject: combine font classes in one. --- src/CMakeLists.txt | 6 +- src/Makefile.am | 8 +- src/being/being.cpp | 8 +- src/being/localplayer.cpp | 2 +- src/commands.cpp | 4 +- src/flooritem.cpp | 4 +- src/gui/base/font.cpp | 87 ----- src/gui/base/font.hpp | 133 ------- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/checkbox.cpp | 3 +- src/gui/base/widgets/label.cpp | 2 +- src/gui/base/widgets/listbox.cpp | 4 +- src/gui/base/widgets/radiobutton.cpp | 3 +- src/gui/base/widgets/textbox.cpp | 3 +- src/gui/base/widgets/textfield.cpp | 3 +- src/gui/base/widgets/window.cpp | 3 +- src/gui/gui.cpp | 16 +- src/gui/gui.h | 24 +- src/gui/popups/beingpopup.cpp | 4 +- src/gui/popups/itempopup.cpp | 4 +- src/gui/popups/speechbubble.cpp | 4 +- src/gui/popups/spellpopup.cpp | 2 +- src/gui/popups/statuspopup.cpp | 2 +- src/gui/popups/textpopup.cpp | 2 +- src/gui/sdlfont.cpp | 603 ----------------------------- src/gui/sdlfont.h | 168 -------- src/gui/viewport.cpp | 4 +- src/gui/widgets/avatarlistbox.cpp | 6 +- src/gui/widgets/browserbox.cpp | 9 +- src/gui/widgets/button.cpp | 6 +- src/gui/widgets/checkbox.cpp | 4 +- src/gui/widgets/colorpage.cpp | 6 +- src/gui/widgets/dropdown.cpp | 4 +- src/gui/widgets/dropshortcutcontainer.cpp | 4 +- src/gui/widgets/emoteshortcutcontainer.cpp | 5 +- src/gui/widgets/extendedlistbox.cpp | 5 +- src/gui/widgets/itemcontainer.cpp | 4 +- src/gui/widgets/itemshortcutcontainer.cpp | 5 +- src/gui/widgets/label.cpp | 8 +- src/gui/widgets/listbox.cpp | 6 +- src/gui/widgets/progressbar.cpp | 6 +- src/gui/widgets/radiobutton.cpp | 6 +- src/gui/widgets/setupitem.cpp | 6 +- src/gui/widgets/shoplistbox.cpp | 4 +- src/gui/widgets/sliderlist.cpp | 5 +- src/gui/widgets/spellshortcutcontainer.cpp | 5 +- src/gui/widgets/tabs/setup_colors.cpp | 4 +- src/gui/widgets/tabs/setup_input.cpp | 2 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/tabs/tab.h | 2 +- src/gui/widgets/textbox.cpp | 6 +- src/gui/widgets/textfield.cpp | 6 +- src/gui/widgets/textpreview.cpp | 9 +- src/gui/widgets/textpreview.h | 4 +- src/gui/widgets/window.cpp | 4 +- src/gui/widgets/window.h | 4 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/confirmdialog.cpp | 2 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/equipmentwindow.cpp | 5 +- src/gui/windows/helpwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 4 +- src/gui/windows/npcdialog.cpp | 6 +- src/gui/windows/okdialog.cpp | 2 +- src/gui/windows/questswindow.cpp | 2 +- src/gui/windows/serverdialog.cpp | 10 +- src/gui/windows/skilldialog.cpp | 5 +- src/gui/windows/textdialog.cpp | 4 +- src/gui/windows/tradewindow.cpp | 6 +- src/maplayer.cpp | 4 +- src/particle/particle.cpp | 4 +- src/particle/particle.h | 7 +- src/particle/textparticle.cpp | 4 +- src/particle/textparticle.h | 4 +- src/text.cpp | 8 +- src/text.h | 11 +- src/touchmanager.cpp | 4 +- 78 files changed, 167 insertions(+), 1189 deletions(-) delete mode 100644 src/gui/base/font.cpp delete mode 100644 src/gui/base/font.hpp delete mode 100644 src/gui/sdlfont.cpp delete mode 100644 src/gui/sdlfont.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 41f99a646..ed80c00cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -364,8 +364,8 @@ SET(SRCS gui/widgets/tabs/setup_visual.cpp gui/widgets/tabs/setup_visual.h gui/setupactiondata.h - gui/sdlfont.cpp - gui/sdlfont.h + gui/font.cpp + gui/font.h gui/windows/shopwindow.cpp gui/windows/shopwindow.h gui/windows/shortcutwindow.cpp @@ -774,7 +774,6 @@ SET(SRCS events/event.h gui/base/focushandler.hpp listeners/focuslistener.h - gui/base/font.hpp gui/base/gui.hpp gui/base/input.hpp events/inputguievent.h @@ -807,7 +806,6 @@ SET(SRCS gui/base/cliprectangle.cpp gui/base/color.cpp gui/base/focushandler.cpp - gui/base/font.cpp gui/base/gui.cpp gui/base/key.cpp gui/base/keyinput.cpp diff --git a/src/Makefile.am b/src/Makefile.am index c60b782a7..09579cc29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,14 +28,12 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/font.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ events/event.h \ - gui/base/font.hpp \ gui/base/rectangle.hpp \ gui/base/widget.hpp @@ -161,7 +159,6 @@ manaplus_SOURCES += events/actionevent.h \ events/event.h \ gui/base/focushandler.hpp \ listeners/focuslistener.h \ - gui/base/font.hpp \ render/graphics.h \ gui/base/gui.hpp \ gui/base/input.hpp \ @@ -195,7 +192,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ gui/base/focushandler.cpp \ - gui/base/font.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ gui/base/keyinput.cpp \ @@ -473,8 +469,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabs/setup_visual.cpp \ gui/widgets/tabs/setup_visual.h \ gui/setupactiondata.h \ - gui/sdlfont.cpp \ - gui/sdlfont.h \ + gui/font.cpp \ + gui/font.h \ gui/windows/shopwindow.cpp \ gui/windows/shopwindow.h \ gui/windows/shortcutwindow.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 8b2ece2b7..1fcccb0cf 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -39,7 +39,7 @@ #include "particle/particle.h" #include "particle/particleinfo.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/popups/speechbubble.h" @@ -537,7 +537,7 @@ void Being::takeDamage(Being *const attacker, const int amount, if (!userPalette || !attacker) return; - gcn::Font *font = nullptr; + Font *font = nullptr; // TRANSLATORS: hit or miss message in attacks const std::string damage = amount ? toString(amount) : type == FLEE ? _("dodge") : _("miss"); @@ -2003,7 +2003,7 @@ void Being::showName() displayName.append(", ").append(toString(getDamageTaken())); } - gcn::Font *font = nullptr; + Font *font = nullptr; if (player_node && player_node->getTarget() == this && mType != MONSTER) { @@ -2519,7 +2519,7 @@ void Being::drawSpriteAt(Graphics *const graphics, if (mDrawHotKeys && !mName.empty()) { - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); if (font) { graphics->setColor(userPalette->getColor(UserPalette::BEING)); diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index ea8218ee4..0e57eabfe 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -42,8 +42,8 @@ #include "input/keyboardconfig.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/chatwindow.h" diff --git a/src/commands.cpp b/src/commands.cpp index 04cd84166..93e07b0f8 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1024,7 +1024,7 @@ impHandler0(cacheInfo) return; /* - SDLFont *const font = dynamic_cast(chatWindow->getFont()); + Font *const font = chatWindow->getFont(); if (!font) return; @@ -1361,7 +1361,7 @@ impHandler0(uploadLog) impHandler0(testsdlfont) { #if defined USE_OPENGL && defined DEBUG_SDLFONT - SDLFont *font = new SDLFont("fonts/dejavusans.ttf", 18); + Font *font = new Font("fonts/dejavusans.ttf", 18); timespec time1; timespec time2; NullOpenGLGraphics *nullGraphics = new NullOpenGLGraphics; diff --git a/src/flooritem.cpp b/src/flooritem.cpp index bf8b54f0b..2592e6feb 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -26,8 +26,8 @@ #include "render/graphics.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/userpalette.h" #include "resources/iteminfo.h" @@ -109,7 +109,7 @@ void FloorItem::draw(Graphics *const graphics, BLOCK_START("FloorItem::draw") const int x = mX * mMap->getTileWidth() + offsetX; const int y = mY * mMap->getTileHeight() + offsetY; - gcn::Font *font = nullptr; + Font *font = nullptr; if (mHighlight) { diff --git a/src/gui/base/font.cpp b/src/gui/base/font.cpp deleted file mode 100644 index ccb2f7022..000000000 --- a/src/gui/base/font.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/font.hpp" - -#include - -#include "debug.h" - -namespace gcn -{ - int Font::getStringIndexAt(const std::string& text, const int x) const - { - const size_t sz = text.size(); - for (size_t i = 0; i < sz; ++i) - { - if (getWidth(text.substr(0, i)) > x) - return i; - } - - return static_cast(sz); - } -} // namespace gcn diff --git a/src/gui/base/font.hpp b/src/gui/base/font.hpp deleted file mode 100644 index 075af4136..000000000 --- a/src/gui/base/font.hpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_FONT_HPP -#define GCN_FONT_HPP - -#include - -#include "localconsts.h" - -class Graphics; - -namespace gcn -{ - /** - * Interface for a font. - * - * @see ImageFont - */ - class Font - { - public: - /** - * Destructor. - */ - virtual ~Font() - { } - - /** - * Gets the width of a string. The width of a string is not necesserily - * the sum of all the widths of it's glyphs. - * - * @param text The string to return the width of. - * @return The width of a string. - */ - virtual int getWidth(const std::string& text) const A_WARN_UNUSED = 0; - - /** - * Gets the height of the glyphs in the font. - * - * @return The height of the glyphs int the font. - */ - virtual int getHeight() const A_WARN_UNUSED = 0; - - /** - * Gets a string index in a string providing an x coordinate. - * Used to retrive a string index (for a character in a - * string) at a certain x position. It is especially useful - * when a mouse clicks in a TextField and you want to know which - * character was clicked. - * - * @return A string index in a string providing an x coordinate. - */ - virtual int getStringIndexAt(const std::string& text, - const int x) const A_WARN_UNUSED; - - /** - * Draws a string. - * - * NOTE: You normally won't use this function to draw text since - * Graphics contains better functions for drawing text. - * - * @param graphics A Graphics object to use for drawing. - * @param text The string to draw. - * @param x The x coordinate where to draw the string. - * @param y The y coordinate where to draw the string. - */ - virtual void drawString(Graphics* graphics, const std::string& text, - int x, int y) = 0; - }; -} // namespace gcn - -#endif // end GCN_FONT_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index ce32b14f3..a459ab4f2 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -76,6 +76,7 @@ class ActionListener; class DeathListener; class FocusListener; +class Font; class Graphics; class KeyListener; class MouseListener; @@ -85,7 +86,6 @@ namespace gcn { class BasicContainer; class FocusHandler; - class Font; class KeyInput; class MouseInput; diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 1276b82b2..9b7473293 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/button.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 5f2477b4d..0a3171fe8 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/checkbox.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index c23666eac..cbee2ac4c 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -67,7 +67,7 @@ #include "gui/base/widgets/label.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 7f46b4b10..6c6472636 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -67,11 +67,13 @@ #include "gui/base/widgets/listbox.hpp" +#include "gui/font.h" + #include "gui/base/basiccontainer.hpp" -#include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" #include "gui/base/mouseinput.hpp" + #include "listeners/selectionlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index e42773de1..f0430c7a2 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/radiobutton.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 06d0e6379..e994804d8 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -67,8 +67,9 @@ #include "gui/base/widgets/textbox.hpp" +#include "gui/font.h" + #include "gui/base/basiccontainer.hpp" -#include "gui/base/font.hpp" #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index df1b844d4..1514d3afb 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/textfield.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/key.hpp" #include "gui/base/mouseinput.hpp" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 9207fe449..fbd42aff2 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -67,7 +67,8 @@ #include "gui/base/widgets/window.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/mouseinput.hpp" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 08794d478..f549727a4 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -25,8 +25,8 @@ #include "gui/gui.h" #include "gui/focushandler.h" +#include "gui/font.h" #include "gui/palette.h" -#include "gui/sdlfont.h" #include "gui/sdlinput.h" #include "gui/theme.h" #include "gui/viewport.h" @@ -60,7 +60,7 @@ Gui *gui = nullptr; SDLInput *guiInput = nullptr; // Bolded font -SDLFont *boldFont = nullptr; +Font *boldFont = nullptr; class GuiConfigListener final : public ConfigListener { @@ -160,7 +160,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("font"); - mGuiFont = new SDLFont(fontFile, fontSize); + mGuiFont = new Font(fontFile, fontSize); // Set particle font fontFile = config.getValue("particleFont", ""); @@ -179,28 +179,28 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("particleFont"); - mInfoParticleFont = new SDLFont(fontFile, fontSize, TTF_STYLE_BOLD); + mInfoParticleFont = new Font(fontFile, fontSize, TTF_STYLE_BOLD); // Set bold font fontFile = config.getValue("boldFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("boldFont"); - boldFont = new SDLFont(fontFile, fontSize); + boldFont = new Font(fontFile, fontSize); // Set help font fontFile = config.getValue("helpFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("helpFont"); - mHelpFont = new SDLFont(fontFile, fontSize); + mHelpFont = new Font(fontFile, fontSize); // Set secure font fontFile = config.getValue("secureFont", ""); if (fontFile.empty()) fontFile = branding.getStringValue("secureFont"); - mSecureFont = new SDLFont(fontFile, fontSize); + mSecureFont = new Font(fontFile, fontSize); // Set npc font const int npcFontSize = config.getIntValue("npcfontSize"); @@ -220,7 +220,7 @@ void Gui::postInit(Graphics *const graphics) if (fontFile.empty()) fontFile = branding.getStringValue("npcFont"); - mNpcFont = new SDLFont(fontFile, npcFontSize); + mNpcFont = new Font(fontFile, npcFontSize); gcn::Widget::setGlobalFont(mGuiFont); diff --git a/src/gui/gui.h b/src/gui/gui.h index 1ec73e42f..1660fcfbf 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -35,7 +35,7 @@ class GuiConfigListener; class ImageSet; class MouseEvent; class MouseInput; -class SDLFont; +class Font; class SDLInput; class Window; @@ -96,32 +96,32 @@ class Gui final : public gcn::Gui /** * Return game font. */ - SDLFont *getFont() const A_WARN_UNUSED + Font *getFont() const A_WARN_UNUSED { return mGuiFont; } /** * Return help font. */ - SDLFont *getHelpFont() const A_WARN_UNUSED + Font *getHelpFont() const A_WARN_UNUSED { return mHelpFont; } /** * Return secure font. */ - SDLFont *getSecureFont() const A_WARN_UNUSED + Font *getSecureFont() const A_WARN_UNUSED { return mSecureFont; } /** * Return npc font. */ - SDLFont *getNpcFont() const A_WARN_UNUSED + Font *getNpcFont() const A_WARN_UNUSED { return mNpcFont; } /** * Return the Font used for "Info Particles", i.e. ones showing, what * you picked up, etc. */ - SDLFont *getInfoParticleFont() const A_WARN_UNUSED + Font *getInfoParticleFont() const A_WARN_UNUSED { return mInfoParticleFont; } /** @@ -183,11 +183,11 @@ class Gui final : public gcn::Gui private: GuiConfigListener *mConfigListener; - SDLFont *mGuiFont; /**< The global GUI font */ - SDLFont *mInfoParticleFont; /**< Font for Info Particles */ - SDLFont *mHelpFont; /**< Font for Help Window */ - SDLFont *mSecureFont; /**< Font for secure labels */ - SDLFont *mNpcFont; /**< Font for npc text */ + Font *mGuiFont; /**< The global GUI font */ + Font *mInfoParticleFont; /**< Font for Info Particles */ + Font *mHelpFont; /**< Font for Help Window */ + Font *mSecureFont; /**< Font for secure labels */ + Font *mNpcFont; /**< Font for npc text */ ImageSet *mMouseCursors; /**< Mouse cursor images */ float mMouseCursorAlpha; int mMouseInactivityTimer; @@ -212,6 +212,6 @@ extern SDLInput *guiInput; /**< GUI input */ /** * Bolded text font */ -extern SDLFont *boldFont; +extern Font *boldFont; #endif // GUI_GUI_H diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 623b19d00..32aa11454 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -24,15 +24,13 @@ #include "being/being.h" #include "being/playerrelations.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/label.h" #include "utils/gettext.h" #include "utils/stringutils.h" -#include "gui/base/font.hpp" - #include "debug.h" BeingPopup::BeingPopup() : diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index f7939b666..d6ea5a48a 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -27,7 +27,7 @@ #include "item.h" #include "units.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/icon.h" #include "gui/widgets/label.h" @@ -38,8 +38,6 @@ #include "resources/image.h" #include "resources/resourcemanager.h" -#include "gui/base/font.hpp" - #include "debug.h" extern int serverVersion; diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index dd8f9ada9..c74f3f5e6 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -23,15 +23,13 @@ #include "gui/popups/speechbubble.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" #include "gui/widgets/textbox.h" -#include "gui/base/font.hpp" - #include "debug.h" SpeechBubble::SpeechBubble() : diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index cc55fef57..141879da4 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -23,7 +23,7 @@ #include "gui/popups/spellpopup.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp index 2332e20a9..7dd3c3634 100644 --- a/src/gui/popups/statuspopup.cpp +++ b/src/gui/popups/statuspopup.cpp @@ -33,7 +33,7 @@ #include "utils/stringutils.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 245bf58b0..0ae53ac1f 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -25,7 +25,7 @@ #include "gui/widgets/label.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/sdlfont.cpp b/src/gui/sdlfont.cpp deleted file mode 100644 index 95a3df390..000000000 --- a/src/gui/sdlfont.cpp +++ /dev/null @@ -1,603 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2009 Aethyra Development Team - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/sdlfont.h" - -#include "logger.h" -#include "main.h" - -#include "render/sdlgraphics.h" - -#include "resources/image.h" -#include "resources/imagehelper.h" -#include "resources/resourcemanager.h" -#include "resources/surfaceimagehelper.h" - -#include "utils/paths.h" -#include "utils/physfsrwops.h" -#include "utils/sdlcheckutils.h" -#include "utils/stringutils.h" -#include "utils/timer.h" - -#include "debug.h" - -const unsigned int CACHE_SIZE = 256; -const unsigned int CACHE_SIZE_SMALL1 = 2; -const unsigned int CACHE_SIZE_SMALL2 = 50; -const unsigned int CACHE_SIZE_SMALL3 = 170; -const unsigned int CLEAN_TIME = 7; -const int OUTLINE_SIZE = 1; - -bool SDLFont::mSoftMode(false); - -char *strBuf = nullptr; - -#ifdef UNITTESTS -int sdlTextChunkCnt = 0; -#endif - -SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, - const gcn::Color &color0, - const gcn::Color &color1) : - text(text0), - color(color0), - color2(color1) -{ -} - -SDLTextChunkSmall::SDLTextChunkSmall(const SDLTextChunkSmall &old) : - text(old.text), - color(old.color), - color2(old.color2) -{ -} - -bool SDLTextChunkSmall::operator==(const SDLTextChunkSmall &chunk) const -{ - return (chunk.text == text && chunk.color == color - && chunk.color2 == color2); -} - -bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const -{ - if (chunk.text != text) - return chunk.text > text; - - const gcn::Color &c = chunk.color; - if (c.r != color.r) - return c.r > color.r; - if (c.g != color.g) - return c.g > color.g; - if (c.b != color.b) - return c.b > color.b; - - const gcn::Color &c2 = chunk.color2; - if (c2.r != color2.r) - return c2.r > color2.r; - if (c2.g != color2.g) - return c2.g > color2.g; - if (c2.b != color2.b) - return c2.b > color2.b; - - if (c.a != color.a && SDLFont::mSoftMode) - return c.a > color.a; - - return false; -} - -SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1) : - img(nullptr), - text(text0), - color(color0), - color2(color1), - prev(nullptr), - next(nullptr) -{ -#ifdef UNITTESTS - sdlTextChunkCnt ++; -#endif -} - -SDLTextChunk::~SDLTextChunk() -{ - delete img; - img = nullptr; -#ifdef UNITTESTS - sdlTextChunkCnt --; -#endif -} - -bool SDLTextChunk::operator==(const SDLTextChunk &chunk) const -{ - return (chunk.text == text && chunk.color == color - && chunk.color2 == color2); -} - -void SDLTextChunk::generate(TTF_Font *const font, const float alpha) -{ - BLOCK_START("SDLTextChunk::generate") - SDL_Color sdlCol; - sdlCol.b = static_cast(color.b); - sdlCol.r = static_cast(color.r); - sdlCol.g = static_cast(color.g); -#ifdef USE_SDL2 - sdlCol.a = 255; -#else - sdlCol.unused = 0; -#endif - - getSafeUtf8String(text, strBuf); - - SDL_Surface *surface = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol); - - if (!surface) - { - img = nullptr; - BLOCK_END("SDLTextChunk::generate") - return; - } - - const int width = surface->w; - const int height = surface->h; - - if (color.r != color2.r || color.g != color2.g - || color.b != color2.b) - { // outlining - SDL_Color sdlCol2; - SDL_Surface *const background = imageHelper->create32BitSurface( - width, height); - if (!background) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("SDLTextChunk::generate") - return; - } - sdlCol2.b = static_cast(color2.b); - sdlCol2.r = static_cast(color2.r); - sdlCol2.g = static_cast(color2.g); -#ifdef USE_SDL2 - sdlCol2.a = 255; -#else - sdlCol2.unused = 0; -#endif - SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended( - font, strBuf, sdlCol2); - if (!surface2) - { - img = nullptr; - MSDL_FreeSurface(surface); - BLOCK_END("SDLTextChunk::generate") - return; - } - SDL_Rect rect = - { - OUTLINE_SIZE, - 0, - static_cast(surface->w), - static_cast(surface->h) - }; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = -OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.y = OUTLINE_SIZE; - SurfaceImageHelper::combineSurface(surface2, nullptr, - background, &rect); - rect.x = 0; - rect.y = 0; - SurfaceImageHelper::combineSurface(surface, nullptr, - background, &rect); - MSDL_FreeSurface(surface); - MSDL_FreeSurface(surface2); - surface = background; - } - img = imageHelper->createTextSurface( - surface, width, height, alpha); - MSDL_FreeSurface(surface); - - BLOCK_END("SDLTextChunk::generate") -} - - -TextChunkList::TextChunkList() : - start(nullptr), - end(nullptr), - size(0), - search(), - searchWidth() -{ -} - -void TextChunkList::insertFirst(SDLTextChunk *const item) -{ - SDLTextChunk *const oldFirst = start; - if (start) - start->prev = item; - item->prev = nullptr; - if (oldFirst) - item->next = oldFirst; - else - end = item; - start = item; - size ++; - search[SDLTextChunkSmall(item->text, item->color, item->color2)] = item; - searchWidth[item->text] = item; -} - -void TextChunkList::moveToFirst(SDLTextChunk *item) -{ - if (item == start) - return; - - SDLTextChunk *oldPrev = item->prev; - if (oldPrev) - oldPrev->next = item->next; - SDLTextChunk *oldNext = item->next; - if (oldNext) - oldNext->prev = item->prev; - else - end = oldPrev; - SDLTextChunk *const oldFirst = start; - if (start) - start->prev = item; - item->prev = nullptr; - item->next = oldFirst; - start = item; -} - -void TextChunkList::removeBack() -{ - SDLTextChunk *oldEnd = end; - if (oldEnd) - { - end = oldEnd->prev; - if (end) - end->next = nullptr; - else - start = nullptr; - search.erase(SDLTextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } -} - -void TextChunkList::removeBack(int n) -{ - SDLTextChunk *item = end; - while (n && item) - { - n --; - SDLTextChunk *oldEnd = item; - item = item->prev; - search.erase(SDLTextChunkSmall(oldEnd->text, - oldEnd->color, oldEnd->color2)); - searchWidth.erase(oldEnd->text); - delete oldEnd; - size --; - } - if (item) - { - item->next = nullptr; - end = item; - } - else - { - start = nullptr; - end = nullptr; - } -} - -void TextChunkList::clear() -{ - search.clear(); - searchWidth.clear(); - SDLTextChunk *item = start; - while (item) - { - SDLTextChunk *item2 = item->next; - delete item; - item = item2; - } - start = nullptr; - end = nullptr; - size = 0; -} - -static int fontCounter; - -SDLFont::SDLFont(std::string filename, - const int size, - const int style) : - mFont(nullptr), - mCreateCounter(0), - mDeleteCounter(0), - mCleanTime(cur_time + CLEAN_TIME) -{ - if (fontCounter == 0) - { - mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE; - if (TTF_Init() == -1) - { - logger->error("Unable to initialize SDL_ttf: " + - std::string(TTF_GetError())); - } - } - - if (!fontCounter) - { - strBuf = new char[65535]; - memset(strBuf, 0, 65535); - } - - ++fontCounter; - - fixDirSeparators(filename); - mFont = openFont(filename.c_str(), size); - - if (!mFont) - { - logger->log("Error finding font " + filename); - std::string backFile("fonts/dejavusans.ttf"); - mFont = openFont(fixDirSeparators(backFile).c_str(), size); - if (!mFont) - { - logger->error("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); - } - } - - TTF_SetFontStyle(mFont, style); -} - -SDLFont::~SDLFont() -{ - TTF_CloseFont(mFont); - mFont = nullptr; - --fontCounter; - clear(); - - if (fontCounter == 0) - { - TTF_Quit(); - delete []strBuf; - } -} - -TTF_Font *SDLFont::openFont(const char *const name, const int size) -{ -// disabled for now because some systems like gentoo cant use it -// #ifdef USE_SDL2 -// SDL_RWops *const rw = MPHYSFSRWOPS_openRead(name); -// if (!rw) -// return nullptr; -// return TTF_OpenFontIndexRW(rw, 1, size, 0); -// #else - return TTF_OpenFontIndex(ResourceManager::getPath(name).c_str(), - size, 0); -// #endif -} - -void SDLFont::loadFont(std::string filename, - const int size, - const int style) -{ - if (fontCounter == 0 && TTF_Init() == -1) - { - logger->log("Unable to initialize SDL_ttf: " + - std::string(TTF_GetError())); - return; - } - - fixDirSeparators(filename); - TTF_Font *const font = openFont(filename.c_str(), size); - - if (!font) - { - logger->log("SDLSDLFont::SDLSDLFont: " + - std::string(TTF_GetError())); - return; - } - - if (mFont) - TTF_CloseFont(mFont); - - mFont = font; - TTF_SetFontStyle(mFont, style); - clear(); -} - -void SDLFont::clear() -{ - for (size_t f = 0; f < CACHES_NUMBER; f ++) - mCache[f].clear(); -} - -void SDLFont::drawString(Graphics *const graphics, - const std::string &text, - const int x, const int y) -{ - BLOCK_START("SDLFont::drawString") - if (text.empty()) - { - BLOCK_END("SDLFont::drawString") - return; - } - - Graphics *const g = dynamic_cast(graphics); - if (!g) - return; - - gcn::Color col = g->getColor(); - const gcn::Color &col2 = g->getColor2(); - const float alpha = static_cast(col.a) / 255.0F; - - /* The alpha value is ignored at string generation so avoid caching the - * same text with different alpha values. - */ - col.a = 255; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->search; - std::map::iterator i - = search.find(SDLTextChunkSmall(text, col, col2)); - if (i != search.end()) - { - SDLTextChunk *const chunk2 = (*i).second; - cache->moveToFirst(chunk2); - Image *const image = chunk2->img; - if (image) - { - image->setAlpha(alpha); - g->drawImage2(image, x, y); - } - } - else - { - if (cache->size >= CACHE_SIZE) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif - cache->removeBack(); - } -#ifdef DEBUG_FONT_COUNTERS - mCreateCounter ++; -#endif - SDLTextChunk *chunk2 = new SDLTextChunk(text, col, col2); - - chunk2->generate(mFont, alpha); - cache->insertFirst(chunk2); - - const Image *const image = chunk2->img; - if (image) - g->drawImage2(image, x, y); - } - BLOCK_END("SDLFont::drawString") -} - -void SDLFont::slowLogic(const int rnd) -{ - BLOCK_START("SDLFont::slowLogic") - if (!mCleanTime) - { - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - else if (mCleanTime < cur_time) - { - doClean(); - mCleanTime = cur_time + CLEAN_TIME + rnd; - } - BLOCK_END("SDLFont::slowLogic") -} - -int SDLFont::getWidth(const std::string &text) const -{ - if (text.empty()) - return 0; - - const unsigned char chr = text[0]; - TextChunkList *const cache = &mCache[chr]; - - std::map &search = cache->searchWidth; - std::map::iterator i = search.find(text); - if (i != search.end()) - { - SDLTextChunk *const chunk = (*i).second; - cache->moveToFirst(chunk); - const Image *const image = chunk->img; - if (image) - return image->getWidth(); - else - return 0; - } - - // if string was not drawed - int w, h; - getSafeUtf8String(text, strBuf); - TTF_SizeUTF8(mFont, strBuf, &w, &h); - return w; -} - -int SDLFont::getHeight() const -{ - return TTF_FontHeight(mFont); -} - -void SDLFont::doClean() -{ - for (unsigned int f = 0; f < CACHES_NUMBER; f ++) - { - TextChunkList *const cache = &mCache[f]; - const size_t size = cache->size; -#ifdef DEBUG_FONT_COUNTERS - logger->log("ptr: %d, size: %d", f, size); -#endif - if (size > CACHE_SIZE_SMALL3) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 100; -#endif - cache->removeBack(100); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete3"); -#endif - } - else if (size > CACHE_SIZE_SMALL2) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter += 20; -#endif - cache->removeBack(20); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete2"); -#endif - } - else if (size > CACHE_SIZE_SMALL1) - { -#ifdef DEBUG_FONT_COUNTERS - mDeleteCounter ++; -#endif - cache->removeBack(); -#ifdef DEBUG_FONT_COUNTERS - logger->log("delete1"); -#endif - } - } -} - -const TextChunkList *SDLFont::getCache() const -{ - return mCache; -} diff --git a/src/gui/sdlfont.h b/src/gui/sdlfont.h deleted file mode 100644 index 1cb6f5c99..000000000 --- a/src/gui/sdlfont.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * Copyright (C) 2009 Aethyra Development Team - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_SDLFONT_H -#define GUI_SDLFONT_H - -#include "gui/base/color.hpp" -#include "gui/base/font.hpp" - -#include - -#include -#include - -#include "localconsts.h" - -class Image; - -const unsigned int CACHES_NUMBER = 256; - -class SDLTextChunkSmall -{ - public: - SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); - - SDLTextChunkSmall(const SDLTextChunkSmall &old); - - bool operator==(const SDLTextChunkSmall &chunk) const; - bool operator<(const SDLTextChunkSmall &chunk) const; - - std::string text; - gcn::Color color; - gcn::Color color2; -}; - -class SDLTextChunk final -{ - public: - SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); - - A_DELETE_COPY(SDLTextChunk) - - ~SDLTextChunk(); - - bool operator==(const SDLTextChunk &chunk) const; - - void generate(TTF_Font *const font, const float alpha); - - Image *img; - std::string text; - gcn::Color color; - gcn::Color color2; - SDLTextChunk *prev; - SDLTextChunk *next; -}; - - -class TextChunkList final -{ - public: - TextChunkList(); - - A_DELETE_COPY(TextChunkList) - - void insertFirst(SDLTextChunk *const item); - - void moveToFirst(SDLTextChunk *item); - - void removeBack(); - - void removeBack(int n); - - void clear(); - - SDLTextChunk *start; - SDLTextChunk *end; - uint32_t size; - std::map search; - std::map searchWidth; -}; - -/** - * A wrapper around SDL_ttf for allowing the use of TrueType fonts. - * - * NOTE: This class initializes SDL_ttf as necessary. - */ -class SDLFont final : public gcn::Font -{ - public: - SDLFont(std::string filename, - const int size, - const int style = 0); - - A_DELETE_COPY(SDLFont) - - ~SDLFont(); - - void loadFont(std::string filename, - const int size, - const int style = 0); - - int getWidth(const std::string &text) const override - final A_WARN_UNUSED; - - int getHeight() const override final A_WARN_UNUSED; - - const TextChunkList *getCache() const A_WARN_UNUSED; - - /** - * @see Font::drawString - */ - void drawString(Graphics *const graphics, - const std::string &text, - const int x, const int y) override final; - - void clear(); - - void doClean(); - - void slowLogic(const int rnd); - - int getCreateCounter() const A_WARN_UNUSED - { return mCreateCounter; } - - int getDeleteCounter() const A_WARN_UNUSED - { return mDeleteCounter; } - - static bool mSoftMode; - - private: - static TTF_Font *openFont(const char *const name, const int size); - - TTF_Font *mFont; - unsigned mCreateCounter; - unsigned mDeleteCounter; - - // Word surfaces cache - int mCleanTime; - mutable TextChunkList mCache[CACHES_NUMBER]; -}; - -#ifdef UNITTESTS -extern int sdlTextChunkCnt; -#endif - -#endif // GUI_SDLFONT_H diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index c3da988b7..ee64736eb 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -42,7 +42,7 @@ #include "gui/windows/ministatuswindow.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -341,7 +341,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const gcn::Color &color) const { graphics->setColor(color); - gcn::Font *const font = getFont(); + Font *const font = getFont(); #ifdef MANASERV_SUPPORT if (Net::getNetworkType() != ServerInfo::MANASERV) diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 8e4d9e483..298ab657a 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -28,16 +28,14 @@ #include "being/localplayer.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/chatwindow.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" int AvatarListBox::instances = 0; @@ -103,7 +101,7 @@ void AvatarListBox::draw(Graphics *graphics) mListModel); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); const gcn::Widget *const parent = mParent; const std::string name = player_node->getName(); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index c158171c0..60b67dc24 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -25,8 +25,8 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/widgets/linkhandler.h" @@ -37,7 +37,6 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/base/font.hpp" #include "gui/base/cliprectangle.hpp" #include "render/graphics.h" @@ -175,7 +174,7 @@ void BrowserBox::addRow(const std::string &row, const bool atTop) std::string tmp = row; std::string newRow; size_t idx1; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); int linksCount = 0; if (getWidth() < 0) @@ -491,7 +490,7 @@ void BrowserBox::draw(Graphics *graphics) } } - gcn::Font *const font = getFont(); + Font *const font = getFont(); FOR_EACH (LinePartCIter, i, mLineParts) { @@ -530,7 +529,7 @@ int BrowserBox::calcHeight() if (maxWidth < 0) return 1; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int fontHeight = font->getHeight() + 2 * mItemPadding; const int fontWidthMinus = font->getWidth("-"); const char *const hyphen = "~"; diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 8bc3d7540..5d27af68a 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -31,7 +31,7 @@ #include "resources/imageset.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -426,7 +426,7 @@ void Button::draw(Graphics *graphics) const gcn::Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; - gcn::Font *const font = getFont(); + Font *const font = getFont(); int textY = height / 2 - font->getHeight() / 2; if (mImages) imageY = height / 2 - mImageHeight / 2; @@ -559,7 +559,7 @@ void Button::widgetMoved(const Event &event A_UNUSED) void Button::adjustSize() { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const Skin *const skin = button[BUTTON_STANDARD]; if (!skin) return; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 9b67b0359..0772c0d4f 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -100,7 +100,7 @@ void CheckBox::draw(Graphics *const graphics) BLOCK_START("CheckBox::draw") drawBox(graphics); - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index a9cf4f71e..6803fbe3c 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -22,7 +22,7 @@ #include "gui/widgets/colormodel.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -33,7 +33,7 @@ ColorPage::ColorPage(const Widget2 *const widget, { mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1; mRowHeight = 13; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) mRowHeight = font->getHeight() + 2 * mItemPadding; if (mListModel) @@ -57,7 +57,7 @@ void ColorPage::draw(Graphics *graphics) mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int rowHeight = getRowHeight(); const int width = mDimension.width; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 225ea11bb..42fa89b30 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -33,7 +33,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include @@ -235,7 +235,7 @@ void DropDown::draw(Graphics* graphics) gcn::ListModel *const model = mPopup->getListModel(); if (model && mPopup->getSelected() >= 0) { - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); if (mExtended) { diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index 693245c2f..bca1f1e12 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -36,7 +36,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -116,7 +116,7 @@ void DropShortcutContainer::draw(Graphics *graphics) return; } - gcn::Font *const font = getFont(); + Font *const font = getFont(); for (unsigned i = 0; i < mMaxItems; i++) { diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 38c76060b..f5d1c19f0 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -27,14 +27,13 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int MAX_ITEMS = 48; @@ -112,7 +111,7 @@ void EmoteShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); drawBackground(graphics); graphics->setColorAll(mForegroundColor, mForegroundColor2); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index f06e89e55..1fcbabd2b 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -22,7 +22,8 @@ #include "gui/widgets/extendedlistmodel.h" -#include "gui/base/font.hpp" +#include "gui/font.h" + #include "gui/base/listmodel.hpp" #include "render/graphics.h" @@ -58,7 +59,7 @@ void ExtendedListBox::draw(Graphics *graphics) mListModel); updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int height = mRowHeight; const int pad2 = 2 + mPadding; diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 4608534b1..b0f887fa2 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -46,7 +46,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "listeners/selectionlistener.h" #include @@ -251,7 +251,7 @@ void ItemContainer::draw(Graphics *graphics) return; BLOCK_START("ItemContainer::draw") - gcn::Font *const font = getFont(); + Font *const font = getFont(); for (int j = 0; j < mGridRows; j++) { diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 984803a99..2496beaa6 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -33,6 +33,7 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -45,8 +46,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" ItemShortcutContainer::ItemShortcutContainer(const unsigned number) : @@ -129,7 +128,7 @@ void ItemShortcutContainer::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); drawBackground(graphics); const Inventory *const inv = PlayerInfo::getInventory(); diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index b2b709052..6cc94cc3d 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/label.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -82,7 +82,7 @@ void Label::draw(Graphics* graphics) int textX; const gcn::Rectangle &rect = mDimension; const int textY = rect.height / 2 - getFont()->getHeight() / 2; - gcn::Font *const font = getFont(); + Font *const font = getFont(); switch (mAlignment) { @@ -108,7 +108,7 @@ void Label::draw(Graphics* graphics) void Label::adjustSize() { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int pad2 = 2 * mPadding; setWidth(font->getWidth(mCaption) + pad2); setHeight(font->getHeight() + pad2); @@ -129,7 +129,7 @@ void Label::setForegroundColorAll(const gcn::Color &color1, void Label::resizeTo(const int maxSize, const int minSize) { - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int pad2 = 2 * mPadding; setHeight(font->getHeight() + pad2); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 52ff775be..537c7283c 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -28,10 +28,10 @@ #include "input/keydata.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/base/focushandler.hpp" -#include "gui/base/font.hpp" #include "gui/base/listmodel.hpp" #include "render/graphics.h" @@ -70,7 +70,7 @@ ListBox::ListBox(const Widget2 *const widget, mItemPadding = mSkin->getOption("itemPadding"); } - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) mRowHeight = font->getHeight() + 2 * mItemPadding; else @@ -110,7 +110,7 @@ void ListBox::draw(Graphics *graphics) mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int rowHeight = getRowHeight(); const int width = mDimension.width; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index b120e4289..a1f597da8 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -25,10 +25,8 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" - -#include "gui/base/font.hpp" #include "debug.h" @@ -271,7 +269,7 @@ void ProgressBar::render(Graphics *graphics) { const gcn::Color oldColor = graphics->getColor(); - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); const int textX = mDimension.width / 2; const int textY = (mDimension.height - font->getHeight()) / 2; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 2fec7a9f6..984d84d76 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -30,7 +30,7 @@ #include "resources/image.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -161,7 +161,7 @@ void RadioButton::draw(Graphics* graphics) BLOCK_START("RadioButton::draw") drawBox(graphics); - gcn::Font *const font = getFont(); + Font *const font = getFont(); graphics->setColorAll(mForegroundColor, mForegroundColor2); font->drawString(graphics, mCaption, mPadding + mImageSize + mSpacing, mPadding); @@ -191,7 +191,7 @@ void RadioButton::keyPressed(KeyEvent& keyEvent) void RadioButton::adjustSize() { - gcn::Font *const font = getFont(); + Font *const font = getFont(); setHeight(font->getHeight() + 2 * mPadding); setWidth(mImagePadding + mImageSize + mSpacing + font->getWidth(mCaption) + mPadding); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 8b6cca5a7..aeeb8e4bc 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -24,7 +24,7 @@ #include "main.h" #include "soundmanager.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/editdialog.h" @@ -41,8 +41,6 @@ #include "utils/gettext.h" #include "utils/mathutils.h" -#include "gui/base/font.hpp" - #include "debug.h" SetupItem::SetupItem(const std::string &restrict text, @@ -918,7 +916,7 @@ int SetupItemSlider2::getMaxWidth() int maxWidth = 0; SetupItemNamesConstIter it = mValues->begin(); const SetupItemNamesConstIter it_end = mValues->end(); - const gcn::Font *const font = gui->getFont(); + const Font *const font = gui->getFont(); while (it != it_end) { diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index f364aaf46..85ff90261 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -27,6 +27,7 @@ #include "being/playerinfo.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -35,7 +36,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" #include "gui/base/listmodel.hpp" #include "debug.h" @@ -95,7 +95,7 @@ void ShopListBox::draw(Graphics *graphics) mAlpha = client->getGuiAlpha(); const int alpha = static_cast(mAlpha * 255.0F); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int sz = mListModel->getNumberOfElements(); const int fontHeigh = getFont()->getHeight(); diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 988db85dd..93a6934ba 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -20,13 +20,12 @@ #include "gui/widgets/sliderlist.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int buttonWidth = 27; @@ -209,7 +208,7 @@ int SliderList::getMaxLabelWidth() const return 1; int maxWidth = 0; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int num = mListModel->getNumberOfElements(); for (int f = 0; f < num; f ++) diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 511360b91..e8d34c9d8 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -27,6 +27,7 @@ #include "itemshortcut.h" #include "spellshortcut.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/spellpopup.h" @@ -36,8 +37,6 @@ #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : @@ -103,7 +102,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) mBackgroundImg->setAlpha(mAlpha); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int selectedId = spellShortcut->getSelectedItem(); graphics->setColorAll(mForegroundColor, mForegroundColor2); diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 1a2bdfeae..d29c56c85 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -21,7 +21,7 @@ #include "gui/widgets/tabs/setup_colors.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/userpalette.h" #include "gui/widgets/browserbox.h" @@ -101,7 +101,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : // TRANSLATORS: color type std::string longText = _("Static"); - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText)) { // TRANSLATORS: color type diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index ba02eb5a2..22bea9a75 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -125,7 +125,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) : mKeyListModel->setSize(mActionDataSize[0]); refreshKeys(); if (gui) - mKeyList->setFont(reinterpret_cast(gui->getHelpFont())); + mKeyList->setFont(gui->getHelpFont()); mKeyList->addActionListener(this); mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index a85b7927b..a097d28e2 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -264,7 +264,7 @@ void Tab::widgetMoved(const Event &event A_UNUSED) mRedraw = true; } -void Tab::setLabelFont(gcn::Font *const font) +void Tab::setLabelFont(Font *const font) { if (!mLabel) return; diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index d22c6bea5..655fba7ea 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -134,7 +134,7 @@ class Tab : public gcn::BasicContainer, void widgetMoved(const Event &event) override final; - void setLabelFont(gcn::Font *const font); + void setLabelFont(Font *const font); Label *getLabel() const A_WARN_UNUSED { return mLabel; } diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index ecdc0e4d0..5f74fa1f8 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -26,7 +26,7 @@ #include "input/keydata.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include @@ -88,7 +88,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) text.substr(lastNewlinePos, newlinePos - lastNewlinePos); size_t lastSpacePos = 0; xpos = 0; - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); const int spaceWidth = font->getWidth(" "); size_t sz = line.size(); @@ -360,7 +360,7 @@ void TextBox::draw(Graphics* graphics) graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); } - gcn::Font *const font = getFont(); + Font *const font = getFont(); if (isFocused() && isEditable()) { drawCaret(graphics, font->getWidth( diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 0d01df51d..4dd2f1c7b 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -28,8 +28,8 @@ #include "events/keyevent.h" +#include "gui/font.h" #include "gui/sdlinput.h" - #include "gui/viewport.h" #include "gui/popups/popupmenu.h" @@ -39,8 +39,6 @@ #include "utils/copynpaste.h" #include "utils/timer.h" -#include "gui/base/font.hpp" - #undef DELETE // Win32 compatibility hack #include "debug.h" @@ -142,7 +140,7 @@ void TextField::draw(Graphics *graphics) BLOCK_START("TextField::draw") updateAlpha(); - gcn::Font *const font = getFont(); + Font *const font = getFont(); if (isFocused()) { drawCaret(graphics, diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 5ef553b3c..2caf2e44c 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -24,8 +24,8 @@ #include "client.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "debug.h" @@ -100,12 +100,11 @@ void TextPreview::draw(Graphics* graphics) if (mTextBGColor) { - const SDLFont *const font = dynamic_cast(mFont); - if (font) + if (mFont) { - const int x = font->getWidth(mText) + 1 + const int x = mFont->getWidth(mText) + 1 + 2 * ((mOutline || mShadow) ? 1 :0); - const int y = font->getHeight() + 1 + const int y = mFont->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index f529e470c..cb524a974 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -78,7 +78,7 @@ class TextPreview final : public gcn::Widget, * * @param font the font to use. */ - inline void setFont(gcn::Font *const font) + inline void setFont(Font *const font) { mFont = font; } /** @@ -123,7 +123,7 @@ class TextPreview final : public gcn::Widget, void adjustSize(); private: - gcn::Font *mFont; + Font *mFont; std::string mText; const gcn::Color *mTextColor; const gcn::Color *mTextColor2; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index c250e79a1..e2f24a0f2 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -29,6 +29,7 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -38,7 +39,6 @@ #include "resources/image.h" #include "gui/base/focushandler.hpp" -#include "gui/base/font.hpp" #include "debug.h" @@ -110,7 +110,7 @@ Window::Window(const std::string &caption, const bool modal, { setPadding(mSkin->getPadding()); if (getOptionBool("titlebarBold")) - mCaptionFont = reinterpret_cast(boldFont); + mCaptionFont = boldFont; mTitlePadding = mSkin->getTitlePadding(); mGripPadding = getOption("resizePadding"); mCaptionOffsetX = getOption("captionoffsetx"); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index a5b6be83c..c6b2ca2cb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -412,7 +412,7 @@ class Window : public gcn::Window, bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; - void setCaptionFont(gcn::Font *font) + void setCaptionFont(Font *font) { mCaptionFont = font; } void enableVisibleSound(bool b) @@ -506,7 +506,7 @@ class Window : public gcn::Window, int mGripPadding; int mResizeHandles; int mOldResizeHandles; - gcn::Font *mCaptionFont; + Font *mCaptionFont; bool mShowTitle; /**< Window has a title bar */ bool mModal; /**< Window is modal */ bool mCloseWindowButton; /**< Window has a close button */ diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index cbff544fc..e49c78803 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -39,7 +39,7 @@ #include "input/inputmanager.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/sdlinput.h" #include "gui/viewport.h" diff --git a/src/gui/windows/confirmdialog.cpp b/src/gui/windows/confirmdialog.cpp index 499538388..6eb21622d 100644 --- a/src/gui/windows/confirmdialog.cpp +++ b/src/gui/windows/confirmdialog.cpp @@ -29,7 +29,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 9b3ba857c..58e6d9c24 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/setupwindow.h" diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 5caf30df1..6f2bb3b3d 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -32,6 +32,7 @@ #include "being/localplayer.h" #include "being/playerinfo.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/itempopup.h" @@ -46,8 +47,6 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" static const int BOX_COUNT = 13; @@ -163,7 +162,7 @@ void EquipmentWindow::draw(Graphics *graphics) Window::draw(graphics); int i = 0; - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int fontHeight = font->getHeight(); if (isBatchDrawRenders(openGLMode)) diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 95bea6e00..0b31a410b 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/didyouknowwindow.h" #include "gui/windows/setupwindow.h" diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 3eb10e0e8..c95c2c54e 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -32,6 +32,7 @@ #include "input/inputmanager.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" @@ -43,7 +44,6 @@ #include "gui/windows/shopwindow.h" #include "gui/windows/tradewindow.h" - #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/itemcontainer.h" @@ -58,8 +58,6 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include #include "debug.h" diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index a883406e7..d1823d5cf 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -32,8 +32,8 @@ #include "being/being.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/viewport.h" #include "gui/windows/inventorywindow.h" @@ -59,8 +59,6 @@ #include "utils/copynpaste.h" #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" // TRANSLATORS: npc dialog button @@ -170,7 +168,7 @@ NpcDialog::NpcDialog(const int npcId) : mTextField->setVisible(true); mIntField->setVisible(true); - const gcn::Font *const fnt = mButton->getFont(); + const Font *const fnt = mButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_WAITING), fnt->getWidth(CAPTION_NEXT)); width = std::max(width, fnt->getWidth(CAPTION_CLOSE)); diff --git a/src/gui/windows/okdialog.cpp b/src/gui/windows/okdialog.cpp index b9f26da20..3d734b7ad 100644 --- a/src/gui/windows/okdialog.cpp +++ b/src/gui/windows/okdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 681949145..2e8c5dcc8 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -26,7 +26,7 @@ #include "being/localplayer.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index ce5c3c815..fb2f5258b 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -31,7 +31,7 @@ #include "input/keydata.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/editserverdialog.h" #include "gui/windows/logindialog.h" @@ -45,8 +45,6 @@ #include "utils/gettext.h" #include "utils/langs.h" -#include "gui/base/font.hpp" - #include #include "debug.h" @@ -182,8 +180,8 @@ public: height)); } - gcn::Font *const font1 = boldFont; - gcn::Font *const font2 = getFont(); + Font *const font1 = boldFont; + Font *const font2 = getFont(); const int fontHeight = font1->getHeight(); const int pad1 = fontHeight + mPadding; const int pad2 = height / 4 + mPadding; @@ -644,7 +642,7 @@ void ServerDialog::loadServers(const bool addNew) version = strprintf(_("requires v%s"), version.c_str()); } - const gcn::Font *const font = gui->getFont(); + const Font *const font = gui->getFont(); for_each_xml_child_node(subNode, serverNode) { diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 8ec8486e3..413f73226 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -29,6 +29,7 @@ #include "being/localplayer.h" +#include "gui/font.h" #include "gui/viewport.h" #include "gui/popups/textpopup.h" @@ -53,8 +54,6 @@ #include "resources/beingcommon.h" -#include "gui/base/font.hpp" - #include "debug.h" class SkillListBox final : public ListBox @@ -121,7 +120,7 @@ class SkillListBox final : public ListBox // Draw the list elements graphics->setColorAll(mTextColor, mTextColor2); - gcn::Font *const font = getFont(); + Font *const font = getFont(); const int space = font->getHeight() + mSpacing; const int width2 = getWidth() - mPadding; for (int i = 0, y = 1; diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp index c4ff71eb7..9b7bb3eb1 100644 --- a/src/gui/windows/textdialog.cpp +++ b/src/gui/windows/textdialog.cpp @@ -30,7 +30,7 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" @@ -68,7 +68,7 @@ TextDialog::TextDialog(const std::string &restrict title, place(2, 2, mOkButton); place(3, 2, cancelButton); - const gcn::Font *const font = getFont(); + const Font *const font = getFont(); if (font) { int width = font->getWidth(title); diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 1793fc2fb..d94b78c34 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -31,7 +31,7 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/windows/inventorywindow.h" #include "gui/windows/itemamountwindow.h" @@ -51,8 +51,6 @@ #include "utils/gettext.h" -#include "gui/base/font.hpp" - #include "debug.h" // TRANSLATORS: trade window button @@ -102,7 +100,7 @@ TradeWindow::TradeWindow(): if (setupWindow) setupWindow->registerWindowForReset(this); - const gcn::Font *const fnt = mOkButton->getFont(); + const Font *const fnt = mOkButton->getFont(); int width = std::max(fnt->getWidth(CAPTION_PROPOSE), fnt->getWidth(CAPTION_CONFIRMED)); width = std::max(width, fnt->getWidth(CAPTION_ACCEPT)); diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 3da8ba7d9..86a431cdf 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -35,8 +35,8 @@ #include "resources/resourcemanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "utils/dtor.h" @@ -823,7 +823,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y, } if (!mName.empty() && mType != PORTAL && mType != EMPTY) { - gcn::Font *const font = gui->getFont(); + Font *const font = gui->getFont(); if (font) { graphics->setColor(userPalette->getColor(UserPalette::BEING)); diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index a9cc9993f..83ec97521 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -415,7 +415,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, Particle *Particle::addTextSplashEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline) { Particle *const newParticle = new TextParticle(text, color, font, outline); @@ -439,7 +439,7 @@ Particle *Particle::addTextSplashEffect(const std::string &text, Particle *Particle::addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline) { Particle *const newParticle = new TextParticle(text, color, font, outline); diff --git a/src/particle/particle.h b/src/particle/particle.h index f75803772..f69770513 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -36,9 +36,10 @@ class ParticleEmitter; namespace gcn { class Color; - class Font; } +class Font; + typedef std::list Particles; typedef Particles::iterator ParticleIterator; typedef Particles::const_iterator ParticleConstIterator; @@ -136,7 +137,7 @@ class Particle : public Actor Particle *addTextSplashEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline = false); /** @@ -145,7 +146,7 @@ class Particle : public Actor Particle *addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, const gcn::Color *const color, - gcn::Font *const font, + Font *const font, const bool outline = false); /** diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index bf72baf25..1ac6ac6c2 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -27,13 +27,13 @@ #include "gui/theme.h" #include "gui/base/color.hpp" -#include "gui/base/font.hpp" +#include "gui/font.h" #include "debug.h" TextParticle::TextParticle(const std::string &text, const gcn::Color *const color, - gcn::Font *const font, const bool outline) : + Font *const font, const bool outline) : Particle(), mText(text), mTextFont(font), diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h index eb8a160e1..0d598508d 100644 --- a/src/particle/textparticle.h +++ b/src/particle/textparticle.h @@ -33,7 +33,7 @@ class TextParticle final : public Particle */ TextParticle(const std::string &text, const gcn::Color *const color, - gcn::Font *const font, const bool outline = false); + Font *const font, const bool outline = false); A_DELETE_COPY(TextParticle) @@ -53,7 +53,7 @@ class TextParticle final : public Particle private: std::string mText; /**< Text of the particle. */ - gcn::Font *mTextFont; /**< Font used for drawing the text. */ + Font *mTextFont; /**< Font used for drawing the text. */ const gcn::Color *mColor; /**< Color used for drawing the text. */ int mTextWidth; bool mOutline; /**< Make the text better readable */ diff --git a/src/text.cpp b/src/text.cpp index 943d31f67..dfc127598 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -26,14 +26,12 @@ #include "configuration.h" #include "textmanager.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "gui/theme.h" #include "resources/image.h" -#include "gui/base/font.hpp" - #include "debug.h" int Text::mInstances = 0; @@ -42,7 +40,7 @@ ImageRect Text::mBubble; Text::Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const gcn::Color *const color, const bool isSpeech, - gcn::Font *const font) : + Font *const font) : mFont(font ? font : (gui ? gui->getFont() : nullptr)), mX(x), mY(y), @@ -154,7 +152,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) FlashText::FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, gcn::Font *const font) : + const gcn::Color *const color, Font *const font) : Text(text, x, y, alignment, color, false, font), mTime(0) { diff --git a/src/text.h b/src/text.h index b21ca51a7..cade9db18 100644 --- a/src/text.h +++ b/src/text.h @@ -30,10 +30,7 @@ #include "localconsts.h" -namespace gcn -{ - class Font; -} +class Font; class Text { @@ -46,7 +43,7 @@ class Text Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const gcn::Color *const color, const bool isSpeech = false, - gcn::Font *const font = nullptr); + Font *const font = nullptr); A_DELETE_COPY(Text) @@ -75,7 +72,7 @@ class Text const int xOff, const int yOff); private: - gcn::Font *mFont; /**< The font of the text */ + Font *mFont; /**< The font of the text */ int mX; /**< Actual x-value of left of text written. */ int mY; /**< Actual y-value of top of text written. */ int mWidth; /**< The width of the text. */ @@ -97,7 +94,7 @@ class FlashText final : public Text FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, const gcn::Color *const color, - gcn::Font *const font = nullptr); + Font *const font = nullptr); A_DELETE_COPY(FlashText) diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index b7b926383..8c4c8b0db 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -25,8 +25,8 @@ #include "mouseinput.h" #include "touchactions.h" +#include "gui/font.h" #include "gui/gui.h" -#include "gui/sdlfont.h" #include "input/inputmanager.h" @@ -239,7 +239,7 @@ void TouchManager::draw() if (!gui) return; - SDLFont *const font = boldFont; + Font *const font = boldFont; mainGraphics->setColorAll(Theme::getThemeColor(Theme::TEXT), Theme::getThemeColor(Theme::TEXT_OUTLINE)); FOR_EACH (TouchItemVectorCIter, it, mObjects) -- cgit v1.2.3-70-g09d2 From 338798cda6e0b58a9517e535b02e9490889feea4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 22:23:44 +0300 Subject: add missing files. --- src/gui/font.cpp | 658 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/gui/font.h | 213 ++++++++++++++++++ 2 files changed, 871 insertions(+) create mode 100644 src/gui/font.cpp create mode 100644 src/gui/font.h (limited to 'src') diff --git a/src/gui/font.cpp b/src/gui/font.cpp new file mode 100644 index 000000000..a154d8c54 --- /dev/null +++ b/src/gui/font.cpp @@ -0,0 +1,658 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2009 Aethyra Development Team + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +#include "gui/font.h" + +#include "logger.h" +#include "main.h" + +#include "render/sdlgraphics.h" + +#include "resources/image.h" +#include "resources/imagehelper.h" +#include "resources/resourcemanager.h" +#include "resources/surfaceimagehelper.h" + +#include "utils/paths.h" +#include "utils/physfsrwops.h" +#include "utils/sdlcheckutils.h" +#include "utils/stringutils.h" +#include "utils/timer.h" + +#include "debug.h" + +const unsigned int CACHE_SIZE = 256; +const unsigned int CACHE_SIZE_SMALL1 = 2; +const unsigned int CACHE_SIZE_SMALL2 = 50; +const unsigned int CACHE_SIZE_SMALL3 = 170; +const unsigned int CLEAN_TIME = 7; +const int OUTLINE_SIZE = 1; + +bool Font::mSoftMode(false); + +char *strBuf = nullptr; + +#ifdef UNITTESTS +int sdlTextChunkCnt = 0; +#endif + +SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, + const gcn::Color &color0, + const gcn::Color &color1) : + text(text0), + color(color0), + color2(color1) +{ +} + +SDLTextChunkSmall::SDLTextChunkSmall(const SDLTextChunkSmall &old) : + text(old.text), + color(old.color), + color2(old.color2) +{ +} + +bool SDLTextChunkSmall::operator==(const SDLTextChunkSmall &chunk) const +{ + return (chunk.text == text && chunk.color == color + && chunk.color2 == color2); +} + +bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const +{ + if (chunk.text != text) + return chunk.text > text; + + const gcn::Color &c = chunk.color; + if (c.r != color.r) + return c.r > color.r; + if (c.g != color.g) + return c.g > color.g; + if (c.b != color.b) + return c.b > color.b; + + const gcn::Color &c2 = chunk.color2; + if (c2.r != color2.r) + return c2.r > color2.r; + if (c2.g != color2.g) + return c2.g > color2.g; + if (c2.b != color2.b) + return c2.b > color2.b; + + if (c.a != color.a && Font::mSoftMode) + return c.a > color.a; + + return false; +} + +SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, + const gcn::Color &color1) : + img(nullptr), + text(text0), + color(color0), + color2(color1), + prev(nullptr), + next(nullptr) +{ +#ifdef UNITTESTS + sdlTextChunkCnt ++; +#endif +} + +SDLTextChunk::~SDLTextChunk() +{ + delete img; + img = nullptr; +#ifdef UNITTESTS + sdlTextChunkCnt --; +#endif +} + +bool SDLTextChunk::operator==(const SDLTextChunk &chunk) const +{ + return (chunk.text == text && chunk.color == color + && chunk.color2 == color2); +} + +void SDLTextChunk::generate(TTF_Font *const font, const float alpha) +{ + BLOCK_START("SDLTextChunk::generate") + SDL_Color sdlCol; + sdlCol.b = static_cast(color.b); + sdlCol.r = static_cast(color.r); + sdlCol.g = static_cast(color.g); +#ifdef USE_SDL2 + sdlCol.a = 255; +#else + sdlCol.unused = 0; +#endif + + getSafeUtf8String(text, strBuf); + + SDL_Surface *surface = MTTF_RenderUTF8_Blended( + font, strBuf, sdlCol); + + if (!surface) + { + img = nullptr; + BLOCK_END("SDLTextChunk::generate") + return; + } + + const int width = surface->w; + const int height = surface->h; + + if (color.r != color2.r || color.g != color2.g + || color.b != color2.b) + { // outlining + SDL_Color sdlCol2; + SDL_Surface *const background = imageHelper->create32BitSurface( + width, height); + if (!background) + { + img = nullptr; + MSDL_FreeSurface(surface); + BLOCK_END("SDLTextChunk::generate") + return; + } + sdlCol2.b = static_cast(color2.b); + sdlCol2.r = static_cast(color2.r); + sdlCol2.g = static_cast(color2.g); +#ifdef USE_SDL2 + sdlCol2.a = 255; +#else + sdlCol2.unused = 0; +#endif + SDL_Surface *const surface2 = MTTF_RenderUTF8_Blended( + font, strBuf, sdlCol2); + if (!surface2) + { + img = nullptr; + MSDL_FreeSurface(surface); + BLOCK_END("SDLTextChunk::generate") + return; + } + SDL_Rect rect = + { + OUTLINE_SIZE, + 0, + static_cast(surface->w), + static_cast(surface->h) + }; + SurfaceImageHelper::combineSurface(surface2, nullptr, + background, &rect); + rect.x = -OUTLINE_SIZE; + SurfaceImageHelper::combineSurface(surface2, nullptr, + background, &rect); + rect.x = 0; + rect.y = -OUTLINE_SIZE; + SurfaceImageHelper::combineSurface(surface2, nullptr, + background, &rect); + rect.y = OUTLINE_SIZE; + SurfaceImageHelper::combineSurface(surface2, nullptr, + background, &rect); + rect.x = 0; + rect.y = 0; + SurfaceImageHelper::combineSurface(surface, nullptr, + background, &rect); + MSDL_FreeSurface(surface); + MSDL_FreeSurface(surface2); + surface = background; + } + img = imageHelper->createTextSurface( + surface, width, height, alpha); + MSDL_FreeSurface(surface); + + BLOCK_END("SDLTextChunk::generate") +} + + +TextChunkList::TextChunkList() : + start(nullptr), + end(nullptr), + size(0), + search(), + searchWidth() +{ +} + +void TextChunkList::insertFirst(SDLTextChunk *const item) +{ + SDLTextChunk *const oldFirst = start; + if (start) + start->prev = item; + item->prev = nullptr; + if (oldFirst) + item->next = oldFirst; + else + end = item; + start = item; + size ++; + search[SDLTextChunkSmall(item->text, item->color, item->color2)] = item; + searchWidth[item->text] = item; +} + +void TextChunkList::moveToFirst(SDLTextChunk *item) +{ + if (item == start) + return; + + SDLTextChunk *oldPrev = item->prev; + if (oldPrev) + oldPrev->next = item->next; + SDLTextChunk *oldNext = item->next; + if (oldNext) + oldNext->prev = item->prev; + else + end = oldPrev; + SDLTextChunk *const oldFirst = start; + if (start) + start->prev = item; + item->prev = nullptr; + item->next = oldFirst; + start = item; +} + +void TextChunkList::removeBack() +{ + SDLTextChunk *oldEnd = end; + if (oldEnd) + { + end = oldEnd->prev; + if (end) + end->next = nullptr; + else + start = nullptr; + search.erase(SDLTextChunkSmall(oldEnd->text, + oldEnd->color, oldEnd->color2)); + searchWidth.erase(oldEnd->text); + delete oldEnd; + size --; + } +} + +void TextChunkList::removeBack(int n) +{ + SDLTextChunk *item = end; + while (n && item) + { + n --; + SDLTextChunk *oldEnd = item; + item = item->prev; + search.erase(SDLTextChunkSmall(oldEnd->text, + oldEnd->color, oldEnd->color2)); + searchWidth.erase(oldEnd->text); + delete oldEnd; + size --; + } + if (item) + { + item->next = nullptr; + end = item; + } + else + { + start = nullptr; + end = nullptr; + } +} + +void TextChunkList::clear() +{ + search.clear(); + searchWidth.clear(); + SDLTextChunk *item = start; + while (item) + { + SDLTextChunk *item2 = item->next; + delete item; + item = item2; + } + start = nullptr; + end = nullptr; + size = 0; +} + +static int fontCounter; + +Font::Font(std::string filename, + const int size, + const int style) : + mFont(nullptr), + mCreateCounter(0), + mDeleteCounter(0), + mCleanTime(cur_time + CLEAN_TIME) +{ + if (fontCounter == 0) + { + mSoftMode = imageHelper->useOpenGL() == RENDER_SOFTWARE; + if (TTF_Init() == -1) + { + logger->error("Unable to initialize SDL_ttf: " + + std::string(TTF_GetError())); + } + } + + if (!fontCounter) + { + strBuf = new char[65535]; + memset(strBuf, 0, 65535); + } + + ++fontCounter; + + fixDirSeparators(filename); + mFont = openFont(filename.c_str(), size); + + if (!mFont) + { + logger->log("Error finding font " + filename); + std::string backFile("fonts/dejavusans.ttf"); + mFont = openFont(fixDirSeparators(backFile).c_str(), size); + if (!mFont) + { + logger->error("Font::Font: " + + std::string(TTF_GetError())); + } + } + + TTF_SetFontStyle(mFont, style); +} + +Font::~Font() +{ + TTF_CloseFont(mFont); + mFont = nullptr; + --fontCounter; + clear(); + + if (fontCounter == 0) + { + TTF_Quit(); + delete []strBuf; + } +} + +TTF_Font *Font::openFont(const char *const name, const int size) +{ +// disabled for now because some systems like gentoo cant use it +// #ifdef USE_SDL2 +// SDL_RWops *const rw = MPHYSFSRWOPS_openRead(name); +// if (!rw) +// return nullptr; +// return TTF_OpenFontIndexRW(rw, 1, size, 0); +// #else + return TTF_OpenFontIndex(ResourceManager::getPath(name).c_str(), + size, 0); +// #endif +} + +void Font::loadFont(std::string filename, + const int size, + const int style) +{ + if (fontCounter == 0 && TTF_Init() == -1) + { + logger->log("Unable to initialize SDL_ttf: " + + std::string(TTF_GetError())); + return; + } + + fixDirSeparators(filename); + TTF_Font *const font = openFont(filename.c_str(), size); + + if (!font) + { + logger->log("Font::Font: " + + std::string(TTF_GetError())); + return; + } + + if (mFont) + TTF_CloseFont(mFont); + + mFont = font; + TTF_SetFontStyle(mFont, style); + clear(); +} + +void Font::clear() +{ + for (size_t f = 0; f < CACHES_NUMBER; f ++) + mCache[f].clear(); +} + +void Font::drawString(Graphics *const graphics, + const std::string &text, + const int x, const int y) +{ + BLOCK_START("Font::drawString") + if (text.empty()) + { + BLOCK_END("Font::drawString") + return; + } + + Graphics *const g = dynamic_cast(graphics); + if (!g) + return; + + gcn::Color col = g->getColor(); + const gcn::Color &col2 = g->getColor2(); + const float alpha = static_cast(col.a) / 255.0F; + + /* The alpha value is ignored at string generation so avoid caching the + * same text with different alpha values. + */ + col.a = 255; + + const unsigned char chr = text[0]; + TextChunkList *const cache = &mCache[chr]; + + std::map &search = cache->search; + std::map::iterator i + = search.find(SDLTextChunkSmall(text, col, col2)); + if (i != search.end()) + { + SDLTextChunk *const chunk2 = (*i).second; + cache->moveToFirst(chunk2); + Image *const image = chunk2->img; + if (image) + { + image->setAlpha(alpha); + g->drawImage2(image, x, y); + } + } + else + { + if (cache->size >= CACHE_SIZE) + { +#ifdef DEBUG_FONT_COUNTERS + mDeleteCounter ++; +#endif + cache->removeBack(); + } +#ifdef DEBUG_FONT_COUNTERS + mCreateCounter ++; +#endif + SDLTextChunk *chunk2 = new SDLTextChunk(text, col, col2); + + chunk2->generate(mFont, alpha); + cache->insertFirst(chunk2); + + const Image *const image = chunk2->img; + if (image) + g->drawImage2(image, x, y); + } + BLOCK_END("Font::drawString") +} + +void Font::slowLogic(const int rnd) +{ + BLOCK_START("Font::slowLogic") + if (!mCleanTime) + { + mCleanTime = cur_time + CLEAN_TIME + rnd; + } + else if (mCleanTime < cur_time) + { + doClean(); + mCleanTime = cur_time + CLEAN_TIME + rnd; + } + BLOCK_END("Font::slowLogic") +} + +int Font::getWidth(const std::string &text) const +{ + if (text.empty()) + return 0; + + const unsigned char chr = text[0]; + TextChunkList *const cache = &mCache[chr]; + + std::map &search = cache->searchWidth; + std::map::iterator i = search.find(text); + if (i != search.end()) + { + SDLTextChunk *const chunk = (*i).second; + cache->moveToFirst(chunk); + const Image *const image = chunk->img; + if (image) + return image->getWidth(); + else + return 0; + } + + // if string was not drawed + int w, h; + getSafeUtf8String(text, strBuf); + TTF_SizeUTF8(mFont, strBuf, &w, &h); + return w; +} + +int Font::getHeight() const +{ + return TTF_FontHeight(mFont); +} + +void Font::doClean() +{ + for (unsigned int f = 0; f < CACHES_NUMBER; f ++) + { + TextChunkList *const cache = &mCache[f]; + const size_t size = cache->size; +#ifdef DEBUG_FONT_COUNTERS + logger->log("ptr: %d, size: %d", f, size); +#endif + if (size > CACHE_SIZE_SMALL3) + { +#ifdef DEBUG_FONT_COUNTERS + mDeleteCounter += 100; +#endif + cache->removeBack(100); +#ifdef DEBUG_FONT_COUNTERS + logger->log("delete3"); +#endif + } + else if (size > CACHE_SIZE_SMALL2) + { +#ifdef DEBUG_FONT_COUNTERS + mDeleteCounter += 20; +#endif + cache->removeBack(20); +#ifdef DEBUG_FONT_COUNTERS + logger->log("delete2"); +#endif + } + else if (size > CACHE_SIZE_SMALL1) + { +#ifdef DEBUG_FONT_COUNTERS + mDeleteCounter ++; +#endif + cache->removeBack(); +#ifdef DEBUG_FONT_COUNTERS + logger->log("delete1"); +#endif + } + } +} + +int Font::getStringIndexAt(const std::string& text, const int x) const +{ + const size_t sz = text.size(); + for (size_t i = 0; i < sz; ++i) + { + if (getWidth(text.substr(0, i)) > x) + return i; + } + + return static_cast(sz); +} + +const TextChunkList *Font::getCache() const +{ + return mCache; +} diff --git a/src/gui/font.h b/src/gui/font.h new file mode 100644 index 000000000..8740b4f3b --- /dev/null +++ b/src/gui/font.h @@ -0,0 +1,213 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * Copyright (C) 2009 Aethyra Development Team + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_FONT_H +#define GUI_FONT_H + +#include "gui/base/color.hpp" + +#include + +#include +#include + +#include "localconsts.h" + +class Graphics; +class Image; + +const unsigned int CACHES_NUMBER = 256; + +class SDLTextChunkSmall +{ + public: + SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, + const gcn::Color &color1); + + SDLTextChunkSmall(const SDLTextChunkSmall &old); + + bool operator==(const SDLTextChunkSmall &chunk) const; + bool operator<(const SDLTextChunkSmall &chunk) const; + + std::string text; + gcn::Color color; + gcn::Color color2; +}; + +class SDLTextChunk final +{ + public: + SDLTextChunk(const std::string &text0, const gcn::Color &color0, + const gcn::Color &color1); + + A_DELETE_COPY(SDLTextChunk) + + ~SDLTextChunk(); + + bool operator==(const SDLTextChunk &chunk) const; + + void generate(TTF_Font *const font, const float alpha); + + Image *img; + std::string text; + gcn::Color color; + gcn::Color color2; + SDLTextChunk *prev; + SDLTextChunk *next; +}; + + +class TextChunkList final +{ + public: + TextChunkList(); + + A_DELETE_COPY(TextChunkList) + + void insertFirst(SDLTextChunk *const item); + + void moveToFirst(SDLTextChunk *item); + + void removeBack(); + + void removeBack(int n); + + void clear(); + + SDLTextChunk *start; + SDLTextChunk *end; + uint32_t size; + std::map search; + std::map searchWidth; +}; + +/** + * A wrapper around SDL_ttf for allowing the use of TrueType fonts. + * + * NOTE: This class initializes SDL_ttf as necessary. + */ +class Font final +{ + public: + Font(std::string filename, + const int size, + const int style = 0); + + A_DELETE_COPY(Font) + + ~Font(); + + void loadFont(std::string filename, + const int size, + const int style = 0); + + int getWidth(const std::string &text) const A_WARN_UNUSED; + + int getHeight() const A_WARN_UNUSED; + + const TextChunkList *getCache() const A_WARN_UNUSED; + + /** + * @see Font::drawString + */ + void drawString(Graphics *const graphics, + const std::string &text, + const int x, const int y); + + void clear(); + + void doClean(); + + void slowLogic(const int rnd); + + int getCreateCounter() const A_WARN_UNUSED + { return mCreateCounter; } + + int getDeleteCounter() const A_WARN_UNUSED + { return mDeleteCounter; } + + int getStringIndexAt(const std::string& text, + const int x) const A_WARN_UNUSED; + + static bool mSoftMode; + + private: + static TTF_Font *openFont(const char *const name, const int size); + + TTF_Font *mFont; + unsigned mCreateCounter; + unsigned mDeleteCounter; + + // Word surfaces cache + int mCleanTime; + mutable TextChunkList mCache[CACHES_NUMBER]; +}; + +#ifdef UNITTESTS +extern int sdlTextChunkCnt; +#endif + +#endif // GUI_FONT_H -- cgit v1.2.3-70-g09d2 From 9fc5e9b475388ef57de62143438eae6d0af7da3c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 22:57:19 +0300 Subject: Fix compilation errors. --- src/gui/sdlfont_unittest.cc | 2 +- src/gui/widgets/browserbox_unittest.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/sdlfont_unittest.cc index eab4d2994..b9d08037c 100644 --- a/src/gui/sdlfont_unittest.cc +++ b/src/gui/sdlfont_unittest.cc @@ -20,7 +20,7 @@ #include "logger.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/theme.h" #include "gtest/gtest.h" diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index 87d31e900..506bb071b 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -22,7 +22,7 @@ #include "client.h" -#include "gui/sdlfont.h" +#include "gui/font.h" #include "gui/theme.h" #include "gui/widgets/browserbox.h" -- cgit v1.2.3-70-g09d2 From d0bc46cd38aa82777621a99005a90d085e9821c3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 23:27:30 +0300 Subject: Combine keyinput into one file. --- src/CMakeLists.txt | 3 - src/Makefile.am | 3 - src/gui/base/gui.cpp | 3 +- src/gui/base/input.hpp | 3 +- src/gui/base/keyinput.cpp | 154 ------------------------ src/gui/base/keyinput.hpp | 289 ---------------------------------------------- src/gui/base/widget.cpp | 6 +- src/gui/base/widget.hpp | 2 +- src/gui/gui.cpp | 2 +- src/gui/sdlinput.cpp | 6 +- src/gui/sdlinput.h | 5 +- src/input/keyinput.cpp | 38 ------ src/input/keyinput.h | 203 ++++++++++++++++++++++++++++++-- 13 files changed, 209 insertions(+), 508 deletions(-) delete mode 100644 src/gui/base/keyinput.cpp delete mode 100644 src/gui/base/keyinput.hpp delete mode 100644 src/input/keyinput.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed80c00cb..3cc4c3dbc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -665,7 +665,6 @@ SET(SRCS input/keyboardconfig.h input/keyboarddata.h input/keydata.h - input/keyinput.cpp input/keyinput.h input/multitouchmanager.cpp input/multitouchmanager.h @@ -779,7 +778,6 @@ SET(SRCS events/inputguievent.h gui/base/key.hpp events/keyevent.h - gui/base/keyinput.hpp listeners/keylistener.h gui/base/listmodel.hpp events/mouseevent.h @@ -808,7 +806,6 @@ SET(SRCS gui/base/focushandler.cpp gui/base/gui.cpp gui/base/key.cpp - gui/base/keyinput.cpp gui/base/mouseinput.cpp gui/base/rectangle.cpp gui/base/widget.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 09579cc29..aa5314c52 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -165,7 +165,6 @@ manaplus_SOURCES += events/actionevent.h \ events/inputguievent.h \ gui/base/key.hpp \ events/keyevent.h \ - gui/base/keyinput.hpp \ listeners/keylistener.h \ gui/base/listmodel.hpp \ events/mouseevent.h \ @@ -194,7 +193,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/focushandler.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ - gui/base/keyinput.cpp \ gui/base/mouseinput.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ @@ -774,7 +772,6 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ input/keyboardconfig.h \ input/keyboarddata.h \ input/keydata.h \ - input/keyinput.cpp \ input/keyinput.h \ input/multitouchmanager.cpp \ input/multitouchmanager.h \ diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index e6fc79856..56e40291a 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -70,10 +70,11 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/input.hpp" -#include "gui/base/keyinput.hpp" #include "gui/base/mouseinput.hpp" #include "gui/base/widget.hpp" +#include "input/keyinput.h" + #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/base/input.hpp b/src/gui/base/input.hpp index 71a15ce85..40aed4d84 100644 --- a/src/gui/base/input.hpp +++ b/src/gui/base/input.hpp @@ -66,9 +66,10 @@ #include "localconsts.h" +class KeyInput; + namespace gcn { - class KeyInput; class MouseInput; /** diff --git a/src/gui/base/keyinput.cpp b/src/gui/base/keyinput.cpp deleted file mode 100644 index 8b7ff3c8a..000000000 --- a/src/gui/base/keyinput.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/keyinput.hpp" - -#include "debug.h" - -namespace gcn -{ - KeyInput::KeyInput(const Key& key, unsigned int type) : - mKey(key), - mType(type), - mShiftPressed(false), - mControlPressed(false), - mAltPressed(false), - mMetaPressed(false), - mNumericPad(false) - { - } - - void KeyInput::setType(unsigned int type) - { - mType = type; - } - - int KeyInput::getType() const - { - return mType; - } - - void KeyInput::setKey(const Key& key) - { - mKey = key; - } - - const Key& KeyInput::getKey() const - { - return mKey; - } - - bool KeyInput::isShiftPressed() const - { - return mShiftPressed; - } - - void KeyInput::setShiftPressed(bool pressed) - { - mShiftPressed = pressed; - } - - bool KeyInput::isControlPressed() const - { - return mControlPressed; - } - - void KeyInput::setControlPressed(bool pressed) - { - mControlPressed = pressed; - } - - bool KeyInput::isAltPressed() const - { - return mAltPressed; - } - - void KeyInput::setAltPressed(bool pressed) - { - mAltPressed = pressed; - } - - bool KeyInput::isMetaPressed() const - { - return mMetaPressed; - } - - void KeyInput::setMetaPressed(bool pressed) - { - mMetaPressed = pressed; - } - - bool KeyInput::isNumericPad() const - { - return mNumericPad; - } - - void KeyInput::setNumericPad(bool numpad) - { - mNumericPad = numpad; - } -} // namespace gcn diff --git a/src/gui/base/keyinput.hpp b/src/gui/base/keyinput.hpp deleted file mode 100644 index 422d9046c..000000000 --- a/src/gui/base/keyinput.hpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEYINPUT_HPP -#define GCN_KEYINPUT_HPP - -#include "gui/base/key.hpp" - -namespace gcn -{ - /** - * Internal class that represents key input. Generally you won't have to - * bother using this class unless you implement an Input class for - * a back end. - * - * @since 0.1.0 - */ - class KeyInput - { - public: - /** - * Constructor. - */ - KeyInput() : - mKey(0), - mType(0), - mShiftPressed(false), - mControlPressed(false), - mAltPressed(false), - mMetaPressed(false), - mNumericPad(false) - { } - - /** - * Constructor. - * - * @param key The key of the key input. - * @param type The type of key input. - */ - KeyInput(const Key& key, unsigned int type); - - /** - * Sets the type of the key input. - * - * @param type The type of key input. - * @see getType - */ - void setType(unsigned int type); - - /** - * Gets the type of the key input. - * - * @return the input type. - * @see setType - */ - int getType() const A_WARN_UNUSED; - - /** - * Sets the key of the key input. - * - * @param key The key of the key input. - * @see getKey - */ - void setKey(const Key& key); - - /** - * Gets the key of the key input. - * - * @return The key of the key input. - * @see setKey - */ - const Key& getKey() const A_WARN_UNUSED; - - /** - * Checks if shift is pressed. - * - * @return True if shift was pressed at the same - * time as the key, false otherwise. - * @see setShiftPressed - * @since 0.6.0 - */ - bool isShiftPressed() const A_WARN_UNUSED; - - /** - * Sets shift to be pressed at the same time as the key, - * or not. - * - * @param pressed True if shift is pressed, false otherwise. - * @see isShiftPressed - * @since 0.6.0 - */ - void setShiftPressed(bool pressed); - - /** - * Checks if control is pressed. - * - * @return True if control was pressed at the same - * time as the key, false otherwise. - * @see setControlPressed - * @since 0.6.0 - */ - bool isControlPressed() const A_WARN_UNUSED; - - /** - * Sets control to be pressed at the same time as the key, - * or not. - * - * @param pressed True if control is pressed, false otherwise. - * @see isControlPressed - * @since 0.6.0 - */ - void setControlPressed(bool pressed); - - /** - * Checks if alt is pressed. - * - * @return True if alt was pressed at the same - * time as the key, false otherwise. - * @see setAltPressed - * @since 0.6.0 - */ - bool isAltPressed() const; - - /** - * Sets the alt to be pressed at the same time as the key, - * or not. - * - * @param pressed True if alt is pressed at the same - * time as the key, , false otherwise. - * @see isAltPressed - * @since 0.6.0 - */ - void setAltPressed(bool pressed); - - /** - * Checks if meta is pressed. - * - * @return True if meta was pressed at the same - * time as the key, false otherwise. - * @see setMetaPressed - * @since 0.6.0 - */ - bool isMetaPressed() const A_WARN_UNUSED; - - /** - * Sets meta to be pressed at the same time as the key, - * or not. - * - * @param pressed True if meta is pressed at the same - * time as the key, false otherwise. - * @see isMetaPressed - * @since 0.6.0 - */ - void setMetaPressed(bool pressed); - - /** - * Checks if the key was pressed at the numeric pad. - * - * @return True if key pressed at the numeric pad, - * false otherwise. - * @setNumericPad - * @since 0.6.0 - */ - bool isNumericPad() const A_WARN_UNUSED; - - /** - * Sets the key to be pressed at the numeric pad. - * - * @param numpad True if the key was pressed at the numeric - * pad, false otherwise. - * @see isNumericPad - * @since 0.6.0 - */ - void setNumericPad(bool numpad); - - /** - * Key input types. This enum corresponds to the enum with event - * types on KeyEvent for easy mapping. - */ - enum - { - PRESSED = 0, - RELEASED - }; - - protected: - /** - * Holds the key of the key input. - */ - Key mKey; - - /** - * Holds the type of the key input. - */ - unsigned int mType; - - /** - * True if shift was pressed at the same time as the key, - * false otherwise. - */ - bool mShiftPressed; - - /** - * True if control was pressed at the same time as the key, - * false otherwise. - */ - bool mControlPressed; - - /** - * True if alt was pressed at the same time as the key, - * false otherwise. - */ - bool mAltPressed; - - /** - * True if meta was pressed at the same time as the key, - * false otherwise. - */ - bool mMetaPressed; - - /** - * True if the numeric pad was used when the key was pressed, - * false otherwise. - */ - bool mNumericPad; - }; -} // namespace gcn - -#endif // end GCN_KEYINPUT_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index e0f33d498..cf3605446 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -69,12 +69,14 @@ #include "events/actionevent.h" -#include "gui/base/basiccontainer.hpp" #include "events/event.h" + +#include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/keyinput.hpp" #include "gui/base/mouseinput.hpp" +#include "input/keyinput.h" + #include "listeners/actionlistener.h" #include "listeners/deathlistener.h" #include "listeners/keylistener.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index a459ab4f2..4043c959a 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -78,6 +78,7 @@ class DeathListener; class FocusListener; class Font; class Graphics; +class KeyInput; class KeyListener; class MouseListener; class WidgetListener; @@ -86,7 +87,6 @@ namespace gcn { class BasicContainer; class FocusHandler; - class KeyInput; class MouseInput; /** diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index f549727a4..85aeb15f5 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -419,7 +419,7 @@ bool Gui::handleKeyInput2() // change focus. if (!keyEventConsumed && mTabbing && keyInput.getActionId() == static_cast(Input::KEY_GUI_TAB) - && keyInput.getType() == gcn::KeyInput::PRESSED) + && keyInput.getType() == KeyInput::PRESSED) { if (keyInput.isShiftPressed()) mFocusHandler->tabPrevious(); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 661be07c5..b61f858e8 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -154,7 +154,7 @@ void SDLInput::pushInput(const SDL_Event &event) { case SDL_KEYDOWN: { - keyInput.setType(gcn::KeyInput::PRESSED); + keyInput.setType(KeyInput::PRESSED); convertKeyEventToKey(event, keyInput); mKeyInputQueue.push(keyInput); break; @@ -162,7 +162,7 @@ void SDLInput::pushInput(const SDL_Event &event) case SDL_KEYUP: { - keyInput.setType(gcn::KeyInput::RELEASED); + keyInput.setType(KeyInput::RELEASED); convertKeyEventToKey(event, keyInput); mKeyInputQueue.push(keyInput); break; @@ -170,7 +170,7 @@ void SDLInput::pushInput(const SDL_Event &event) #ifdef USE_SDL2 case SDL_TEXTINPUT: - keyInput.setType(gcn::KeyInput::PRESSED); + keyInput.setType(KeyInput::PRESSED); keyInput.setKey(gcn::Key(Key::TEXTINPUT)); keyInput.setText(event.text.text); mKeyInputQueue.push(keyInput); diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 345e939c5..73e2896d5 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -85,7 +85,6 @@ #include #include "gui/base/input.hpp" -#include "gui/base/keyinput.hpp" #include "gui/base/mouseinput.hpp" #include @@ -176,8 +175,8 @@ public: KeyInput dequeueKeyInput2() A_WARN_UNUSED; - gcn::KeyInput dequeueKeyInput() override final A_WARN_UNUSED - { return gcn::KeyInput(); } + KeyInput dequeueKeyInput() override final A_WARN_UNUSED + { return KeyInput(); } // Inherited from Input diff --git a/src/input/keyinput.cpp b/src/input/keyinput.cpp deleted file mode 100644 index d04305e0e..000000000 --- a/src/input/keyinput.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "input/keyinput.h" - -#include "debug.h" - -KeyInput::KeyInput() : - gcn::KeyInput(), -#ifdef USE_SDL2 - mActionId(-2), - mText() -#else - mActionId(-2) -#endif -{ -} - -KeyInput::~KeyInput() -{ -} diff --git a/src/input/keyinput.h b/src/input/keyinput.h index d68c071f2..396d7c218 100644 --- a/src/input/keyinput.h +++ b/src/input/keyinput.h @@ -18,41 +18,226 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 INPUT_KEYINPUT_H #define INPUT_KEYINPUT_H -#include "gui/base/keyinput.hpp" +#include "gui/base/key.hpp" #include #include "localconsts.h" -class KeyInput final : public gcn::KeyInput +class KeyInput final { public: - KeyInput(); + KeyInput() : + mKey(0), + mType(0), +#ifdef USE_SDL2 + mText(), +#endif + mActionId(-2), + mShiftPressed(false), + mControlPressed(false), + mAltPressed(false), + mMetaPressed(false), + mNumericPad(false) + { } + + ~KeyInput() + { } + + /** + * Key input types. This enum corresponds to the enum with event + * types on KeyEvent for easy mapping. + */ + enum + { + PRESSED = 0, + RELEASED + }; + + void setType(unsigned int type) + { + mType = type; + } + + int getType() const + { + return mType; + } + + void setKey(const gcn::Key& key) + { + mKey = key; + } + + const gcn::Key& getKey() const + { + return mKey; + } + + bool isShiftPressed() const + { + return mShiftPressed; + } + + void setShiftPressed(bool pressed) + { + mShiftPressed = pressed; + } - ~KeyInput(); + bool isControlPressed() const + { + return mControlPressed; + } + + void setControlPressed(bool pressed) + { + mControlPressed = pressed; + } + + bool isAltPressed() const + { + return mAltPressed; + } + + void setAltPressed(bool pressed) + { + mAltPressed = pressed; + } + + bool isMetaPressed() const + { + return mMetaPressed; + } + + void setMetaPressed(bool pressed) + { + mMetaPressed = pressed; + } + + bool isNumericPad() const + { + return mNumericPad; + } + + void setNumericPad(bool numpad) + { + mNumericPad = numpad; + } void setActionId(const int n) - { mActionId = n; } + { + mActionId = n; + } int getActionId() const A_WARN_UNUSED - { return mActionId; } + { + return mActionId; + } #ifdef USE_SDL2 void setText(const std::string &text) - { mText = text; } + { + mText = text; + } std::string getText() const - { return mText; } + { + return mText; + } #endif protected: - int mActionId; + /** + * Holds the key of the key input. + */ + gcn::Key mKey; + + /** + * Holds the type of the key input. + */ + unsigned int mType; + #ifdef USE_SDL2 std::string mText; #endif + + int mActionId; + + /** + * True if shift was pressed at the same time as the key, + * false otherwise. + */ + bool mShiftPressed; + + /** + * True if control was pressed at the same time as the key, + * false otherwise. + */ + bool mControlPressed; + + /** + * True if alt was pressed at the same time as the key, + * false otherwise. + */ + bool mAltPressed; + + /** + * True if meta was pressed at the same time as the key, + * false otherwise. + */ + bool mMetaPressed; + + /** + * True if the numeric pad was used when the key was pressed, + * false otherwise. + */ + bool mNumericPad; }; #endif // INPUT_KEYINPUT_H -- cgit v1.2.3-70-g09d2 From e8270acbc5118aabbf10738eb9deee07457ea56d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Feb 2014 23:31:20 +0300 Subject: Fix tests compilation. --- src/gui/widgets/browserbox_unittest.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index 506bb071b..7bf674037 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -51,7 +51,7 @@ TEST(browserbox, test1) logger = new Logger(); imageHelper = new SDLImageHelper(); Theme *theme = Theme::instance(); - gcn::Widget::setGlobalFont(new SDLFont("/usr/share/fonts/truetype/" + gcn::Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/" "ttf-dejavu/DejaVuSans-Oblique.ttf", 18)); BrowserBox *box = new BrowserBox(nullptr, BrowserBox::AUTO_WRAP, true, ""); box->setWidth(100); -- cgit v1.2.3-70-g09d2 From e78036b3372e5773fac4207ea48bb61e2fd7873e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 00:09:12 +0300 Subject: combine mouseinput into one file. --- src/CMakeLists.txt | 5 +- src/Makefile.am | 5 +- src/gui/base/basiccontainer.cpp | 2 +- src/gui/base/gui.cpp | 2 +- src/gui/base/gui.hpp | 2 +- src/gui/base/input.hpp | 3 +- src/gui/base/mouseinput.cpp | 136 ------------------ src/gui/base/mouseinput.hpp | 260 ----------------------------------- src/gui/base/widget.cpp | 2 +- src/gui/base/widget.hpp | 2 +- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/checkbox.cpp | 3 +- src/gui/base/widgets/listbox.cpp | 3 +- src/gui/base/widgets/radiobutton.cpp | 3 +- src/gui/base/widgets/slider.cpp | 3 +- src/gui/base/widgets/textbox.cpp | 3 +- src/gui/base/widgets/textfield.cpp | 3 +- src/gui/base/widgets/window.cpp | 2 +- src/gui/gui.cpp | 19 ++- src/gui/gui.h | 6 +- src/gui/sdlinput.cpp | 34 ++--- src/gui/sdlinput.h | 8 +- src/gui/widgets/itemlinkhandler.cpp | 11 +- src/input/mouseinput.h | 216 +++++++++++++++++++++++++++++ src/input/multitouchmanager.cpp | 2 +- src/mouseinput.cpp | 34 ----- src/mouseinput.h | 63 --------- src/touchactions.cpp | 4 +- src/touchmanager.cpp | 7 +- 29 files changed, 285 insertions(+), 561 deletions(-) delete mode 100644 src/gui/base/mouseinput.cpp delete mode 100644 src/gui/base/mouseinput.hpp create mode 100644 src/input/mouseinput.h delete mode 100644 src/mouseinput.cpp delete mode 100644 src/mouseinput.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3cc4c3dbc..b523f084c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -685,8 +685,7 @@ SET(SRCS render/mgl.h render/mobileopenglgraphics.cpp render/mobileopenglgraphics.h - mouseinput.cpp - mouseinput.h + input/mouseinput.h mumblemanager.cpp mumblemanager.h navigationmanager.cpp @@ -781,7 +780,6 @@ SET(SRCS listeners/keylistener.h gui/base/listmodel.hpp events/mouseevent.h - gui/base/mouseinput.hpp listeners/mouselistener.h gui/base/rectangle.hpp events/selectionevent.h @@ -806,7 +804,6 @@ SET(SRCS gui/base/focushandler.cpp gui/base/gui.cpp gui/base/key.cpp - gui/base/mouseinput.cpp gui/base/rectangle.cpp gui/base/widget.cpp gui/base/widgets/button.cpp diff --git a/src/Makefile.am b/src/Makefile.am index aa5314c52..19f8fe4f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -168,7 +168,6 @@ manaplus_SOURCES += events/actionevent.h \ listeners/keylistener.h \ gui/base/listmodel.hpp \ events/mouseevent.h \ - gui/base/mouseinput.hpp \ listeners/mouselistener.h \ gui/base/rectangle.hpp \ events/selectionevent.h \ @@ -193,7 +192,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/focushandler.cpp \ gui/base/gui.cpp \ gui/base/key.cpp \ - gui/base/mouseinput.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ gui/base/widgets/button.cpp \ @@ -792,8 +790,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ render/mgl.h \ render/mobileopenglgraphics.cpp \ render/mobileopenglgraphics.h \ - mouseinput.cpp \ - mouseinput.h \ + input/mouseinput.h \ navigationmanager.cpp \ navigationmanager.h \ render/normalopenglgraphics.cpp \ diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 4a745dc63..82ef1c025 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -70,7 +70,7 @@ #include #include "gui/base/focushandler.hpp" -#include "gui/base/mouseinput.hpp" +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index 56e40291a..e5291cb60 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -70,10 +70,10 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" #include "gui/base/input.hpp" -#include "gui/base/mouseinput.hpp" #include "gui/base/widget.hpp" #include "input/keyinput.h" +#include "input/mouseinput.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index b853a4210..2ec5d7082 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -70,7 +70,7 @@ #include "events/keyevent.h" #include "events/mouseevent.h" -#include "gui/base/mouseinput.hpp" +#include "input/mouseinput.h" class Graphics; class KeyListener; diff --git a/src/gui/base/input.hpp b/src/gui/base/input.hpp index 40aed4d84..1643482d3 100644 --- a/src/gui/base/input.hpp +++ b/src/gui/base/input.hpp @@ -67,11 +67,10 @@ #include "localconsts.h" class KeyInput; +class MouseInput; namespace gcn { - class MouseInput; - /** * Abstract class for providing functions for user input. * diff --git a/src/gui/base/mouseinput.cpp b/src/gui/base/mouseinput.cpp deleted file mode 100644 index bc5d6c8e0..000000000 --- a/src/gui/base/mouseinput.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/mouseinput.hpp" - -#include "debug.h" - -namespace gcn -{ - MouseInput::MouseInput(const unsigned int button, - const unsigned int type, - const int x, - const int y, - const int timeStamp) : - mType(type), - mButton(button), - mTimeStamp(timeStamp), - mX(x), - mY(y) - { - } - - void MouseInput::setType(unsigned int type) - { - mType = type; - } - - unsigned int MouseInput::getType() const - { - return mType; - } - - void MouseInput::setButton(unsigned int button) - { - mButton = button; - } - - unsigned int MouseInput::getButton() const - { - return mButton; - } - - int MouseInput::getTimeStamp() const - { - return mTimeStamp; - } - - void MouseInput::setTimeStamp(int timeStamp) - { - mTimeStamp = timeStamp; - } - - void MouseInput::setX(int x) - { - mX = x; - } - - int MouseInput::getX() const - { - return mX; - } - - void MouseInput::setY(int y) - { - mY = y; - } - - int MouseInput::getY() const - { - return mY; - } -} // namespace gcn diff --git a/src/gui/base/mouseinput.hpp b/src/gui/base/mouseinput.hpp deleted file mode 100644 index 018205740..000000000 --- a/src/gui/base/mouseinput.hpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_MOUSEINPUT_HPP -#define GCN_MOUSEINPUT_HPP - -#include "localconsts.h" - -namespace gcn -{ - - /** - * Internal class that represents mouse input. Generally you won't have to - * bother using this class unless you implement an Input class for - * a back end. - * - * @author Olof Naessén - * @author Per Larsson - * @since 0.1.0 - */ - class MouseInput - { - public: - /** - * Constructor. - */ - MouseInput() : - mType(0), - mButton(0), - mTimeStamp(0), - mX(0), - mY(0) - { } - - /** - * Constructor. - * - * @param button The button pressed. - * @param type The type of mouse input. - * @param x The mouse x coordinate. - * @param y The mouse y coordinate. - * @param timeStamp The timestamp of the mouse input. Used to - * check for double clicks. - */ - MouseInput(const unsigned int button, - const unsigned int type, - const int x, - const int y, - const int timeStamp); - - /** - * Sets the type of the mouse input. - * - * @param type The type of the mouse input. Should be a value from the - * mouse event type enum - * @see getType - * @since 0.1.0 - */ - void setType(unsigned int type); - - /** - * Gets the type of the mouse input. - * - * @return The type of the mouse input. A value from the mouse event - * type enum. - * @see setType - * @since 0.1.0 - */ - unsigned int getType() const A_WARN_UNUSED; - - /** - * Sets the button pressed. - * - * @param button The button pressed. Should be one of the values - * in the mouse event button enum. - * @see getButton. - * @since 0.1.0 - */ - void setButton(unsigned int button); - - /** - * Gets the button pressed. - * - * @return The button pressed. A value from the mouse event - * button enum. - * @see setButton - * @since 0.1.0 - */ - unsigned int getButton() const A_WARN_UNUSED; - - /** - * Sets the timestamp for the mouse input. - * Used to check for double clicks. - * - * @param timeStamp The timestamp of the mouse input. - * @see getTimeStamp - * @since 0.1.0 - */ - void setTimeStamp(int timeStamp); - - /** - * Gets the time stamp of the input. - * Used to check for double clicks. - * - * @return The time stamp of the mouse input. - * @see setTimeStamp - * @since 0.1.0 - */ - int getTimeStamp() const A_WARN_UNUSED; - - /** - * Sets the x coordinate of the mouse input. - * - * @param x The x coordinate of the mouse input. - * @see getX - * @since 0.6.0 - */ - void setX(int x); - - /** - * Gets the x coordinate of the mouse input. - * - * @return The x coordinate of the mouse input. - * @see setX - * @since 0.6.0 - */ - int getX() const A_WARN_UNUSED; - - /** - * Sets the y coordinate of the mouse input. - * - * @param y The y coordinate of the mouse input. - * @see getY - * @since 0.6.0 - */ - void setY(int y); - - /** - * Gets the y coordinate of the mouse input. - * - * @return The y coordinate of the mouse input. - * @see setY - * @since 0.6.0 - */ - int getY() const A_WARN_UNUSED; - - /** - * Mouse input event types. This enum partially corresponds - * to the enum with event types in MouseEvent for easy mapping. - */ - enum - { - MOVED = 0, - PRESSED, - RELEASED, - WHEEL_MOVED_DOWN, - WHEEL_MOVED_UP - }; - - /** - * Mouse button types. - */ - enum - { - EMPTY = 0, - LEFT, - RIGHT, - MIDDLE - }; - - protected: - /** - * Holds the type of the mouse input. - */ - unsigned int mType; - - /** - * Holds the button of the mouse input. - */ - unsigned int mButton; - - /** - * Holds the timestamp of the mouse input. Used to - * check for double clicks. - */ - int mTimeStamp; - - /** - * Holds the x coordinate of the mouse input. - */ - int mX; - - /** - * Holds the y coordinate of the mouse input. - */ - int mY; - }; -} // namespace gcn - -#endif // end GCN_MOUSEINPUT_HPP diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index cf3605446..5b4ada76e 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -73,9 +73,9 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/mouseinput.hpp" #include "input/keyinput.h" +#include "input/mouseinput.h" #include "listeners/actionlistener.h" #include "listeners/deathlistener.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 4043c959a..f2718697e 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -80,6 +80,7 @@ class Font; class Graphics; class KeyInput; class KeyListener; +class MouseInput; class MouseListener; class WidgetListener; @@ -87,7 +88,6 @@ namespace gcn { class BasicContainer; class FocusHandler; - class MouseInput; /** * Abstract class for widgets of Guichan. It contains basic functions diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 9b7473293..56ba72590 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "events/mouseevent.h" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 0a3171fe8..18f635052 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 6c6472636..f13a96e39 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -72,7 +72,8 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "listeners/selectionlistener.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index f0430c7a2..ff6a39db0 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index 91c054e7d..d61f2766c 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -68,7 +68,8 @@ #include "gui/base/widgets/slider.hpp" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index e994804d8..db5d91b92 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -71,7 +71,8 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 1514d3afb..891e7e86b 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -70,7 +70,8 @@ #include "gui/font.h" #include "gui/base/key.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index fbd42aff2..8d33c1dd5 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -69,7 +69,7 @@ #include "gui/font.h" -#include "gui/base/mouseinput.hpp" +#include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 85aeb15f5..243b3817e 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -20,8 +20,6 @@ * along with this program. If not, see . */ -#include "mouseinput.h" - #include "gui/gui.h" #include "gui/focushandler.h" @@ -44,6 +42,7 @@ #include "input/keydata.h" #include "input/keyinput.h" +#include "input/mouseinput.h" #include "resources/cursor.h" #include "resources/image.h" @@ -524,13 +523,13 @@ void Gui::setUseCustomCursor(const bool customCursor) } } -void Gui::handleMouseMoved(const gcn::MouseInput &mouseInput) +void Gui::handleMouseMoved(const MouseInput &mouseInput) { gcn::Gui::handleMouseMoved(mouseInput); mMouseInactivityTimer = 0; } -void Gui::handleMousePressed(const gcn::MouseInput &mouseInput) +void Gui::handleMousePressed(const MouseInput &mouseInput) { const int x = mouseInput.getX(); const int y = mouseInput.getY(); @@ -781,19 +780,19 @@ void Gui::handleMouseInput() #endif switch (mouseInput.getType()) { - case gcn::MouseInput::PRESSED: + case MouseInput::PRESSED: handleMousePressed(mouseInput); break; - case gcn::MouseInput::RELEASED: + case MouseInput::RELEASED: handleMouseReleased(mouseInput); break; - case gcn::MouseInput::MOVED: + case MouseInput::MOVED: handleMouseMoved(mouseInput); break; - case gcn::MouseInput::WHEEL_MOVED_DOWN: + case MouseInput::WHEEL_MOVED_DOWN: handleMouseWheelMovedDown(mouseInput); break; - case gcn::MouseInput::WHEEL_MOVED_UP: + case MouseInput::WHEEL_MOVED_UP: handleMouseWheelMovedUp(mouseInput); break; default: @@ -803,7 +802,7 @@ void Gui::handleMouseInput() BLOCK_END("Gui::handleMouseInput") } -void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput) +void Gui::handleMouseReleased(const MouseInput &mouseInput) { gcn::Widget *sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); diff --git a/src/gui/gui.h b/src/gui/gui.h index 1660fcfbf..b790d4d2c 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -169,11 +169,11 @@ class Gui final : public gcn::Gui static uint32_t getMouseState(int *const x, int *const y); protected: - void handleMouseMoved(const gcn::MouseInput &mouseInput); + void handleMouseMoved(const MouseInput &mouseInput); - void handleMouseReleased(const gcn::MouseInput &mouseInput); + void handleMouseReleased(const MouseInput &mouseInput); - void handleMousePressed(const gcn::MouseInput &mouseInput); + void handleMousePressed(const MouseInput &mouseInput); void handleMouseInput(); diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index b61f858e8..21a8d3957 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -119,9 +119,9 @@ bool SDLInput::isMouseQueueEmpty() return mMouseInputQueue.empty(); } -gcn::MouseInput SDLInput::dequeueMouseInput() +MouseInput SDLInput::dequeueMouseInput() { - gcn::MouseInput mouseInput; + MouseInput mouseInput; if (mMouseInputQueue.empty()) return MouseInput(); @@ -189,9 +189,9 @@ void SDLInput::pushInput(const SDL_Event &event) #endif mouseInput.setButton(-1); if (y > 0) - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP); + mouseInput.setType(MouseInput::WHEEL_MOVED_UP); else - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } @@ -227,12 +227,12 @@ void SDLInput::pushInput(const SDL_Event &event) #ifndef USE_SDL2 if (event.button.button == SDL_BUTTON_WHEELDOWN) - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_DOWN); + mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN); else if (event.button.button == SDL_BUTTON_WHEELUP) - mouseInput.setType(gcn::MouseInput::WHEEL_MOVED_UP); + mouseInput.setType(MouseInput::WHEEL_MOVED_UP); else #endif - mouseInput.setType(gcn::MouseInput::PRESSED); + mouseInput.setType(MouseInput::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -254,7 +254,7 @@ void SDLInput::pushInput(const SDL_Event &event) #endif #endif mouseInput.setButton(convertMouseButton(event.button.button)); - mouseInput.setType(gcn::MouseInput::RELEASED); + mouseInput.setType(MouseInput::RELEASED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -274,8 +274,8 @@ void SDLInput::pushInput(const SDL_Event &event) event.motion.realy / scale); #endif #endif - mouseInput.setButton(gcn::MouseInput::EMPTY); - mouseInput.setType(gcn::MouseInput::MOVED); + mouseInput.setButton(MouseInput::EMPTY); + mouseInput.setType(MouseInput::MOVED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); break; @@ -295,8 +295,8 @@ void SDLInput::pushInput(const SDL_Event &event) { mouseInput.setX(-1); mouseInput.setY(-1); - mouseInput.setButton(gcn::MouseInput::EMPTY); - mouseInput.setType(gcn::MouseInput::MOVED); + mouseInput.setButton(MouseInput::EMPTY); + mouseInput.setType(MouseInput::MOVED); mMouseInputQueue.push(mouseInput); } } @@ -338,11 +338,11 @@ int SDLInput::convertMouseButton(const int button) switch (button) { case SDL_BUTTON_LEFT: - return gcn::MouseInput::LEFT; + return MouseInput::LEFT; case SDL_BUTTON_RIGHT: - return gcn::MouseInput::RIGHT; + return MouseInput::RIGHT; case SDL_BUTTON_MIDDLE: - return gcn::MouseInput::MIDDLE; + return MouseInput::MIDDLE; default: // We have an unknown mouse type which is ignored. return button; @@ -569,10 +569,10 @@ void SDLInput::simulateMouseClick(const int x, const int y, mouseInput.setY(y); mouseInput.setReal(x, y); mouseInput.setButton(button); - mouseInput.setType(gcn::MouseInput::PRESSED); + mouseInput.setType(MouseInput::PRESSED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); - mouseInput.setType(gcn::MouseInput::RELEASED); + mouseInput.setType(MouseInput::RELEASED); mouseInput.setTimeStamp(SDL_GetTicks()); mMouseInputQueue.push(mouseInput); } diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 73e2896d5..1a19e8790 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -79,13 +79,13 @@ #define GUI_SDLINPUT_H #include "input/keyinput.h" - -#include "mouseinput.h" +#include "input/mouseinput.h" #include #include "gui/base/input.hpp" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" #include @@ -184,7 +184,7 @@ public: bool isMouseQueueEmpty() override final A_WARN_UNUSED; - gcn::MouseInput dequeueMouseInput() override final A_WARN_UNUSED; + MouseInput dequeueMouseInput() override final A_WARN_UNUSED; MouseInput dequeueMouseInput2() A_WARN_UNUSED; diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index deb3b4451..3e9a99a2a 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -35,10 +35,11 @@ #include "resources/db/itemdb.h" -#include - #include "listeners/actionlistener.h" -#include "gui/base/mouseinput.hpp" + +#include "input/mouseinput.h" + +#include #include "debug.h" @@ -85,7 +86,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) replaceAll(url, " ", ""); listener.url = url; const int button = event->getButton(); - if (button == gcn::MouseInput::LEFT) + if (button == MouseInput::LEFT) { ConfirmDialog *const confirmDlg = new ConfirmDialog( // TRANSLATORS: dialog message @@ -93,7 +94,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) confirmDlg->postInit(); confirmDlg->addActionListener(&listener); } - else if (button == gcn::MouseInput::RIGHT) + else if (button == MouseInput::RIGHT) { if (viewport) viewport->showLinkPopup(url); diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h new file mode 100644 index 000000000..5ece1f77a --- /dev/null +++ b/src/input/mouseinput.h @@ -0,0 +1,216 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 MOUSEINPUT_H +#define MOUSEINPUT_H + +#include "input/mouseinput.h" + +#include "localconsts.h" + +class MouseInput final +{ + public: + MouseInput() : + mType(0), + mButton(0), + mTimeStamp(0), + mX(0), + mY(0), + mRealX(0), + mRealY(0) + { } + + ~MouseInput() + { } + + /** + * Mouse input event types. This enum partially corresponds + * to the enum with event types in MouseEvent for easy mapping. + */ + enum + { + MOVED = 0, + PRESSED, + RELEASED, + WHEEL_MOVED_DOWN, + WHEEL_MOVED_UP + }; + + /** + * Mouse button types. + */ + enum + { + EMPTY = 0, + LEFT, + RIGHT, + MIDDLE + }; + + void setType(unsigned int type) + { + mType = type; + } + + unsigned int getType() const + { + return mType; + } + + void setButton(unsigned int button) + { + mButton = button; + } + + unsigned int getButton() const + { + return mButton; + } + + int getTimeStamp() const + { + return mTimeStamp; + } + + void setTimeStamp(int timeStamp) + { + mTimeStamp = timeStamp; + } + + void setX(int x) + { + mX = x; + } + + int getX() const + { + return mX; + } + + void setY(int y) + { + mY = y; + } + + int getY() const + { + return mY; + } + + void setReal(const int x, const int y) + { mRealX = x; mRealY = y; } + + int getRealX() const A_WARN_UNUSED + { return mRealX; } + + int getRealY() const A_WARN_UNUSED + { return mRealY; } + +#ifdef ANDROID + int getTouchX() const A_WARN_UNUSED + { return mRealX; } + + int getTouchY() const A_WARN_UNUSED + { return mRealY; } +#else + int getTouchX() const A_WARN_UNUSED + { return mX; } + + int getTouchY() const A_WARN_UNUSED + { return mY; } +#endif + + protected: + /** + * Holds the type of the mouse input. + */ + unsigned int mType; + + /** + * Holds the button of the mouse input. + */ + unsigned int mButton; + + /** + * Holds the timestamp of the mouse input. Used to + * check for double clicks. + */ + int mTimeStamp; + + /** + * Holds the x coordinate of the mouse input. + */ + int mX; + + /** + * Holds the y coordinate of the mouse input. + */ + int mY; + + int mRealX; + + int mRealY; +}; + +#endif // MOUSEINPUT_H diff --git a/src/input/multitouchmanager.cpp b/src/input/multitouchmanager.cpp index 7e6798807..446e40aa1 100644 --- a/src/input/multitouchmanager.cpp +++ b/src/input/multitouchmanager.cpp @@ -82,7 +82,7 @@ void MultiTouchManager::checkDevice(const int touchId, const int w = mainGraphics->mWidth; const int h = mainGraphics->mHeight; guiInput->simulateMouseClick(finger0.x * w, finger0.y * h, - gcn::MouseInput::RIGHT); + MouseInput::RIGHT); } } } diff --git a/src/mouseinput.cpp b/src/mouseinput.cpp deleted file mode 100644 index 208690935..000000000 --- a/src/mouseinput.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "mouseinput.h" - -#include "debug.h" - -MouseInput::MouseInput() : - gcn::MouseInput(), - mRealX(0), - mRealY(0) -{ -} - -MouseInput::~MouseInput() -{ -} diff --git a/src/mouseinput.h b/src/mouseinput.h deleted file mode 100644 index 47e04eceb..000000000 --- a/src/mouseinput.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef MOUSEINPUT_H -#define MOUSEINPUT_H - -#include "gui/base/mouseinput.hpp" - -#include "localconsts.h" - -class MouseInput final : public gcn::MouseInput -{ - public: - MouseInput(); - - ~MouseInput(); - - void setReal(const int x, const int y) - { mRealX = x; mRealY = y; } - - int getRealX() const A_WARN_UNUSED - { return mRealX; } - - int getRealY() const A_WARN_UNUSED - { return mRealY; } - -#ifdef ANDROID - int getTouchX() const A_WARN_UNUSED - { return mRealX; } - - int getTouchY() const A_WARN_UNUSED - { return mRealY; } -#else - int getTouchX() const A_WARN_UNUSED - { return mX; } - - int getTouchY() const A_WARN_UNUSED - { return mY; } -#endif - - protected: - int mRealX; - int mRealY; -}; - -#endif // MOUSEINPUT_H diff --git a/src/touchactions.cpp b/src/touchactions.cpp index a79c14275..d4f7d9f6e 100644 --- a/src/touchactions.cpp +++ b/src/touchactions.cpp @@ -20,10 +20,10 @@ #include "touchactions.h" -#include "mouseinput.h" #include "touchmanager.h" #include "input/inputmanager.h" +#include "input/mouseinput.h" #include "debug.h" @@ -109,7 +109,7 @@ impHandler(padClick) impHandler(padEvents) { - if (mouseInput.getType() == gcn::MouseInput::MOVED) + if (mouseInput.getType() == MouseInput::MOVED) { if (padClicked) moveChar(mouseInput.getX(), mouseInput.getY()); diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 8c4c8b0db..20c56b8d6 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -22,9 +22,10 @@ #include "configuration.h" #include "graphicsvertexes.h" -#include "mouseinput.h" #include "touchactions.h" +#include "input/mouseinput.h" + #include "gui/font.h" #include "gui/gui.h" @@ -278,13 +279,13 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) switch (mouseInput.getType()) { - case gcn::MouseInput::PRESSED: + case MouseInput::PRESSED: if (!item->eventPressed.empty()) executeAction(item->eventPressed); else if (item->funcPressed) item->funcPressed(event); break; - case gcn::MouseInput::RELEASED: + case MouseInput::RELEASED: if (!item->eventReleased.empty()) executeAction(item->eventReleased); else if (item->funcReleased) -- cgit v1.2.3-70-g09d2 From 9a85b675f326c956b2c87af296c724a68192d7cc Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 00:41:13 +0300 Subject: combine input into one file. --- src/CMakeLists.txt | 1 - src/Makefile.am | 1 - src/gui/base/gui.cpp | 7 +-- src/gui/base/gui.hpp | 8 +-- src/gui/base/input.hpp | 134 ------------------------------------------------- src/gui/sdlinput.cpp | 4 +- src/gui/sdlinput.h | 24 ++++----- 7 files changed, 21 insertions(+), 158 deletions(-) delete mode 100644 src/gui/base/input.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b523f084c..a024966a3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -773,7 +773,6 @@ SET(SRCS gui/base/focushandler.hpp listeners/focuslistener.h gui/base/gui.hpp - gui/base/input.hpp events/inputguievent.h gui/base/key.hpp events/keyevent.h diff --git a/src/Makefile.am b/src/Makefile.am index 19f8fe4f2..2476a6bff 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -161,7 +161,6 @@ manaplus_SOURCES += events/actionevent.h \ listeners/focuslistener.h \ render/graphics.h \ gui/base/gui.hpp \ - gui/base/input.hpp \ events/inputguievent.h \ gui/base/key.hpp \ events/keyevent.h \ diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index e5291cb60..02c6e6674 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -69,9 +69,10 @@ #include "gui/base/basiccontainer.hpp" #include "gui/base/focushandler.hpp" -#include "gui/base/input.hpp" #include "gui/base/widget.hpp" +#include "gui/sdlinput.h" + #include "input/keyinput.h" #include "input/mouseinput.h" @@ -139,12 +140,12 @@ namespace gcn return mGraphics; } - void Gui::setInput(Input* input) + void Gui::setInput(SDLInput* input) { mInput = input; } - Input* Gui::getInput() const + SDLInput* Gui::getInput() const { return mInput; } diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 2ec5d7082..6e6a3867d 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -74,11 +74,11 @@ class Graphics; class KeyListener; +class SDLInput; namespace gcn { class FocusHandler; - class Input; class Widget; // The following comment will appear in the doxygen main page. @@ -178,7 +178,7 @@ namespace gcn * SDLInput * @since 0.1.0 */ - virtual void setInput(Input* input); + virtual void setInput(SDLInput* input); /** * Gets the input object being used for input handling. @@ -189,7 +189,7 @@ namespace gcn * SDLInput * @since 0.1.0 */ - virtual Input* getInput() const A_WARN_UNUSED; + virtual SDLInput* getInput() const A_WARN_UNUSED; /** * Performs logic of the GUI. By calling this function all logic @@ -418,7 +418,7 @@ namespace gcn /** * Holds the input implementation used. */ - Input* mInput; + SDLInput* mInput; /** * Holds the focus handler for the Gui. diff --git a/src/gui/base/input.hpp b/src/gui/base/input.hpp deleted file mode 100644 index 1643482d3..000000000 --- a/src/gui/base/input.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_INPUT_HPP -#define GCN_INPUT_HPP - -#include "localconsts.h" - -class KeyInput; -class MouseInput; - -namespace gcn -{ - /** - * Abstract class for providing functions for user input. - * - * Guichan contains implementations of Input for common - * libraries like the Allegro library, the HGE library, - * and the SDL library. - * To make Guichan usable with other libraries, an Input - * class must be implemented. - * - * @see AllegroInput, HGEInput, OpenLayerInput, - * SDLInput - */ - class Input - { - public: - /** - * Destructor. - */ - virtual ~Input(){ } - - /** - * Checks if the key queue is empty, or not. - * - * @return True if the key queue is empty, - * false otherwise. - */ - virtual bool isKeyQueueEmpty() A_WARN_UNUSED = 0; - - /** - * Dequeues the key input queue. - * - * @return The first key input in the key input queue. - */ - virtual KeyInput dequeueKeyInput() = 0; - - /** - * Checks if the mouse queue is empyt, or not. - * - * @return True if the mouse queue is empty, - * false otherwise. - */ - virtual bool isMouseQueueEmpty() A_WARN_UNUSED = 0; - - /** - * Dequeues the mouse input queue. - * - * @return The first mouse input in the mouse input queue. - */ - virtual MouseInput dequeueMouseInput() = 0; - - /** - * Polls all exsisting input. Called when input should - * be polled. The function exists for compatibility reason - * where some libraries need to poll input at a certain - * logic rate. - */ - virtual void _pollInput() = 0; - }; -} // namespace gcn - -#endif // end GCN_INPUT_HPP diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 21a8d3957..33c15f5c7 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -75,12 +75,12 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "gui/sdlinput.h" - #include "sdlshared.h" #include "input/inputmanager.h" +#include "gui/sdlinput.h" + #include "render/graphics.h" #ifdef USE_SDL2 diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 1a19e8790..3454f2d9f 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -75,16 +75,14 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GUI_SDLINPUT_H -#define GUI_SDLINPUT_H +#ifndef GUI_INPUT_H +#define GUI_INPUT_H #include "input/keyinput.h" #include "input/mouseinput.h" #include -#include "gui/base/input.hpp" - #include "input/mouseinput.h" #include @@ -145,9 +143,9 @@ namespace Key } // namespace Key /** - * SDL implementation of Input. + * SDL implementation of SDLInput. */ -class SDLInput final : public gcn::Input +class SDLInput final { public: /** @@ -170,21 +168,21 @@ public: * only use SDL and plan sticking with SDL you can safely ignore this * function as it in the SDL case does nothing. */ - void _pollInput() override final + void _pollInput() { } KeyInput dequeueKeyInput2() A_WARN_UNUSED; - KeyInput dequeueKeyInput() override final A_WARN_UNUSED + KeyInput dequeueKeyInput() A_WARN_UNUSED { return KeyInput(); } - // Inherited from Input + // Inherited from SDLInput - bool isKeyQueueEmpty() override final A_WARN_UNUSED; + bool isKeyQueueEmpty() A_WARN_UNUSED; - bool isMouseQueueEmpty() override final A_WARN_UNUSED; + bool isMouseQueueEmpty() A_WARN_UNUSED; - MouseInput dequeueMouseInput() override final A_WARN_UNUSED; + MouseInput dequeueMouseInput() A_WARN_UNUSED; MouseInput dequeueMouseInput2() A_WARN_UNUSED; @@ -220,4 +218,4 @@ protected: bool mMouseInWindow; }; -#endif // GUI_SDLINPUT_H +#endif // GUI_INPUT_H -- cgit v1.2.3-70-g09d2 From b1a2e2bc36735e61d903f31fd2d541b082970392 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 00:42:43 +0300 Subject: Add missing guichan headers into tab and tabbedarea classes. --- src/gui/widgets/tabbedarea.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ src/gui/widgets/tabbedarea.h | 43 ++++++++++++++++++++++++++++++++++++++++++ src/gui/widgets/tabs/tab.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ src/gui/widgets/tabs/tab.h | 43 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 172 insertions(+) (limited to 'src') diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 83df191d1..0527486ad 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + #include "gui/widgets/tabbedarea.h" #include "events/keyevent.h" diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 2fb894f6f..7ac24165b 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_WIDGETS_TABBEDAREA_H #define GUI_WIDGETS_TABBEDAREA_H diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index a097d28e2..87bd8bde2 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + #include "gui/widgets/tabs/tab.h" #include "client.h" diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 655fba7ea..c186a0b4e 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_WIDGETS_TABS_TAB_H #define GUI_WIDGETS_TABS_TAB_H -- cgit v1.2.3-70-g09d2 From d2b34e1d51d04288274eca0151de959817f037a2 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 02:00:20 +0300 Subject: Move key into input directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/events/keyevent.h | 8 +- src/gui/base/key.cpp | 113 -------------------- src/gui/base/key.hpp | 201 ----------------------------------- src/gui/base/widgets/button.cpp | 3 +- src/gui/base/widgets/checkbox.cpp | 3 +- src/gui/base/widgets/listbox.cpp | 2 +- src/gui/base/widgets/radiobutton.cpp | 3 +- src/gui/base/widgets/slider.cpp | 3 +- src/gui/base/widgets/textbox.cpp | 2 +- src/gui/base/widgets/textfield.cpp | 3 +- src/gui/sdlinput.cpp | 4 +- src/gui/sdlinput.h | 55 ---------- src/gui/widgets/guitable.cpp | 3 +- src/gui/widgets/textbox.cpp | 2 +- src/input/key.cpp | 110 +++++++++++++++++++ src/input/key.h | 197 ++++++++++++++++++++++++++++++++++ src/input/keyinput.h | 8 +- src/listeners/keylistener.h | 5 +- 20 files changed, 332 insertions(+), 401 deletions(-) delete mode 100644 src/gui/base/key.cpp delete mode 100644 src/gui/base/key.hpp create mode 100644 src/input/key.cpp create mode 100644 src/input/key.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a024966a3..0d1c5697a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -774,7 +774,7 @@ SET(SRCS listeners/focuslistener.h gui/base/gui.hpp events/inputguievent.h - gui/base/key.hpp + input/key.hpp events/keyevent.h listeners/keylistener.h gui/base/listmodel.hpp @@ -802,7 +802,7 @@ SET(SRCS gui/base/color.cpp gui/base/focushandler.cpp gui/base/gui.cpp - gui/base/key.cpp + input/key.cpp gui/base/rectangle.cpp gui/base/widget.cpp gui/base/widgets/button.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 2476a6bff..ff2368ed0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -162,7 +162,7 @@ manaplus_SOURCES += events/actionevent.h \ render/graphics.h \ gui/base/gui.hpp \ events/inputguievent.h \ - gui/base/key.hpp \ + input/key.hpp \ events/keyevent.h \ listeners/keylistener.h \ gui/base/listmodel.hpp \ @@ -190,7 +190,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/color.cpp \ gui/base/focushandler.cpp \ gui/base/gui.cpp \ - gui/base/key.cpp \ + input/key.cpp \ gui/base/rectangle.cpp \ gui/base/widget.cpp \ gui/base/widgets/button.cpp \ diff --git a/src/events/keyevent.h b/src/events/keyevent.h index ec5b5489a..f27851f0e 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -65,7 +65,7 @@ #define EVENTS_KEYEVENT_HPP #include "events/inputguievent.h" -#include "gui/base/key.hpp" +#include "input/key.h" namespace gcn { @@ -108,7 +108,7 @@ class KeyEvent: public InputGuiEvent const unsigned int type, const bool numericPad, const int actionId, - const gcn::Key &key) : + const Key &key) : InputGuiEvent(source, shiftPressed, controlPressed, @@ -152,7 +152,7 @@ class KeyEvent: public InputGuiEvent * * @return The key of the event. */ - const gcn::Key &getKey() const A_WARN_UNUSED + const Key &getKey() const A_WARN_UNUSED { return mKey; } int getActionId() const A_WARN_UNUSED @@ -170,7 +170,7 @@ class KeyEvent: public InputGuiEvent /** * Holds the key of the key event. */ - gcn::Key mKey; + Key mKey; #ifdef USE_SDL2 std::string mText; diff --git a/src/gui/base/key.cpp b/src/gui/base/key.cpp deleted file mode 100644 index 8cf21bdfe..000000000 --- a/src/gui/base/key.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/key.hpp" - -#include "debug.h" - -namespace gcn -{ - Key::Key(const int value) : - mValue(value) - { - } - - bool Key::isCharacter() const - { - return (mValue >= 32 && mValue <= 126) - || (mValue >= 162 && mValue <= 255) - || (mValue == 9); - } - - bool Key::isNumber() const - { - return mValue >= 48 && mValue <= 57; - } - - bool Key::isLetter() const - { - return (((mValue >= 65 && mValue <= 90) - || (mValue >= 97 && mValue <= 122) - || (mValue >= 192 && mValue <= 255)) - && (mValue != 215) && (mValue != 247)); - } - - int Key::getValue() const - { - return mValue; - } - - bool Key::operator==(const Key& key) const - { - return mValue == key.mValue; - } - - bool Key::operator!=(const Key& key) const - { - return (mValue != key.mValue); - } -} // namespace gcn diff --git a/src/gui/base/key.hpp b/src/gui/base/key.hpp deleted file mode 100644 index 46b36a179..000000000 --- a/src/gui/base/key.hpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_KEY_HPP -#define GCN_KEY_HPP - -#include "localconsts.h" - -// windows.h defines DELETE which breaks this file as we have a constant named -// DELETE, hence we undefine DELETE if it is defined and hope people don't use -// that windows define with Guichan. -#if defined (_WIN32) && defined(DELETE) -#undef DELETE -#endif - -namespace gcn -{ - /** - * Represents a key or a character. - */ - class Key final - { - public: - /** - * Constructor. - * - * @param value The ascii or enum value for the key. - */ - explicit Key(const int value = 0); - - /** - * Checks if a key is a character. - * - * @return True if the key is a letter, number or whitespace, - * false otherwise. - */ - bool isCharacter() const A_WARN_UNUSED; - - /** - * Checks if a key is a number. - * - * @return True if the key is a number (0-9), - * false otherwise. - */ - bool isNumber() const A_WARN_UNUSED; - - /** - * Checks if a key is a letter. - * - * @return True if the key is a letter (a-z,A-Z), - * false otherwise. - */ - bool isLetter() const A_WARN_UNUSED; - - /** - * Gets the value of the key. If an ascii value exists it - * will be returned. Otherwise an enum value will be returned. - * - * @return the value of the key. - */ - int getValue() const A_WARN_UNUSED; - - /** - * Compares two keys. - * - * @param key The key to compare this key with. - * @return True if the keys are equal, false otherwise. - */ - bool operator==(const Key& key) const; - - /** - * Compares two keys. - * - * @param key The key to compare this key with. - * @return True if the keys are not equal, false otherwise. - */ - bool operator!=(const Key& key) const; - - /** - * An enum with key values. - */ - enum - { - SPACE = ' ', - TAB = '\t', - ENTER = '\n', - LEFT_ALT = 1000, - RIGHT_ALT, - LEFT_SHIFT, - RIGHT_SHIFT, - LEFT_CONTROL, - RIGHT_CONTROL, - LEFT_META, - RIGHT_META, - LEFT_SUPER, - RIGHT_SUPER, - INSERT, - HOME, - PAGE_UP, - DELETE, - END, - PAGE_DOWN, - ESCAPE, - CAPS_LOCK, - BACKSPACE, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - PRINT_SCREEN, - SCROLL_LOCK, - PAUSE, - NUM_LOCK, - ALT_GR, - LEFT, - RIGHT, - UP, - DOWN - }; - - protected: - /** - * Holds the value of the key. It may be an ascii value - * or an enum value. - */ - int mValue; - }; -} // namespace gcn - -#endif // end GCN_KEY_HPP diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 56ba72590..5867b9dc8 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -69,8 +69,7 @@ #include "gui/font.h" -#include "gui/base/key.hpp" - +#include "input/key.h" #include "input/mouseinput.h" #include "events/mouseevent.h" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 18f635052..7cba5ac47 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -69,8 +69,7 @@ #include "gui/font.h" -#include "gui/base/key.hpp" - +#include "input/key.h" #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index f13a96e39..ad1bf2535 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -70,9 +70,9 @@ #include "gui/font.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/key.hpp" #include "gui/base/listmodel.hpp" +#include "input/key.h" #include "input/mouseinput.h" #include "listeners/selectionlistener.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index ff6a39db0..4cd515bba 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -69,8 +69,7 @@ #include "gui/font.h" -#include "gui/base/key.hpp" - +#include "input/key.h" #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index d61f2766c..1245b6590 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -67,8 +67,7 @@ #include "gui/base/widgets/slider.hpp" -#include "gui/base/key.hpp" - +#include "input/key.h" #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index db5d91b92..292e35850 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -70,8 +70,8 @@ #include "gui/font.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/key.hpp" +#include "input/key.h" #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 891e7e86b..f149e8667 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -69,8 +69,7 @@ #include "gui/font.h" -#include "gui/base/key.hpp" - +#include "input/key.h" #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index 33c15f5c7..d8a63b60c 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -171,7 +171,7 @@ void SDLInput::pushInput(const SDL_Event &event) #ifdef USE_SDL2 case SDL_TEXTINPUT: keyInput.setType(KeyInput::PRESSED); - keyInput.setKey(gcn::Key(Key::TEXTINPUT)); + keyInput.setKey(Key(Key::TEXTINPUT)); keyInput.setText(event.text.text); mKeyInputQueue.push(keyInput); break; @@ -315,7 +315,7 @@ void SDLInput::pushInput(const SDL_Event &event) void SDLInput::convertKeyEventToKey(const SDL_Event &event, KeyInput &keyInput) { - keyInput.setKey(gcn::Key(convertKeyCharacter(event))); + keyInput.setKey(Key(convertKeyCharacter(event))); keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT); keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL); keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT); diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 3454f2d9f..8a9128920 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -87,61 +87,6 @@ #include -namespace Key -{ - enum - { - SPACE = ' ', - TAB = '\t', - ENTER = '\n', - // Negative values, to avoid conflicts with higher character codes. - LEFT_ALT = -1000, - RIGHT_ALT, - LEFT_SHIFT, - RIGHT_SHIFT, - LEFT_CONTROL, - RIGHT_CONTROL, - LEFT_META, - RIGHT_META, - LEFT_SUPER, - RIGHT_SUPER, - INSERT, - HOME, - PAGE_UP, - DELETE_, - END, - PAGE_DOWN, - ESCAPE, - CAPS_LOCK, - BACKSPACE, - F1, - F2, - F3, - F4, - F5, - F6, - F7, - F8, - F9, - F10, - F11, - F12, - F13, - F14, - F15, - PRINT_SCREEN, - SCROLL_LOCK, - PAUSE, - NUM_LOCK, - ALT_GR, - LEFT, - RIGHT, - UP, - DOWN, - TEXTINPUT - }; -} // namespace Key - /** * SDL implementation of SDLInput. */ diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 5873ef4ce..f87ca2fe7 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -31,7 +31,8 @@ #include "utils/dtor.h" #include "listeners/actionlistener.h" -#include "gui/base/key.hpp" + +#include "input/key.h" #include "render/graphics.h" diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 5f74fa1f8..0ea05e585 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -168,7 +168,7 @@ void TextBox::setTextWrapped(const std::string &text, const int minDimension) void TextBox::keyPressed(KeyEvent& keyEvent) { - const gcn::Key &key = keyEvent.getKey(); + const Key &key = keyEvent.getKey(); const int action = keyEvent.getActionId(); switch (action) diff --git a/src/input/key.cpp b/src/input/key.cpp new file mode 100644 index 000000000..13d2a301d --- /dev/null +++ b/src/input/key.cpp @@ -0,0 +1,110 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "input/key.h" + +#include "debug.h" + +Key::Key(const int value) : + mValue(value) +{ +} + +bool Key::isCharacter() const +{ + return (mValue >= 32 && mValue <= 126) + || (mValue >= 162 && mValue <= 255) + || (mValue == 9); +} + +bool Key::isNumber() const +{ + return mValue >= 48 && mValue <= 57; +} + +bool Key::isLetter() const +{ + return (((mValue >= 65 && mValue <= 90) + || (mValue >= 97 && mValue <= 122) + || (mValue >= 192 && mValue <= 255)) + && (mValue != 215) && (mValue != 247)); +} + +int Key::getValue() const +{ + return mValue; +} + +bool Key::operator==(const Key& key) const +{ + return mValue == key.mValue; +} + +bool Key::operator!=(const Key& key) const +{ + return (mValue != key.mValue); +} diff --git a/src/input/key.h b/src/input/key.h new file mode 100644 index 000000000..fa48d3583 --- /dev/null +++ b/src/input/key.h @@ -0,0 +1,197 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 INPUT_KEY_H +#define INPUT_KEY_H + +#include "localconsts.h" + +// windows.h defines DELETE which breaks this file as we have a constant named +// DELETE, hence we undefine DELETE if it is defined and hope people don't use +// that windows define with Guichan. +#if defined (_WIN32) && defined(DELETE) +#undef DELETE +#endif + +/** + * Represents a key or a character. + */ +class Key final +{ + public: + /** + * Constructor. + * + * @param value The ascii or enum value for the key. + */ + explicit Key(const int value = 0); + + enum + { + SPACE = ' ', + TAB = '\t', + ENTER = '\n', + // Negative values, to avoid conflicts with higher character codes. + LEFT_ALT = -1000, + RIGHT_ALT, + LEFT_SHIFT, + RIGHT_SHIFT, + LEFT_CONTROL, + RIGHT_CONTROL, + LEFT_META, + RIGHT_META, + LEFT_SUPER, + RIGHT_SUPER, + INSERT, + HOME, + PAGE_UP, + DELETE_, + END, + PAGE_DOWN, + ESCAPE, + CAPS_LOCK, + BACKSPACE, + F1, + F2, + F3, + F4, + F5, + F6, + F7, + F8, + F9, + F10, + F11, + F12, + F13, + F14, + F15, + PRINT_SCREEN, + SCROLL_LOCK, + PAUSE, + NUM_LOCK, + ALT_GR, + LEFT, + RIGHT, + UP, + DOWN, + TEXTINPUT + }; + + /** + * Checks if a key is a character. + * + * @return True if the key is a letter, number or whitespace, + * false otherwise. + */ + bool isCharacter() const A_WARN_UNUSED; + + /** + * Checks if a key is a number. + * + * @return True if the key is a number (0-9), + * false otherwise. + */ + bool isNumber() const A_WARN_UNUSED; + + /** + * Checks if a key is a letter. + * + * @return True if the key is a letter (a-z,A-Z), + * false otherwise. + */ + bool isLetter() const A_WARN_UNUSED; + + /** + * Gets the value of the key. If an ascii value exists it + * will be returned. Otherwise an enum value will be returned. + * + * @return the value of the key. + */ + int getValue() const A_WARN_UNUSED; + + /** + * Compares two keys. + * + * @param key The key to compare this key with. + * @return True if the keys are equal, false otherwise. + */ + bool operator==(const Key& key) const; + + /** + * Compares two keys. + * + * @param key The key to compare this key with. + * @return True if the keys are not equal, false otherwise. + */ + bool operator!=(const Key& key) const; + + protected: + /** + * Holds the value of the key. It may be an ascii value + * or an enum value. + */ + int mValue; +}; + +#endif // end GCN_KEY_HPP diff --git a/src/input/keyinput.h b/src/input/keyinput.h index 396d7c218..9920cfa17 100644 --- a/src/input/keyinput.h +++ b/src/input/keyinput.h @@ -64,7 +64,7 @@ #ifndef INPUT_KEYINPUT_H #define INPUT_KEYINPUT_H -#include "gui/base/key.hpp" +#include "input/key.h" #include @@ -110,12 +110,12 @@ class KeyInput final return mType; } - void setKey(const gcn::Key& key) + void setKey(const Key& key) { mKey = key; } - const gcn::Key& getKey() const + const Key& getKey() const { return mKey; } @@ -196,7 +196,7 @@ class KeyInput final /** * Holds the key of the key input. */ - gcn::Key mKey; + Key mKey; /** * Holds the type of the key input. diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h index 2d4a74b9e..0873de835 100644 --- a/src/listeners/keylistener.h +++ b/src/listeners/keylistener.h @@ -68,10 +68,7 @@ #include "localconsts.h" -namespace gcn -{ - class Key; -} +class Key; /** * Interface for listening for key events from widgets. -- cgit v1.2.3-70-g09d2 From 695fadf9f104443e3a925c88c074b0585a51f81c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 02:10:50 +0300 Subject: fix make files. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0d1c5697a..3fca244eb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -774,7 +774,7 @@ SET(SRCS listeners/focuslistener.h gui/base/gui.hpp events/inputguievent.h - input/key.hpp + input/key.h events/keyevent.h listeners/keylistener.h gui/base/listmodel.hpp diff --git a/src/Makefile.am b/src/Makefile.am index ff2368ed0..1b3710b60 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -162,7 +162,7 @@ manaplus_SOURCES += events/actionevent.h \ render/graphics.h \ gui/base/gui.hpp \ events/inputguievent.h \ - input/key.hpp \ + input/key.h \ events/keyevent.h \ listeners/keylistener.h \ gui/base/listmodel.hpp \ -- cgit v1.2.3-70-g09d2 From a520c88cabf03973ddf27435eb5a970f9c214d30 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 21:31:57 +0300 Subject: combine focushandler into one file. --- src/CMakeLists.txt | 2 - src/Makefile.am | 6 +- src/gui/base/basiccontainer.cpp | 3 +- src/gui/base/focushandler.cpp | 569 ---------------------------------------- src/gui/base/focushandler.hpp | 417 ----------------------------- src/gui/base/gui.cpp | 2 +- src/gui/base/gui.hpp | 2 +- src/gui/base/widget.cpp | 3 +- src/gui/base/widget.hpp | 2 +- src/gui/focushandler.cpp | 518 +++++++++++++++++++++++++++++++++++- src/gui/focushandler.h | 379 ++++++++++++++++++++++++-- src/gui/gui.h | 2 +- src/gui/widgets/guitable.cpp | 2 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/listbox.cpp | 2 +- src/gui/widgets/window.cpp | 3 +- src/gui/windows/chatwindow.cpp | 3 +- src/input/inputmanager.cpp | 2 +- 18 files changed, 879 insertions(+), 1040 deletions(-) delete mode 100644 src/gui/base/focushandler.cpp delete mode 100644 src/gui/base/focushandler.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3fca244eb..711d9e47b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -770,7 +770,6 @@ SET(SRCS gui/base/color.hpp listeners/deathlistener.h events/event.h - gui/base/focushandler.hpp listeners/focuslistener.h gui/base/gui.hpp events/inputguievent.h @@ -800,7 +799,6 @@ SET(SRCS gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp gui/base/color.cpp - gui/base/focushandler.cpp gui/base/gui.cpp input/key.cpp gui/base/rectangle.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 1b3710b60..f20376feb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -29,13 +29,11 @@ dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ gui/base/color.cpp \ gui/base/rectangle.cpp \ - gui/base/widget.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ gui/base/color.hpp \ events/event.h \ - gui/base/rectangle.hpp \ - gui/base/widget.hpp + gui/base/rectangle.hpp dyecmd_SOURCES += dyetool/dyemain.cpp \ animatedsprite.cpp \ @@ -157,7 +155,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/color.hpp \ listeners/deathlistener.h \ events/event.h \ - gui/base/focushandler.hpp \ listeners/focuslistener.h \ render/graphics.h \ gui/base/gui.hpp \ @@ -188,7 +185,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ gui/base/color.cpp \ - gui/base/focushandler.cpp \ gui/base/gui.cpp \ input/key.cpp \ gui/base/rectangle.cpp \ diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 82ef1c025..05d89f172 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -69,7 +69,8 @@ #include -#include "gui/base/focushandler.hpp" +#include "gui/focushandler.h" + #include "input/mouseinput.h" #include "render/graphics.h" diff --git a/src/gui/base/focushandler.cpp b/src/gui/base/focushandler.cpp deleted file mode 100644 index 3c6978e70..000000000 --- a/src/gui/base/focushandler.cpp +++ /dev/null @@ -1,569 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/focushandler.hpp" - -#include "gui/base/widget.hpp" - -#include "listeners/focuslistener.h" - -#include "debug.h" - -namespace gcn -{ - FocusHandler::FocusHandler() : - mWidgets(), - mFocusedWidget(nullptr), - mModalFocusedWidget(nullptr), - mModalMouseInputFocusedWidget(nullptr), - mDraggedWidget(nullptr), - mLastWidgetWithMouse(nullptr), - mLastWidgetWithModalFocus(nullptr), - mLastWidgetWithModalMouseInputFocus(nullptr), - mLastWidgetPressed(nullptr) - { - } - - void FocusHandler::requestFocus(Widget* widget) - { - if (!widget || widget == mFocusedWidget) - return; - - int toBeFocusedIndex = -1; - for (unsigned int i = 0, sz = static_cast( - mWidgets.size()); i < sz; ++i) - { - if (mWidgets[i] == widget) - { - toBeFocusedIndex = i; - break; - } - } - - if (toBeFocusedIndex < 0) - return; - - Widget *const oldFocused = mFocusedWidget; - - if (oldFocused != widget) - { - mFocusedWidget = mWidgets.at(toBeFocusedIndex); - - if (oldFocused) - { - Event focusEvent(oldFocused); - distributeFocusLostEvent(focusEvent); - } - - Event focusEvent(mWidgets.at(toBeFocusedIndex)); - distributeFocusGainedEvent(focusEvent); - } - } - - void FocusHandler::requestModalFocus(Widget* widget) - { - if (mModalFocusedWidget && mModalFocusedWidget != widget) - return; - - mModalFocusedWidget = widget; - if (mFocusedWidget && !mFocusedWidget->isModalFocused()) - focusNone(); - } - - void FocusHandler::requestModalMouseInputFocus(Widget* widget) - { - if (mModalMouseInputFocusedWidget - && mModalMouseInputFocusedWidget != widget) - { - return; - } - - mModalMouseInputFocusedWidget = widget; - } - - void FocusHandler::releaseModalFocus(Widget* widget) - { - if (mModalFocusedWidget == widget) - mModalFocusedWidget = nullptr; - } - - void FocusHandler::releaseModalMouseInputFocus(Widget* widget) - { - if (mModalMouseInputFocusedWidget == widget) - mModalMouseInputFocusedWidget = nullptr; - } - - Widget* FocusHandler::getFocused() const - { - return mFocusedWidget; - } - - Widget* FocusHandler::getModalFocused() const - { - return mModalFocusedWidget; - } - - Widget* FocusHandler::getModalMouseInputFocused() const - { - return mModalMouseInputFocusedWidget; - } - - void FocusHandler::focusNext() - { - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - ++ focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget >= sz) - focusedWidget = 0; - - if (focusedWidget == focused) - return; - } - while (!mWidgets.at(focusedWidget)->isFocusable()); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::focusPrevious() - { - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - -- focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget <= 0) - focusedWidget = sz - 1; - - if (focusedWidget == focused) - return; - } - while (!mWidgets.at(focusedWidget)->isFocusable()); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - bool FocusHandler::isFocused(const Widget* widget) const - { - return mFocusedWidget == widget; - } - - void FocusHandler::add(Widget* widget) - { - mWidgets.push_back(widget); - } - - void FocusHandler::remove(Widget* widget) - { - if (isFocused(widget)) - mFocusedWidget = nullptr; - - for (WidgetIterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++iter) - { - if ((*iter) == widget) - { - mWidgets.erase(iter); - break; - } - } - - if (mDraggedWidget == widget) - { - mDraggedWidget = nullptr; - return; - } - - if (mLastWidgetWithMouse == widget) - { - mLastWidgetWithMouse = nullptr; - return; - } - - if (mLastWidgetWithModalFocus == widget) - { - mLastWidgetWithModalFocus = nullptr; - return; - } - - if (mLastWidgetWithModalMouseInputFocus == widget) - { - mLastWidgetWithModalMouseInputFocus = nullptr; - return; - } - - if (mLastWidgetPressed == widget) - { - mLastWidgetPressed = nullptr; - return; - } - } - - void FocusHandler::focusNone() - { - if (mFocusedWidget) - { - Widget *const focused = mFocusedWidget; - mFocusedWidget = nullptr; - - Event focusEvent(focused); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::tabNext() - { - if (mFocusedWidget) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - bool done = false; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - ++ focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget >= sz) - focusedWidget = 0; - - if (focusedWidget == focused) - return; - - const Widget *const widget = mWidgets.at(focusedWidget); - if (widget->isFocusable() && widget->isTabInEnabled() && - (!mModalFocusedWidget || widget->isModalFocused())) - { - done = true; - } - } - while (!done); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::tabPrevious() - { - if (mFocusedWidget) - { - if (!mFocusedWidget->isTabOutEnabled()) - return; - } - - if (mWidgets.empty()) - { - mFocusedWidget = nullptr; - return; - } - - int i; - int focusedWidget = -1; - const int sz = static_cast(mWidgets.size()); - for (i = 0; i < sz; ++ i) - { - if (mWidgets[i] == mFocusedWidget) - focusedWidget = i; - } - const int focused = focusedWidget; - bool done = false; - - // i is a counter that ensures that the following loop - // won't get stuck in an infinite loop - i = sz; - do - { - -- focusedWidget; - - if (i == 0) - { - focusedWidget = -1; - break; - } - - -- i; - - if (focusedWidget <= 0) - focusedWidget = sz - 1; - - if (focusedWidget == focused) - return; - - const Widget *const widget = mWidgets.at(focusedWidget); - if (widget->isFocusable() && widget->isTabInEnabled() && - (!mModalFocusedWidget || widget->isModalFocused())) - { - done = true; - } - } - while (!done); - - if (focusedWidget >= 0) - { - mFocusedWidget = mWidgets.at(focusedWidget); - Event focusEvent(mFocusedWidget); - distributeFocusGainedEvent(focusEvent); - } - - if (focused >= 0) - { - Event focusEvent(mWidgets.at(focused)); - distributeFocusLostEvent(focusEvent); - } - } - - void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) - { - Widget *const sourceWidget = focusEvent.getSource(); - - std::list focusListeners - = sourceWidget->_getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusLost(focusEvent); - } - } - - void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent) - { - Widget *const sourceWidget = focusEvent.getSource(); - - std::list focusListeners - = sourceWidget->_getFocusListeners(); - - // Send the event to all focus listeners of the widget. - for (std::list::const_iterator - it = focusListeners.begin(); - it != focusListeners.end(); - ++ it) - { - (*it)->focusGained(focusEvent); - } - } - - Widget* FocusHandler::getDraggedWidget() - { - return mDraggedWidget; - } - - void FocusHandler::setDraggedWidget(Widget* draggedWidget) - { - mDraggedWidget = draggedWidget; - } - - Widget* FocusHandler::getLastWidgetWithMouse() - { - return mLastWidgetWithMouse; - } - - void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse) - { - mLastWidgetWithMouse = lastWidgetWithMouse; - } - - Widget* FocusHandler::getLastWidgetWithModalFocus() - { - return mLastWidgetWithModalFocus; - } - - void FocusHandler::setLastWidgetWithModalFocus(Widget* widget) - { - mLastWidgetWithModalFocus = widget; - } - - Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() - { - return mLastWidgetWithModalMouseInputFocus; - } - - void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget) - { - mLastWidgetWithModalMouseInputFocus = widget; - } - - Widget* FocusHandler::getLastWidgetPressed() - { - return mLastWidgetPressed; - } - - void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed) - { - mLastWidgetPressed = lastWidgetPressed; - } -} // namespace gcn diff --git a/src/gui/base/focushandler.hpp b/src/gui/base/focushandler.hpp deleted file mode 100644 index a5c1b14a1..000000000 --- a/src/gui/base/focushandler.hpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_FOCUSHANDLER_HPP -#define GCN_FOCUSHANDLER_HPP - -#include - -#include "events/event.h" - -namespace gcn -{ - class Widget; - - /** - * Handles focus for widgets in a Gui. Each Gui has at least one - * focus handler. - * You will probably not use the focus handler directly as Widget - * has functions that automatically uses the active focus handler. - * - * @see Widget::isFocus, Widget::isModalFocused, - * Widget::isModalMouseInputFocused, Widget::requestFocus, - * Widget::requestModalFocus, Widget::requestModalMouseInputFocus, - * Widget::releaseModalFocus, Widget::relaseModalMouseInputFocus, - * Widget::setFocusable, Widget::isFocusable, FocusListener - * - * @since 0.1.0 - */ - class FocusHandler - { - public: - /** - * Constructor. - */ - FocusHandler(); - - A_DELETE_COPY(FocusHandler) - - /** - * Destructor. - */ - virtual ~FocusHandler() - { } - - /** - * Requests focus for a widget. Focus will only be granted to a widget - * if it's focusable and if no other widget has modal focus. - * If a widget receives focus a focus event will be sent to the - * focus listeners of the widget. - * - * @param widget The widget to request focus for. - * @see isFocused, Widget::requestFocus - */ - virtual void requestFocus(Widget* widget); - - /** - * Requests modal focus for a widget. Focus will only be granted - * to a widget if it's focusable and if no other widget has modal - * focus. - * - * @param widget The widget to request modal focus for. - * @throws Exception when another widget already has modal focus. - * @see releaseModalFocus, Widget::requestModalFocus - */ - virtual void requestModalFocus(Widget* widget); - - /** - * Requests modal mouse input focus for a widget. Focus will only - * be granted to a widget if it's focusable and if no other widget - * has modal mouse input focus. - * - * Modal mouse input focus means no other widget then the widget with - * modal mouse input focus will receive mouse input. The widget with - * modal mouse input focus will also receive mouse input no matter what - * the mouse input is or where the mouse input occurs. - * - * @param widget The widget to focus for modal mouse input focus. - * @throws Exception when another widget already has modal mouse input - * focus. - * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus - */ - virtual void requestModalMouseInputFocus(Widget* widget); - - /** - * Releases modal focus if the widget has modal focus. - * If the widget doesn't have modal focus no relase will occur. - * - * @param widget The widget to release modal focus for. - * @see reuqestModalFocus, Widget::releaseModalFocus - */ - virtual void releaseModalFocus(Widget* widget); - - /** - * Releases modal mouse input focus if the widget has modal mouse input - * focus. If the widget doesn't have modal mouse input focus no relase - * will occur. - * - * @param widget the widget to release modal mouse input focus for. - * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus - */ - virtual void releaseModalMouseInputFocus(Widget* widget); - - /** - * Checks if a widget is focused. - * - * @param widget The widget to check. - * @return True if the widget is focused, false otherwise. - * @see Widget::isFocused - */ - virtual bool isFocused(const Widget* widget) const; - - /** - * Gets the widget with focus. - * - * @return The widget with focus. NULL if no widget has focus. - */ - virtual Widget* getFocused() const A_WARN_UNUSED; - - /** - * Gets the widget with modal focus. - * - * @return The widget with modal focus. NULL if no widget has - * modal focus. - */ - virtual Widget* getModalFocused() const A_WARN_UNUSED; - - /** - * Gets the widget with modal mouse input focus. - * - * @return The widget with modal mouse input focus. NULL if - * no widget has modal mouse input focus. - */ - virtual Widget* getModalMouseInputFocused() const A_WARN_UNUSED; - - /** - * Focuses the next widget added to a conainer. - * If no widget has focus the first widget gets focus. The order - * in which the widgets are focused is determined by the order - * they were added to a container. - * - * @see focusPrevious - */ - virtual void focusNext(); - - /** - * Focuses the previous widget added to a contaienr. - * If no widget has focus the first widget gets focus. The order - * in which the widgets are focused is determined by the order - * they were added to a container. - * - * @see focusNext - */ - virtual void focusPrevious(); - - /** - * Adds a widget to by handles by the focus handler. - * - * @param widget The widget to add. - * @see remove - */ - virtual void add(Widget* widget); - - /** - * Removes a widget from the focus handler. - * - * @param widget The widget to remove. - * @see add - */ - virtual void remove(Widget* widget); - - /** - * Focuses nothing. A focus event will also be sent to the - * focused widget's focus listeners if a widget has focus. - */ - virtual void focusNone(); - - /** - * Focuses the next widget which allows tabbing in unless - * the current focused Widget disallows tabbing out. - * - * @see tabPrevious - */ - virtual void tabNext(); - - /** - * Focuses the previous widget which allows tabbing in unless - * current focused widget disallows tabbing out. - * - * @see tabNext - */ - virtual void tabPrevious(); - - /** - * Gets the widget being dragged. Used by the Gui class to - * keep track of the dragged widget. - * - * @return the widget being dragged. - * @see setDraggedWidget - */ - virtual Widget* getDraggedWidget() A_WARN_UNUSED; - - /** - * Sets the widget being dragged. Used by the Gui class to - * keep track of the dragged widget. - * - * @param draggedWidget The widget being dragged. - * @see getDraggedWidget - */ - virtual void setDraggedWidget(Widget* draggedWidget); - - /** - * Gets the last widget with the mouse. Used by the Gui class - * to keep track the last widget with the mouse. - * - * @return The last widget with the mouse. - * @see setLastWidgetWithMouse - */ - virtual Widget* getLastWidgetWithMouse() A_WARN_UNUSED; - - /** - * Sets the last widget with the mouse. Used by the Gui class - * to keep track the last widget with the mouse. - * - * @param lastWidgetWithMouse The last widget with the mouse. - * @see getLastWidgetWithMouse - */ - virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); - - /** - * Gets the last widget with modal focus. - * - * @return The last widget with modal focus. - * @see setLastWidgetWithModalFocus - */ - virtual Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; - - /** - * Sets the last widget with modal focus. - * - * @param widget The last widget with modal focus. - * @see getLastWidgetWithModalFocus - */ - virtual void setLastWidgetWithModalFocus(Widget* widget); - - /** - * Gets the last widget with modal mouse input focus. - * - * @return The last widget with modal mouse input focus. - * @see setLastWidgetWithModalMouseInputFocus - */ - virtual Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; - - /** - * Sets the last widget with modal mouse input focus. - * - * @param widget The last widget with modal mouse input focus. - * @see getLastWidgetWithModalMouseInputFocus - */ - virtual void setLastWidgetWithModalMouseInputFocus(Widget* widget); - - /** - * Gets the last widget pressed. Used by the Gui class to keep track - * of pressed widgets. - * - * @return The last widget pressed. - * @see setLastWidgetPressed - */ - virtual Widget* getLastWidgetPressed() A_WARN_UNUSED; - - /** - * Sets the last widget pressed. Used by the Gui class to keep track - * of pressed widgets. - * - * @param lastWidgetPressed The last widget pressed. - * @see getLastWidgetPressed - */ - virtual void setLastWidgetPressed(Widget* lastWidgetPressed); - - protected: - /** - * Distributes a focus lost event. - * - * @param focusEvent the event to distribute. - * @since 0.7.0 - */ - virtual void distributeFocusLostEvent(const Event& focusEvent); - - /** - * Distributes a focus gained event. - * - * @param focusEvent the event to distribute. - * @since 0.7.0 - */ - virtual void distributeFocusGainedEvent(const Event& focusEvent); - - /** - * Typedef. - */ - typedef std::vector WidgetVector; - - /** - * Typedef. - */ - typedef WidgetVector::iterator WidgetIterator; - - /** - * Holds the widgets currently being handled by the - * focus handler. - */ - WidgetVector mWidgets; - - /** - * Holds the focused widget. NULL if no widget has focus. - */ - Widget* mFocusedWidget; - - /** - * Holds the modal focused widget. NULL if no widget has - * modal focused. - */ - Widget* mModalFocusedWidget; - - /** - * Holds the modal mouse input focused widget. NULL if no widget - * is being dragged. - */ - Widget* mModalMouseInputFocusedWidget; - - /** - * Holds the dragged widget. NULL if no widget is - * being dragged. - */ - Widget* mDraggedWidget; - - /** - * Holds the last widget with the mouse. - */ - Widget* mLastWidgetWithMouse; - - /** - * Holds the last widget with modal focus. - */ - Widget* mLastWidgetWithModalFocus; - - /** - * Holds the last widget with modal mouse input focus. - */ - Widget* mLastWidgetWithModalMouseInputFocus; - - /** - * Holds the last widget pressed. - */ - Widget* mLastWidgetPressed; - }; -} // namespace gcn - -#endif // end GCN_FOCUSHANDLER_HPP diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index 02c6e6674..f62e24260 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -68,9 +68,9 @@ #include "gui/base/gui.hpp" #include "gui/base/basiccontainer.hpp" -#include "gui/base/focushandler.hpp" #include "gui/base/widget.hpp" +#include "gui/focushandler.h" #include "gui/sdlinput.h" #include "input/keyinput.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 6e6a3867d..f614c00fd 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -72,13 +72,13 @@ #include "input/mouseinput.h" +class FocusHandler; class Graphics; class KeyListener; class SDLInput; namespace gcn { - class FocusHandler; class Widget; // The following comment will appear in the doxygen main page. diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index 5b4ada76e..9e2912d39 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -72,7 +72,8 @@ #include "events/event.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/focushandler.hpp" + +#include "gui/focushandler.h" #include "input/keyinput.h" #include "input/mouseinput.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index f2718697e..1c1c0ae14 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -75,6 +75,7 @@ class ActionListener; class DeathListener; +class FocusHandler; class FocusListener; class Font; class Graphics; @@ -87,7 +88,6 @@ class WidgetListener; namespace gcn { class BasicContainer; - class FocusHandler; /** * Abstract class for widgets of Guichan. It contains basic functions diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 04cb3f555..22153c91f 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + #include "gui/focushandler.h" #include "gui/gui.h" @@ -28,6 +71,20 @@ #include "debug.h" +FocusHandler::FocusHandler() : + mWidgets(), + mFocusedWidget(nullptr), + mModalFocusedWidget(nullptr), + mModalMouseInputFocusedWidget(nullptr), + mDraggedWidget(nullptr), + mLastWidgetWithMouse(nullptr), + mLastWidgetWithModalFocus(nullptr), + mLastWidgetWithModalMouseInputFocus(nullptr), + mLastWidgetPressed(nullptr), + mModalStack() +{ +} + void FocusHandler::requestModalFocus(gcn::Widget *widget) { /* If there is another widget with modal focus, remove its modal focus @@ -39,7 +96,9 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) mModalFocusedWidget = nullptr; } - gcn::FocusHandler::requestModalFocus(widget); + mModalFocusedWidget = widget; + if (mFocusedWidget && !mFocusedWidget->isModalFocused()) + focusNone(); } void FocusHandler::releaseModalFocus(gcn::Widget *widget) @@ -48,14 +107,15 @@ void FocusHandler::releaseModalFocus(gcn::Widget *widget) if (mModalFocusedWidget == widget) { - gcn::FocusHandler::releaseModalFocus(widget); + if (mModalFocusedWidget == widget) + mModalFocusedWidget = nullptr; /* Check if there were any previously modal widgets that'd still like * to regain their modal focus. */ if (!mModalStack.empty()) { - gcn::FocusHandler::requestModalFocus(mModalStack.front()); + requestModalFocus(mModalStack.front()); mModalStack.pop_front(); } } @@ -65,19 +125,188 @@ void FocusHandler::remove(gcn::Widget *widget) { releaseModalFocus(widget); - gcn::FocusHandler::remove(widget); + if (isFocused(widget)) + mFocusedWidget = nullptr; + + for (WidgetIterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++iter) + { + if ((*iter) == widget) + { + mWidgets.erase(iter); + break; + } + } + + if (mDraggedWidget == widget) + { + mDraggedWidget = nullptr; + return; + } + + if (mLastWidgetWithMouse == widget) + { + mLastWidgetWithMouse = nullptr; + return; + } + + if (mLastWidgetWithModalFocus == widget) + { + mLastWidgetWithModalFocus = nullptr; + return; + } + + if (mLastWidgetWithModalMouseInputFocus == widget) + { + mLastWidgetWithModalMouseInputFocus = nullptr; + return; + } + + if (mLastWidgetPressed == widget) + { + mLastWidgetPressed = nullptr; + return; + } } void FocusHandler::tabNext() { - gcn::FocusHandler::tabNext(); + if (mFocusedWidget) + { + if (!mFocusedWidget->isTabOutEnabled()) + return; + } + + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + bool done = false; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + ++ focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget >= sz) + focusedWidget = 0; + + if (focusedWidget == focused) + return; + + const gcn::Widget *const widget = mWidgets.at(focusedWidget); + if (widget->isFocusable() && widget->isTabInEnabled() && + (!mModalFocusedWidget || widget->isModalFocused())) + { + done = true; + } + } + while (!done); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } checkForWindow(); } void FocusHandler::tabPrevious() { - gcn::FocusHandler::tabPrevious(); + if (mFocusedWidget) + { + if (!mFocusedWidget->isTabOutEnabled()) + return; + } + + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + bool done = false; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + -- focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget <= 0) + focusedWidget = sz - 1; + + if (focusedWidget == focused) + return; + + const gcn::Widget *const widget = mWidgets.at(focusedWidget); + if (widget->isFocusable() && widget->isTabInEnabled() && + (!mModalFocusedWidget || widget->isModalFocused())) + { + done = true; + } + } + while (!done); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } checkForWindow(); } @@ -107,5 +336,280 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) { if (gui) gui->distributeGlobalFocusGainedEvent(focusEvent); - gcn::FocusHandler::distributeFocusGainedEvent(focusEvent); + + gcn::Widget *const sourceWidget = focusEvent.getSource(); + + std::list focusListeners + = sourceWidget->_getFocusListeners(); + + // Send the event to all focus listeners of the widget. + for (std::list::const_iterator + it = focusListeners.begin(); + it != focusListeners.end(); + ++ it) + { + (*it)->focusGained(focusEvent); + } +} + +void FocusHandler::requestFocus(gcn::Widget* widget) +{ + if (!widget || widget == mFocusedWidget) + return; + + int toBeFocusedIndex = -1; + for (unsigned int i = 0, sz = static_cast( + mWidgets.size()); i < sz; ++i) + { + if (mWidgets[i] == widget) + { + toBeFocusedIndex = i; + break; + } + } + + if (toBeFocusedIndex < 0) + return; + + gcn::Widget *const oldFocused = mFocusedWidget; + + if (oldFocused != widget) + { + mFocusedWidget = mWidgets.at(toBeFocusedIndex); + + if (oldFocused) + { + Event focusEvent(oldFocused); + distributeFocusLostEvent(focusEvent); + } + + Event focusEvent(mWidgets.at(toBeFocusedIndex)); + distributeFocusGainedEvent(focusEvent); + } +} + +void FocusHandler::requestModalMouseInputFocus(gcn::Widget* widget) +{ + if (mModalMouseInputFocusedWidget + && mModalMouseInputFocusedWidget != widget) + { + return; + } + + mModalMouseInputFocusedWidget = widget; +} + +void FocusHandler::releaseModalMouseInputFocus(gcn::Widget* widget) +{ + if (mModalMouseInputFocusedWidget == widget) + mModalMouseInputFocusedWidget = nullptr; +} + +gcn::Widget* FocusHandler::getFocused() const +{ + return mFocusedWidget; +} + +gcn::Widget* FocusHandler::getModalFocused() const +{ + return mModalFocusedWidget; +} + +gcn::Widget* FocusHandler::getModalMouseInputFocused() const +{ + return mModalMouseInputFocusedWidget; +} + +void FocusHandler::focusNext() +{ + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + ++ focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget >= sz) + focusedWidget = 0; + + if (focusedWidget == focused) + return; + } + while (!mWidgets.at(focusedWidget)->isFocusable()); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } +} + +void FocusHandler::focusPrevious() +{ + if (mWidgets.empty()) + { + mFocusedWidget = nullptr; + return; + } + + int i; + int focusedWidget = -1; + const int sz = static_cast(mWidgets.size()); + for (i = 0; i < sz; ++ i) + { + if (mWidgets[i] == mFocusedWidget) + focusedWidget = i; + } + const int focused = focusedWidget; + + // i is a counter that ensures that the following loop + // won't get stuck in an infinite loop + i = sz; + do + { + -- focusedWidget; + + if (i == 0) + { + focusedWidget = -1; + break; + } + + -- i; + + if (focusedWidget <= 0) + focusedWidget = sz - 1; + + if (focusedWidget == focused) + return; + } + while (!mWidgets.at(focusedWidget)->isFocusable()); + + if (focusedWidget >= 0) + { + mFocusedWidget = mWidgets.at(focusedWidget); + Event focusEvent(mFocusedWidget); + distributeFocusGainedEvent(focusEvent); + } + + if (focused >= 0) + { + Event focusEvent(mWidgets.at(focused)); + distributeFocusLostEvent(focusEvent); + } +} + +bool FocusHandler::isFocused(const gcn::Widget* widget) const +{ + return mFocusedWidget == widget; +} + +void FocusHandler::add(gcn::Widget* widget) +{ + mWidgets.push_back(widget); +} + +void FocusHandler::focusNone() +{ + if (mFocusedWidget) + { + gcn::Widget *const focused = mFocusedWidget; + mFocusedWidget = nullptr; + + Event focusEvent(focused); + distributeFocusLostEvent(focusEvent); + } +} + +void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) +{ + gcn::Widget *const sourceWidget = focusEvent.getSource(); + + std::list focusListeners + = sourceWidget->_getFocusListeners(); + + // Send the event to all focus listeners of the widget. + for (std::list::const_iterator + it = focusListeners.begin(); + it != focusListeners.end(); + ++ it) + { + (*it)->focusLost(focusEvent); + } +} + +gcn::Widget* FocusHandler::getDraggedWidget() +{ + return mDraggedWidget; +} + +void FocusHandler::setDraggedWidget(gcn::Widget* draggedWidget) +{ + mDraggedWidget = draggedWidget; +} + +gcn::Widget* FocusHandler::getLastWidgetWithMouse() +{ + return mLastWidgetWithMouse; +} + +void FocusHandler::setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse) +{ + mLastWidgetWithMouse = lastWidgetWithMouse; +} + +gcn::Widget* FocusHandler::getLastWidgetWithModalFocus() +{ + return mLastWidgetWithModalFocus; +} + +void FocusHandler::setLastWidgetWithModalFocus(gcn::Widget* widget) +{ + mLastWidgetWithModalFocus = widget; +} + +gcn::Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() +{ + return mLastWidgetWithModalMouseInputFocus; +} + +void FocusHandler::setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget) +{ + mLastWidgetWithModalMouseInputFocus = widget; +} + +gcn::Widget* FocusHandler::getLastWidgetPressed() +{ + return mLastWidgetPressed; +} + +void FocusHandler::setLastWidgetPressed(gcn::Widget* lastWidgetPressed) +{ + mLastWidgetPressed = lastWidgetPressed; } diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 0e07625b7..0131a4c29 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -20,59 +20,311 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_FOCUSHANDLER_H #define GUI_FOCUSHANDLER_H -#include "gui/base/focushandler.hpp" +#include "gui/focushandler.h" + +#include "events/event.h" #include +#include #include "localconsts.h" +namespace gcn +{ + class Widget; +} + /** * The focus handler. This focus handler does exactly the same as the Guichan * focus handler, but keeps a stack of modal widgets to be able to handle * multiple modal focus requests. */ -class FocusHandler final : public gcn::FocusHandler +class FocusHandler final { public: - FocusHandler() : - mModalStack() - { } + FocusHandler(); A_DELETE_COPY(FocusHandler) /** - * Sets modal focus to a widget. When there is already a modal widget - * then that widget loses modal focus and will regain it after this - * widget releases his modal focus. - */ - void requestModalFocus(gcn::Widget *widget) override final; + * Requests focus for a widget. Focus will only be granted to a widget + * if it's focusable and if no other widget has modal focus. + * If a widget receives focus a focus event will be sent to the + * focus listeners of the widget. + * + * @param widget The widget to request focus for. + * @see isFocused, Widget::requestFocus + */ + void requestFocus(gcn::Widget* widget); /** - * Releases modal focus of a widget. When this widget had modal focus - * and there are other widgets that had also requested modal focus, - * then modal focus will be transfered to the last of those. - */ - void releaseModalFocus(gcn::Widget *widget) override final; + * Requests modal focus for a widget. Focus will only be granted + * to a widget if it's focusable and if no other widget has modal + * focus. + * + * @param widget The widget to request modal focus for. + * @throws Exception when another widget already has modal focus. + * @see releaseModalFocus, Widget::requestModalFocus + */ + void requestModalFocus(gcn::Widget* widget); /** - * Removes a widget from the focus handler. Also makes sure no dangling - * pointers remain in modal focus stack. - */ - void remove(gcn::Widget *widget) override final; + * Requests modal mouse input focus for a widget. Focus will only + * be granted to a widget if it's focusable and if no other widget + * has modal mouse input focus. + * + * Modal mouse input focus means no other widget then the widget with + * modal mouse input focus will receive mouse input. The widget with + * modal mouse input focus will also receive mouse input no matter what + * the mouse input is or where the mouse input occurs. + * + * @param widget The widget to focus for modal mouse input focus. + * @throws Exception when another widget already has modal mouse input + * focus. + * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus + */ + void requestModalMouseInputFocus(gcn::Widget* widget); /** - * Overloaded to allow windows to move to the top when one of their - * widgets is tabbed to when tabbing through focusable elements. - */ - void tabNext() override final; + * Releases modal focus if the widget has modal focus. + * If the widget doesn't have modal focus no relase will occur. + * + * @param widget The widget to release modal focus for. + * @see reuqestModalFocus, Widget::releaseModalFocus + */ + void releaseModalFocus(gcn::Widget* widget); + + /** + * Releases modal mouse input focus if the widget has modal mouse input + * focus. If the widget doesn't have modal mouse input focus no relase + * will occur. + * + * @param widget the widget to release modal mouse input focus for. + * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus + */ + void releaseModalMouseInputFocus(gcn::Widget* widget); + + /** + * Checks if a widget is focused. + * + * @param widget The widget to check. + * @return True if the widget is focused, false otherwise. + * @see Widget::isFocused + */ + bool isFocused(const gcn::Widget* widget) const; + + /** + * Gets the widget with focus. + * + * @return The widget with focus. NULL if no widget has focus. + */ + gcn::Widget* getFocused() const A_WARN_UNUSED; + + /** + * Gets the widget with modal focus. + * + * @return The widget with modal focus. NULL if no widget has + * modal focus. + */ + gcn::Widget* getModalFocused() const A_WARN_UNUSED; + + /** + * Gets the widget with modal mouse input focus. + * + * @return The widget with modal mouse input focus. NULL if + * no widget has modal mouse input focus. + */ + gcn::Widget* getModalMouseInputFocused() const A_WARN_UNUSED; + + /** + * Focuses the next widget added to a conainer. + * If no widget has focus the first widget gets focus. The order + * in which the widgets are focused is determined by the order + * they were added to a container. + * + * @see focusPrevious + */ + void focusNext(); + + /** + * Focuses the previous widget added to a contaienr. + * If no widget has focus the first widget gets focus. The order + * in which the widgets are focused is determined by the order + * they were added to a container. + * + * @see focusNext + */ + void focusPrevious(); + + /** + * Adds a widget to by handles by the focus handler. + * + * @param widget The widget to add. + * @see remove + */ + void add(gcn::Widget* widget); + + /** + * Removes a widget from the focus handler. + * + * @param widget The widget to remove. + * @see add + */ + void remove(gcn::Widget* widget); + + /** + * Focuses nothing. A focus event will also be sent to the + * focused widget's focus listeners if a widget has focus. + */ + void focusNone(); + + /** + * Focuses the next widget which allows tabbing in unless + * the current focused Widget disallows tabbing out. + * + * @see tabPrevious + */ + void tabNext(); + + /** + * Focuses the previous widget which allows tabbing in unless + * current focused widget disallows tabbing out. + * + * @see tabNext + */ + void tabPrevious(); + + /** + * Gets the widget being dragged. Used by the Gui class to + * keep track of the dragged widget. + * + * @return the widget being dragged. + * @see setDraggedWidget + */ + gcn::Widget* getDraggedWidget() A_WARN_UNUSED; + + /** + * Sets the widget being dragged. Used by the Gui class to + * keep track of the dragged widget. + * + * @param draggedWidget The widget being dragged. + * @see getDraggedWidget + */ + void setDraggedWidget(gcn::Widget* draggedWidget); + + /** + * Gets the last widget with the mouse. Used by the Gui class + * to keep track the last widget with the mouse. + * + * @return The last widget with the mouse. + * @see setLastWidgetWithMouse + */ + gcn::Widget* getLastWidgetWithMouse() A_WARN_UNUSED; + + /** + * Sets the last widget with the mouse. Used by the Gui class + * to keep track the last widget with the mouse. + * + * @param lastWidgetWithMouse The last widget with the mouse. + * @see getLastWidgetWithMouse + */ + void setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse); + + /** + * Gets the last widget with modal focus. + * + * @return The last widget with modal focus. + * @see setLastWidgetWithModalFocus + */ + gcn::Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; + + /** + * Sets the last widget with modal focus. + * + * @param widget The last widget with modal focus. + * @see getLastWidgetWithModalFocus + */ + void setLastWidgetWithModalFocus(gcn::Widget* widget); + + /** + * Gets the last widget with modal mouse input focus. + * + * @return The last widget with modal mouse input focus. + * @see setLastWidgetWithModalMouseInputFocus + */ + gcn::Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; + + /** + * Sets the last widget with modal mouse input focus. + * + * @param widget The last widget with modal mouse input focus. + * @see getLastWidgetWithModalMouseInputFocus + */ + void setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget); - void tabPrevious() override final; + /** + * Gets the last widget pressed. Used by the Gui class to keep track + * of pressed widgets. + * + * @return The last widget pressed. + * @see setLastWidgetPressed + */ + gcn::Widget* getLastWidgetPressed() A_WARN_UNUSED; - void distributeFocusGainedEvent(const Event &focusEvent) - override final; + /** + * Sets the last widget pressed. Used by the Gui class to keep track + * of pressed widgets. + * + * @param lastWidgetPressed The last widget pressed. + * @see getLastWidgetPressed + */ + void setLastWidgetPressed(gcn::Widget* lastWidgetPressed); private: /** @@ -81,6 +333,81 @@ class FocusHandler final : public gcn::FocusHandler */ void checkForWindow() const; + /** + * Distributes a focus lost event. + * + * @param focusEvent the event to distribute. + * @since 0.7.0 + */ + void distributeFocusLostEvent(const Event& focusEvent); + + /** + * Distributes a focus gained event. + * + * @param focusEvent the event to distribute. + * @since 0.7.0 + */ + void distributeFocusGainedEvent(const Event& focusEvent); + + /** + * Typedef. + */ + typedef std::vector WidgetVector; + + /** + * Typedef. + */ + typedef WidgetVector::iterator WidgetIterator; + + /** + * Holds the widgets currently being handled by the + * focus handler. + */ + WidgetVector mWidgets; + + /** + * Holds the focused widget. NULL if no widget has focus. + */ + gcn::Widget* mFocusedWidget; + + /** + * Holds the modal focused widget. NULL if no widget has + * modal focused. + */ + gcn::Widget* mModalFocusedWidget; + + /** + * Holds the modal mouse input focused widget. NULL if no widget + * is being dragged. + */ + gcn::Widget* mModalMouseInputFocusedWidget; + + /** + * Holds the dragged widget. NULL if no widget is + * being dragged. + */ + gcn::Widget* mDraggedWidget; + + /** + * Holds the last widget with the mouse. + */ + gcn::Widget* mLastWidgetWithMouse; + + /** + * Holds the last widget with modal focus. + */ + gcn::Widget* mLastWidgetWithModalFocus; + + /** + * Holds the last widget with modal mouse input focus. + */ + gcn::Widget* mLastWidgetWithModalMouseInputFocus; + + /** + * Holds the last widget pressed. + */ + gcn::Widget* mLastWidgetPressed; + /** * Stack of widgets that have requested modal forcus. */ diff --git a/src/gui/gui.h b/src/gui/gui.h index b790d4d2c..aacd33946 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -90,7 +90,7 @@ class Gui final : public gcn::Gui */ void videoResized() const; - gcn::FocusHandler *getFocusHandler() const A_WARN_UNUSED + FocusHandler *getFocusHandler() const A_WARN_UNUSED { return mFocusHandler; } /** diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index f87ca2fe7..1b1124cff 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -588,7 +588,7 @@ int GuiTable::getColumnForX(int x) const return column; } -void GuiTable::_setFocusHandler(gcn::FocusHandler* focusHandler) +void GuiTable::_setFocusHandler(FocusHandler* focusHandler) { // add check for focusHandler. may be need remove it? diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index da367dd94..ab7dc1a66 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -122,7 +122,7 @@ public: void moveToBottom(gcn::Widget *child) override final; - void _setFocusHandler(gcn::FocusHandler* focusHandler) override final; + void _setFocusHandler(FocusHandler* focusHandler) override final; // Inherited from KeyListener void keyPressed(KeyEvent& keyEvent) override final; diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 537c7283c..c2fa1a686 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -28,10 +28,10 @@ #include "input/keydata.h" +#include "gui/focushandler.h" #include "gui/font.h" #include "gui/gui.h" -#include "gui/base/focushandler.hpp" #include "gui/base/listmodel.hpp" #include "render/graphics.h" diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index e2f24a0f2..2ea86f9df 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -29,6 +29,7 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "gui/focushandler.h" #include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -38,8 +39,6 @@ #include "resources/cursor.h" #include "resources/image.h" -#include "gui/base/focushandler.hpp" - #include "debug.h" const int resizeMask = 8 + 4 + 2 + 1; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index e49c78803..45a76495b 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -39,6 +39,7 @@ #include "input/inputmanager.h" +#include "gui/focushandler.h" #include "gui/font.h" #include "gui/sdlinput.h" #include "gui/viewport.h" @@ -69,8 +70,6 @@ #include "resources/resourcemanager.h" -#include "gui/base/focushandler.hpp" - #include #include diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index 46494532a..d19130e7c 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -51,7 +51,7 @@ #include "utils/timer.h" -#include "gui/base/focushandler.hpp" +#include "gui/focushandler.h" #include -- cgit v1.2.3-70-g09d2 From 1d71d02a40dc1f4c50572bf0681bbc2907a3c361 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 17 Feb 2014 22:16:29 +0300 Subject: move sdlpixel file into utils directory. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/sdl/sdlpixel.hpp | 306 ------------------------------------ src/render/sdl2graphics.cpp | 2 +- src/render/sdl2softwaregraphics.cpp | 4 +- src/render/sdlgraphics.cpp | 4 +- src/utils/sdlpixel.h | 232 +++++++++++++++++++++++++++ 7 files changed, 239 insertions(+), 313 deletions(-) delete mode 100644 src/gui/base/sdl/sdlpixel.hpp create mode 100644 src/utils/sdlpixel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 711d9e47b..cdc61aa91 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -782,7 +782,7 @@ SET(SRCS gui/base/rectangle.hpp events/selectionevent.h listeners/selectionlistener.h - gui/base/sdl/sdlpixel.hpp + utils/sdlpixel.h gui/base/widget.hpp listeners/widgetlistener.h gui/base/widgets/button.hpp diff --git a/src/Makefile.am b/src/Makefile.am index f20376feb..246da6073 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -168,7 +168,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/rectangle.hpp \ events/selectionevent.h \ listeners/selectionlistener.h \ - gui/base/sdl/sdlpixel.hpp \ + utils/sdlpixel.h \ gui/base/widget.hpp \ listeners/widgetlistener.h \ gui/base/widgets/button.hpp \ diff --git a/src/gui/base/sdl/sdlpixel.hpp b/src/gui/base/sdl/sdlpixel.hpp deleted file mode 100644 index 06a22f65f..000000000 --- a/src/gui/base/sdl/sdlpixel.hpp +++ /dev/null @@ -1,306 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_SDLPIXEL_HPP -#define GCN_SDLPIXEL_HPP - -#include "SDL.h" -#include "gui/base/color.hpp" - -namespace gcn -{ - - /** - * Checks a pixels color of an SDL_Surface. - * - * @param surface an SDL_Surface where to check for a pixel color. - * @param x the x coordinate on the surface. - * @param y the y coordinate on the surface. - * @return a color of a pixel. - */ - inline const Color SDLgetPixel(SDL_Surface* surface, int x, int y) - { - if (!surface) - return Color(0, 0, 0, 0); - - int bpp = surface->format->BytesPerPixel; - - SDL_LockSurface(surface); - - Uint8 *p = static_cast(surface->pixels) - + y * surface->pitch + x * bpp; - - unsigned int color = 0; - - switch (bpp) - { - case 1: - color = *p; - break; - - case 2: - color = *reinterpret_cast(p); - break; - - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - color = p[0] << 16 | p[1] << 8 | p[2]; -#else - color = p[0] | p[1] << 8 | p[2] << 16; -#endif - break; - - case 4: - color = *reinterpret_cast(p); - break; - - default: - color = *p; - break; - } - - unsigned char r, g, b, a; - - SDL_GetRGBA(color, surface->format, &r, &g, &b, &a); - SDL_UnlockSurface(surface); - - return Color(r, g, b, a); - } - - /** - * Puts a pixel on an SDL_Surface. - * - * @param x the x coordinate on the surface. - * @param y the y coordinate on the surface. - * @param color the color the pixel should be in. - */ - inline void SDLputPixel(SDL_Surface* surface, int x, int y, - const Color& color) - { - if (!surface) - return; - - int bpp = surface->format->BytesPerPixel; - - SDL_LockSurface(surface); - - Uint8 *p = static_cast(surface->pixels) - + y * surface->pitch + x * bpp; - - Uint32 pixel = SDL_MapRGB(surface->format, - static_cast(color.r), static_cast(color.g), - static_cast(color.b)); - - switch (bpp) - { - case 1: - *p = static_cast(pixel); - break; - - case 2: - *reinterpret_cast(p) = static_cast(pixel); - break; - - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - p[0] = static_cast((pixel >> 16) & 0xff); - p[1] = static_cast((pixel >> 8) & 0xff); - p[2] = static_cast((pixel) & 0xff); -#else - p[0] = static_cast((pixel) & 0xff); - p[1] = static_cast((pixel >> 8) & 0xff); - p[2] = static_cast((pixel >> 16) & 0xff); -#endif - break; - - case 4: - *reinterpret_cast(p) = pixel; - break; - - default: - break; - } - - SDL_UnlockSurface(surface); - } - - /** - * Blends two 32 bit colors together. - * - * @param src the source color. - * @param dst the destination color. - * @param a alpha. - */ - inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, - unsigned char a) - { - unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8; - unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) - * (255 - a)) >> 8; - unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) - * (255 - a)) >> 8; - - return (b & 0xff) | (g & 0xff00) | (r & 0xff0000); - } - - /** - * Blends two 16 bit colors together. - * - * @param src the source color. - * @param dst the destination color. - * @param a alpha. - */ - inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, - unsigned char a, const SDL_PixelFormat *f) - { - unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask) - * (255 - a)) >> 8; - unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask) - * (255 - a)) >> 8; - unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) - * (255 - a)) >> 8; - - return static_cast((b & f->Rmask) - | (g & f->Gmask) | (r & f->Bmask)); - } - - /* - typedef struct{ - SDL_Palette *palette; - Uint8 BitsPerPixel; - Uint8 BytesPerPixel; - Uint32 Rmask, Gmask, Bmask, Amask; - Uint8 Rshift, Gshift, Bshift, Ashift; - Uint8 Rloss, Gloss, Bloss, Aloss; - Uint32 colorkey; - Uint8 alpha; - } SDL_PixelFormat; - */ - - /** - * Puts a pixel on an SDL_Surface with alpha - * - * @param x the x coordinate on the surface. - * @param y the y coordinate on the surface. - * @param color the color the pixel should be in. - */ - inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, - const Color& color) - { - int bpp = surface->format->BytesPerPixel; - - SDL_LockSurface(surface); - - Uint8 *p = static_cast(surface->pixels) - + y * surface->pitch + x * bpp; - - Uint32 pixel = SDL_MapRGB(surface->format, - static_cast(color.r), - static_cast(color.g), - static_cast(color.b)); - - switch (bpp) - { - case 1: - *p = static_cast(pixel); - break; - - case 2: - *reinterpret_cast(p) = SDLAlpha16( - static_cast(pixel), - *reinterpret_cast(p), - static_cast(color.a), surface->format); - break; - - case 3: -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - p[2] = static_cast((p[2] * (255 - color.a) - + color.b * color.a) >> 8); - p[1] = static_cast((p[1] * (255 - color.a) - + color.g * color.a) >> 8); - p[0] = static_cast((p[0] * (255 - color.a) - + color.r * color.a) >> 8); -#else - p[0] = static_cast((p[0] * (255 - color.a) - + color.b * color.a) >> 8); - p[1] = static_cast((p[1] * (255 - color.a) - + color.g * color.a) >> 8); - p[2] = static_cast((p[2] * (255 - color.a) - + color.r * color.a) >> 8); -#endif - break; - - case 4: - *reinterpret_cast(p) = SDLAlpha32(pixel, - *reinterpret_cast(p), - static_cast(color.a)); - break; - default: - break; - } - - SDL_UnlockSurface(surface); - } -} // namespace gcn - -#endif // end GCN_SDLPIXEL_HPP diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 46d8360b6..2cd7c965e 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -79,7 +79,7 @@ #include "utils/sdlcheckutils.h" -#include "gui/base/sdl/sdlpixel.hpp" +#include "utils/sdlpixel.h" #include "debug.h" diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index e78a87c7e..8efd73d68 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -36,7 +36,7 @@ #include "utils/sdlcheckutils.h" -#include "gui/base/sdl/sdlpixel.hpp" +#include "utils/sdlpixel.h" #include "debug.h" @@ -967,7 +967,7 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle) for (x = x1; x < x2; x++) { uint8_t *const p = p0 + x * 2; - *reinterpret_cast(p) = gcn::SDLAlpha16( + *reinterpret_cast(p) = SDLAlpha16( static_cast(pixel), *reinterpret_cast(p), static_cast(mColor.a), mSurface->format); diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 2226be0da..7a15713be 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -31,7 +31,7 @@ #include "utils/sdlcheckutils.h" -#include "gui/base/sdl/sdlpixel.hpp" +#include "utils/sdlpixel.h" #include "debug.h" @@ -963,7 +963,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle) for (x = x1; x < x2; x++) { uint8_t *const p = p0 + x * 2; - *reinterpret_cast(p) = gcn::SDLAlpha16( + *reinterpret_cast(p) = SDLAlpha16( static_cast(pixel), *reinterpret_cast(p), static_cast(mColor.a), mWindow->format); diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h new file mode 100644 index 000000000..2a26f28a1 --- /dev/null +++ b/src/utils/sdlpixel.h @@ -0,0 +1,232 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 UTILS_SDLPIXEL_HPP +#define UTILS_SDLPIXEL_HPP + +#include "SDL.h" +#include "gui/base/color.hpp" + +/** + * Puts a pixel on an SDL_Surface. + * + * @param x the x coordinate on the surface. + * @param y the y coordinate on the surface. + * @param color the color the pixel should be in. + */ +inline void SDLputPixel(SDL_Surface* surface, int x, int y, + const gcn::Color& color) +{ + if (!surface) + return; + + int bpp = surface->format->BytesPerPixel; + + SDL_LockSurface(surface); + + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; + + Uint32 pixel = SDL_MapRGB(surface->format, + static_cast(color.r), static_cast(color.g), + static_cast(color.b)); + + switch (bpp) + { + case 1: + *p = static_cast(pixel); + break; + + case 2: + *reinterpret_cast(p) = static_cast(pixel); + break; + + case 3: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + p[0] = static_cast((pixel >> 16) & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast((pixel) & 0xff); +#else + p[0] = static_cast((pixel) & 0xff); + p[1] = static_cast((pixel >> 8) & 0xff); + p[2] = static_cast((pixel >> 16) & 0xff); +#endif + break; + + case 4: + *reinterpret_cast(p) = pixel; + break; + + default: + break; + } + + SDL_UnlockSurface(surface); +} + +/** + * Blends two 32 bit colors together. + * + * @param src the source color. + * @param dst the destination color. + * @param a alpha. + */ +inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, + unsigned char a) +{ + unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8; + unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) + * (255 - a)) >> 8; + unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) + * (255 - a)) >> 8; + + return (b & 0xff) | (g & 0xff00) | (r & 0xff0000); +} + +/** + * Blends two 16 bit colors together. + * + * @param src the source color. + * @param dst the destination color. + * @param a alpha. + */ +inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, + unsigned char a, const SDL_PixelFormat *f) +{ + unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask) + * (255 - a)) >> 8; + unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask) + * (255 - a)) >> 8; + unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) + * (255 - a)) >> 8; + + return static_cast((b & f->Rmask) + | (g & f->Gmask) | (r & f->Bmask)); +} + +/** + * Puts a pixel on an SDL_Surface with alpha + * + * @param x the x coordinate on the surface. + * @param y the y coordinate on the surface. + * @param color the color the pixel should be in. + */ +inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, + const gcn::Color& color) +{ + int bpp = surface->format->BytesPerPixel; + + SDL_LockSurface(surface); + + Uint8 *p = static_cast(surface->pixels) + + y * surface->pitch + x * bpp; + + Uint32 pixel = SDL_MapRGB(surface->format, + static_cast(color.r), + static_cast(color.g), + static_cast(color.b)); + + switch (bpp) + { + case 1: + *p = static_cast(pixel); + break; + + case 2: + *reinterpret_cast(p) = SDLAlpha16( + static_cast(pixel), + *reinterpret_cast(p), + static_cast(color.a), surface->format); + break; + + case 3: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + p[2] = static_cast((p[2] * (255 - color.a) + + color.b * color.a) >> 8); + p[1] = static_cast((p[1] * (255 - color.a) + + color.g * color.a) >> 8); + p[0] = static_cast((p[0] * (255 - color.a) + + color.r * color.a) >> 8); +#else + p[0] = static_cast((p[0] * (255 - color.a) + + color.b * color.a) >> 8); + p[1] = static_cast((p[1] * (255 - color.a) + + color.g * color.a) >> 8); + p[2] = static_cast((p[2] * (255 - color.a) + + color.r * color.a) >> 8); +#endif + break; + + case 4: + *reinterpret_cast(p) = SDLAlpha32(pixel, + *reinterpret_cast(p), + static_cast(color.a)); + break; + default: + break; + } + + SDL_UnlockSurface(surface); +} + +#endif // UTILS_SDLPIXEL_HPP -- cgit v1.2.3-70-g09d2 From 14a0a04b2bb3928f7429fd748dd40e1843fca571 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 18 Feb 2014 00:45:23 +0300 Subject: Remove default constructor from Widget2. --- src/game.cpp | 11 +++++++---- src/gui/widgets/dropshortcutcontainer.cpp | 4 ++-- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emoteshortcutcontainer.cpp | 4 ++-- src/gui/widgets/emoteshortcutcontainer.h | 2 +- src/gui/widgets/itemshortcutcontainer.cpp | 5 +++-- src/gui/widgets/itemshortcutcontainer.h | 3 ++- src/gui/widgets/playerbox.cpp | 10 +++++++--- src/gui/widgets/playerbox.h | 7 +++++-- src/gui/widgets/progressindicator.cpp | 4 ++-- src/gui/widgets/progressindicator.h | 2 +- src/gui/widgets/scrollarea.cpp | 10 ++++++++-- src/gui/widgets/scrollarea.h | 6 ++++-- src/gui/widgets/setupitem.cpp | 8 ++++---- src/gui/widgets/shortcutcontainer.cpp | 4 ++-- src/gui/widgets/shortcutcontainer.h | 2 +- src/gui/widgets/slider.cpp | 11 +++++++---- src/gui/widgets/slider.h | 7 +++++-- src/gui/widgets/spellshortcutcontainer.cpp | 5 +++-- src/gui/widgets/spellshortcutcontainer.h | 3 ++- src/gui/widgets/tabs/setup_colors.cpp | 10 +++++----- src/gui/widgets/tabs/setup_video.cpp | 4 ++-- src/gui/widgets/widget2.h | 6 ------ src/gui/widgets/window.cpp | 2 +- src/gui/windows/buydialog.cpp | 2 +- src/gui/windows/charcreatedialog.cpp | 4 ++-- src/gui/windows/connectiondialog.cpp | 2 +- src/gui/windows/emotewindow.cpp | 4 ++-- src/gui/windows/equipmentwindow.cpp | 3 ++- src/gui/windows/itemamountwindow.cpp | 4 ++-- src/gui/windows/selldialog.cpp | 2 +- 31 files changed, 88 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 26807b8b6..e0957b57d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -236,7 +236,7 @@ static void createGuiWindows() for (unsigned f = 0; f < SHORTCUT_TABS; f ++) { itemShortcutWindow->addTab(toString(f + 1), - new ItemShortcutContainer(f)); + new ItemShortcutContainer(nullptr, f)); } if (config.getBoolValue("showDidYouKnow")) { @@ -245,20 +245,23 @@ static void createGuiWindows() } emoteShortcutWindow = new ShortcutWindow("EmoteShortcut", - new EmoteShortcutContainer, "emotes.xml", 130, 480); + new EmoteShortcutContainer(nullptr), + "emotes.xml", + 130, 480); outfitWindow = new OutfitWindow(); #ifdef MANASERV_SUPPORT specialsWindow = new SpecialsWindow(); #endif dropShortcutWindow = new ShortcutWindow("DropShortcut", - new DropShortcutContainer, "drops.xml"); + new DropShortcutContainer(nullptr), + "drops.xml"); spellShortcutWindow = new ShortcutWindow("SpellShortcut", "spells.xml", 265, 328); for (unsigned f = 0; f < SPELL_SHORTCUT_TABS; f ++) { spellShortcutWindow->addTab(toString(f + 1), - new SpellShortcutContainer(f)); + new SpellShortcutContainer(nullptr, f)); } botCheckerWindow = new BotCheckerWindow; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index bca1f1e12..fcb0f8ea1 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -40,8 +40,8 @@ #include "debug.h" -DropShortcutContainer::DropShortcutContainer(): - ShortcutContainer(), +DropShortcutContainer::DropShortcutContainer(Widget2 *const widget): + ShortcutContainer(widget), mItemClicked(false), mItemPopup(new ItemPopup), mEquipedColor(getThemeColor(Theme::ITEM_EQUIPPED)), diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 9880f526d..dbaac1d9c 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -38,7 +38,7 @@ class DropShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - DropShortcutContainer(); + DropShortcutContainer(Widget2 *const widget); A_DELETE_COPY(DropShortcutContainer) diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index f5d1c19f0..47c45c2dd 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -38,8 +38,8 @@ static const int MAX_ITEMS = 48; -EmoteShortcutContainer::EmoteShortcutContainer(): - ShortcutContainer(), +EmoteShortcutContainer::EmoteShortcutContainer(Widget2 *const widget) : + ShortcutContainer(widget), mEmoteImg(), mEmotePopup(new TextPopup), mEmoteClicked(false), diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index ed6b4c8b3..ec0e98675 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -41,7 +41,7 @@ class EmoteShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - EmoteShortcutContainer(); + EmoteShortcutContainer(Widget2 *const widget); A_DELETE_COPY(EmoteShortcutContainer) diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 2496beaa6..83c8820ae 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -48,8 +48,9 @@ #include "debug.h" -ItemShortcutContainer::ItemShortcutContainer(const unsigned number) : - ShortcutContainer(), +ItemShortcutContainer::ItemShortcutContainer(Widget2 *const widget, + const unsigned number) : + ShortcutContainer(widget), mItemClicked(false), mNumber(number), mItemPopup(new ItemPopup), diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index f01c2779c..dd95851a6 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -39,7 +39,8 @@ class ItemShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - explicit ItemShortcutContainer(const unsigned number); + ItemShortcutContainer(Widget2 *const widget, + const unsigned number); A_DELETE_COPY(ItemShortcutContainer) diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 3bcb8476e..97fd4a713 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -30,9 +30,11 @@ #include "debug.h" -PlayerBox::PlayerBox(Being *const being, const std::string &skin, +PlayerBox::PlayerBox(Widget2 *const widget, + Being *const being, + const std::string &skin, const std::string &selectedSkin) : - Widget2(), + Widget2(widget), ScrollArea(), mBeing(being), mAlpha(1.0), @@ -48,8 +50,10 @@ PlayerBox::PlayerBox(Being *const being, const std::string &skin, init(skin, selectedSkin); } -PlayerBox::PlayerBox(const std::string &skin, +PlayerBox::PlayerBox(Widget2 *const widget, + const std::string &skin, const std::string &selectedSkin) : + Widget2(widget), ScrollArea(), mBeing(nullptr), mAlpha(1.0), diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 30d79ff2f..3669a23a9 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -45,10 +45,13 @@ class PlayerBox final : public Widget2, * Constructor. Takes the initial player character that this box should * display, which defaults to NULL. */ - explicit PlayerBox(Being *const being, const std::string &skin = "", + explicit PlayerBox(Widget2 *const widget, + Being *const being, + const std::string &skin = "", const std::string &selectedSkin = ""); - explicit PlayerBox(const std::string &skin = "", + explicit PlayerBox(Widget2 *const widget, + const std::string &skin = "", const std::string &selectedSkin = ""); A_DELETE_COPY(PlayerBox) diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index b3f5b0e54..198094b6d 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -28,9 +28,9 @@ #include "debug.h" -ProgressIndicator::ProgressIndicator() : +ProgressIndicator::ProgressIndicator(Widget2 *const widget) : gcn::Widget(), - Widget2(), + Widget2(widget), mIndicator(nullptr) { ImageSet *const images = Theme::getImageSetFromTheme( diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index 8dd33bf4d..7357931e9 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -38,7 +38,7 @@ class ProgressIndicator final : public gcn::Widget, public Widget2 { public: - ProgressIndicator(); + ProgressIndicator(Widget2 *const widget); A_DELETE_COPY(ProgressIndicator) diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 0ee2c3357..708949f9c 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -45,8 +45,11 @@ static std::string const buttonFiles[2] = "scrollbuttons_pressed.xml" }; -ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : +ScrollArea::ScrollArea(Widget2 *const widget, + const bool opaque, + const std::string &skin) : gcn::ScrollArea(), + Widget2(widget), WidgetListener(), mX(0), mY(0), @@ -66,9 +69,12 @@ ScrollArea::ScrollArea(const bool opaque, const std::string &skin) : init(skin); } -ScrollArea::ScrollArea(gcn::Widget *const widget, const bool opaque, +ScrollArea::ScrollArea(Widget2 *const widget2, + gcn::Widget *const widget, + const bool opaque, const std::string &skin) : gcn::ScrollArea(widget), + Widget2(widget2), WidgetListener(), mX(0), mY(0), diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 3f6195271..bc25baa27 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -52,7 +52,8 @@ class ScrollArea final : public gcn::ScrollArea, * Constructor that takes no content. Needed for use with the DropDown * class. */ - explicit ScrollArea(const bool opaque = true, + explicit ScrollArea(Widget2 *const widget, + const bool opaque = true, const std::string &skin = ""); /** @@ -60,7 +61,8 @@ class ScrollArea final : public gcn::ScrollArea, * * @param content the initial content to show in the scroll area */ - explicit ScrollArea(gcn::Widget *const widget, + explicit ScrollArea(Widget2 *const widget2, + gcn::Widget *const widget, const bool opaque = true, const std::string &skin = ""); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index aeeb8e4bc..649388d04 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -50,7 +50,7 @@ SetupItem::SetupItem(const std::string &restrict text, const std::string &restrict eventName, const bool mainConfig) : ActionListener(), - Widget2(), + Widget2(parent), mText(text), mDescription(description), mKeyName(keyName), @@ -74,7 +74,7 @@ SetupItem::SetupItem(const std::string &restrict text, const std::string &restrict def, const bool mainConfig) : ActionListener(), - Widget2(), + Widget2(parent), mText(text), mDescription(description), mKeyName(keyName), @@ -762,7 +762,7 @@ void SetupItemSlider::createControls() mHorizont = new HorizontContainer(this, 32, 2); mLabel = new Label(this, mText); - mSlider = new Slider(mMin, mMax); + mSlider = new Slider(this, mMin, mMax); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); mSlider->setValue2(atof(mValue.c_str())); @@ -886,7 +886,7 @@ void SetupItemSlider2::createControls() mLabel = new Label(this, mText); mLabel2 = new Label(this, ""); mLabel2->setWidth(width); - mSlider = new Slider(mMin, mMax); + mSlider = new Slider(this, mMin, mMax); mSlider->setActionEventId(mEventName); mSlider->addActionListener(mParent); mSlider->setValue2(atof(mValue.c_str())); diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 767a32974..866dde6f1 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -28,9 +28,9 @@ float ShortcutContainer::mAlpha = 1.0; -ShortcutContainer::ShortcutContainer() : +ShortcutContainer::ShortcutContainer(Widget2 *const widget) : gcn::Widget(), - Widget2(), + Widget2(widget), WidgetListener(), MouseListener(), mBackgroundImg(nullptr), diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index e7ec2ff62..8df401775 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -102,7 +102,7 @@ class ShortcutContainer : public gcn::Widget, /** * Constructor. Initializes the shortcut container. */ - explicit ShortcutContainer(); + explicit ShortcutContainer(Widget2 *const widget); /** * Gets the index from the grid provided the point is in an item box. diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 02ebc2ccb..c5988ff54 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -43,9 +43,10 @@ static std::string const data[2] = "slider_highlighted.xml" }; -Slider::Slider(const double scaleEnd) : +Slider::Slider(Widget2 *const widget, + const double scaleEnd) : gcn::Slider(scaleEnd), - Widget2(), + Widget2(widget), mVertexes(new ImageCollection), mHasMouse(false), mRedraw(true) @@ -53,9 +54,11 @@ Slider::Slider(const double scaleEnd) : init(); } -Slider::Slider(const double scaleStart, const double scaleEnd) : +Slider::Slider(Widget2 *const widget, + const double scaleStart, + const double scaleEnd) : gcn::Slider(scaleStart, scaleEnd), - Widget2(), + Widget2(widget), mVertexes(new ImageCollection), mHasMouse(false), mRedraw(true) diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 2d4853539..27b03976d 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -43,12 +43,15 @@ class Slider final : public gcn::Slider, /** * Constructor with scale start equal to 0. */ - explicit Slider(const double scaleEnd = 1.0); + explicit Slider(Widget2 *const widget, + const double scaleEnd = 1.0); /** * Constructor. */ - Slider(const double scaleStart, const double scaleEnd); + Slider(Widget2 *const widget, + const double scaleStart, + const double scaleEnd); A_DELETE_COPY(Slider) diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index e8d34c9d8..5441c4d8a 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -39,8 +39,9 @@ #include "debug.h" -SpellShortcutContainer::SpellShortcutContainer(const unsigned number) : - ShortcutContainer(), +SpellShortcutContainer::SpellShortcutContainer(Widget2 *const widget, + const unsigned number) : + ShortcutContainer(widget), mSpellPopup(new SpellPopup), mNumber(number), mSpellClicked(false) diff --git a/src/gui/widgets/spellshortcutcontainer.h b/src/gui/widgets/spellshortcutcontainer.h index d8f5d22b4..afff6dcf9 100644 --- a/src/gui/widgets/spellshortcutcontainer.h +++ b/src/gui/widgets/spellshortcutcontainer.h @@ -38,7 +38,8 @@ class SpellShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - explicit SpellShortcutContainer(const unsigned number); + explicit SpellShortcutContainer(Widget2 *const widget, + const unsigned number); A_DELETE_COPY(SpellShortcutContainer) diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index d29c56c85..8ea9d5fbb 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -58,23 +58,23 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mSelected(-1), // TRANSLATORS: colors tab. label. mGradTypeLabel(new Label(this, _("Type:"))), - mGradTypeSlider(new Slider(0, 3)), + mGradTypeSlider(new Slider(this, 0, 3)), mGradTypeText(new Label(this)), // TRANSLATORS: colors tab. label. mGradDelayLabel(new Label(this, _("Delay:"))), - mGradDelaySlider(new Slider(20, 100)), + mGradDelaySlider(new Slider(this, 20, 100)), mGradDelayText(new TextField(this)), // TRANSLATORS: colors tab. label. mRedLabel(new Label(this, _("Red:"))), - mRedSlider(new Slider(0, 255)), + mRedSlider(new Slider(this, 0, 255)), mRedText(new TextField(this)), // TRANSLATORS: colors tab. label. mGreenLabel(new Label(this, _("Green:"))), - mGreenSlider(new Slider(0, 255)), + mGreenSlider(new Slider(this, 0, 255)), mGreenText(new TextField(this)), // TRANSLATORS: colors tab. label. mBlueLabel(new Label(this, _("Blue:"))), - mBlueSlider(new Slider(0, 255)), + mBlueSlider(new Slider(this, 0, 255)), mBlueText(new TextField(this)) { mColorBox->postInit(); diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index 589b08e5e..be00937f2 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -191,9 +191,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mOpenGLDropDown(new DropDown(widget, mOpenGLListModel)), // TRANSLATORS: video settings checkbox mFpsCheckBox(new CheckBox(this, _("FPS limit:"))), - mFpsSlider(new Slider(2, 160)), + mFpsSlider(new Slider(this, 2, 160)), mFpsLabel(new Label(this)), - mAltFpsSlider(new Slider(2, 160)), + mAltFpsSlider(new Slider(this, 2, 160)), // TRANSLATORS: video settings label mAltFpsLabel(new Label(this, _("Alt FPS limit: "))), #if !defined(ANDROID) && !defined(__APPLE__) diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index f6e94556a..a57ccbb41 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -78,12 +78,6 @@ class Widget2 } protected: - Widget2() : - mPaletteOffset(0), - mForegroundColor2() - { - } - explicit Widget2(const Widget2 *const widget) : mPaletteOffset(widget ? widget->mPaletteOffset : 0), mForegroundColor2() diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 2ea86f9df..82c2d91f8 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -49,7 +49,7 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, const bool modal, Window *const parent, std::string skin) : gcn::Window(caption), - Widget2(), + Widget2(nullptr), WidgetListener(), mSkin(nullptr), mDefaultX(0), diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 19a46b9b8..4d2acfac9 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -244,7 +244,7 @@ void BuyDialog::init() getOptionBool("showbackground"), "buy_background.xml"); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mSlider = new Slider(1.0); + mSlider = new Slider(this, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); mQuantityLabel->setAlignment(Graphics::CENTER); diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index a3fdcde3a..d6b572d40 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -124,7 +124,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, mMaxLook(CharDB::getMaxLook()), mPlayer(new Being(0, ActorSprite::PLAYER, static_cast(mRace), nullptr)), - mPlayerBox(new PlayerBox(mPlayer, "charcreate_playerbox.xml", + mPlayerBox(new PlayerBox(this, mPlayer, "charcreate_playerbox.xml", "charcreate_selectedplayerbox.xml")), mHairStyle(0), mHairColor(0), @@ -528,7 +528,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels, mAttributeLabel[i]->adjustSize(); add(mAttributeLabel[i]); - mAttributeSlider[i] = new Slider(min, max); + mAttributeSlider[i] = new Slider(this, min, max); mAttributeSlider[i]->setDimension(gcn::Rectangle(140, y + i * 24, 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); diff --git a/src/gui/windows/connectiondialog.cpp b/src/gui/windows/connectiondialog.cpp index 0d0633ff8..1a7c23187 100644 --- a/src/gui/windows/connectiondialog.cpp +++ b/src/gui/windows/connectiondialog.cpp @@ -41,7 +41,7 @@ ConnectionDialog::ConnectionDialog(const std::string &text, setMovable(false); setMinWidth(0); - ProgressIndicator *const progressIndicator = new ProgressIndicator; + ProgressIndicator *const progressIndicator = new ProgressIndicator(this); Label *const label = new Label(this, text); Button *const cancelButton = new Button( // TRANSLATORS: connection dialog button diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index 5f3aa1bb1..d94344090 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -51,10 +51,10 @@ EmoteWindow::EmoteWindow() : mEmotePage(new EmotePage(this)), mColorModel(ColorModel::createDefault(this)), mColorPage(new ColorPage(this, mColorModel, "colorpage.xml")), - mScrollColorPage(new ScrollArea(mColorPage, false, "emotepage.xml")), + mScrollColorPage(new ScrollArea(this, mColorPage, false, "emotepage.xml")), mFontModel(new NamesModel), mFontPage(new ListBox(this, mFontModel, "")), - mScrollFontPage(new ScrollArea(mFontPage, false, "fontpage.xml")), + mScrollFontPage(new ScrollArea(this, mFontPage, false, "fontpage.xml")), mImageSet(Theme::getImageSetFromThemeXml("emotetabs.xml", "", 17, 16)) { mTabs->postInit(); diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 6f2bb3b3d..01f74c50d 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -59,7 +59,8 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, ActionListener(), mEquipment(equipment), mItemPopup(new ItemPopup), - mPlayerBox(new PlayerBox("equipment_playerbox.xml", + mPlayerBox(new PlayerBox(this, + "equipment_playerbox.xml", "equipment_selectedplayerbox.xml")), // TRANSLATORS: equipment window button mUnequip(new Button(this, _("Unequip"), "unequip", this)), diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 6b7d10173..8e981ae96 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -148,7 +148,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mMax(maxRange), mUsage(usage), mItemPopup(new ItemPopup), - mItemAmountSlide(new Slider(1.0, mMax)), + mItemAmountSlide(new Slider(this, 1.0, mMax)), mItemPriceSlide(nullptr), mItemDropDown(nullptr), mItemsModal(nullptr), @@ -182,7 +182,7 @@ ItemAmountWindow::ItemAmountWindow(const Usage usage, Window *const parent, mItemPriceTextField->setWidth(35); mItemPriceTextField->addKeyListener(this); - mItemPriceSlide = new Slider(1.0, 10000000); + mItemPriceSlide = new Slider(this, 1.0, 10000000); mItemPriceSlide->setHeight(10); mItemPriceSlide->setActionEventId("slidePrice"); mItemPriceSlide->addActionListener(this); diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index aad3619ba..b79d18dcf 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -90,7 +90,7 @@ void SellDialog::init() getOptionBool("showbackground"), "sell_background.xml"); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - mSlider = new Slider(1.0); + mSlider = new Slider(this, 1.0); mQuantityLabel = new Label(this, strprintf( "%d / %d", mAmountItems, mMaxItems)); -- cgit v1.2.3-70-g09d2 From f24b4360e73d45bc0830d2964c06e295890e5f18 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 18 Feb 2014 01:12:45 +0300 Subject: derive Widget from Widget2. --- src/gui/base/basiccontainer.hpp | 4 +++- src/gui/base/widget.cpp | 3 ++- src/gui/base/widget.hpp | 6 ++++-- src/gui/base/widgets/button.cpp | 9 +++++---- src/gui/base/widgets/button.hpp | 5 +++-- src/gui/base/widgets/checkbox.cpp | 10 ++++++---- src/gui/base/widgets/checkbox.hpp | 6 ++++-- src/gui/base/widgets/container.cpp | 4 ++-- src/gui/base/widgets/container.hpp | 2 +- src/gui/base/widgets/label.cpp | 9 +++++---- src/gui/base/widgets/label.hpp | 5 +++-- src/gui/base/widgets/listbox.cpp | 9 +++++---- src/gui/base/widgets/listbox.hpp | 5 +++-- src/gui/base/widgets/radiobutton.cpp | 9 +++++---- src/gui/base/widgets/radiobutton.hpp | 5 +++-- src/gui/base/widgets/scrollarea.cpp | 14 ++++++++------ src/gui/base/widgets/scrollarea.hpp | 8 +++++--- src/gui/base/widgets/slider.cpp | 11 +++++++---- src/gui/base/widgets/slider.hpp | 7 +++++-- src/gui/base/widgets/textbox.cpp | 9 +++++---- src/gui/base/widgets/textbox.hpp | 5 +++-- src/gui/base/widgets/textfield.cpp | 9 +++++---- src/gui/base/widgets/textfield.hpp | 5 +++-- src/gui/base/widgets/window.cpp | 9 +++++---- src/gui/base/widgets/window.hpp | 5 +++-- src/gui/popups/popupmenu.cpp | 2 +- src/gui/widgets/avatarlistbox.h | 6 ++++-- src/gui/widgets/browserbox.cpp | 3 +-- src/gui/widgets/browserbox.h | 1 - src/gui/widgets/button.cpp | 15 +++++---------- src/gui/widgets/button.h | 1 - src/gui/widgets/checkbox.cpp | 6 +++--- src/gui/widgets/checkbox.h | 3 +-- src/gui/widgets/container.cpp | 3 +-- src/gui/widgets/container.h | 3 +-- src/gui/widgets/dropdown.cpp | 3 +-- src/gui/widgets/dropdown.h | 3 +-- src/gui/widgets/emotepage.cpp | 3 +-- src/gui/widgets/emotepage.h | 1 - src/gui/widgets/flowcontainer.cpp | 3 ++- src/gui/widgets/flowcontainer.h | 3 ++- src/gui/widgets/guitable.cpp | 6 +++--- src/gui/widgets/guitable.h | 1 - src/gui/widgets/horizontcontainer.cpp | 3 ++- src/gui/widgets/horizontcontainer.h | 3 ++- src/gui/widgets/icon.cpp | 12 ++++++------ src/gui/widgets/icon.h | 9 +++++---- src/gui/widgets/inttextfield.cpp | 9 ++++++--- src/gui/widgets/inttextfield.h | 9 ++++++--- src/gui/widgets/itemcontainer.cpp | 3 +-- src/gui/widgets/itemcontainer.h | 1 - src/gui/widgets/label.cpp | 9 ++++----- src/gui/widgets/label.h | 5 +++-- src/gui/widgets/listbox.cpp | 3 +-- src/gui/widgets/listbox.h | 3 +-- src/gui/widgets/playerbox.cpp | 6 ++---- src/gui/widgets/playerbox.h | 3 +-- src/gui/widgets/popuplist.cpp | 2 +- src/gui/widgets/progressbar.cpp | 12 +++++++----- src/gui/widgets/progressbar.h | 10 ++++++---- src/gui/widgets/progressindicator.cpp | 3 +-- src/gui/widgets/progressindicator.h | 3 +-- src/gui/widgets/radiobutton.cpp | 3 +-- src/gui/widgets/radiobutton.h | 3 +-- src/gui/widgets/radiogroup.h | 3 ++- src/gui/widgets/scrollarea.cpp | 27 +-------------------------- src/gui/widgets/scrollarea.h | 17 ++++------------- src/gui/widgets/shortcutcontainer.cpp | 3 +-- src/gui/widgets/shortcutcontainer.h | 1 - src/gui/widgets/slider.cpp | 6 ++---- src/gui/widgets/slider.h | 3 +-- src/gui/widgets/tabbedarea.cpp | 7 +++---- src/gui/widgets/tabbedarea.h | 3 +-- src/gui/widgets/tabs/chattab.cpp | 5 +++-- src/gui/widgets/tabs/chattab.h | 3 ++- src/gui/widgets/tabs/guildchattab.h | 3 ++- src/gui/widgets/tabs/langtab.cpp | 3 ++- src/gui/widgets/tabs/langtab.h | 3 ++- src/gui/widgets/tabs/setup_colors.cpp | 5 +++-- src/gui/widgets/tabs/setup_input.cpp | 3 ++- src/gui/widgets/tabs/setup_relations.cpp | 2 +- src/gui/widgets/tabs/setup_video.cpp | 2 +- src/gui/widgets/tabs/setup_video.h | 3 ++- src/gui/widgets/tabs/setuptabscroll.cpp | 2 +- src/gui/widgets/tabs/tab.cpp | 3 +-- src/gui/widgets/tabs/tab.h | 1 - src/gui/widgets/tabs/whispertab.cpp | 3 ++- src/gui/widgets/tabs/whispertab.h | 3 ++- src/gui/widgets/tabstrip.cpp | 6 ++++-- src/gui/widgets/tabstrip.h | 6 ++++-- src/gui/widgets/textbox.cpp | 3 +-- src/gui/widgets/textbox.h | 3 +-- src/gui/widgets/textfield.cpp | 3 +-- src/gui/widgets/textfield.h | 3 +-- src/gui/widgets/textpreview.cpp | 3 +-- src/gui/widgets/textpreview.h | 6 +++--- src/gui/widgets/vertcontainer.cpp | 3 ++- src/gui/widgets/vertcontainer.h | 3 ++- src/gui/widgets/widgetgroup.cpp | 3 ++- src/gui/widgets/widgetgroup.h | 3 ++- src/gui/widgets/window.cpp | 3 +-- src/gui/widgets/window.h | 1 - src/gui/windows/botcheckerwindow.cpp | 2 +- src/gui/windows/buydialog.cpp | 2 +- src/gui/windows/didyouknowwindow.cpp | 2 +- src/gui/windows/helpwindow.cpp | 3 ++- src/gui/windows/inventorywindow.cpp | 4 ++-- src/gui/windows/npcdialog.cpp | 6 +++--- src/gui/windows/npcpostdialog.cpp | 2 +- src/gui/windows/questswindow.cpp | 4 ++-- src/gui/windows/selldialog.cpp | 2 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/shopwindow.cpp | 4 ++-- src/gui/windows/shortcutwindow.cpp | 7 ++++--- src/gui/windows/skilldialog.cpp | 8 +++++--- src/gui/windows/socialwindow.cpp | 31 ++++++++++++++++++------------- src/gui/windows/statuswindow.cpp | 4 ++-- src/gui/windows/tradewindow.cpp | 5 +++-- src/gui/windows/updaterwindow.cpp | 3 ++- src/gui/windows/whoisonline.cpp | 2 +- src/gui/windows/worldselectdialog.cpp | 2 +- src/net/ea/gui/guildtab.h | 3 ++- src/net/ea/gui/partytab.h | 3 ++- 123 files changed, 311 insertions(+), 306 deletions(-) (limited to 'src') diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp index 0fec2c0e7..cc3aee808 100644 --- a/src/gui/base/basiccontainer.hpp +++ b/src/gui/base/basiccontainer.hpp @@ -85,7 +85,9 @@ namespace gcn public DeathListener { public: - BasicContainer() : + BasicContainer(const Widget2 *const widget) : + Widget(widget), + DeathListener(), mWidgets() { } diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index 9e2912d39..f5994d1af 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -94,7 +94,8 @@ namespace gcn std::list Widget::mWidgets; std::set Widget::mWidgetsSet; - Widget::Widget() : + Widget::Widget(const Widget2 *const widget) : + Widget2(widget), mMouseListeners(), mKeyListeners(), mActionListeners(), diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 1c1c0ae14..013ead3b8 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -71,6 +71,8 @@ #include "gui/base/color.hpp" #include "gui/base/rectangle.hpp" +#include "gui/widgets/widget2.h" + #include "localconsts.h" class ActionListener; @@ -100,7 +102,7 @@ namespace gcn * @author Per Larsson. * @since 0.1.0 */ - class Widget + class Widget : public Widget2 { public: /** @@ -108,7 +110,7 @@ namespace gcn * focusable as default, therefore, widgets that are supposed to be * focusable should overide this default in their own constructor. */ - Widget(); + Widget(const Widget2 *const widget); A_DELETE_COPY(Widget) diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 5867b9dc8..e4285cffd 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -80,8 +80,8 @@ namespace gcn { - Button::Button() : - gcn::Widget(), + Button::Button(const Widget2 *const widget) : + gcn::Widget(widget), MouseListener(), KeyListener(), FocusListener(), @@ -101,8 +101,9 @@ namespace gcn addFocusListener(this); } - Button::Button(const std::string& caption) : - gcn::Widget(), + Button::Button(const Widget2 *const widget, + const std::string& caption) : + gcn::Widget(widget), MouseListener(), KeyListener(), FocusListener(), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index 6fee7f3b3..7fd5613bd 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -96,7 +96,7 @@ namespace gcn /** * Constructor. */ - Button(); + explicit Button(const Widget2 *const widget); /** * Constructor. The button will be automatically resized @@ -104,7 +104,8 @@ namespace gcn * * @param caption The caption of the button. */ - explicit Button(const std::string& caption); + Button(const Widget2 *const widget, + const std::string& caption); A_DELETE_COPY(Button) diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index 7cba5ac47..d75fb5cb0 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -79,8 +79,8 @@ namespace gcn { - CheckBox::CheckBox() : - gcn::Widget(), + CheckBox::CheckBox(const Widget2 *const widget) : + gcn::Widget(widget), MouseListener(), KeyListener(), mSelected(false), @@ -91,8 +91,10 @@ namespace gcn addKeyListener(this); } - CheckBox::CheckBox(const std::string &caption, bool selected) : - gcn::Widget(), + CheckBox::CheckBox(const Widget2 *const widget, + const std::string &caption, + bool selected) : + gcn::Widget(widget), MouseListener(), KeyListener(), mSelected(selected), diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index c03187bba..d87a6b206 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -90,7 +90,7 @@ namespace gcn /** * Contructor. */ - CheckBox(); + CheckBox(const Widget2 *const widget); /** * Constructor. The check box will be automatically resized @@ -99,7 +99,9 @@ namespace gcn * @param caption The caption of the check box. * @param marked True if the check box is selected, false otherwise. */ - CheckBox(const std::string &caption, bool selected = false); + CheckBox(const Widget2 *const widget, + const std::string &caption, + bool selected = false); A_DELETE_COPY(CheckBox) diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp index 6026b920d..c79f8fcbc 100644 --- a/src/gui/base/widgets/container.cpp +++ b/src/gui/base/widgets/container.cpp @@ -75,8 +75,8 @@ namespace gcn { - Container::Container() : - BasicContainer(), + Container::Container(const Widget2 *const widget) : + BasicContainer(widget), mOpaque(true) { } diff --git a/src/gui/base/widgets/container.hpp b/src/gui/base/widgets/container.hpp index bffe6e884..ba3cff153 100644 --- a/src/gui/base/widgets/container.hpp +++ b/src/gui/base/widgets/container.hpp @@ -89,7 +89,7 @@ namespace gcn * * @see setOpaque, isOpaque */ - Container(); + Container(const Widget2 *const widget); /** * Destructor. diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index cbee2ac4c..84ba87d84 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -75,15 +75,16 @@ namespace gcn { - Label::Label() : - gcn::Widget(), + Label::Label(const Widget2 *const widget) : + gcn::Widget(widget), mCaption(), mAlignment(Graphics::LEFT) { } - Label::Label(const std::string& caption) : - gcn::Widget(), + Label::Label(const Widget2 *const widget, + const std::string& caption) : + gcn::Widget(widget), mCaption(caption), mAlignment(Graphics::LEFT) { diff --git a/src/gui/base/widgets/label.hpp b/src/gui/base/widgets/label.hpp index 90a395f7b..399e4202a 100644 --- a/src/gui/base/widgets/label.hpp +++ b/src/gui/base/widgets/label.hpp @@ -81,7 +81,7 @@ namespace gcn /** * Constructor. */ - Label(); + explicit Label(const Widget2 *const widget); /** * Constructor. The label will be automatically resized @@ -89,7 +89,8 @@ namespace gcn * * @param caption The caption of the label. */ - explicit Label(const std::string& caption); + Label(const Widget2 *const widget, + const std::string& caption); A_DELETE_COPY(Label) diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index ad1bf2535..0dd5c88f7 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -83,8 +83,8 @@ namespace gcn { - ListBox::ListBox() : - gcn::Widget(), + ListBox::ListBox(const Widget2 *const widget) : + gcn::Widget(widget), MouseListener(), KeyListener(), mSelected(-1), @@ -99,8 +99,9 @@ namespace gcn addKeyListener(this); } - ListBox::ListBox(ListModel *listModel) : - gcn::Widget(), + ListBox::ListBox(const Widget2 *const widget, + ListModel *listModel) : + gcn::Widget(widget), MouseListener(), KeyListener(), mSelected(-1), diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index 61c8486bb..ff2df395c 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -96,14 +96,15 @@ namespace gcn /** * Constructor. */ - ListBox(); + explicit ListBox(const Widget2 *const widget); /** * Constructor. * * @param listModel the list model to use. */ - explicit ListBox(ListModel *listModel); + ListBox(const Widget2 *const widget, + ListModel *listModel); A_DELETE_COPY(ListBox) diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index 4cd515bba..832c00bbe 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -80,8 +80,8 @@ namespace gcn { RadioButton::GroupMap RadioButton::mGroupMap; - RadioButton::RadioButton() : - gcn::Widget(), + RadioButton::RadioButton(const Widget2 *const widget) : + gcn::Widget(widget), MouseListener(), KeyListener(), mSelected(false), @@ -95,10 +95,11 @@ namespace gcn addKeyListener(this); } - RadioButton::RadioButton(const std::string &caption, + RadioButton::RadioButton(const Widget2 *const widget, + const std::string &caption, const std::string &group, bool selected) : - gcn::Widget(), + gcn::Widget(widget), MouseListener(), KeyListener(), mSelected(false), diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index 8a9a8b585..4d4403fac 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -93,7 +93,7 @@ namespace gcn /** * Constructor. */ - RadioButton(); + RadioButton(const Widget2 *const widget); /** * Constructor. The radio button will be automatically resized @@ -103,7 +103,8 @@ namespace gcn * @param group The group the radio button should belong to. * @param selected True if the radio button should be selected. */ - RadioButton(const std::string &caption, + RadioButton(const Widget2 *const widget, + const std::string &caption, const std::string &group, bool selected = false); diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index f76226bc5..68e1b72d3 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -74,8 +74,8 @@ namespace gcn { - ScrollArea::ScrollArea() : - gcn::BasicContainer(), + ScrollArea::ScrollArea(const Widget2 *const widget) : + gcn::BasicContainer(widget), MouseListener(), mVScroll(0), mHScroll(0), @@ -101,8 +101,9 @@ namespace gcn addMouseListener(this); } - ScrollArea::ScrollArea(Widget *const content) : - gcn::BasicContainer(), + ScrollArea::ScrollArea(const Widget2 *const widget, + Widget *const content) : + gcn::BasicContainer(widget), MouseListener(), mVScroll(0), mHScroll(0), @@ -129,10 +130,11 @@ namespace gcn addMouseListener(this); } - ScrollArea::ScrollArea(Widget *content, + ScrollArea::ScrollArea(const Widget2 *const widget, + Widget *content, ScrollPolicy hPolicy, ScrollPolicy vPolicy) : - gcn::BasicContainer(), + gcn::BasicContainer(widget), MouseListener(), mVScroll(0), mHScroll(0), diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp index 1d4c0dd54..e2d8aada5 100644 --- a/src/gui/base/widgets/scrollarea.hpp +++ b/src/gui/base/widgets/scrollarea.hpp @@ -100,14 +100,15 @@ namespace gcn /** * Constructor. */ - ScrollArea(); + explicit ScrollArea(const Widget2 *const widget); /** * Constructor. * * @param content The content of the scroll area. */ - explicit ScrollArea(Widget *const content); + ScrollArea(const Widget2 *const widget, + Widget *const content); /** * Constructor. @@ -118,7 +119,8 @@ namespace gcn * @param vPolicy The policy for the vertical scrollbar. See enum with * policies. */ - ScrollArea(Widget *content, + ScrollArea(const Widget2 *const widget, + Widget *content, ScrollPolicy hPolicy, ScrollPolicy vPolicy); diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index 1245b6590..e995ff55a 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -76,8 +76,9 @@ namespace gcn { - Slider::Slider(const double scaleEnd) : - gcn::Widget(), + Slider::Slider(const Widget2 *const widget, + const double scaleEnd) : + gcn::Widget(widget), MouseListener(), KeyListener(), mDragged(false), @@ -95,8 +96,10 @@ namespace gcn addKeyListener(this); } - Slider::Slider(const double scaleStart, const double scaleEnd) : - gcn::Widget(), + Slider::Slider(const Widget2 *const widget, + const double scaleStart, + const double scaleEnd) : + gcn::Widget(widget), MouseListener(), KeyListener(), mDragged(false), diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp index f77d3f5dd..f29ad5950 100644 --- a/src/gui/base/widgets/slider.hpp +++ b/src/gui/base/widgets/slider.hpp @@ -99,7 +99,8 @@ namespace gcn * * @param scaleEnd The end value of the slider scale. */ - explicit Slider(const double scaleEnd = 1.0); + explicit Slider(const Widget2 *const widget, + const double scaleEnd = 1.0); /** * Constructor. @@ -107,7 +108,9 @@ namespace gcn * @param scaleStart The start value of the slider scale. * @param scaleEnd The end value of the slider scale. */ - Slider(const double scaleStart, const double scaleEnd); + Slider(const Widget2 *const widget, + const double scaleStart, + const double scaleEnd); A_DELETE_COPY(Slider) diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 292e35850..7a5b63a50 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -80,8 +80,8 @@ namespace gcn { - TextBox::TextBox() : - gcn::Widget(), + TextBox::TextBox(const Widget2 *const widget) : + gcn::Widget(widget), MouseListener(), KeyListener(), mTextRows(), @@ -98,8 +98,9 @@ namespace gcn adjustSize(); } - TextBox::TextBox(const std::string& text) : - gcn::Widget(), + TextBox::TextBox(const Widget2 *const widget, + const std::string& text) : + gcn::Widget(widget), MouseListener(), KeyListener(), mTextRows(), diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 8fc788816..0c96096ec 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -87,14 +87,15 @@ namespace gcn /** * Constructor. */ - TextBox(); + explicit TextBox(const Widget2 *const widget); /** * Constructor. * * @param text The default text of the text box. */ - explicit TextBox(const std::string& text); + TextBox(const Widget2 *const widget, + const std::string& text); A_DELETE_COPY(TextBox) diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index f149e8667..6ca37c4af 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -78,8 +78,8 @@ namespace gcn { - TextField::TextField() : - gcn::Widget(), + TextField::TextField(const Widget2 *const widget) : + gcn::Widget(widget), MouseListener(), KeyListener(), mText(), @@ -92,8 +92,9 @@ namespace gcn addKeyListener(this); } - TextField::TextField(const std::string& text) : - gcn::Widget(), + TextField::TextField(const Widget2 *const widget, + const std::string& text) : + gcn::Widget(widget), MouseListener(), KeyListener(), mText(text), diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp index 099ed1356..aa5f210c5 100644 --- a/src/gui/base/widgets/textfield.hpp +++ b/src/gui/base/widgets/textfield.hpp @@ -85,7 +85,7 @@ namespace gcn /** * Constructor. */ - TextField(); + explicit TextField(const Widget2 *const widget); /** * Constructor. The text field will be automatically resized @@ -93,7 +93,8 @@ namespace gcn * * @param text The default text of the text field. */ - explicit TextField(const std::string& text); + TextField(const Widget2 *const widget, + const std::string& text); A_DELETE_COPY(TextField) diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 8d33c1dd5..0ead95bc1 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -77,8 +77,8 @@ namespace gcn { - Window::Window() : - Container(), + Window::Window(const Widget2 *const widget) : + Container(widget), MouseListener(), mCaption(), mAlignment(Graphics::CENTER), @@ -94,8 +94,9 @@ namespace gcn addMouseListener(this); } - Window::Window(const std::string& caption) : - Container(), + Window::Window(const Widget2 *const widget, + const std::string& caption) : + Container(widget), MouseListener(), mCaption(caption), mAlignment(Graphics::CENTER), diff --git a/src/gui/base/widgets/window.hpp b/src/gui/base/widgets/window.hpp index 030d57edc..e2772d850 100644 --- a/src/gui/base/widgets/window.hpp +++ b/src/gui/base/widgets/window.hpp @@ -82,7 +82,7 @@ namespace gcn /** * Constructor. */ - Window(); + explicit Window(const Widget2 *const widget); /** * Constructor. The window will be automatically resized in height @@ -90,7 +90,8 @@ namespace gcn * * @param caption the caption of the window. */ - explicit Window(const std::string& caption); + Window(const Widget2 *const widget, + const std::string& caption); A_DELETE_COPY(Window) diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 45551d165..450bd504f 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -118,7 +118,7 @@ PopupMenu::PopupMenu() : mPlayerListener.setNick(""); mPlayerListener.setDialog(nullptr); mPlayerListener.setType(static_cast(Being::UNKNOWN)); - mScrollArea = new ScrollArea(mBrowserBox, false); + mScrollArea = new ScrollArea(this, mBrowserBox, false); mScrollArea->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); } diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index d0449231b..005ba7c72 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -41,10 +41,12 @@ public: { return getAvatarAt(i)->getName(); } }; -class AvatarListBox final : public ListBox, public ConfigListener +class AvatarListBox final : public ListBox, + public ConfigListener { public: - AvatarListBox(const Widget2 *const widget, AvatarListModel *const model); + AvatarListBox(const Widget2 *const widget, + AvatarListModel *const model); A_DELETE_COPY(AvatarListBox) diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 60b67dc24..cc83d2b83 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -52,8 +52,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode, const bool opaque, const std::string &skin) : - gcn::Widget(), - Widget2(widget), + gcn::Widget(widget), MouseListener(), mTextRows(), mTextRowLinksCount(), diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index f1c1aa1f6..23f221e63 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -103,7 +103,6 @@ class LinePart final * parent conteiner. */ class BrowserBox final : public gcn::Widget, - public Widget2, public MouseListener { public: diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 5d27af68a..a9b621d90 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -49,8 +49,7 @@ static std::string const data[Button::BUTTON_COUNT] = Skin *Button::button[BUTTON_COUNT]; Button::Button(const Widget2 *const widget) : - gcn::Button(), - Widget2(widget), + gcn::Button(widget), WidgetListener(), mDescription(), mVertexes2(new ImageCollection), @@ -83,8 +82,7 @@ Button::Button(const Widget2 *const widget, const std::string &restrict caption, const std::string &restrict actionEventId, ActionListener *const listener) : - gcn::Button(caption), - Widget2(widget), + gcn::Button(widget, caption), WidgetListener(), mDescription(), mVertexes2(new ImageCollection), @@ -123,8 +121,7 @@ Button::Button(const Widget2 *const widget, const int imageWidth, const int imageHeight, const std::string &restrict actionEventId, ActionListener *const listener) : - gcn::Button(caption), - Widget2(widget), + gcn::Button(widget, caption), WidgetListener(), mDescription(), mVertexes2(new ImageCollection), @@ -163,8 +160,7 @@ Button::Button(const Widget2 *const widget, const int imageWidth, const int imageHeight, const std::string &restrict actionEventId, ActionListener *const listener) : - gcn::Button(), - Widget2(widget), + gcn::Button(widget), WidgetListener(), mDescription(), mVertexes2(new ImageCollection), @@ -203,8 +199,7 @@ Button::Button(const Widget2 *const widget, const std::string &restrict imageName, const std::string &restrict actionEventId, ActionListener *const listener) : - gcn::Button(caption), - Widget2(widget), + gcn::Button(widget, caption), WidgetListener(), mDescription(), mVertexes2(new ImageCollection), diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index a9722f6a2..73c0d70eb 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -43,7 +43,6 @@ const std::string BUTTON_PLAY = "buttonplay.png"; * \ingroup GUI */ class Button final : public gcn::Button, - public Widget2, public WidgetListener { public: diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 0772c0d4f..e500815c0 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -39,11 +39,11 @@ Skin *CheckBox::mSkin = nullptr; float CheckBox::mAlpha = 1.0; CheckBox::CheckBox(const Widget2 *const widget, - const std::string &restrict caption, const bool selected, + const std::string &restrict caption, + const bool selected, ActionListener *const listener, const std::string &restrict eventId) : - gcn::CheckBox(caption, selected), - Widget2(widget), + gcn::CheckBox(widget, caption, selected), mPadding(0), mImagePadding(0), mImageSize(9), diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index 3b0830cee..e05ab29d3 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -36,8 +36,7 @@ class Skin; * * \ingroup GUI */ -class CheckBox final : public gcn::CheckBox, - public Widget2 +class CheckBox final : public gcn::CheckBox { public: /** diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index e37bd5103..3c048d630 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -25,8 +25,7 @@ #include "debug.h" Container::Container(const Widget2 *const widget) : - gcn::Container(), - Widget2(widget) + gcn::Container(widget) { setOpaque(false); } diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index a83ec8d48..efddb1566 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -36,8 +36,7 @@ * * This container is also non-opaque by default. */ -class Container : public gcn::Container, - public Widget2 +class Container : public gcn::Container { public: explicit Container(const Widget2 *const widget); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 42fa89b30..86170036c 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -58,12 +58,11 @@ DropDown::DropDown(const Widget2 *const widget, ActionListener *const listener, const std::string &eventId): ActionListener(), - gcn::BasicContainer(), + gcn::BasicContainer(widget), KeyListener(), MouseListener(), FocusListener(), SelectionListener(), - Widget2(widget), mPopup(new PopupList(this, listModel, extended, modal)), mShadowColor(getThemeColor(Theme::DROPDOWN_SHADOW)), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 8f42bfc65..b638a2a05 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -55,8 +55,7 @@ class DropDown final : public ActionListener, public KeyListener, public MouseListener, public FocusListener, - public SelectionListener, - public Widget2 + public SelectionListener { public: /** diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 6456913a9..1ebcb4841 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -34,8 +34,7 @@ namespace } // namespace EmotePage::EmotePage(const Widget2 *const widget) : - gcn::Widget(), - Widget2(widget), + gcn::Widget(widget), MouseListener(), WidgetListener(), mEmotes(ResourceManager::getInstance()->getImageSet( diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 74f93e8d3..8eb1e5f7b 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -31,7 +31,6 @@ #include "localconsts.h" class EmotePage final : public gcn::Widget, - public Widget2, public MouseListener, public WidgetListener { diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 1c5961140..06fb731c4 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -24,7 +24,8 @@ #include "debug.h" FlowContainer::FlowContainer(const Widget2 *const widget, - const int boxWidth, const int boxHeight) : + const int boxWidth, + const int boxHeight) : Container(widget), WidgetListener(), mBoxWidth(boxWidth), diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index a425e8465..8e96204ae 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -41,7 +41,8 @@ class FlowContainer final : public Container, * Constructor. Initializes the shortcut container. */ FlowContainer(const Widget2 *const widget, - const int boxWidth, const int boxHeight); + const int boxWidth, + const int boxHeight); A_DELETE_COPY(FlowContainer) diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 1b1124cff..84bc19e0e 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -94,9 +94,9 @@ void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED) GuiTable::GuiTable(const Widget2 *const widget, - TableModel *const initial_model, const bool opacity) : - gcn::Widget(), - Widget2(widget), + TableModel *const initial_model, + const bool opacity) : + gcn::Widget(widget), MouseListener(), KeyListener(), mModel(nullptr), diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index ab7dc1a66..d68e222ac 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -47,7 +47,6 @@ class GuiTableActionListener; * \ingroup GUI */ class GuiTable final : public gcn::Widget, - public Widget2, public MouseListener, public KeyListener, public TableModelListener diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index b2fddfcae..5d0e14903 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -24,7 +24,8 @@ #include "debug.h" HorizontContainer::HorizontContainer(const Widget2 *const widget, - const int height, const int spacing) : + const int height, + const int spacing) : Container(widget), WidgetListener(), mSpacing(spacing), diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 4f652df64..9a873272c 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -38,7 +38,8 @@ class HorizontContainer final : public Container, { public: HorizontContainer(const Widget2 *const widget, - const int height, const int spacing); + const int height, + const int spacing); A_DELETE_COPY(HorizontContainer) diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 66313d397..73607c048 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -27,9 +27,9 @@ #include "debug.h" -Icon::Icon(const Widget2 *const widget, const std::string &file) : - gcn::Widget(), - Widget2(widget), +Icon::Icon(const Widget2 *const widget, + const std::string &file) : + gcn::Widget(widget), mImage(ResourceManager::getInstance()->getImage(file)) { if (mImage) @@ -39,9 +39,9 @@ Icon::Icon(const Widget2 *const widget, const std::string &file) : } } -Icon::Icon(const Widget2 *const widget, Image *const image) : - gcn::Widget(), - Widget2(widget), +Icon::Icon(const Widget2 *const widget, + Image *const image) : + gcn::Widget(widget), mImage(image) { if (mImage) diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index a39cec517..9dc4827ac 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -36,19 +36,20 @@ class Image; * * \ingroup GUI */ -class Icon final : public gcn::Widget, - public Widget2 +class Icon final : public gcn::Widget { public: /** * Constructor. */ - Icon(const Widget2 *const widget, const std::string &filename); + Icon(const Widget2 *const widget, + const std::string &filename); /** * Constructor, uses an existing Image. */ - Icon(const Widget2 *const widget, Image *const image); + Icon(const Widget2 *const widget, + Image *const image); A_DELETE_COPY(Icon) diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index e693526f0..6d8eed228 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -33,9 +33,12 @@ #include "utils/stringutils.h" #include "debug.h" -IntTextField::IntTextField(const Widget2 *const widget, const int def, - const int min, const int max, - const bool enabled, const int width) : +IntTextField::IntTextField(const Widget2 *const widget, + const int def, + const int min, + const int max, + const bool enabled, + const int width) : TextField(widget, toString(def)), mMin(0), mMax(0), diff --git a/src/gui/widgets/inttextfield.h b/src/gui/widgets/inttextfield.h index 2e4e68083..91b076e30 100644 --- a/src/gui/widgets/inttextfield.h +++ b/src/gui/widgets/inttextfield.h @@ -34,9 +34,12 @@ class IntTextField final : public TextField /** * Constructor, sets default value. */ - explicit IntTextField(const Widget2 *const widget, const int def = 0, - const int min = 0, const int max = 0, - const bool enabled = true, const int width = 0); + explicit IntTextField(const Widget2 *const widget, + const int def = 0, + const int min = 0, + const int max = 0, + const bool enabled = true, + const int width = 0); A_DELETE_COPY(IntTextField) diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index b0f887fa2..85f020af4 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -158,8 +158,7 @@ namespace ItemContainer::ItemContainer(const Widget2 *const widget, Inventory *const inventory, const bool forceQuantity) : - gcn::Widget(), - Widget2(widget), + gcn::Widget(widget), KeyListener(), MouseListener(), WidgetListener(), diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 4f530320d..76dd51ef7 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -47,7 +47,6 @@ class SelectionListener; * \ingroup GUI */ class ItemContainer final : public gcn::Widget, - public Widget2, public KeyListener, public MouseListener, public WidgetListener diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 6cc94cc3d..73e3bca64 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -29,16 +29,15 @@ Skin *Label::mSkin = nullptr; int Label::mInstances = 0; Label::Label(const Widget2 *const widget) : - gcn::Label(), - Widget2(widget), + gcn::Label(widget), mPadding(0) { init(); } -Label::Label(const Widget2 *const widget, const std::string &caption) : - gcn::Label(caption), - Widget2(widget), +Label::Label(const Widget2 *const widget, + const std::string &caption) : + gcn::Label(widget, caption), mPadding(0) { init(); diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 0b96b87e4..b6adf9fba 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -36,7 +36,7 @@ class Skin; * * \ingroup GUI */ -class Label final : public gcn::Label, public Widget2 +class Label final : public gcn::Label { public: /** @@ -48,7 +48,8 @@ class Label final : public gcn::Label, public Widget2 * Constructor. This version of the constructor sets the label with an * inintialization string. */ - Label(const Widget2 *const widget, const std::string &caption); + Label(const Widget2 *const widget, + const std::string &caption); A_DELETE_COPY(Label) diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index c2fa1a686..a57dc07cd 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -43,8 +43,7 @@ float ListBox::mAlpha = 1.0; ListBox::ListBox(const Widget2 *const widget, gcn::ListModel *const listModel, const std::string &skin) : - gcn::ListBox(listModel), - Widget2(widget), + gcn::ListBox(widget, listModel), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), mForegroundSelectedColor(getThemeColor(Theme::LISTBOX_SELECTED)), mForegroundSelectedColor2(getThemeColor(Theme::LISTBOX_SELECTED_OUTLINE)), diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index adf266f7e..cd20ea50a 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -38,8 +38,7 @@ class Skin; * * \ingroup GUI */ -class ListBox : public gcn::ListBox, - public Widget2 +class ListBox : public gcn::ListBox { public: /** diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 97fd4a713..976a1c8f9 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -34,8 +34,7 @@ PlayerBox::PlayerBox(Widget2 *const widget, Being *const being, const std::string &skin, const std::string &selectedSkin) : - Widget2(widget), - ScrollArea(), + ScrollArea(widget), mBeing(being), mAlpha(1.0), mBackground(), @@ -53,8 +52,7 @@ PlayerBox::PlayerBox(Widget2 *const widget, PlayerBox::PlayerBox(Widget2 *const widget, const std::string &skin, const std::string &selectedSkin) : - Widget2(widget), - ScrollArea(), + ScrollArea(widget), mBeing(nullptr), mAlpha(1.0), mBackground(), diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index 3669a23a9..d3fb4e5e3 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -37,8 +37,7 @@ class Skin; * * \ingroup GUI */ -class PlayerBox final : public Widget2, - public gcn::ScrollArea +class PlayerBox final : public gcn::ScrollArea { public: /** diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index 62bc2f448..133cbd2ca 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -37,7 +37,7 @@ PopupList::PopupList(DropDown *const widget, mListBox(extended ? new ExtendedListBox( widget, listModel, "extendedlistbox.xml", 0) : new ListBox(widget, listModel, "popuplistbox.xml")), - mScrollArea(new ScrollArea(mListBox, false)), + mScrollArea(new ScrollArea(this, mListBox, false)), mDropDown(widget), mPressedIndex(-2), mModal(modal) diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index a1f597da8..b44b6a1a0 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -33,12 +33,14 @@ int ProgressBar::mInstances = 0; float ProgressBar::mAlpha = 1.0; -ProgressBar::ProgressBar(const Widget2 *const widget, float progress, - const int width, const int height, +ProgressBar::ProgressBar(const Widget2 *const widget, + float progress, + const int width, + const int height, const int backColor, - const std::string &skin, const std::string &skinFill): - gcn::Widget(), - Widget2(widget), + const std::string &skin, + const std::string &skinFill): + gcn::Widget(widget), WidgetListener(), mFillRect(), mSkin(nullptr), diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 86e314e16..1d4d83687 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -42,17 +42,19 @@ class Skin; * \ingroup GUI */ class ProgressBar final : public gcn::Widget, - public Widget2, public WidgetListener { public: /** * Constructor, initializes the progress with the given value. */ - ProgressBar(const Widget2 *const widget, float progress, - const int width, const int height, + ProgressBar(const Widget2 *const widget, + float progress, + const int width, + const int height, const int backColor, - const std::string &skin, const std::string &skinFill); + const std::string &skin, + const std::string &skinFill); A_DELETE_COPY(ProgressBar) diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 198094b6d..8d4cdd67c 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -29,8 +29,7 @@ #include "debug.h" ProgressIndicator::ProgressIndicator(Widget2 *const widget) : - gcn::Widget(), - Widget2(widget), + gcn::Widget(widget), mIndicator(nullptr) { ImageSet *const images = Theme::getImageSetFromTheme( diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index 7357931e9..08526c7c2 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -34,8 +34,7 @@ class SimpleAnimation; * A widget that indicates progress. Suitable to use instead of a progress bar * in cases where it is unknown how long something is going to take. */ -class ProgressIndicator final : public gcn::Widget, - public Widget2 +class ProgressIndicator final : public gcn::Widget { public: ProgressIndicator(Widget2 *const widget); diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 984d84d76..d52295b57 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -42,8 +42,7 @@ RadioButton::RadioButton(const Widget2 *const widget, const std::string &restrict caption, const std::string &restrict group, const bool marked): - gcn::RadioButton(caption, group, marked), - Widget2(widget), + gcn::RadioButton(widget, caption, group, marked), mPadding(0), mImagePadding(0), mImageSize(9), diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index 6c33447c4..faff6bc0e 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -34,8 +34,7 @@ class Skin; /** * Guichan based RadioButton with custom look */ -class RadioButton final : public gcn::RadioButton, - public Widget2 +class RadioButton final : public gcn::RadioButton { public: /** diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h index 0fd1f2605..d0bf18532 100644 --- a/src/gui/widgets/radiogroup.h +++ b/src/gui/widgets/radiogroup.h @@ -29,7 +29,8 @@ class RadioGroup final : public WidgetGroup { public: RadioGroup(const Widget2 *const widget, - const std::string &group, const int height, + const std::string &group, + const int height, const int spacing); A_DELETE_COPY(RadioGroup) diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 708949f9c..6dd2be526 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -45,36 +45,11 @@ static std::string const buttonFiles[2] = "scrollbuttons_pressed.xml" }; -ScrollArea::ScrollArea(Widget2 *const widget, - const bool opaque, - const std::string &skin) : - gcn::ScrollArea(), - Widget2(widget), - WidgetListener(), - mX(0), - mY(0), - mClickX(0), - mClickY(0), - mVertexes(new ImageCollection), - mVertexes2(new ImageCollection), - mXOffset(0), - mYOffset(0), - mDrawWidth(0), - mDrawHeight(0), - mHasMouse(false), - mRedraw(true) -{ - mOpaque = opaque; - addWidgetListener(this); - init(skin); -} - ScrollArea::ScrollArea(Widget2 *const widget2, gcn::Widget *const widget, const bool opaque, const std::string &skin) : - gcn::ScrollArea(widget), - Widget2(widget2), + gcn::ScrollArea(widget2, widget), WidgetListener(), mX(0), mY(0), diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index bc25baa27..bc652e296 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -44,27 +44,18 @@ class ImageCollection; * \ingroup GUI */ class ScrollArea final : public gcn::ScrollArea, - public Widget2, public WidgetListener { public: - /** - * Constructor that takes no content. Needed for use with the DropDown - * class. - */ - explicit ScrollArea(Widget2 *const widget, - const bool opaque = true, - const std::string &skin = ""); - /** * Constructor. * * @param content the initial content to show in the scroll area */ - explicit ScrollArea(Widget2 *const widget2, - gcn::Widget *const widget, - const bool opaque = true, - const std::string &skin = ""); + ScrollArea(Widget2 *const widget2, + gcn::Widget *const widget, + const bool opaque = true, + const std::string &skin = ""); A_DELETE_COPY(ScrollArea) diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 866dde6f1..5df0eafb0 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -29,8 +29,7 @@ float ShortcutContainer::mAlpha = 1.0; ShortcutContainer::ShortcutContainer(Widget2 *const widget) : - gcn::Widget(), - Widget2(widget), + gcn::Widget(widget), WidgetListener(), MouseListener(), mBackgroundImg(nullptr), diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 8df401775..610cfef1f 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -38,7 +38,6 @@ class ImageCollection; * \ingroup GUI */ class ShortcutContainer : public gcn::Widget, - public Widget2, public WidgetListener, public MouseListener { diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index c5988ff54..0c9b74202 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -45,8 +45,7 @@ static std::string const data[2] = Slider::Slider(Widget2 *const widget, const double scaleEnd) : - gcn::Slider(scaleEnd), - Widget2(widget), + gcn::Slider(widget, scaleEnd), mVertexes(new ImageCollection), mHasMouse(false), mRedraw(true) @@ -57,8 +56,7 @@ Slider::Slider(Widget2 *const widget, Slider::Slider(Widget2 *const widget, const double scaleStart, const double scaleEnd) : - gcn::Slider(scaleStart, scaleEnd), - Widget2(widget), + gcn::Slider(widget, scaleStart, scaleEnd), mVertexes(new ImageCollection), mHasMouse(false), mRedraw(true) diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index 27b03976d..d03799cae 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -36,8 +36,7 @@ class ImageCollection; * * \ingroup GUI */ -class Slider final : public gcn::Slider, - public Widget2 +class Slider final : public gcn::Slider { public: /** diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 0527486ad..af5892845 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -78,15 +78,14 @@ #include "debug.h" TabbedArea::TabbedArea(const Widget2 *const widget) : - Widget2(widget), ActionListener(), - gcn::BasicContainer(), + gcn::BasicContainer(widget), KeyListener(), MouseListener(), WidgetListener(), mSelectedTab(nullptr), - mTabContainer(new gcn::Container()), - mWidgetContainer(new gcn::Container()), + mTabContainer(new gcn::Container(widget)), + mWidgetContainer(new gcn::Container(widget)), mTabsToDelete(), mTabs(), mTabsWidth(0), diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 7ac24165b..1d0794c5c 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -83,8 +83,7 @@ class Tab; /** * A tabbed area, the same as the guichan tabbed area in 0.8, but extended */ -class TabbedArea final : public Widget2, - public ActionListener, +class TabbedArea final : public ActionListener, public gcn::BasicContainer, public KeyListener, public MouseListener, diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 331101209..283f1927e 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -50,12 +50,13 @@ static const unsigned int MAX_WORD_SIZE = 50; -ChatTab::ChatTab(const Widget2 *const widget, const std::string &name, +ChatTab::ChatTab(const Widget2 *const widget, + const std::string &name, const std::string &channel) : Tab(widget), mTextOutput(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")), - mScrollArea(new ScrollArea(mTextOutput, false)), + mScrollArea(new ScrollArea(this, mTextOutput, false)), mChannelName(channel), mAllowHightlight(true), mRemoveNames(false), diff --git a/src/gui/widgets/tabs/chattab.h b/src/gui/widgets/tabs/chattab.h index 651e69d6b..a46279483 100644 --- a/src/gui/widgets/tabs/chattab.h +++ b/src/gui/widgets/tabs/chattab.h @@ -58,7 +58,8 @@ class ChatTab : public Tab /** * Constructor. */ - ChatTab(const Widget2 *const widget, const std::string &name, + ChatTab(const Widget2 *const widget, + const std::string &name, const std::string &channel); A_DELETE_COPY(ChatTab) diff --git a/src/gui/widgets/tabs/guildchattab.h b/src/gui/widgets/tabs/guildchattab.h index fbfd3a032..cfcf901ca 100644 --- a/src/gui/widgets/tabs/guildchattab.h +++ b/src/gui/widgets/tabs/guildchattab.h @@ -28,7 +28,8 @@ /** * A tab for a guild chat channel. */ -class GuildChatTab final : public ChatTab, public ConfigListener +class GuildChatTab final : public ChatTab, + public ConfigListener { public: explicit GuildChatTab(const Widget2 *const widget); diff --git a/src/gui/widgets/tabs/langtab.cpp b/src/gui/widgets/tabs/langtab.cpp index fb6a5e12b..f5064be8c 100644 --- a/src/gui/widgets/tabs/langtab.cpp +++ b/src/gui/widgets/tabs/langtab.cpp @@ -26,7 +26,8 @@ #include "debug.h" -LangTab::LangTab(const Widget2 *const widget, const std::string &lang) : +LangTab::LangTab(const Widget2 *const widget, + const std::string &lang) : // TRANSLATORS: lang chat tab name ChatTab(widget, _("Lang"), lang + " ") { diff --git a/src/gui/widgets/tabs/langtab.h b/src/gui/widgets/tabs/langtab.h index 275b69399..e036e4dd8 100644 --- a/src/gui/widgets/tabs/langtab.h +++ b/src/gui/widgets/tabs/langtab.h @@ -26,7 +26,8 @@ class LangTab final : public ChatTab { public: - LangTab(const Widget2 *const widget, const std::string &lang); + LangTab(const Widget2 *const widget, + const std::string &lang); A_DELETE_COPY(LangTab) diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 8ea9d5fbb..2aaad6301 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -49,11 +49,12 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : SetupTab(widget), SelectionListener(), mColorBox(new ListBox(this, userPalette, "")), - mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")), + mScroll(new ScrollArea(this, mColorBox, + true, "setup_colors_background.xml")), mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")), mTextPreview(new TextPreview(this, gettext(rawmsg))), - mPreviewBox(new ScrollArea(mPreview, true, + mPreviewBox(new ScrollArea(this, mPreview, true, "setup_colors_preview_background.xml")), mSelected(-1), // TRANSLATORS: colors tab. label. diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 22bea9a75..72d05d966 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -103,7 +103,8 @@ Setup_Input::Setup_Input(const Widget2 *const widget) : // TRANSLATORS: button in input settings tab mResetKeysButton(new Button(this, _("Reset all keys"), "resetkeys", this)), mTabs(new TabStrip(this, config.getIntValue("fontSize") + 10)), - mScrollArea(new ScrollArea(mKeyList, true, "setup_input_background.xml")), + mScrollArea(new ScrollArea(this, mKeyList, + true, "setup_input_background.xml")), mKeySetting(false), mActionDataSize(new int [9]) { diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index d23ac565c..35bd2094a 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -249,7 +249,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) : mPlayerTableModel(new PlayerTableModel(this)), mPlayerTable(new GuiTable(this, mPlayerTableModel)), mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)), - mPlayerScrollArea(new ScrollArea(mPlayerTable)), + mPlayerScrollArea(new ScrollArea(this, mPlayerTable)), // TRANSLATORS: relation dialog button mDefaultTrading(new CheckBox(this, _("Allow trading"), player_relations.getDefault() & PlayerRelation::TRADE)), diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index be00937f2..d2ef01378 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -224,7 +224,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : // TRANSLATORS: video settings tab name setName(_("Video")); - ScrollArea *const scrollArea = new ScrollArea(mModeList, + ScrollArea *const scrollArea = new ScrollArea(this, mModeList, true, "setup_video_background.xml"); scrollArea->setWidth(150); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h index b385d0358..250fac0e0 100644 --- a/src/gui/widgets/tabs/setup_video.h +++ b/src/gui/widgets/tabs/setup_video.h @@ -37,7 +37,8 @@ class OpenGLListModel; class Slider; class TextDialog; -class Setup_Video final : public SetupTab, public KeyListener +class Setup_Video final : public SetupTab, + public KeyListener { public: explicit Setup_Video(const Widget2 *const widget); diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp index 9a37ced42..9c185b2bb 100644 --- a/src/gui/widgets/tabs/setuptabscroll.cpp +++ b/src/gui/widgets/tabs/setuptabscroll.cpp @@ -29,7 +29,7 @@ SetupTabScroll::SetupTabScroll(const Widget2 *const widget) : SetupTab(widget), mContainer(new VertContainer(this, 25, false, 8)), - mScroll(new ScrollArea(mContainer, false)), + mScroll(new ScrollArea(this, mContainer, false)), mItems(), mAllItems(), mPreferredFirstItemSize(200) diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 87bd8bde2..c1650e8a8 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -87,8 +87,7 @@ static std::string const data[Tab::TAB_COUNT] = Skin *Tab::tabImg[Tab::TAB_COUNT]; Tab::Tab(const Widget2 *const widget) : - gcn::BasicContainer(), - Widget2(widget), + gcn::BasicContainer(widget), MouseListener(), WidgetListener(), mLabel(new Label(this)), diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index c186a0b4e..878663e36 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -84,7 +84,6 @@ class TabbedArea; * A tab, the same as the Guichan tab in 0.8, but extended */ class Tab : public gcn::BasicContainer, - public Widget2, public MouseListener, public WidgetListener { diff --git a/src/gui/widgets/tabs/whispertab.cpp b/src/gui/widgets/tabs/whispertab.cpp index ec02bb70f..023d94110 100644 --- a/src/gui/widgets/tabs/whispertab.cpp +++ b/src/gui/widgets/tabs/whispertab.cpp @@ -34,7 +34,8 @@ #include "debug.h" -WhisperTab::WhisperTab(const Widget2 *const widget, const std::string &nick) : +WhisperTab::WhisperTab(const Widget2 *const widget, + const std::string &nick) : ChatTab(widget, nick, ""), mNick(nick) { diff --git a/src/gui/widgets/tabs/whispertab.h b/src/gui/widgets/tabs/whispertab.h index 5dbb05a4e..84b55ae58 100644 --- a/src/gui/widgets/tabs/whispertab.h +++ b/src/gui/widgets/tabs/whispertab.h @@ -57,7 +57,8 @@ class WhisperTab final : public ChatTab * * @param nick the name of the player this tab is whispering to */ - WhisperTab(const Widget2 *const widget, const std::string &nick); + WhisperTab(const Widget2 *const widget, + const std::string &nick); ~WhisperTab(); diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index ca31e393d..4a72d7ccd 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -25,14 +25,16 @@ #include "debug.h" TabStrip::TabStrip(const Widget2 *const widget, - const std::string &group, const int height, + const std::string &group, + const int height, const int spacing) : WidgetGroup(widget, group, height, spacing) { } TabStrip::TabStrip(const Widget2 *const widget, - const int height, const int spacing) : + const int height, + const int spacing) : WidgetGroup(widget, "", height, spacing) { } diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index 2e5ccfe34..57a178ff0 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -29,11 +29,13 @@ class TabStrip final : public WidgetGroup { public: TabStrip(const Widget2 *const widget, - const std::string &group, const int height, + const std::string &group, + const int height, const int spacing = 0); TabStrip(const Widget2 *const widget, - const int height, const int spacing = 0); + const int height, + const int spacing = 0); A_DELETE_COPY(TabStrip) diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 0ea05e585..729d40ead 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -33,8 +33,7 @@ #include "debug.h" TextBox::TextBox(const Widget2 *const widget) : - gcn::TextBox(), - Widget2(widget), + gcn::TextBox(widget), mMinWidth(getWidth()) { mForegroundColor = getThemeColor(Theme::TEXTBOX); diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 6b0429483..fe719faf8 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -36,8 +36,7 @@ * * \ingroup GUI */ -class TextBox final : public gcn::TextBox, - public Widget2 +class TextBox final : public gcn::TextBox { public: /** diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 4dd2f1c7b..eb1484449 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -54,9 +54,8 @@ TextField::TextField(const Widget2 *restrict const widget, ActionListener *restrict const listener, const std::string &restrict eventId, const bool sendAlwaysEvents): - gcn::TextField(text), + gcn::TextField(widget, text), FocusListener(), - Widget2(widget), mSendAlwaysEvents(sendAlwaysEvents), mCaretColor(&getThemeColor(Theme::CARET)), mPopupMenu(nullptr), diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index ed08de2fa..bfa721b7a 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -39,8 +39,7 @@ class PopupMenu; * \ingroup GUI */ class TextField : public gcn::TextField, - public FocusListener, - public Widget2 + public FocusListener { public: /** diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 2caf2e44c..1344c647a 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -35,8 +35,7 @@ Skin *TextPreview::mSkin = nullptr; TextPreview::TextPreview(const Widget2 *const widget, const std::string &text) : - gcn::Widget(), - Widget2(widget), + gcn::Widget(widget), mFont(gui->getFont()), mText(text), mTextColor(&getThemeColor(Theme::TEXT)), diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index cb524a974..532175a82 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -32,11 +32,11 @@ /** * Preview widget for particle colors, etc. */ -class TextPreview final : public gcn::Widget, - public Widget2 +class TextPreview final : public gcn::Widget { public: - TextPreview(const Widget2 *const widget, const std::string &text); + TextPreview(const Widget2 *const widget, + const std::string &text); A_DELETE_COPY(TextPreview) diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index e38ebb9af..9d596d620 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -24,7 +24,8 @@ #include "debug.h" VertContainer::VertContainer(const Widget2 *const widget, - const int verticalItemSize, const bool resizable, + const int verticalItemSize, + const bool resizable, const int leftSpacing) : Container(widget), WidgetListener(), diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 1d396efc9..5fb212b48 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -40,7 +40,8 @@ class VertContainer final : public Container, { public: VertContainer(const Widget2 *const widget, - const int verticalItemSize, const bool resizable = true, + const int verticalItemSize, + const bool resizable = true, const int leftSpacing = 0); A_DELETE_COPY(VertContainer) diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 3957fab30..4a0065ca8 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -23,7 +23,8 @@ #include "debug.h" WidgetGroup::WidgetGroup(const Widget2 *const widget, - const std::string &group, const int height, + const std::string &group, + const int height, const int spacing) : Container(widget), WidgetListener(), diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index b26d88d15..37523fcdc 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -54,7 +54,8 @@ class WidgetGroup : public Container, protected: WidgetGroup(const Widget2 *const widget, - const std::string &group, const int height, + const std::string &group, + const int height, const int spacing); int mSpacing; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 82c2d91f8..d26580fc2 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -48,8 +48,7 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, const bool modal, Window *const parent, std::string skin) : - gcn::Window(caption), - Widget2(nullptr), + gcn::Window(nullptr, caption), WidgetListener(), mSkin(nullptr), mDefaultX(0), diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index c6b2ca2cb..64963be3e 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -47,7 +47,6 @@ class WindowContainer; * \ingroup GUI */ class Window : public gcn::Window, - public Widget2, private WidgetListener { public: diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index e04174962..ade95eba5 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -263,7 +263,7 @@ BotCheckerWindow::BotCheckerWindow(): ActionListener(), mTableModel(new UsersTableModel(this)), mTable(new GuiTable(this, mTableModel)), - playersScrollArea(new ScrollArea(mTable, true, + playersScrollArea(new ScrollArea(this, mTable, true, "bochecker_background.xml")), mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)), diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index 4d2acfac9..cd593bf92 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -240,7 +240,7 @@ void BuyDialog::init() mShopItemList = new ShopListBox(this, mShopItems, mShopItems); mShopItemList->postInit(); - mScrollArea = new ScrollArea(mShopItemList, + mScrollArea = new ScrollArea(this, mShopItemList, getOptionBool("showbackground"), "buy_background.xml"); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 58e6d9c24..95d657772 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -51,7 +51,7 @@ DidYouKnowWindow::DidYouKnowWindow() : ActionListener(), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, "browserbox.xml")), - mScrollArea(new ScrollArea(mBrowserBox, + mScrollArea(new ScrollArea(this, mBrowserBox, true, "didyouknow_background.xml")), // TRANSLATORS: did you know window button mButtonPrev(new Button(this, _("< Previous"), "prev", this)), diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 0b31a410b..7457c7b1e 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -53,7 +53,8 @@ HelpWindow::HelpWindow() : mDYKButton(new Button(this, _("Did you know..."), "DYK", this)), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, "browserbox.xml")), - mScrollArea(new ScrollArea(mBrowserBox, true, "help_background.xml")), + mScrollArea(new ScrollArea(this, mBrowserBox, + true, "help_background.xml")), mTagFileMap() { setMinWidth(300); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index c95c2c54e..bc66f588c 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -182,8 +182,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory): mItems->addSelectionListener(this); - gcn::ScrollArea *const invenScroll = new ScrollArea( - mItems, getOptionBool("showbackground"), "inventory_background.xml"); + gcn::ScrollArea *const invenScroll = new ScrollArea(this, mItems, + getOptionBool("showbackground"), "inventory_background.xml"); invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); const int size = config.getIntValue("fontSize"); diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp index d1823d5cf..a1b2109fb 100644 --- a/src/gui/windows/npcdialog.cpp +++ b/src/gui/windows/npcdialog.cpp @@ -84,12 +84,12 @@ NpcDialog::NpcDialog(const int npcId) : mDefaultString(), mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")), - mScrollArea(new ScrollArea(mTextBox, + mScrollArea(new ScrollArea(this, mTextBox, getOptionBool("showtextbackground"), "npc_textbackground.xml")), mText(), mNewText(), mItemList(new ExtendedListBox(this, this, "extendedlistbox.xml")), - mListScrollArea(new ScrollArea(mItemList, + mListScrollArea(new ScrollArea(this, mItemList, getOptionBool("showlistbackground"), "npc_listbackground.xml")), mItems(), mImages(), @@ -111,7 +111,7 @@ NpcDialog::NpcDialog(const int npcId) : mResetButton(new Button(this, _("Reset"), "reset", this)), mInventory(new Inventory(Inventory::NPC, 1)), mItemContainer(new ItemContainer(this, mInventory)), - mItemScrollArea(new ScrollArea(mItemContainer, + mItemScrollArea(new ScrollArea(this, mItemContainer, getOptionBool("showitemsbackground"), "npc_listbackground.xml")), mInputState(NPC_INPUT_NONE), mActionState(NPC_ACTION_WAIT), diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp index 587f94ab2..23c21da0c 100644 --- a/src/gui/windows/npcpostdialog.cpp +++ b/src/gui/windows/npcpostdialog.cpp @@ -74,7 +74,7 @@ void NpcPostDialog::postInit() mText->setEditable(true); // create scroll box for letter text - ScrollArea *const scrollArea = new ScrollArea(mText); + ScrollArea *const scrollArea = new ScrollArea(this, mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); scrollArea->setDimension(gcn::Rectangle( 5, mSender->getHeight() + 5, diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 2e8c5dcc8..1a8749899 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -126,11 +126,11 @@ QuestsWindow::QuestsWindow() : mQuestsModel(new QuestsModel), mQuestsListBox(new ExtendedListBox(this, mQuestsModel, "extendedlistbox.xml")), - mQuestScrollArea(new ScrollArea(mQuestsListBox, + mQuestScrollArea(new ScrollArea(this, mQuestsListBox, getOptionBool("showlistbackground"), "quests_list_background.xml")), mItemLinkHandler(new ItemLinkHandler), mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true, "browserbox.xml")), - mTextScrollArea(new ScrollArea(mText, + mTextScrollArea(new ScrollArea(this, mText, getOptionBool("showtextbackground"), "quests_text_background.xml")), // TRANSLATORS: quests window button mCloseButton(new Button(this, _("Close"), "close", this)), diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index b79d18dcf..dc932ca69 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -86,7 +86,7 @@ void SellDialog::init() mShopItemList = new ShopListBox(this, mShopItems, mShopItems); mShopItemList->postInit(); mShopItemList->setProtectItems(true); - mScrollArea = new ScrollArea(mShopItemList, + mScrollArea = new ScrollArea(this, mShopItemList, getOptionBool("showbackground"), "sell_background.xml"); mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index fb2f5258b..6823c2649 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -292,7 +292,7 @@ ServerDialog::ServerDialog(ServerInfo *const serverInfo, mServersList->addMouseListener(this); - ScrollArea *const usedScroll = new ScrollArea(mServersList, + ScrollArea *const usedScroll = new ScrollArea(this, mServersList, getOptionBool("showbackground"), "server_background.xml"); usedScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 9e55af797..706438f61 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -79,9 +79,9 @@ ShopWindow::ShopWindow(): mSellShopItems(new ShopItems), mBuyShopItemList(new ShopListBox(this, mBuyShopItems, mBuyShopItems)), mSellShopItemList(new ShopListBox(this, mSellShopItems, mSellShopItems)), - mBuyScrollArea(new ScrollArea(mBuyShopItemList, + mBuyScrollArea(new ScrollArea(this, mBuyShopItemList, getOptionBool("showbuybackground"), "shop_buy_background.xml")), - mSellScrollArea(new ScrollArea(mSellShopItemList, + mSellScrollArea(new ScrollArea(this, mSellShopItemList, getOptionBool("showsellbackground"), "shop_sell_background.xml")), // TRANSLATORS: shop window label mBuyLabel(new Label(this, _("Buy items"))), diff --git a/src/gui/windows/shortcutwindow.cpp b/src/gui/windows/shortcutwindow.cpp index 50bc6fcd1..5b3c03e90 100644 --- a/src/gui/windows/shortcutwindow.cpp +++ b/src/gui/windows/shortcutwindow.cpp @@ -40,7 +40,8 @@ class ShortcutTab final : public Tab { public: ShortcutTab(const Widget2 *const widget, - std::string name, ShortcutContainer *const content) : + std::string name, + ShortcutContainer *const content) : Tab(widget), mContent(content) { @@ -58,7 +59,7 @@ ShortcutWindow::ShortcutWindow(const std::string &restrict title, int width, int height) : Window("Window", false, nullptr, skinFile), mItems(content), - mScrollArea(new ScrollArea(mItems, false)), + mScrollArea(new ScrollArea(this, mItems, false)), mTabs(nullptr), mPages() { @@ -160,7 +161,7 @@ ShortcutWindow::~ShortcutWindow() void ShortcutWindow::addTab(const std::string &name, ShortcutContainer *const content) { - ScrollArea *const scroll = new ScrollArea(content, false); + ScrollArea *const scroll = new ScrollArea(this, content, false); scroll->setPosition(SCROLL_PADDING, SCROLL_PADDING); scroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); content->setWidget2(this); diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 413f73226..9cc952ec6 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -59,7 +59,8 @@ class SkillListBox final : public ListBox { public: - SkillListBox(const Widget2 *const widget, SkillModel *const model) : + SkillListBox(const Widget2 *const widget, + SkillModel *const model) : ListBox(widget, model, "skilllistbox.xml"), mModel(model), mPopup(new TextPopup), @@ -241,7 +242,8 @@ class SkillTab final : public Tab { public: SkillTab(const Widget2 *const widget, - const std::string &name, SkillListBox *const listBox) : + const std::string &name, + SkillListBox *const listBox) : Tab(widget), mListBox(listBox) { @@ -541,7 +543,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName) SkillListBox *const listbox = new SkillListBox(this, model); listbox->setActionEventId("sel"); listbox->addActionListener(this); - ScrollArea *const scroll = new ScrollArea(listbox, false); + ScrollArea *const scroll = new ScrollArea(this, listbox, false); scroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); scroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 704bf0ca6..52ddc9439 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -173,7 +173,8 @@ class SocialGuildTab final : public SocialTab, public ActionListener { public: SocialGuildTab(const Widget2 *const widget, - Guild *const guild, const bool showBackground) : + Guild *const guild, + const bool showBackground) : SocialTab(widget), ActionListener(), mGuild(guild) @@ -191,7 +192,7 @@ public: mList = new AvatarListBox(this, guild); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -308,7 +309,8 @@ private: class SocialGuildTab2 final : public SocialTab, public ActionListener { public: - SocialGuildTab2(const Widget2 *const widget, Guild *const guild, + SocialGuildTab2(const Widget2 *const widget, + Guild *const guild, const bool showBackground) : SocialTab(widget), ActionListener() @@ -326,7 +328,7 @@ public: mList = new AvatarListBox(this, guild); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -376,7 +378,8 @@ class SocialPartyTab final : public SocialTab, public ActionListener { public: SocialPartyTab(const Widget2 *const widget, - Party *const party, const bool showBackground) : + Party *const party, + const bool showBackground) : SocialTab(widget), ActionListener(), mParty(party) @@ -394,7 +397,7 @@ public: mList = new AvatarListBox(this, party); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -538,13 +541,14 @@ class SocialPlayersTab final : public SocialTab { public: SocialPlayersTab(const Widget2 *const widget, - std::string name, const bool showBackground) : + std::string name, + const bool showBackground) : SocialTab(widget), mBeings(new BeingsListModal) { mList = new AvatarListBox(this, mBeings); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -710,7 +714,7 @@ public: { mList = new AvatarListBox(this, mBeings); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -1039,7 +1043,7 @@ public: { mList = new AvatarListBox(this, mBeings); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -1086,7 +1090,7 @@ public: { mList = new AvatarListBox(this, mBeings); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); @@ -1126,13 +1130,14 @@ class SocialFriendsTab final : public SocialTab { public: SocialFriendsTab(const Widget2 *const widget, - std::string name, const bool showBackground) : + std::string name, + const bool showBackground) : SocialTab(widget), mBeings(new BeingsListModal) { mList = new AvatarListBox(this, mBeings); mList->postInit(); - mScroll = new ScrollArea(mList, showBackground, + mScroll = new ScrollArea(this, mList, showBackground, "social_background.xml"); mScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_AUTO); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index 1279961e6..05172c9b3 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -159,9 +159,9 @@ StatusWindow::StatusWindow() : mJobLabel(nullptr), mJobBar(nullptr), mAttrCont(new VertContainer(this, 32)), - mAttrScroll(new ScrollArea(mAttrCont, false)), + mAttrScroll(new ScrollArea(this, mAttrCont, false)), mDAttrCont(new VertContainer(this, 32)), - mDAttrScroll(new ScrollArea(mDAttrCont, false)), + mDAttrScroll(new ScrollArea(this, mDAttrCont, false)), mCharacterPointsLabel(new Label(this, "C")), mCorrectionPointsLabel(nullptr), // TRANSLATORS: status window button diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index d94b78c34..25d077d5d 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -110,13 +110,14 @@ TradeWindow::TradeWindow(): mMyItemContainer->addSelectionListener(this); - ScrollArea *const myScroll = new ScrollArea(mMyItemContainer, + ScrollArea *const myScroll = new ScrollArea(this, mMyItemContainer, true, "trade_background.xml"); myScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); mPartnerItemContainer->addSelectionListener(this); - ScrollArea *const partnerScroll = new ScrollArea(mPartnerItemContainer, + ScrollArea *const partnerScroll = new ScrollArea(this, + mPartnerItemContainer, true, "trade_background.xml"); partnerScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 8e31939ff..e72308da7 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -190,7 +190,8 @@ UpdaterWindow::UpdaterWindow(const std::string &restrict updateHost, "updateprogressbar.xml", "updateprogressbar_fill.xml")), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, "browserbox.xml")), - mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")), + mScrollArea(new ScrollArea(this, mBrowserBox, + true, "update_background.xml")), mUpdateServerPath(mUpdateHost) { setWindowName("UpdaterWindow"); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 1af21866d..76f12f795 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -87,7 +87,7 @@ WhoIsOnline::WhoIsOnline() : mCurlError(new char[CURL_ERROR_SIZE]), mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true, "onlinebrowserbox.xml")), - mScrollArea(new ScrollArea(mBrowserBox, false)), + mScrollArea(new ScrollArea(this, mBrowserBox, false)), mUpdateTimer(0), mOnlinePlayers(), mOnlineNicks(), diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 0d861b85c..3c7602a70 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -93,7 +93,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): mChooseWorld(new Button(this, _("Choose World"), "world", this)) { mWorldList->postInit(); - ScrollArea *const worldsScroll = new ScrollArea(mWorldList, + ScrollArea *const worldsScroll = new ScrollArea(this, mWorldList, getOptionBool("showbackground"), "world_background.xml"); worldsScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); diff --git a/src/net/ea/gui/guildtab.h b/src/net/ea/gui/guildtab.h index 2b6a4bd1a..931b53397 100644 --- a/src/net/ea/gui/guildtab.h +++ b/src/net/ea/gui/guildtab.h @@ -31,7 +31,8 @@ namespace Ea /** * A tab for a guild chat channel. */ -class GuildTab : public ChatTab, public ConfigListener +class GuildTab : public ChatTab, + public ConfigListener { public: explicit GuildTab(const Widget2 *const widget); diff --git a/src/net/ea/gui/partytab.h b/src/net/ea/gui/partytab.h index d141452d0..6c61990dd 100644 --- a/src/net/ea/gui/partytab.h +++ b/src/net/ea/gui/partytab.h @@ -31,7 +31,8 @@ namespace Ea /** * A tab for a party chat channel. */ -class PartyTab : public ChatTab, public ConfigListener +class PartyTab : public ChatTab, + public ConfigListener { public: explicit PartyTab(const Widget2 *const widget); -- cgit v1.2.3-70-g09d2 From 50b5afdb7e68cdec8f77020b578dc3f6874933bb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 18 Feb 2014 23:45:53 +0300 Subject: fix compilation with SDL2. --- src/events/keyevent.h | 2 ++ src/gui/widgets/inttextfield.cpp | 2 +- src/gui/widgets/textfield.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/events/keyevent.h b/src/events/keyevent.h index f27851f0e..728cd79ea 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -67,6 +67,8 @@ #include "events/inputguievent.h" #include "input/key.h" +#include + namespace gcn { class Widget; diff --git a/src/gui/widgets/inttextfield.cpp b/src/gui/widgets/inttextfield.cpp index 6d8eed228..160cfe5de 100644 --- a/src/gui/widgets/inttextfield.cpp +++ b/src/gui/widgets/inttextfield.cpp @@ -71,7 +71,7 @@ void IntTextField::keyPressed(KeyEvent &event) if (val != Key::TEXTINPUT) return; - const std::string str = event->getText(); + const std::string str = event.getText(); if (str.empty()) return; const size_t sz = str.size(); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index eb1484449..226d9172c 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -201,7 +201,7 @@ void TextField::keyPressed(KeyEvent &keyEvent) #ifdef USE_SDL2 if (val == Key::TEXTINPUT) { - std::string str = keyEvent->getText(); + std::string str = keyEvent.getText(); mText.insert(mCaretPosition, str); mCaretPosition += str.size(); keyEvent.consume(); -- cgit v1.2.3-70-g09d2 From 26f9aad24bc50d4e9fd161d185df049c9e7a62cf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 19 Feb 2014 01:18:16 +0300 Subject: improve includes. --- src/actionmanager.cpp | 4 +--- src/being/actorsprite.cpp | 3 +++ src/being/being.cpp | 1 + src/being/being.h | 10 +++++++--- src/being/localplayer.cpp | 5 +++-- src/being/playerrelations.cpp | 2 ++ src/being/playerrelations.h | 3 +-- src/client.cpp | 3 ++- src/commandhandler.cpp | 2 ++ src/commandhandler.h | 5 +++-- src/configuration.cpp | 1 + src/defaults.cpp | 1 + src/defaults.h | 4 ++-- src/events/actionevent.h | 6 +++--- src/events/event.h | 6 +++--- src/events/inputguievent.h | 6 +++--- src/events/keyevent.h | 6 +++--- src/events/mouseevent.h | 6 +++--- src/events/selectionevent.h | 6 +++--- src/graphicsvertexes.h | 4 +++- src/gui/base/basiccontainer.cpp | 2 -- src/gui/base/basiccontainer.hpp | 3 +-- src/gui/base/gui.cpp | 5 ----- src/gui/base/gui.hpp | 1 - src/gui/base/rectangle.hpp | 3 +++ src/gui/base/widget.cpp | 7 ------- src/gui/base/widget.hpp | 4 +--- src/gui/base/widgets/button.cpp | 5 ----- src/gui/base/widgets/button.hpp | 2 -- src/gui/base/widgets/checkbox.cpp | 7 ------- src/gui/base/widgets/checkbox.hpp | 2 +- src/gui/base/widgets/container.hpp | 6 +----- src/gui/base/widgets/listbox.cpp | 8 -------- src/gui/base/widgets/radiobutton.cpp | 7 ------- src/gui/base/widgets/radiobutton.hpp | 2 +- src/gui/base/widgets/scrollarea.cpp | 3 --- src/gui/base/widgets/scrollarea.hpp | 2 -- src/gui/base/widgets/slider.cpp | 5 ----- src/gui/base/widgets/textbox.cpp | 5 ----- src/gui/base/widgets/textbox.hpp | 1 - src/gui/base/widgets/textfield.cpp | 5 ----- src/gui/base/widgets/window.cpp | 4 ---- src/gui/focushandler.cpp | 2 ++ src/gui/font.cpp | 1 - src/gui/gui.cpp | 2 ++ src/gui/gui.h | 3 +-- src/gui/popups/beingpopup.cpp | 1 + src/gui/popups/itempopup.cpp | 1 + src/gui/popups/itempopup.h | 1 + src/gui/popups/popupmenu.cpp | 2 ++ src/gui/popups/popupmenu.h | 1 + src/gui/popups/speechbubble.cpp | 2 +- src/gui/popups/spellpopup.cpp | 1 + src/gui/sdlinput.h | 7 +++---- src/gui/widgets/browserbox.h | 2 -- src/gui/widgets/button.cpp | 2 ++ src/gui/widgets/button.h | 2 -- src/gui/widgets/characterdisplay.cpp | 5 +++-- src/gui/widgets/characterdisplay.h | 8 +++++--- src/gui/widgets/characterviewnormal.cpp | 1 - src/gui/widgets/characterviewsmall.cpp | 2 ++ src/gui/widgets/characterviewsmall.h | 2 ++ src/gui/widgets/checkbox.cpp | 1 + src/gui/widgets/checkbox.h | 2 -- src/gui/widgets/container.cpp | 2 ++ src/gui/widgets/container.h | 2 -- src/gui/widgets/dropdown.cpp | 1 + src/gui/widgets/dropdown.h | 7 ++++++- src/gui/widgets/dropshortcutcontainer.h | 2 +- src/gui/widgets/emotepage.h | 2 -- src/gui/widgets/emoteshortcutcontainer.cpp | 2 ++ src/gui/widgets/emoteshortcutcontainer.h | 6 +++--- src/gui/widgets/guitable.cpp | 4 ++-- src/gui/widgets/icon.cpp | 2 ++ src/gui/widgets/icon.h | 2 -- src/gui/widgets/itemcontainer.h | 2 -- src/gui/widgets/label.cpp | 1 + src/gui/widgets/layout.cpp | 2 ++ src/gui/widgets/layout.h | 8 ++++++-- src/gui/widgets/layouthelper.cpp | 2 ++ src/gui/widgets/listbox.h | 2 -- src/gui/widgets/playerbox.cpp | 2 ++ src/gui/widgets/progressbar.h | 2 -- src/gui/widgets/progressindicator.cpp | 2 ++ src/gui/widgets/progressindicator.h | 4 +--- src/gui/widgets/radiobutton.cpp | 1 + src/gui/widgets/radiobutton.h | 2 -- src/gui/widgets/scrollarea.cpp | 4 ++++ src/gui/widgets/scrollarea.h | 2 -- src/gui/widgets/setupitem.cpp | 4 ++++ src/gui/widgets/setupitem.h | 8 ++++++-- src/gui/widgets/setuptouchitem.cpp | 2 ++ src/gui/widgets/shortcutcontainer.cpp | 2 ++ src/gui/widgets/shortcutcontainer.h | 2 -- src/gui/widgets/slider.cpp | 2 ++ src/gui/widgets/slider.h | 2 -- src/gui/widgets/sliderlist.cpp | 2 ++ src/gui/widgets/sliderlist.h | 7 +++++-- src/gui/widgets/spellshortcutcontainer.cpp | 1 - src/gui/widgets/tabbedarea.cpp | 2 ++ src/gui/widgets/tabbedarea.h | 2 -- src/gui/widgets/tabs/chattab.cpp | 1 + src/gui/widgets/tabs/setup_audio.h | 2 ++ src/gui/widgets/tabs/setup_colors.cpp | 1 + src/gui/widgets/tabs/setup_colors.h | 2 -- src/gui/widgets/tabs/setup_input.cpp | 1 + src/gui/widgets/tabs/setup_relations.h | 2 ++ src/gui/widgets/tabs/setup_theme.cpp | 2 ++ src/gui/widgets/tabs/setup_touch.cpp | 2 ++ src/gui/widgets/tabs/setup_touch.h | 5 ++++- src/gui/widgets/tabs/setup_visual.h | 2 ++ src/gui/widgets/tabs/tab.cpp | 4 ++++ src/gui/widgets/tabs/tab.h | 2 -- src/gui/widgets/textbox.cpp | 1 + src/gui/widgets/textbox.h | 2 -- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textpreview.h | 2 -- src/gui/widgets/widget2.h | 1 - src/gui/widgets/window.h | 2 -- src/gui/windowmenu.cpp | 2 ++ src/gui/windowmenu.h | 4 ++-- src/gui/windows/buydialog.h | 1 - src/gui/windows/charcreatedialog.cpp | 1 + src/gui/windows/charcreatedialog.h | 4 +++- src/gui/windows/charselectdialog.cpp | 1 + src/gui/windows/charselectdialog.h | 1 - src/gui/windows/chatwindow.cpp | 3 +-- src/gui/windows/didyouknowwindow.cpp | 5 +++-- src/gui/windows/helpwindow.cpp | 5 +++-- src/gui/windows/inventorywindow.cpp | 3 +++ src/gui/windows/inventorywindow.h | 1 - src/gui/windows/itemamountwindow.cpp | 2 ++ src/gui/windows/npcdialog.h | 1 - src/gui/windows/questswindow.cpp | 3 ++- src/gui/windows/serverdialog.cpp | 4 +++- src/gui/windows/serverdialog.h | 2 +- src/gui/windows/setupwindow.cpp | 1 + src/gui/windows/textcommandeditor.cpp | 2 ++ src/gui/windows/tradewindow.cpp | 1 + src/input/inputmanager.cpp | 4 ++-- src/input/key.h | 2 +- src/input/mouseinput.h | 6 +++--- src/input/multitouchmanager.h | 2 ++ src/listeners/actionlistener.h | 6 +++--- src/listeners/deathlistener.h | 6 +++--- src/listeners/focuslistener.h | 6 +++--- src/listeners/keylistener.h | 6 +++--- src/listeners/mouselistener.h | 6 +++--- src/listeners/playerrelationslistener.h | 6 +++--- src/listeners/selectionlistener.h | 6 +++--- src/listeners/widgetlistener.h | 6 +++--- src/logger.cpp | 3 ++- src/maplayer.cpp | 1 + src/net/ea/buysellhandler.cpp | 2 -- src/net/ea/charserverhandler.cpp | 1 + src/net/ea/charserverhandler.h | 9 +++++++-- src/net/ea/chathandler.cpp | 2 ++ src/net/ea/chathandler.h | 6 +++++- src/net/ea/gamehandler.cpp | 2 ++ src/net/ea/gamehandler.h | 6 +++++- src/net/ea/gui/guildtab.cpp | 3 +-- src/net/ea/guildhandler.cpp | 4 ++++ src/net/ea/guildhandler.h | 7 +++++-- src/net/ea/inventoryhandler.cpp | 2 ++ src/net/ea/inventoryhandler.h | 6 +++++- src/net/ea/itemhandler.cpp | 2 ++ src/net/ea/itemhandler.h | 7 +++++++ src/net/ea/loginhandler.cpp | 2 ++ src/net/ea/loginhandler.h | 6 +++++- src/net/ea/npchandler.cpp | 2 ++ src/net/ea/npchandler.h | 8 +++++++- src/net/ea/partyhandler.cpp | 5 +++++ src/net/ea/partyhandler.h | 9 ++++++--- src/net/ea/playerhandler.cpp | 1 + src/net/ea/playerhandler.h | 6 +++++- src/net/ea/skillhandler.cpp | 2 ++ src/net/ea/skillhandler.h | 8 +++++++- src/net/ea/tradehandler.cpp | 1 + src/net/ea/tradehandler.h | 6 +++++- src/net/eathena/chathandler.cpp | 3 +-- src/net/eathena/chathandler.h | 2 +- src/net/eathena/generalhandler.cpp | 1 + src/net/eathena/network.cpp | 1 + src/net/eathena/network.h | 3 +-- src/net/eathena/partyhandler.cpp | 1 + src/net/tmwa/chathandler.cpp | 3 +-- src/net/tmwa/chathandler.h | 2 +- src/net/tmwa/generalhandler.cpp | 1 + src/net/tmwa/network.cpp | 1 + src/net/tmwa/network.h | 3 +-- src/net/tmwa/partyhandler.cpp | 1 + src/net/tmwa/pethandler.cpp | 3 +-- src/net/tradehandler.h | 2 ++ src/render/sdlgraphics.cpp | 2 ++ src/simpleanimation.cpp | 1 - src/statuseffect.cpp | 3 +++ src/statuseffect.h | 7 ++++--- src/touchmanager.cpp | 2 ++ src/touchmanager.h | 3 +-- src/utils/files.cpp | 1 - src/utils/paths.cpp | 2 ++ src/utils/sdlpixel.h | 6 +++--- src/utils/translation/poparser.cpp | 2 ++ src/utils/translation/poparser.h | 4 ++-- src/utils/xml.h | 2 +- 205 files changed, 376 insertions(+), 278 deletions(-) (limited to 'src') diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp index 473e6cbc7..b8ea34286 100644 --- a/src/actionmanager.cpp +++ b/src/actionmanager.cpp @@ -31,10 +31,9 @@ #include "being/playerinfo.h" #include "being/playerrelations.h" -#include "events/inputevent.h" - #include "input/inputmanager.h" +#include "gui/gui.h" #include "gui/sdlinput.h" #include "gui/viewport.h" @@ -45,7 +44,6 @@ #include "gui/windows/questswindow.h" #include "gui/windows/quitdialog.h" #include "gui/windows/whoisonline.h" - #include "gui/windows/botcheckerwindow.h" #include "gui/windows/buyselldialog.h" #include "gui/windows/chatwindow.h" diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index a74f4f477..bbb016525 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -21,6 +21,7 @@ #include "being/actorsprite.h" +#include "animatedsprite.h" #include "configuration.h" #include "imagesprite.h" #include "statuseffect.h" @@ -31,6 +32,8 @@ #include "listeners/actorspritelistener.h" +#include "particle/particle.h" + #include "resources/resourcemanager.h" #include "utils/checkutils.h" diff --git a/src/being/being.cpp b/src/being/being.cpp index 1fcccb0cf..76af509d3 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -40,6 +40,7 @@ #include "particle/particleinfo.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/popups/speechbubble.h" diff --git a/src/being/being.h b/src/being/being.h index c8da2d97c..afa023068 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -23,12 +23,10 @@ #ifndef BEING_BEING_H #define BEING_BEING_H -#include "equipment.h" +//#include "equipment.h" #include "resources/beinginfo.h" -#include "gui/base/color.hpp" - #include #include "localconsts.h" @@ -45,6 +43,7 @@ static const int DEFAULT_BEING_HEIGHT = 32; class AnimatedSprite; class BeingCacheEntry; +class Equipment; class FlashText; class Guild; class ItemInfo; @@ -55,6 +54,11 @@ class Text; struct ParticleInfo; +namespace gcn +{ + class Color; +} + extern volatile int cur_time; enum Gender diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 0e57eabfe..2a3c5fa2f 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -23,6 +23,7 @@ #include "being/localplayer.h" #include "actormanager.h" +#include "animatedsprite.h" #include "client.h" #include "configuration.h" #include "dropshortcut.h" @@ -42,7 +43,6 @@ #include "input/keyboardconfig.h" -#include "gui/font.h" #include "gui/gui.h" #include "gui/viewport.h" @@ -51,7 +51,6 @@ #include "gui/windows/okdialog.h" #include "gui/windows/outfitwindow.h" #include "gui/windows/shopwindow.h" -#include "gui/windows/skilldialog.h" #include "gui/windows/socialwindow.h" #include "gui/windows/updaterwindow.h" @@ -85,6 +84,8 @@ typedef std::map::const_iterator GuildMapCIter; LocalPlayer *player_node = nullptr; +class SkillDialog; + extern std::list beingInfoCache; extern OkDialog *weightNotice; extern int weightNoticeTime; diff --git a/src/being/playerrelations.cpp b/src/being/playerrelations.cpp index a04c77e76..4404791ca 100644 --- a/src/being/playerrelations.cpp +++ b/src/being/playerrelations.cpp @@ -30,6 +30,8 @@ #include "utils/dtor.h" #include "utils/gettext.h" +#include "listeners/playerrelationslistener.h" + #include #include "debug.h" diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h index cddec5f10..3543d4221 100644 --- a/src/being/playerrelations.h +++ b/src/being/playerrelations.h @@ -25,14 +25,13 @@ #include "utils/stringvector.h" -#include "listeners/playerrelationslistener.h" - #include #include #include "localconsts.h" class Being; +class PlayerRelationsListener; struct PlayerRelation final { diff --git a/src/client.cpp b/src/client.cpp index 0fac5b3f2..a08406d10 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -85,6 +85,8 @@ #include "net/netconsts.h" #include "net/partyhandler.h" +#include "particle/particle.h" + #include "resources/imagehelper.h" #include "resources/openglimagehelper.h" #include "resources/surfaceimagehelper.h" @@ -112,7 +114,6 @@ #include "utils/files.h" #include "utils/fuzzer.h" #include "utils/gettext.h" -#include "utils/files.h" #include "utils/mkdir.h" #include "utils/paths.h" #include "utils/physfstools.h" diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 6d3881432..ef8acc26c 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -22,6 +22,8 @@ #include "commandhandler.h" +#include "commands.h" + #include "input/inputmanager.h" #include "gui/widgets/tabs/chattab.h" diff --git a/src/commandhandler.h b/src/commandhandler.h index de1561d74..b2b74d77d 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -23,15 +23,16 @@ #ifndef COMMANDHANDLER_H #define COMMANDHANDLER_H -#include "commands.h" - #include +#include #include #include "localconsts.h" class ChatTab; +struct CommandInfo; + extern ChatTab *localChatTab; typedef std::map CommandsMap; diff --git a/src/configuration.cpp b/src/configuration.cpp index 7d6fc43fd..ed2adfc61 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -23,6 +23,7 @@ #include "configuration.h" #include "logger.h" +#include "variabledata.h" #include "listeners/configlistener.h" diff --git a/src/defaults.cpp b/src/defaults.cpp index c343f9f11..7a110a539 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -22,6 +22,7 @@ #include "defaults.h" #include "graphicsmanager.h" +#include "variabledata.h" #include "being/being.h" diff --git a/src/defaults.h b/src/defaults.h index e4ba4d5ae..abc9eb50c 100644 --- a/src/defaults.h +++ b/src/defaults.h @@ -22,13 +22,13 @@ #ifndef DEFAULTS_H #define DEFAULTS_H -#include "variabledata.h" - #include #include #include "localconsts.h" +class VariableData; + typedef std::map DefaultsData; VariableData* createData(const int defData) A_WARN_UNUSED; diff --git a/src/events/actionevent.h b/src/events/actionevent.h index 70ed0f398..3164955e6 100644 --- a/src/events/actionevent.h +++ b/src/events/actionevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_ACTIONEVENT_HPP -#define EVENTS_ACTIONEVENT_HPP +#ifndef EVENTS_ACTIONEVENT_H +#define EVENTS_ACTIONEVENT_H #include "events/event.h" @@ -136,4 +136,4 @@ class ActionEvent final : public Event std::string mId; }; -#endif // EVENTS_ACTIONEVENT_HPP +#endif // EVENTS_ACTIONEVENT_H diff --git a/src/events/event.h b/src/events/event.h index d62dd672b..b71d0edd4 100644 --- a/src/events/event.h +++ b/src/events/event.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_EVENT_HPP -#define EVENTS_EVENT_HPP +#ifndef EVENTS_EVENT_H +#define EVENTS_EVENT_H #include "localconsts.h" @@ -114,4 +114,4 @@ class Event gcn::Widget* mSource; }; -#endif // EVENTS_EVENT_HPP +#endif // EVENTS_EVENT_H diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h index a2aefc35f..8523959ed 100644 --- a/src/events/inputguievent.h +++ b/src/events/inputguievent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_INPUTEVENT_HPP -#define EVENTS_INPUTEVENT_HPP +#ifndef EVENTS_INPUTGUIEVENT_H +#define EVENTS_INPUTGUIEVENT_H #include "events/event.h" @@ -184,4 +184,4 @@ class InputGuiEvent: public Event bool mIsConsumed; }; -#endif // EVENTS_INPUTEVENT_HPP +#endif // EVENTS_INPUTGUIEVENT_H diff --git a/src/events/keyevent.h b/src/events/keyevent.h index 728cd79ea..c0c950639 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_KEYEVENT_HPP -#define EVENTS_KEYEVENT_HPP +#ifndef EVENTS_KEYEVENT_H +#define EVENTS_KEYEVENT_H #include "events/inputguievent.h" #include "input/key.h" @@ -191,4 +191,4 @@ class KeyEvent: public InputGuiEvent bool mIsNumericPad; }; -#endif // EVENTS_KEYEVENT_HPP +#endif // EVENTS_KEYEVENT_H diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index 9284822ba..9378faac6 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_MOUSEEVENT_HPP -#define EVENTS_MOUSEEVENT_HPP +#ifndef EVENTS_MOUSEEVENT_H +#define EVENTS_MOUSEEVENT_H #include "events/inputguievent.h" @@ -237,4 +237,4 @@ class MouseEvent: public InputGuiEvent friend class gcn::Gui; }; -#endif // EVENTS_MOUSEEVENT_HPP +#endif // EVENTS_MOUSEEVENT_H diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h index fc030cab0..b2e91e04f 100644 --- a/src/events/selectionevent.h +++ b/src/events/selectionevent.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef EVENTS_SELECTIONEVENT_HPP -#define EVENTS_SELECTIONEVENT_HPP +#ifndef EVENTS_SELECTIONEVENT_H +#define EVENTS_SELECTIONEVENT_H #include "events/event.h" @@ -98,4 +98,4 @@ class SelectionEvent final: public Event { } }; -#endif // EVENTS_SELECTIONEVENT_HPP +#endif // EVENTS_SELECTIONEVENT_H diff --git a/src/graphicsvertexes.h b/src/graphicsvertexes.h index 15256113f..8746bcce3 100644 --- a/src/graphicsvertexes.h +++ b/src/graphicsvertexes.h @@ -38,10 +38,12 @@ #endif -#include "resources/image.h" +#include #include +class Image; + struct DoubleRect final { SDL_Rect src; diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 05d89f172..edc465726 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -71,8 +71,6 @@ #include "gui/focushandler.h" -#include "input/mouseinput.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp index cc3aee808..fd28ef7b6 100644 --- a/src/gui/base/basiccontainer.hpp +++ b/src/gui/base/basiccontainer.hpp @@ -64,7 +64,6 @@ #ifndef GCN_BASICCONTAINER_HPP #define GCN_BASICCONTAINER_HPP -#include #include #include "gui/base/widget.hpp" @@ -85,7 +84,7 @@ namespace gcn public DeathListener { public: - BasicContainer(const Widget2 *const widget) : + explicit BasicContainer(const Widget2 *const widget) : Widget(widget), DeathListener(), mWidgets() diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index f62e24260..d5b23e960 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -67,20 +67,15 @@ #include "gui/base/gui.hpp" -#include "gui/base/basiccontainer.hpp" #include "gui/base/widget.hpp" #include "gui/focushandler.h" -#include "gui/sdlinput.h" -#include "input/keyinput.h" #include "input/mouseinput.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index f614c00fd..391a0520e 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -68,7 +68,6 @@ #include #include "events/keyevent.h" -#include "events/mouseevent.h" #include "input/mouseinput.h" diff --git a/src/gui/base/rectangle.hpp b/src/gui/base/rectangle.hpp index b8503db98..299ce99b9 100644 --- a/src/gui/base/rectangle.hpp +++ b/src/gui/base/rectangle.hpp @@ -95,6 +95,9 @@ namespace gcn */ Rectangle(const int x, const int y, const int width, const int height); + virtual ~Rectangle() + { } + /** * Sets the dimension of a rectangle. * diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp index f5994d1af..692ea479c 100644 --- a/src/gui/base/widget.cpp +++ b/src/gui/base/widget.cpp @@ -71,17 +71,10 @@ #include "events/event.h" -#include "gui/base/basiccontainer.hpp" - #include "gui/focushandler.h" -#include "input/keyinput.h" -#include "input/mouseinput.h" - #include "listeners/actionlistener.h" #include "listeners/deathlistener.h" -#include "listeners/keylistener.h" -#include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" #include "render/graphics.h" diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 013ead3b8..6245d3c98 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -89,8 +89,6 @@ class WidgetListener; namespace gcn { - class BasicContainer; - /** * Abstract class for widgets of Guichan. It contains basic functions * every widget should have. @@ -110,7 +108,7 @@ namespace gcn * focusable as default, therefore, widgets that are supposed to be * focusable should overide this default in their own constructor. */ - Widget(const Widget2 *const widget); + explicit Widget(const Widget2 *const widget); A_DELETE_COPY(Widget) diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index e4285cffd..5187c625b 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -67,11 +67,6 @@ #include "gui/base/widgets/button.hpp" -#include "gui/font.h" - -#include "input/key.h" -#include "input/mouseinput.h" - #include "events/mouseevent.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index 7fd5613bd..fea175362 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -70,8 +70,6 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "events/mouseevent.h" - #include "gui/base/widget.hpp" #include "render/graphics.h" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index d75fb5cb0..a5ec72dfa 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -67,13 +67,6 @@ #include "gui/base/widgets/checkbox.hpp" -#include "gui/font.h" - -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index d87a6b206..c79ccaff9 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -90,7 +90,7 @@ namespace gcn /** * Contructor. */ - CheckBox(const Widget2 *const widget); + explicit CheckBox(const Widget2 *const widget); /** * Constructor. The check box will be automatically resized diff --git a/src/gui/base/widgets/container.hpp b/src/gui/base/widgets/container.hpp index ba3cff153..3e6c0a587 100644 --- a/src/gui/base/widgets/container.hpp +++ b/src/gui/base/widgets/container.hpp @@ -64,12 +64,8 @@ #ifndef GCN_CONTAINER_HPP #define GCN_CONTAINER_HPP -#include - #include "gui/base/basiccontainer.hpp" -#include "render/graphics.h" - namespace gcn { /** @@ -89,7 +85,7 @@ namespace gcn * * @see setOpaque, isOpaque */ - Container(const Widget2 *const widget); + explicit Container(const Widget2 *const widget); /** * Destructor. diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 0dd5c88f7..02d94626c 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -69,16 +69,8 @@ #include "gui/font.h" -#include "gui/base/basiccontainer.hpp" -#include "gui/base/listmodel.hpp" - -#include "input/key.h" -#include "input/mouseinput.h" - #include "listeners/selectionlistener.h" -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index 832c00bbe..e17b9f776 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -67,13 +67,6 @@ #include "gui/base/widgets/radiobutton.hpp" -#include "gui/font.h" - -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index 4d4403fac..f4bfd53fa 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -93,7 +93,7 @@ namespace gcn /** * Constructor. */ - RadioButton(const Widget2 *const widget); + explicit RadioButton(const Widget2 *const widget); /** * Constructor. The radio button will be automatically resized diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index 68e1b72d3..0fc605fa3 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -67,9 +67,6 @@ #include "gui/base/widgets/scrollarea.hpp" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp index e2d8aada5..669ccfbdd 100644 --- a/src/gui/base/widgets/scrollarea.hpp +++ b/src/gui/base/widgets/scrollarea.hpp @@ -64,8 +64,6 @@ #ifndef GCN_SCROLLAREA_HPP #define GCN_SCROLLAREA_HPP -#include - #include "gui/base/basiccontainer.hpp" #include "listeners/mouselistener.h" diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index e995ff55a..4e9df0341 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -67,11 +67,6 @@ #include "gui/base/widgets/slider.hpp" -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 7a5b63a50..bb22a6f46 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -69,11 +69,6 @@ #include "gui/font.h" -#include "gui/base/basiccontainer.hpp" - -#include "input/key.h" -#include "input/mouseinput.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 0c96096ec..151af8c00 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -64,7 +64,6 @@ #ifndef GCN_TEXTBOX_HPP #define GCN_TEXTBOX_HPP -#include #include #include diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index 6ca37c4af..ddcbec1b4 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -69,11 +69,6 @@ #include "gui/font.h" -#include "input/key.h" -#include "input/mouseinput.h" - -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp index 0ead95bc1..401e3ab6d 100644 --- a/src/gui/base/widgets/window.cpp +++ b/src/gui/base/widgets/window.cpp @@ -67,10 +67,6 @@ #include "gui/base/widgets/window.hpp" -#include "gui/font.h" - -#include "input/mouseinput.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 22153c91f..0d45b6432 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -69,6 +69,8 @@ #include "gui/widgets/window.h" +#include "listeners/focuslistener.h" + #include "debug.h" FocusHandler::FocusHandler() : diff --git a/src/gui/font.cpp b/src/gui/font.cpp index a154d8c54..fcc8e8344 100644 --- a/src/gui/font.cpp +++ b/src/gui/font.cpp @@ -77,7 +77,6 @@ #include "resources/surfaceimagehelper.h" #include "utils/paths.h" -#include "utils/physfsrwops.h" #include "utils/sdlcheckutils.h" #include "utils/stringutils.h" #include "utils/timer.h" diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 243b3817e..fdaa299af 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -40,6 +40,8 @@ #include "events/keyevent.h" +#include "listeners/focuslistener.h" + #include "input/keydata.h" #include "input/keyinput.h" #include "input/mouseinput.h" diff --git a/src/gui/gui.h b/src/gui/gui.h index aacd33946..f6b4fbbf6 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -26,10 +26,9 @@ #include "gui/base/color.hpp" #include "gui/base/gui.hpp" -#include "listeners/focuslistener.h" - #include "localconsts.h" +class FocusListener; class Graphics; class GuiConfigListener; class ImageSet; diff --git a/src/gui/popups/beingpopup.cpp b/src/gui/popups/beingpopup.cpp index 32aa11454..07d4b064a 100644 --- a/src/gui/popups/beingpopup.cpp +++ b/src/gui/popups/beingpopup.cpp @@ -25,6 +25,7 @@ #include "being/playerrelations.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/itempopup.cpp b/src/gui/popups/itempopup.cpp index d6ea5a48a..0a65ce3bc 100644 --- a/src/gui/popups/itempopup.cpp +++ b/src/gui/popups/itempopup.cpp @@ -28,6 +28,7 @@ #include "units.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/icon.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/itempopup.h b/src/gui/popups/itempopup.h index 714e0305c..f1cedf046 100644 --- a/src/gui/popups/itempopup.h +++ b/src/gui/popups/itempopup.h @@ -29,6 +29,7 @@ #include "resources/iteminfo.h" class Icon; +class Item; class Label; class TextBox; diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 450bd504f..a37994884 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -23,6 +23,7 @@ #include "gui/popups/popupmenu.h" #include "actormanager.h" +#include "commands.h" #include "commandhandler.h" #include "configuration.h" #include "dropshortcut.h" @@ -56,6 +57,7 @@ #include "gui/viewport.h" +#include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/tabs/chattab.h" #include "gui/widgets/progressbar.h" diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 1ebb0dd89..70f8b7885 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -29,6 +29,7 @@ #include "being/actorsprite.h" #include "listeners/actionlistener.h" + #include "gui/base/listmodel.hpp" #include "localconsts.h" diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index c74f3f5e6..9bb6157bc 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -24,11 +24,11 @@ #include "gui/popups/speechbubble.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/viewport.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" -#include "gui/widgets/textbox.h" #include "debug.h" diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index 141879da4..8849a53cb 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -24,6 +24,7 @@ #include "gui/popups/spellpopup.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/label.h" diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 8a9128920..29cb5ce1f 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -75,11 +75,10 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GUI_INPUT_H -#define GUI_INPUT_H +#ifndef GUI_SDLINPUT_H +#define GUI_SDLINPUT_H #include "input/keyinput.h" -#include "input/mouseinput.h" #include @@ -163,4 +162,4 @@ protected: bool mMouseInWindow; }; -#endif // GUI_INPUT_H +#endif // GUI_SDLINPUT_H diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 23f221e63..1f09dd0b1 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -24,8 +24,6 @@ #ifndef GUI_WIDGETS_BROWSERBOX_H #define GUI_WIDGETS_BROWSERBOX_H -#include "gui/widgets/widget2.h" - #include "listeners/mouselistener.h" #include "gui/base/widget.hpp" diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index a9b621d90..d7871503e 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -29,9 +29,11 @@ #include "input/keydata.h" +#include "resources/image.h" #include "resources/imageset.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 73c0d70eb..4f2e9fd89 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_BUTTON_H #define GUI_WIDGETS_BUTTON_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/button.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp index bdd740874..7bfc938de 100644 --- a/src/gui/widgets/characterdisplay.cpp +++ b/src/gui/widgets/characterdisplay.cpp @@ -24,6 +24,8 @@ #include "units.h" +#include "gui/gui.h" + #include "gui/windows/charselectdialog.h" #include "gui/popups/textpopup.h" @@ -32,8 +34,7 @@ #include "gui/widgets/layouthelper.h" #include "utils/gettext.h" - -#include +#include "utils/stringutils.h" #include "debug.h" diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h index 8571363c3..8f9acf462 100644 --- a/src/gui/widgets/characterdisplay.h +++ b/src/gui/widgets/characterdisplay.h @@ -26,9 +26,6 @@ #include "gui/widgets/container.h" #include "gui/widgets/playerbox.h" -#include "net/charserverhandler.h" -#include "net/net.h" - #include "listeners/widgetlistener.h" #include "localconsts.h" @@ -37,6 +34,11 @@ class CharSelectDialog; class Label; class TextPopup; +namespace Net +{ + struct Character; +} + class CharacterDisplay final : public Container, public MouseListener, public WidgetListener diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp index 75481268b..1df98d85e 100644 --- a/src/gui/widgets/characterviewnormal.cpp +++ b/src/gui/widgets/characterviewnormal.cpp @@ -23,7 +23,6 @@ #include "configuration.h" #include "gui/widgets/characterdisplay.h" -#include "gui/widgets/characterviewsmall.h" #include "debug.h" diff --git a/src/gui/widgets/characterviewsmall.cpp b/src/gui/widgets/characterviewsmall.cpp index eda1e4a71..4d2c93b48 100644 --- a/src/gui/widgets/characterviewsmall.cpp +++ b/src/gui/widgets/characterviewsmall.cpp @@ -24,6 +24,8 @@ #include "gui/widgets/characterdisplay.h" #include "gui/widgets/label.h" +#include "utils/stringutils.h" + #include "debug.h" CharacterViewSmall::CharacterViewSmall(CharSelectDialog *const widget, diff --git a/src/gui/widgets/characterviewsmall.h b/src/gui/widgets/characterviewsmall.h index 17a549718..a9f6d7f9b 100644 --- a/src/gui/widgets/characterviewsmall.h +++ b/src/gui/widgets/characterviewsmall.h @@ -25,6 +25,8 @@ #include "localconsts.h" +class Label; + class CharacterViewSmall final : public CharacterViewBase { public: diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index e500815c0..63e32a0f9 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -31,6 +31,7 @@ #include "resources/image.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/checkbox.h b/src/gui/widgets/checkbox.h index e05ab29d3..28eadb75c 100644 --- a/src/gui/widgets/checkbox.h +++ b/src/gui/widgets/checkbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_CHECKBOX_H #define GUI_WIDGETS_CHECKBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/checkbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 3c048d630..2d8aad965 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/container.h" +#include "gui/gui.h" + #include "debug.h" Container::Container(const Widget2 *const widget) : diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index efddb1566..36d7cce86 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_CONTAINER_H #define GUI_WIDGETS_CONTAINER_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/container.hpp" /** diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 86170036c..6189af75e 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -34,6 +34,7 @@ #include "resources/image.h" #include "gui/font.h" +#include "gui/gui.h" #include diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index b638a2a05..a1908a3c6 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -26,7 +26,7 @@ #include "gui/widgets/widget2.h" #include "gui/base/basiccontainer.hpp" -#include "gui/base/listmodel.hpp" +//#include "gui/base/listmodel.hpp" #include "listeners/actionlistener.h" #include "listeners/focuslistener.h" @@ -43,6 +43,11 @@ class PopupList; class ScrollArea; class Skin; +namespace gcn +{ + class ListModel; +} + /** * A drop down box from which you can select different values. * diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index dbaac1d9c..236415b32 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -38,7 +38,7 @@ class DropShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - DropShortcutContainer(Widget2 *const widget); + explicit DropShortcutContainer(Widget2 *const widget); A_DELETE_COPY(DropShortcutContainer) diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 8eb1e5f7b..8a508bd26 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -21,8 +21,6 @@ #ifndef GUI_WIDGETS_EMOTEPAGE_H #define GUI_WIDGETS_EMOTEPAGE_H -#include "gui/widgets/widget2.h" - #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index 47c45c2dd..296f21126 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -34,6 +34,8 @@ #include "resources/image.h" +#include "resources/db/emotedb.h" + #include "debug.h" static const int MAX_ITEMS = 48; diff --git a/src/gui/widgets/emoteshortcutcontainer.h b/src/gui/widgets/emoteshortcutcontainer.h index ec0e98675..a3061441f 100644 --- a/src/gui/widgets/emoteshortcutcontainer.h +++ b/src/gui/widgets/emoteshortcutcontainer.h @@ -24,12 +24,12 @@ #include "gui/widgets/shortcutcontainer.h" -#include "resources/db/emotedb.h" - #include class TextPopup; +struct EmoteSprite; + /** * An emote shortcut container. Used to quickly use emoticons. * @@ -41,7 +41,7 @@ class EmoteShortcutContainer final : public ShortcutContainer /** * Constructor. Initializes the graphic. */ - EmoteShortcutContainer(Widget2 *const widget); + explicit EmoteShortcutContainer(Widget2 *const widget); A_DELETE_COPY(EmoteShortcutContainer) diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 84bc19e0e..324d4b23e 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -24,6 +24,8 @@ #include "client.h" +#include "gui/gui.h" + #include "events/keyevent.h" #include "input/keydata.h" @@ -32,8 +34,6 @@ #include "listeners/actionlistener.h" -#include "input/key.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 73607c048..73c0db76c 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/icon.h" +#include "gui/gui.h" + #include "resources/image.h" #include "resources/resourcemanager.h" diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index 9dc4827ac..dffdb8e8c 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_ICON_H #define GUI_WIDGETS_ICON_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 76dd51ef7..ab813b08f 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_ITEMCONTAINER_H #define GUI_WIDGETS_ITEMCONTAINER_H -#include "gui/widgets/widget2.h" - #include "listeners/keylistener.h" #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 73e3bca64..0c19d03c3 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/label.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index d9a818e0f..f16f40322 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -24,6 +24,8 @@ #include "logger.h" +#include "gui/base/widgets/container.hpp" + #include #include "debug.h" diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 013963bfa..85998d8e7 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -25,12 +25,16 @@ #include "localconsts.h" -#include "gui/base/widgets/container.hpp" - #include class LayoutCell; +namespace gcn +{ + class Container; + class Widget; +} + /** * This class is a helper for adding widgets to nested tables in a window. */ diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 066cabaf8..7b8a428a9 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/layouthelper.h" +#include "gui/base/widgets/container.hpp" + #include "debug.h" LayoutHelper::LayoutHelper(gcn::Container *const container) : diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index cd20ea50a..f1ebee317 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_LISTBOX_H #define GUI_WIDGETS_LISTBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/listbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 976a1c8f9..7ef543511 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -26,6 +26,8 @@ #include "being/being.h" +#include "gui/gui.h" + #include "resources/image.h" #include "debug.h" diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index 1d4d83687..a2c55e077 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_PROGRESSBAR_H #define GUI_WIDGETS_PROGRESSBAR_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index 8d4cdd67c..f5b295ec8 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -23,6 +23,8 @@ #include "simpleanimation.h" +#include "gui/gui.h" + #include "resources/animation.h" #include "resources/imageset.h" diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index 08526c7c2..e62e7ec90 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -22,8 +22,6 @@ #ifndef GUI_WIDGETS_PROGRESSINDICATOR_H #define GUI_WIDGETS_PROGRESSINDICATOR_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "localconsts.h" @@ -37,7 +35,7 @@ class SimpleAnimation; class ProgressIndicator final : public gcn::Widget { public: - ProgressIndicator(Widget2 *const widget); + explicit ProgressIndicator(Widget2 *const widget); A_DELETE_COPY(ProgressIndicator) diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index d52295b57..7b5c5fa11 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -31,6 +31,7 @@ #include "resources/image.h" #include "gui/font.h" +#include "gui/gui.h" #include "debug.h" diff --git a/src/gui/widgets/radiobutton.h b/src/gui/widgets/radiobutton.h index faff6bc0e..2deb9a772 100644 --- a/src/gui/widgets/radiobutton.h +++ b/src/gui/widgets/radiobutton.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_RADIOBUTTON_H #define GUI_WIDGETS_RADIOBUTTON_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/radiobutton.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 6dd2be526..0cadee888 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -25,6 +25,10 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/gui.h" + +#include "resources/image.h" + #include "debug.h" int ScrollArea::instances = 0; diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index bc652e296..39a7eea80 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_SCROLLAREA_H #define GUI_WIDGETS_SCROLLAREA_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/scrollarea.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 649388d04..1f5d48d06 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -25,9 +25,11 @@ #include "soundmanager.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/editdialog.h" +#include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/horizontcontainer.h" @@ -37,6 +39,8 @@ #include "gui/widgets/sliderlist.h" #include "gui/widgets/vertcontainer.h" +#include "gui/widgets/tabs/setuptabscroll.h" + #include "utils/base64.h" #include "utils/gettext.h" #include "utils/mathutils.h" diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index b5261e2f4..87b7c46f9 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -21,14 +21,17 @@ #ifndef GUI_WIDGETS_SETUPITEM_H #define GUI_WIDGETS_SETUPITEM_H -#include "gui/widgets/button.h" -#include "gui/widgets/tabs/setuptabscroll.h" +//#include "gui/widgets/button.h" +//#include "gui/widgets/tabs/setuptabscroll.h" + +#include "gui/widgets/widget2.h" #include "listeners/actionlistener.h" #include #include +class Button; class CheckBox; class Configuration; class DropDown; @@ -36,6 +39,7 @@ class EditDialog; class HorizontContainer; class IntTextField; class Label; +class SetupTabScroll; class Slider; class SliderList; class TextField; diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index b080de428..f4c213b2f 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -27,6 +27,8 @@ #include "gui/widgets/label.h" #include "gui/widgets/vertcontainer.h" +#include "gui/widgets/tabs/setuptabscroll.h" + #include #include "debug.h" diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 5df0eafb0..0482281ed 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -24,6 +24,8 @@ #include "graphicsvertexes.h" +#include "gui/gui.h" + #include "debug.h" float ShortcutContainer::mAlpha = 1.0; diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 610cfef1f..115298081 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_SHORTCUTCONTAINER_H #define GUI_WIDGETS_SHORTCUTCONTAINER_H -#include "gui/widgets/widget2.h" - #include "listeners/mouselistener.h" #include "gui/base/widget.hpp" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 0c9b74202..c785f4016 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -29,6 +29,8 @@ #include "input/keydata.h" +#include "gui/gui.h" + #include "resources/image.h" #include "debug.h" diff --git a/src/gui/widgets/slider.h b/src/gui/widgets/slider.h index d03799cae..2f21127d1 100644 --- a/src/gui/widgets/slider.h +++ b/src/gui/widgets/slider.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_SLIDER_H #define GUI_WIDGETS_SLIDER_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/slider.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index 93a6934ba..c5791f1c2 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -23,6 +23,8 @@ #include "gui/font.h" #include "gui/gui.h" +#include "gui/base/listmodel.hpp" + #include "gui/widgets/button.h" #include "gui/widgets/label.h" diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 785ada74b..9adba8080 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -21,8 +21,6 @@ #ifndef GUI_WIDGETS_SLIDERLIST_H #define GUI_WIDGETS_SLIDERLIST_H -#include "gui/base/listmodel.hpp" - #include "listeners/actionlistener.h" #include "listeners/mouselistener.h" @@ -33,6 +31,11 @@ class Button; class Label; +namespace gcn +{ + class ListModel; +} + class SliderList final : public Container, public ActionListener, public MouseListener diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 5441c4d8a..768206bdb 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -32,7 +32,6 @@ #include "gui/popups/spellpopup.h" -#include "gui/windows/inventorywindow.h" #include "gui/windows/shortcutwindow.h" #include "resources/image.h" diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index af5892845..879ac8ec0 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -69,6 +69,8 @@ #include "input/keydata.h" +#include "gui/gui.h" + #include "gui/widgets/button.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabs/tab.h" diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 1d0794c5c..a95438605 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -66,8 +66,6 @@ #ifndef GUI_WIDGETS_TABBEDAREA_H #define GUI_WIDGETS_TABBEDAREA_H -#include "gui/widgets/widget2.h" - #include "listeners/keylistener.h" #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 283f1927e..b74dc53b8 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -24,6 +24,7 @@ #include "chatlogger.h" #include "client.h" +#include "commands.h" #include "commandhandler.h" #include "configuration.h" #include "soundconsts.h" diff --git a/src/gui/widgets/tabs/setup_audio.h b/src/gui/widgets/tabs/setup_audio.h index 839734b39..aaadebf32 100644 --- a/src/gui/widgets/tabs/setup_audio.h +++ b/src/gui/widgets/tabs/setup_audio.h @@ -25,6 +25,8 @@ #include "gui/widgets/setupitem.h" +#include "gui/widgets/tabs/setuptabscroll.h" + class Setup_Audio final : public SetupTabScroll { public: diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 2aaad6301..9e78133f5 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -22,6 +22,7 @@ #include "gui/widgets/tabs/setup_colors.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/userpalette.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h index 8864db7db..ce491706c 100644 --- a/src/gui/widgets/tabs/setup_colors.h +++ b/src/gui/widgets/tabs/setup_colors.h @@ -26,8 +26,6 @@ #include "listeners/selectionlistener.h" -#include - class BrowserBox; class Label; class ListBox; diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 72d05d966..03c8f31e3 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -28,6 +28,7 @@ #include "input/inputmanager.h" #include "input/keyboardconfig.h" +#include "gui/gui.h" #include "gui/setupactiondata.h" #include "gui/windows/okdialog.h" diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h index 55da0bedc..e32889008 100644 --- a/src/gui/widgets/tabs/setup_relations.h +++ b/src/gui/widgets/tabs/setup_relations.h @@ -27,6 +27,8 @@ #include "gui/widgets/tabs/setuptab.h" +#include "listeners/playerrelationslistener.h" + class Button; class CheckBox; class DropDown; diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index fd70b9158..d27a095d5 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -22,6 +22,8 @@ #include "gui/widgets/tabs/setup_theme.h" +#include "gui/gui.h" + #include "gui/windows/okdialog.h" #include "gui/widgets/button.h" diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index 5d995f914..2baae029e 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -21,6 +21,8 @@ #include "gui/widgets/tabs/setup_touch.h" #include "gui/widgets/layouthelper.h" +#include "gui/widgets/namesmodel.h" +#include "gui/widgets/setuptouchitem.h" #include "gui/widgets/scrollarea.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/setup_touch.h b/src/gui/widgets/tabs/setup_touch.h index 9adc2d5cd..ef1afdda3 100644 --- a/src/gui/widgets/tabs/setup_touch.h +++ b/src/gui/widgets/tabs/setup_touch.h @@ -21,7 +21,10 @@ #ifndef GUI_WIDGETS_TABS_SETUP_TOUCH_H #define GUI_WIDGETS_TABS_SETUP_TOUCH_H -#include "gui/widgets/setuptouchitem.h" +#include "gui/widgets/tabs/setuptabscroll.h" + +class NamesModel; +class TouchActionsModel; class Setup_Touch final : public SetupTabScroll { diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h index 2d40d3a08..1229757dd 100644 --- a/src/gui/widgets/tabs/setup_visual.h +++ b/src/gui/widgets/tabs/setup_visual.h @@ -24,6 +24,8 @@ #include "gui/widgets/setupitem.h" +#include "gui/widgets/tabs/setuptabscroll.h" + class NamesModel; class Setup_Visual final : public SetupTabScroll diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index c1650e8a8..2d91129f2 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -68,9 +68,13 @@ #include "client.h" #include "graphicsvertexes.h" +#include "gui/gui.h" + #include "gui/widgets/label.h" #include "gui/widgets/tabbedarea.h" +#include "resources/image.h" + #include "debug.h" int Tab::mInstances = 0; diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 878663e36..463a6b668 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -66,8 +66,6 @@ #ifndef GUI_WIDGETS_TABS_TAB_H #define GUI_WIDGETS_TABS_TAB_H -#include "gui/widgets/widget2.h" - #include "gui/base/basiccontainer.hpp" #include "listeners/mouselistener.h" diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 729d40ead..ec0d09a26 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -27,6 +27,7 @@ #include "input/keydata.h" #include "gui/font.h" +#include "gui/gui.h" #include diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index fe719faf8..24dd57adb 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_TEXTBOX_H #define GUI_WIDGETS_TEXTBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/textbox.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 226d9172c..c30045c02 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -29,7 +29,7 @@ #include "events/keyevent.h" #include "gui/font.h" -#include "gui/sdlinput.h" +#include "gui/gui.h" #include "gui/viewport.h" #include "gui/popups/popupmenu.h" diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 532175a82..31f64f545 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_TEXTPREVIEW_H #define GUI_WIDGETS_TEXTPREVIEW_H -#include "gui/widgets/widget2.h" - #include "gui/base/widget.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index a57ccbb41..c6317702f 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -21,7 +21,6 @@ #ifndef GUI_WIDGETS_WIDGET2_H #define GUI_WIDGETS_WIDGET2_H -#include "gui/gui.h" #include "gui/theme.h" #include "render/renderers.h" diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 64963be3e..37a9900ee 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -25,8 +25,6 @@ #include "render/graphics.h" -#include "gui/widgets/widget2.h" - #include "listeners/widgetlistener.h" #include "gui/base/widgets/window.hpp" diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 4417f18a6..27418b892 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -35,6 +35,8 @@ #include "gui/specialswindow.h" #endif +#include "gui/widgets/button.h" + #include "utils/dtor.h" #include "utils/gettext.h" diff --git a/src/gui/windowmenu.h b/src/gui/windowmenu.h index 1f2d8adb2..a1ed66a7d 100644 --- a/src/gui/windowmenu.h +++ b/src/gui/windowmenu.h @@ -26,9 +26,9 @@ #include "listeners/configlistener.h" #include "gui/widgets/container.h" -#include "gui/widgets/button.h" #include "listeners/actionlistener.h" +#include "listeners/mouselistener.h" #include "listeners/selectionlistener.h" #include "localconsts.h" @@ -36,8 +36,8 @@ #include #include +class Button; class TextPopup; -class Window; struct ButtonInfo final { diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h index 500f378ef..aa163d5d0 100644 --- a/src/gui/windows/buydialog.h +++ b/src/gui/windows/buydialog.h @@ -35,7 +35,6 @@ class ShopListBox; class SortListModelBuy; class IntTextField; class Label; -class ListBox; class ScrollArea; class Slider; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index d6b572d40..fb407b9cc 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -31,6 +31,7 @@ #include "gui/windows/okdialog.h" #include "gui/widgets/button.h" +#include "gui/windows/charselectdialog.h" #include "gui/widgets/label.h" #include "gui/widgets/playerbox.h" #include "gui/widgets/radiobutton.h" diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index 123d826f2..12ddf7970 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -25,11 +25,13 @@ #include "being/being.h" -#include "gui/windows/charselectdialog.h" +#include "gui/widgets/window.h" #include "listeners/actionlistener.h" #include "listeners/keylistener.h" +class Button; +class CharSelectDialog; class Label; class PlayerBox; class RadioButton; diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 7c6e387a4..12a78ce10 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -44,6 +44,7 @@ #include "net/logindata.h" #include "net/loginhandler.h" +#include "net/net.h" #include "utils/gettext.h" diff --git a/src/gui/windows/charselectdialog.h b/src/gui/windows/charselectdialog.h index 348811ee3..38c307f30 100644 --- a/src/gui/windows/charselectdialog.h +++ b/src/gui/windows/charselectdialog.h @@ -35,7 +35,6 @@ class Button; class CharacterDisplay; class CharacterViewBase; -class Label; class LoginData; class TextDialog; diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 45a76495b..565d3644a 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -40,8 +40,7 @@ #include "input/inputmanager.h" #include "gui/focushandler.h" -#include "gui/font.h" -#include "gui/sdlinput.h" +#include "gui/gui.h" #include "gui/viewport.h" #include "gui/windows/emotewindow.h" diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp index 95d657772..79ad4c208 100644 --- a/src/gui/windows/didyouknowwindow.cpp +++ b/src/gui/windows/didyouknowwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/setupwindow.h" @@ -78,7 +78,8 @@ DidYouKnowWindow::DidYouKnowWindow() : Button *const okButton = new Button(this, _("Close"), "close", this); mBrowserBox->setLinkHandler(this); - mBrowserBox->setFont(gui->getHelpFont()); + if (gui) + mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVersion(true); mBrowserBox->setEnableImages(true); mBrowserBox->setEnableKeys(true); diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp index 7457c7b1e..fa9963217 100644 --- a/src/gui/windows/helpwindow.cpp +++ b/src/gui/windows/helpwindow.cpp @@ -24,7 +24,7 @@ #include "configuration.h" -#include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/didyouknowwindow.h" #include "gui/windows/setupwindow.h" @@ -73,7 +73,8 @@ HelpWindow::HelpWindow() : mBrowserBox->setOpaque(false); mBrowserBox->setLinkHandler(this); - mBrowserBox->setFont(gui->getHelpFont()); + if (gui) + mBrowserBox->setFont(gui->getHelpFont()); mBrowserBox->setProcessVersion(true); mBrowserBox->setEnableImages(true); mBrowserBox->setEnableKeys(true); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index bc66f588c..603b1b26d 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -33,8 +33,11 @@ #include "input/inputmanager.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/viewport.h" +#include "gui/base/listmodel.hpp" + #include "gui/popups/textpopup.h" #include "gui/windows/equipmentwindow.h" diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h index 6a6999034..c81e83d77 100644 --- a/src/gui/windows/inventorywindow.h +++ b/src/gui/windows/inventorywindow.h @@ -37,7 +37,6 @@ class Button; class DropDown; class Item; class ItemContainer; -class Label; class LayoutCell; class ProgressBar; class SortListModelInv; diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index 8e981ae96..c63157e27 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -33,6 +33,8 @@ #include "net/net.h" #include "gui/viewport.h" +#include "gui/base/listmodel.hpp" + #include "gui/popups/itempopup.h" #include "gui/windows/shopwindow.h" diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index b7b036659..b9fa1aab8 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -45,7 +45,6 @@ class ItemContainer; class NpcDialog; class PlayerBox; class ScrollArea; -class TextBox; class TextField; typedef std::map NpcDialogs; diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 1a8749899..d62ca36ad 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -27,6 +27,7 @@ #include "being/localplayer.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -166,7 +167,7 @@ QuestsWindow::QuestsWindow() : mText->setLinkHandler(mItemLinkHandler); mTextScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); mQuestsListBox->setWidth(500); - if (gui->getNpcFont()->getHeight() < 20) + if (gui && gui->getNpcFont()->getHeight() < 20) mQuestsListBox->setRowHeight(20); else mQuestsListBox->setRowHeight(gui->getNpcFont()->getHeight()); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 6823c2649..a06257b10 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -32,7 +32,9 @@ #include "input/keydata.h" #include "gui/font.h" +#include "gui/gui.h" +#include "gui/widgets/checkbox.h" #include "gui/windows/editserverdialog.h" #include "gui/windows/logindialog.h" @@ -132,7 +134,7 @@ void ServersListModel::setVersionString(const int index, if (index < 0 || index >= static_cast(mVersionStrings.size())) return; - if (version.empty()) + if (version.empty() || !gui) { mVersionStrings[index] = VersionString(0, ""); } diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 112c8001d..3f63562f7 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -24,7 +24,6 @@ #define GUI_WINDOWS_SERVERDIALOG_H #include "gui/widgets/window.h" -#include "gui/widgets/checkbox.h" #include "net/download.h" #include "net/serverinfo.h" @@ -41,6 +40,7 @@ #include class Button; +class CheckBox; class Label; class ListBox; class ServerDialog; diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index a996d776b..9878807d9 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -44,6 +44,7 @@ #include "gui/widgets/tabs/setup_video.h" #include "gui/widgets/tabs/setup_visual.h" +#include "gui/widgets/button.h" #include "gui/widgets/label.h" #include "gui/widgets/tabbedarea.h" diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 98b9cae60..82d1c9ef6 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -27,6 +27,8 @@ #include "input/keyboardconfig.h" +#include "gui/base/listmodel.hpp" + #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/inttextfield.h" diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 25d077d5d..7fe1a1e36 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -32,6 +32,7 @@ #include "being/playerrelations.h" #include "gui/font.h" +#include "gui/gui.h" #include "gui/windows/inventorywindow.h" #include "gui/windows/itemamountwindow.h" diff --git a/src/input/inputmanager.cpp b/src/input/inputmanager.cpp index d19130e7c..5d157f0fa 100644 --- a/src/input/inputmanager.cpp +++ b/src/input/inputmanager.cpp @@ -28,7 +28,6 @@ #include "input/keyboardconfig.h" #include "input/keyboarddata.h" #include "being/localplayer.h" -#include "being/playerinfo.h" #ifdef USE_SDL2 #include "input/multitouchmanager.h" #endif @@ -47,7 +46,6 @@ #include "gui/windows/setupwindow.h" #include "gui/windows/textdialog.h" #include "gui/windows/tradewindow.h" -#include "gui/windows/quitdialog.h" #include "utils/timer.h" @@ -59,6 +57,8 @@ InputManager inputManager; +class QuitDialog; + extern QuitDialog *quitDialog; static class KeyFunctor final diff --git a/src/input/key.h b/src/input/key.h index fa48d3583..97bc7113d 100644 --- a/src/input/key.h +++ b/src/input/key.h @@ -194,4 +194,4 @@ class Key final int mValue; }; -#endif // end GCN_KEY_HPP +#endif // INPUT_KEY_H diff --git a/src/input/mouseinput.h b/src/input/mouseinput.h index 5ece1f77a..a90a1366d 100644 --- a/src/input/mouseinput.h +++ b/src/input/mouseinput.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef MOUSEINPUT_H -#define MOUSEINPUT_H +#ifndef INPUT_MOUSEINPUT_H +#define INPUT_MOUSEINPUT_H #include "input/mouseinput.h" @@ -213,4 +213,4 @@ class MouseInput final int mRealY; }; -#endif // MOUSEINPUT_H +#endif // INPUT_MOUSEINPUT_H diff --git a/src/input/multitouchmanager.h b/src/input/multitouchmanager.h index 076ccb3a8..82bfd0881 100644 --- a/src/input/multitouchmanager.h +++ b/src/input/multitouchmanager.h @@ -25,7 +25,9 @@ #include "localconsts.h" +#ifdef USE_SDL2 union SDL_Event; +#endif struct MultiTouchEvent { diff --git a/src/listeners/actionlistener.h b/src/listeners/actionlistener.h index b22e5abc6..895cc985d 100644 --- a/src/listeners/actionlistener.h +++ b/src/listeners/actionlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_ACTIONLISTENER_HPP -#define LISTENERS_ACTIONLISTENER_HPP +#ifndef LISTENERS_ACTIONLISTENER_H +#define LISTENERS_ACTIONLISTENER_H #include @@ -106,4 +106,4 @@ class ActionListener { } }; -#endif // end LISTENERS_ACTIONLISTENER_HPP +#endif // LISTENERS_ACTIONLISTENER_H diff --git a/src/listeners/deathlistener.h b/src/listeners/deathlistener.h index beefe1746..ddd7db910 100644 --- a/src/listeners/deathlistener.h +++ b/src/listeners/deathlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_DEATHLISTENER_HPP -#define LISTENERS_DEATHLISTENER_HPP +#ifndef LISTENERS_DEATHLISTENER_H +#define LISTENERS_DEATHLISTENER_H #include @@ -103,4 +103,4 @@ class DeathListener { } }; -#endif // LISTENERS_DEATHLISTENER_HPP +#endif // LISTENERS_DEATHLISTENER_H diff --git a/src/listeners/focuslistener.h b/src/listeners/focuslistener.h index c910f833e..10e4a2af0 100644 --- a/src/listeners/focuslistener.h +++ b/src/listeners/focuslistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_FOCUSLISTENER_HPP -#define LISTENERS_FOCUSLISTENER_HPP +#ifndef LISTENERS_FOCUSLISTENER_H +#define LISTENERS_FOCUSLISTENER_H #include @@ -113,4 +113,4 @@ class FocusListener { } }; -#endif // LISTENERS_FOCUSLISTENER_HPP +#endif // LISTENERS_FOCUSLISTENER_H diff --git a/src/listeners/keylistener.h b/src/listeners/keylistener.h index 0873de835..efc387300 100644 --- a/src/listeners/keylistener.h +++ b/src/listeners/keylistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_KEYLISTENER_HPP -#define GCN_KEYLISTENER_HPP +#ifndef LISTENERS_KEYLISTENER_H +#define LISTENERS_KEYLISTENER_H #include "events/keyevent.h" @@ -113,4 +113,4 @@ class KeyListener { } }; -#endif // end GCN_KEYLISTENER_HPP +#endif // LISTENERS_KEYLISTENER_H diff --git a/src/listeners/mouselistener.h b/src/listeners/mouselistener.h index d294e4dd6..9a2a4ef04 100644 --- a/src/listeners/mouselistener.h +++ b/src/listeners/mouselistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_MOUSELISTENER_HPP -#define GCN_MOUSELISTENER_HPP +#ifndef LISTENERS_MOUSELISTENER_H +#define LISTENERS_MOUSELISTENER_H #include "events/mouseevent.h" @@ -190,4 +190,4 @@ class MouseListener { } }; -#endif // end GCN_MOUSELISTENER_HPP +#endif // LISTENERS_MOUSELISTENER_H diff --git a/src/listeners/playerrelationslistener.h b/src/listeners/playerrelationslistener.h index b95f18c33..6a8bf3b20 100644 --- a/src/listeners/playerrelationslistener.h +++ b/src/listeners/playerrelationslistener.h @@ -20,8 +20,8 @@ * along with this program. If not, see . */ -#ifndef LISTERNERS_PLAYERRELATIONSLISTENER_H -#define LISTERNERS_PLAYERRELATIONSLISTENER_H +#ifndef LISTENERS_PLAYERRELATIONSLISTENER_H +#define LISTENERS_PLAYERRELATIONSLISTENER_H #include @@ -40,4 +40,4 @@ class PlayerRelationsListener { } }; -#endif // LISTERNERS_PLAYERRELATIONSLISTENER_H +#endif // LISTENERS_PLAYERRELATIONSLISTENER_H diff --git a/src/listeners/selectionlistener.h b/src/listeners/selectionlistener.h index d3be0f0eb..2efe0a67e 100644 --- a/src/listeners/selectionlistener.h +++ b/src/listeners/selectionlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GCN_SELECTIONLISTENER_HPP -#define GCN_SELECTIONLISTENER_HPP +#ifndef LISTENERS_SELECTIONLISTENER_H +#define LISTENERS_SELECTIONLISTENER_H #include @@ -111,4 +111,4 @@ class SelectionListener { } }; -#endif // end GCN_SELECTIONLISTENER_HPP +#endif // LISTENERS_SELECTIONLISTENER_H diff --git a/src/listeners/widgetlistener.h b/src/listeners/widgetlistener.h index 16d9e1f15..48641cbaa 100644 --- a/src/listeners/widgetlistener.h +++ b/src/listeners/widgetlistener.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef LISTENERS_WIDGETLISTENER_HPP -#define LISTENERS_WIDGETLISTENER_HPP +#ifndef LISTENERS_WIDGETLISTENER_H +#define LISTENERS_WIDGETLISTENER_H #include @@ -137,4 +137,4 @@ class WidgetListener { } }; -#endif // LISTENERS_WIDGETLISTENER_HPP +#endif // LISTENERS_WIDGETLISTENER_H diff --git a/src/logger.cpp b/src/logger.cpp index c430aefec..21fea14d7 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -22,9 +22,10 @@ #include "logger.h" -#include #include +#include + #ifdef WIN32 #include #elif defined __APPLE__ diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 86a431cdf..b4fbc6da6 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -33,6 +33,7 @@ #include "render/graphics.h" +#include "resources/image.h" #include "resources/resourcemanager.h" #include "gui/font.h" diff --git a/src/net/ea/buysellhandler.cpp b/src/net/ea/buysellhandler.cpp index 0f592b123..d55a3cea6 100644 --- a/src/net/ea/buysellhandler.cpp +++ b/src/net/ea/buysellhandler.cpp @@ -39,8 +39,6 @@ #include "net/chathandler.h" #include "net/net.h" -#include "net/ea/eaprotocol.h" - #include "utils/timer.h" #include "debug.h" diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index a11c157fd..d541ce09b 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -33,6 +33,7 @@ #include "net/ea/gamehandler.h" #include "net/ea/network.h" +#include "net/messagein.h" #include "net/net.h" #include "utils/dtor.h" diff --git a/src/net/ea/charserverhandler.h b/src/net/ea/charserverhandler.h index 5ffd714f2..af6aafa9b 100644 --- a/src/net/ea/charserverhandler.h +++ b/src/net/ea/charserverhandler.h @@ -24,8 +24,13 @@ #define NET_EA_CHARSERVERHANDLER_H #include "net/charserverhandler.h" -#include "net/messagein.h" -#include "net/serverinfo.h" + +class ServerInfo; + +namespace Net +{ + class MessageIn; +} namespace Ea { diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index 6654950f2..997e4bfc1 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -38,6 +38,8 @@ #include "gui/widgets/tabs/chattab.h" +#include "net/messagein.h" + #include #include "debug.h" diff --git a/src/net/ea/chathandler.h b/src/net/ea/chathandler.h index 1fabda09d..237abf10a 100644 --- a/src/net/ea/chathandler.h +++ b/src/net/ea/chathandler.h @@ -24,10 +24,14 @@ #define NET_EA_CHATHANDLER_H #include "net/chathandler.h" -#include "net/messagein.h" #include +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/gamehandler.cpp b/src/net/ea/gamehandler.cpp index 6e1982b6d..de1d6f151 100644 --- a/src/net/ea/gamehandler.cpp +++ b/src/net/ea/gamehandler.cpp @@ -31,6 +31,8 @@ #include "gui/windows/okdialog.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/gamehandler.h b/src/net/ea/gamehandler.h index 8a31ee030..4a0624be0 100644 --- a/src/net/ea/gamehandler.h +++ b/src/net/ea/gamehandler.h @@ -24,7 +24,11 @@ #define NET_EA_GAMEHANDLER_H #include "net/gamehandler.h" -#include "net/messagein.h" + +namespace Net +{ + class MessageIn; +} namespace Ea { diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index 46b1f1649..af8c3b8df 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -28,10 +28,9 @@ #include "soundconsts.h" #include "soundmanager.h" +#include "net/guildhandler.h" #include "net/net.h" -#include "net/ea/guildhandler.h" - #include "utils/gettext.h" #include "debug.h" diff --git a/src/net/ea/guildhandler.cpp b/src/net/ea/guildhandler.cpp index 536c93263..1e56ac75b 100644 --- a/src/net/ea/guildhandler.cpp +++ b/src/net/ea/guildhandler.cpp @@ -30,6 +30,10 @@ #include "gui/windows/socialwindow.h" +#include "net/messagein.h" + +#include "net/ea/gui/guildtab.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/guildhandler.h b/src/net/ea/guildhandler.h index 191d6fd44..e8bec6a09 100644 --- a/src/net/ea/guildhandler.h +++ b/src/net/ea/guildhandler.h @@ -23,12 +23,15 @@ #define NET_EA_GUILDHANDLER_H #include "net/guildhandler.h" -#include "net/messagein.h" -#include "net/ea/gui/guildtab.h" +namespace Net +{ + class MessageIn; +} namespace Ea { +class GuildTab; class GuildHandler : public Net::GuildHandler { diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 74f0a4ba7..3f4eb9228 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -29,6 +29,8 @@ #include "gui/windows/ministatuswindow.h" +#include "net/messagein.h" + #include "net/ea/eaprotocol.h" #include "debug.h" diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 6e8ecec38..494b9145a 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -33,11 +33,15 @@ #include "gui/windows/inventorywindow.h" #include "net/inventoryhandler.h" -#include "net/messagein.h" #include #include +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/itemhandler.cpp b/src/net/ea/itemhandler.cpp index 9ce85a59b..383ba2753 100644 --- a/src/net/ea/itemhandler.cpp +++ b/src/net/ea/itemhandler.cpp @@ -24,6 +24,8 @@ #include "actormanager.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/itemhandler.h b/src/net/ea/itemhandler.h index 6bc23fb10..80c0a4dbf 100644 --- a/src/net/ea/itemhandler.h +++ b/src/net/ea/itemhandler.h @@ -25,6 +25,13 @@ #include "net/messagein.h" +#include "localconsts.h" + +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 57edcefbf..62514b10b 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -32,6 +32,8 @@ #include "utils/gettext.h" #include "utils/paths.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/loginhandler.h b/src/net/ea/loginhandler.h index 8fea9d49f..f539176f5 100644 --- a/src/net/ea/loginhandler.h +++ b/src/net/ea/loginhandler.h @@ -24,7 +24,6 @@ #define NET_EA_LOGINHANDLER_H #include "net/loginhandler.h" -#include "net/messagein.h" #include "net/ea/token.h" @@ -32,6 +31,11 @@ class LoginData; +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/npchandler.cpp b/src/net/ea/npchandler.cpp index 70c4ce08a..03def7298 100644 --- a/src/net/ea/npchandler.cpp +++ b/src/net/ea/npchandler.cpp @@ -24,6 +24,8 @@ #include "gui/windows/npcdialog.h" +#include "net/messagein.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/npchandler.h b/src/net/ea/npchandler.h index b8a10bc18..07c281587 100644 --- a/src/net/ea/npchandler.h +++ b/src/net/ea/npchandler.h @@ -23,11 +23,17 @@ #ifndef NET_EA_NPCHANDLER_H #define NET_EA_NPCHANDLER_H -#include "net/messagein.h" #include "net/npchandler.h" +#include "localconsts.h" + class NpcDialog; +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 98dec750a..7f29f277a 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -25,11 +25,16 @@ #include "configuration.h" #include "notifications.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" #include "gui/windows/socialwindow.h" +#include "net/messagein.h" + +#include "net/ea/gui/partytab.h" + #include "debug.h" namespace Ea diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index e7ab8f8ef..29f242285 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -22,15 +22,18 @@ #ifndef NET_EA_PARTYHANDLER_H #define NET_EA_PARTYHANDLER_H -#include "net/messagein.h" #include "net/partyhandler.h" -#include "net/ea/gui/partytab.h" +class Party; -#include "party.h" +namespace Net +{ + class MessageIn; +} namespace Ea { +class PartyTab; class PartyHandler : public Net::PartyHandler { diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp index 28f16735c..de376cead 100644 --- a/src/net/ea/playerhandler.cpp +++ b/src/net/ea/playerhandler.cpp @@ -41,6 +41,7 @@ #include "resources/db/deaddb.h" +#include "net/messagein.h" #include "net/net.h" #include "net/ea/eaprotocol.h" diff --git a/src/net/ea/playerhandler.h b/src/net/ea/playerhandler.h index 589874e2e..087627f92 100644 --- a/src/net/ea/playerhandler.h +++ b/src/net/ea/playerhandler.h @@ -23,9 +23,13 @@ #ifndef NET_EA_PLAYERHANDLER_H #define NET_EA_PLAYERHANDLER_H -#include "net/messagein.h" #include "net/playerhandler.h" +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/skillhandler.cpp b/src/net/ea/skillhandler.cpp index 3a5a1ab75..fd10a6087 100644 --- a/src/net/ea/skillhandler.cpp +++ b/src/net/ea/skillhandler.cpp @@ -33,6 +33,8 @@ #include "utils/stringutils.h" +#include "net/messagein.h" + #include "debug.h" /** job dependend identifiers (?) */ diff --git a/src/net/ea/skillhandler.h b/src/net/ea/skillhandler.h index 8dc724e0a..484ca6878 100644 --- a/src/net/ea/skillhandler.h +++ b/src/net/ea/skillhandler.h @@ -23,9 +23,15 @@ #ifndef NET_EA_SKILLHANDLER_H #define NET_EA_SKILLHANDLER_H -#include "net/messagein.h" #include "net/skillhandler.h" +#include "localconsts.h" + +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/ea/tradehandler.cpp b/src/net/ea/tradehandler.cpp index 4cb424fc9..19e597967 100644 --- a/src/net/ea/tradehandler.cpp +++ b/src/net/ea/tradehandler.cpp @@ -34,6 +34,7 @@ #include "gui/windows/confirmdialog.h" #include "gui/windows/tradewindow.h" +#include "net/messagein.h" #include "net/net.h" #include "net/ea/eaprotocol.h" diff --git a/src/net/ea/tradehandler.h b/src/net/ea/tradehandler.h index 22a78e9e6..d4c9510b8 100644 --- a/src/net/ea/tradehandler.h +++ b/src/net/ea/tradehandler.h @@ -23,9 +23,13 @@ #ifndef NET_EA_TRADEHANDLER_H #define NET_EA_TRADEHANDLER_H -#include "net/messagein.h" #include "net/tradehandler.h" +namespace Net +{ + class MessageIn; +} + namespace Ea { diff --git a/src/net/eathena/chathandler.cpp b/src/net/eathena/chathandler.cpp index 61e0a8404..a9d11f563 100644 --- a/src/net/eathena/chathandler.cpp +++ b/src/net/eathena/chathandler.cpp @@ -24,8 +24,7 @@ #include "being/localplayer.h" -#include "gui/widgets/tabs/chattab.h" - +#include "net/eathena/messageout.h" #include "net/eathena/protocol.h" #include diff --git a/src/net/eathena/chathandler.h b/src/net/eathena/chathandler.h index 9c6b8ea0c..3efaf2d31 100644 --- a/src/net/eathena/chathandler.h +++ b/src/net/eathena/chathandler.h @@ -26,10 +26,10 @@ #include "net/ea/chathandler.h" #include "net/eathena/messagehandler.h" -#include "net/eathena/messageout.h" namespace EAthena { +class MessageOut; class ChatHandler final : public MessageHandler, public Ea::ChatHandler { diff --git a/src/net/eathena/generalhandler.cpp b/src/net/eathena/generalhandler.cpp index ebb5d46d7..3a18dede9 100644 --- a/src/net/eathena/generalhandler.cpp +++ b/src/net/eathena/generalhandler.cpp @@ -33,6 +33,7 @@ #include "net/ea/guildhandler.h" +#include "net/ea/gui/guildtab.h" #include "net/ea/gui/partytab.h" #include "net/eathena/adminhandler.h" diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp index 56d4f5aae..0162d82e8 100644 --- a/src/net/eathena/network.cpp +++ b/src/net/eathena/network.cpp @@ -24,6 +24,7 @@ #include "logger.h" +#include "net/eathena/messagehandler.h" #include "net/eathena/messagein.h" #include "net/eathena/protocol.h" diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h index 4c9349f96..fae4f06d5 100644 --- a/src/net/eathena/network.h +++ b/src/net/eathena/network.h @@ -25,8 +25,6 @@ #include "net/ea/network.h" -#include "net/eathena/messagehandler.h" - /** * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. @@ -35,6 +33,7 @@ namespace EAthena { +class MessageHandler; class Network final : public Ea::Network { diff --git a/src/net/eathena/partyhandler.cpp b/src/net/eathena/partyhandler.cpp index fcc650171..cfec2fe81 100644 --- a/src/net/eathena/partyhandler.cpp +++ b/src/net/eathena/partyhandler.cpp @@ -24,6 +24,7 @@ #include "actormanager.h" #include "notifications.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" diff --git a/src/net/tmwa/chathandler.cpp b/src/net/tmwa/chathandler.cpp index af236f00b..d00f12dd3 100644 --- a/src/net/tmwa/chathandler.cpp +++ b/src/net/tmwa/chathandler.cpp @@ -24,8 +24,7 @@ #include "being/localplayer.h" -#include "gui/widgets/tabs/chattab.h" - +#include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" #include diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h index a7226c52c..c4f51fec7 100644 --- a/src/net/tmwa/chathandler.h +++ b/src/net/tmwa/chathandler.h @@ -26,10 +26,10 @@ #include "net/ea/chathandler.h" #include "net/tmwa/messagehandler.h" -#include "net/tmwa/messageout.h" namespace TmwAthena { +class MessageOut; class ChatHandler final : public MessageHandler, public Ea::ChatHandler { diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp index 683eb0711..46d1d490f 100644 --- a/src/net/tmwa/generalhandler.cpp +++ b/src/net/tmwa/generalhandler.cpp @@ -33,6 +33,7 @@ #include "net/ea/guildhandler.h" +#include "net/ea/gui/guildtab.h" #include "net/ea/gui/partytab.h" #include "net/tmwa/adminhandler.h" diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index c91387898..cc94b6161 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -24,6 +24,7 @@ #include "logger.h" +#include "net/tmwa/messagehandler.h" #include "net/tmwa/messagein.h" #include "net/tmwa/protocol.h" diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 6d05d0e48..bf9381227 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -25,8 +25,6 @@ #include "net/ea/network.h" -#include "net/tmwa/messagehandler.h" - /** * Protocol version, reported to the eAthena char and mapserver who can adjust * the protocol accordingly. @@ -36,6 +34,7 @@ namespace TmwAthena { +class MessageHandler; class Network final : public Ea::Network { diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp index 78d56f669..ba18a9efa 100644 --- a/src/net/tmwa/partyhandler.cpp +++ b/src/net/tmwa/partyhandler.cpp @@ -24,6 +24,7 @@ #include "actormanager.h" #include "notifications.h" #include "notifymanager.h" +#include "party.h" #include "being/localplayer.h" diff --git a/src/net/tmwa/pethandler.cpp b/src/net/tmwa/pethandler.cpp index 6b9e5adb7..3293b7edd 100644 --- a/src/net/tmwa/pethandler.cpp +++ b/src/net/tmwa/pethandler.cpp @@ -24,8 +24,7 @@ #include "net/net.h" -#include "net/tmwa/chathandler.h" -#include "net/tmwa/protocol.h" +#include "net/chathandler.h" #include "debug.h" diff --git a/src/net/tradehandler.h b/src/net/tradehandler.h index 823352239..21ca65e97 100644 --- a/src/net/tradehandler.h +++ b/src/net/tradehandler.h @@ -29,6 +29,8 @@ #include "localconsts.h" +class Item; + namespace Net { class TradeHandler diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 7a15713be..2f4f6c0c2 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -33,6 +33,8 @@ #include "utils/sdlpixel.h" +#include "resources/image.h" + #include "debug.h" #if SDL_BYTEORDER == SDL_LIL_ENDIAN diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 63f15c18f..1409146df 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -29,7 +29,6 @@ #include "resources/animation.h" #include "resources/dye.h" -#include "resources/image.h" #include "resources/imageset.h" #include "resources/resourcemanager.h" diff --git a/src/statuseffect.cpp b/src/statuseffect.cpp index 049c010b3..647c6dd99 100644 --- a/src/statuseffect.cpp +++ b/src/statuseffect.cpp @@ -22,12 +22,15 @@ #include "statuseffect.h" +#include "animatedsprite.h" #include "configuration.h" #include "logger.h" #include "soundmanager.h" #include "gui/widgets/tabs/chattab.h" +#include "particle/particle.h" + #include "resources/beingcommon.h" #include diff --git a/src/statuseffect.h b/src/statuseffect.h index 6dda71cfc..8bb164820 100644 --- a/src/statuseffect.h +++ b/src/statuseffect.h @@ -23,12 +23,13 @@ #ifndef STATUSEFFECT_H #define STATUSEFFECT_H -#include "animatedsprite.h" - -#include "particle/particle.h" +#include #include "localconsts.h" +class AnimatedSprite; +class Particle; + class StatusEffect final { public: diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 20c56b8d6..49a5a0d3d 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -35,6 +35,8 @@ #include "gui/theme.h" +#include "resources/image.h" + #include "debug.h" TouchManager touchManager; diff --git a/src/touchmanager.h b/src/touchmanager.h index 6419c4b17..09eaabad5 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -21,8 +21,6 @@ #ifndef TOUCHMANAGER_H #define TOUCHMANAGER_H -#include "resources/image.h" - #include "listeners/configlistener.h" #include "input/keydata.h" @@ -34,6 +32,7 @@ #include "localconsts.h" +class Image; class ImageCollection; class ImageRect; class MouseInput; diff --git a/src/utils/files.cpp b/src/utils/files.cpp index 24ec9366e..11ac222f5 100644 --- a/src/utils/files.cpp +++ b/src/utils/files.cpp @@ -24,7 +24,6 @@ #include "resources/resourcemanager.h" #endif -#include "utils/mkdir.h" #include "utils/physfstools.h" #include "localconsts.h" diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index a3f61bde3..96cd0ed29 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -28,7 +28,9 @@ #include "utils/physfstools.h" #include "utils/stringutils.h" +#ifdef USE_X11 #include "resources/resourcemanager.h" +#endif #ifdef __native_client__ #include diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index 2a26f28a1..692615688 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef UTILS_SDLPIXEL_HPP -#define UTILS_SDLPIXEL_HPP +#ifndef UTILS_SDLPIXEL_H +#define UTILS_SDLPIXEL_H #include "SDL.h" #include "gui/base/color.hpp" @@ -229,4 +229,4 @@ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, SDL_UnlockSurface(surface); } -#endif // UTILS_SDLPIXEL_HPP +#endif // UTILS_SDLPIXEL_H diff --git a/src/utils/translation/poparser.cpp b/src/utils/translation/poparser.cpp index f0ab95005..c105bf0da 100644 --- a/src/utils/translation/poparser.cpp +++ b/src/utils/translation/poparser.cpp @@ -24,6 +24,8 @@ #include "utils/stringutils.h" +#include "utils/translation/podict.h" + #include "logger.h" #include "debug.h" diff --git a/src/utils/translation/poparser.h b/src/utils/translation/poparser.h index 08a6ac7b1..41598442b 100644 --- a/src/utils/translation/poparser.h +++ b/src/utils/translation/poparser.h @@ -21,13 +21,13 @@ #ifndef UTILS_TRANSLATION_POPARSER_H #define UTILS_TRANSLATION_POPARSER_H -#include "utils/translation/podict.h" - #include "localconsts.h" #include #include +class PoDict; + class PoParser final { public: diff --git a/src/utils/xml.h b/src/utils/xml.h index 48d60cda7..d8a281045 100644 --- a/src/utils/xml.h +++ b/src/utils/xml.h @@ -23,8 +23,8 @@ #ifndef UTILS_XML_H #define UTILS_XML_H -#include #include +#include #include -- cgit v1.2.3-70-g09d2 From d83c6dd523827087681f019ebfca8798380dc968 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 20 Feb 2014 22:36:48 +0300 Subject: fix code style. --- src/being/being.h | 2 -- src/events/keyevent.h | 24 ++++++++++++------------ src/events/mouseevent.h | 18 +++++++++--------- src/gui/base/basiccontainer.cpp | 2 -- src/gui/base/gui.hpp | 7 ++++--- src/gui/base/widget.hpp | 2 -- src/gui/base/widgets/listbox.cpp | 2 ++ src/gui/base/widgets/listbox.hpp | 3 ++- src/gui/focushandler.h | 4 ++-- src/gui/popups/popupmenu.h | 10 ++++++---- src/gui/popups/spellpopup.cpp | 3 ++- src/gui/popups/spellpopup.h | 3 +-- src/gui/widgets/avatarlistbox.h | 2 ++ src/gui/widgets/colormodel.h | 6 +++++- src/gui/widgets/dropdown.h | 6 ------ src/gui/widgets/guitable.h | 1 - src/gui/widgets/itemlinkhandler.cpp | 2 ++ src/gui/widgets/label.h | 2 -- src/gui/widgets/listbox.h | 11 +++++++++++ src/gui/widgets/playerbox.h | 2 -- src/gui/widgets/popuplist.h | 7 +++++-- src/gui/widgets/setupitem.h | 3 --- src/gui/widgets/setuptouchitem.cpp | 2 +- src/gui/widgets/textfield.h | 2 -- src/gui/windows/botcheckerwindow.cpp | 10 +++++----- src/gui/windows/botcheckerwindow.h | 2 +- src/gui/windows/socialwindow.cpp | 10 +++++----- src/gui/windows/worldselectdialog.cpp | 2 ++ src/render/sdl2graphics.cpp | 1 + src/render/sdl2softwaregraphics.cpp | 1 + src/utils/files.cpp | 2 ++ src/utils/sdlpixel.h | 29 ++++++++++++++++------------- 32 files changed, 99 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/being/being.h b/src/being/being.h index afa023068..4ef40d9fd 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -23,8 +23,6 @@ #ifndef BEING_BEING_H #define BEING_BEING_H -//#include "equipment.h" - #include "resources/beinginfo.h" #include diff --git a/src/events/keyevent.h b/src/events/keyevent.h index c0c950639..6ca3d87d8 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -103,19 +103,19 @@ class KeyEvent: public InputGuiEvent * @param key The key of the event. */ KeyEvent(gcn::Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const bool numericPad, - const int actionId, - const Key &key) : + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const bool numericPad, + const int actionId, + const Key &key) : InputGuiEvent(source, - shiftPressed, - controlPressed, - altPressed, - metaPressed), + shiftPressed, + controlPressed, + altPressed, + metaPressed), mKey(key), #ifdef USE_SDL2 mText(), diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index 9378faac6..fc8088341 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -97,15 +97,15 @@ class MouseEvent: public InputGuiEvent * It's set to zero if another button is used. */ MouseEvent(gcn::Widget *const source, - const bool shiftPressed, - const bool controlPressed, - const bool altPressed, - const bool metaPressed, - const unsigned int type, - const unsigned int button, - const int x, - const int y, - const int clickCount) : + const bool shiftPressed, + const bool controlPressed, + const bool altPressed, + const bool metaPressed, + const unsigned int type, + const unsigned int button, + const int x, + const int y, + const int clickCount) : InputGuiEvent(source, shiftPressed, controlPressed, diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index edc465726..9f2806016 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -69,8 +69,6 @@ #include -#include "gui/focushandler.h" - #include "render/graphics.h" #include "debug.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 391a0520e..8c4ac4db0 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -67,13 +67,14 @@ #include #include -#include "events/keyevent.h" - -#include "input/mouseinput.h" +#include "localconsts.h" +class Event; class FocusHandler; class Graphics; +class KeyEvent; class KeyListener; +class MouseInput; class SDLInput; namespace gcn diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 6245d3c98..dd872d9a1 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -81,9 +81,7 @@ class FocusHandler; class FocusListener; class Font; class Graphics; -class KeyInput; class KeyListener; -class MouseInput; class MouseListener; class WidgetListener; diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 02d94626c..765878834 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -69,6 +69,8 @@ #include "gui/font.h" +#include "gui/base/listmodel.hpp" + #include "listeners/selectionlistener.h" #include "debug.h" diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index ff2df395c..c46aca6ae 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -66,7 +66,6 @@ #include -#include "gui/base/listmodel.hpp" #include "gui/base/widget.hpp" #include "listeners/keylistener.h" @@ -76,6 +75,8 @@ class SelectionListener; namespace gcn { + class ListModel; + /** * An implementation of a list box where an item can be selected. * diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 0131a4c29..c8885ef2c 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -68,13 +68,13 @@ #include "gui/focushandler.h" -#include "events/event.h" - #include #include #include "localconsts.h" +class Event; + namespace gcn { class Widget; diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 70f8b7885..1ce274122 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -26,14 +26,11 @@ #include "gui/widgets/linkhandler.h" #include "gui/widgets/popup.h" -#include "being/actorsprite.h" - #include "listeners/actionlistener.h" -#include "gui/base/listmodel.hpp" - #include "localconsts.h" +class ActorSprite; class Being; class BrowserBox; class Button; @@ -48,6 +45,11 @@ class TextField; class ProgressBar; class Window; +namespace gcn +{ + class ListModel; +} + class RenameListener final : public ActionListener { public: diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index 8849a53cb..07bcc2330 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -23,7 +23,8 @@ #include "gui/popups/spellpopup.h" -#include "gui/font.h" +#include "textcommand.h" + #include "gui/gui.h" #include "gui/widgets/label.h" diff --git a/src/gui/popups/spellpopup.h b/src/gui/popups/spellpopup.h index 152dfb306..cbbd53703 100644 --- a/src/gui/popups/spellpopup.h +++ b/src/gui/popups/spellpopup.h @@ -26,9 +26,8 @@ #include "gui/widgets/popup.h" -#include "textcommand.h" - class Label; +class TextCommand; /** * A popup that displays information about an item. diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index 005ba7c72..e2ab3bf83 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -28,6 +28,8 @@ #include "gui/widgets/listbox.h" +#include "gui/base/listmodel.hpp" + #include class Image; diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h index 4d29e24d3..c019d9aac 100644 --- a/src/gui/widgets/colormodel.h +++ b/src/gui/widgets/colormodel.h @@ -23,13 +23,17 @@ #include "utils/stringvector.h" -#include "gui/base/color.hpp" #include "gui/base/listmodel.hpp" #include "localconsts.h" class Widget2; +namespace gcn +{ + class Color; +} + struct ColorPair { ColorPair(const gcn::Color* c1, const gcn::Color* c2) : diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index a1908a3c6..9bb459d45 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -23,10 +23,7 @@ #ifndef GUI_WIDGETS_DROPDOWN_H #define GUI_WIDGETS_DROPDOWN_H -#include "gui/widgets/widget2.h" - #include "gui/base/basiccontainer.hpp" -//#include "gui/base/listmodel.hpp" #include "listeners/actionlistener.h" #include "listeners/focuslistener.h" @@ -37,10 +34,7 @@ #include "localconsts.h" class Image; -class ImageRect; -class ListBox; class PopupList; -class ScrollArea; class Skin; namespace gcn diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index d68e222ac..96f2a9532 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -26,7 +26,6 @@ #include "localconsts.h" #include "gui/widgets/tablemodel.h" -#include "gui/widgets/widget2.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index 3e9a99a2a..2cf27ae30 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -48,6 +48,7 @@ namespace struct OpenUrlListener : public ActionListener { OpenUrlListener() : + ActionListener(), url() { } @@ -65,6 +66,7 @@ namespace } // namespace ItemLinkHandler::ItemLinkHandler() : + LinkHandler(), mItemPopup(new ItemPopup) { mItemPopup->postInit(); diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index b6adf9fba..b63c9b10e 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -22,8 +22,6 @@ #ifndef GUI_WIDGETS_LABEL_H #define GUI_WIDGETS_LABEL_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/label.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index f1ebee317..625f21085 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -23,12 +23,23 @@ #ifndef GUI_WIDGETS_LISTBOX_H #define GUI_WIDGETS_LISTBOX_H +#include "gui/base/color.hpp" + #include "gui/base/widgets/listbox.hpp" +#include "render/graphics.h" + #include "localconsts.h" class Skin; +class KeyEvent; +class MouseEvent; +class Widget2; +namespace gcn +{ + class ListModel; +} /** * A list box, meant to be used inside a scroll area. Same as the Guichan list * box except this one doesn't have a background, instead completely relying diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h index d3fb4e5e3..7481dc9db 100644 --- a/src/gui/widgets/playerbox.h +++ b/src/gui/widgets/playerbox.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_PLAYERBOX_H #define GUI_WIDGETS_PLAYERBOX_H -#include "gui/widgets/widget2.h" - #include "gui/base/widgets/scrollarea.hpp" #include "localconsts.h" diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index 45f52d3b3..a495d7c46 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -25,14 +25,17 @@ #include "listeners/focuslistener.h" -#include "gui/base/listmodel.hpp" - #include "localconsts.h" class DropDown; class ListBox; class ScrollArea; +namespace gcn +{ + class ListModel; +} + class PopupList final : public Popup, public FocusListener { diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 87b7c46f9..502d85d21 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -21,9 +21,6 @@ #ifndef GUI_WIDGETS_SETUPITEM_H #define GUI_WIDGETS_SETUPITEM_H -//#include "gui/widgets/button.h" -//#include "gui/widgets/tabs/setuptabscroll.h" - #include "gui/widgets/widget2.h" #include "listeners/actionlistener.h" diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index f4c213b2f..d50af8ff3 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -27,7 +27,7 @@ #include "gui/widgets/label.h" #include "gui/widgets/vertcontainer.h" -#include "gui/widgets/tabs/setuptabscroll.h" +#include "gui/widgets/tabs/setuptabscroll.h" #include diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index bfa721b7a..b05a498dc 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -23,8 +23,6 @@ #ifndef GUI_WIDGETS_TEXTFIELD_H #define GUI_WIDGETS_TEXTFIELD_H -#include "gui/widgets/widget2.h" - #include "listeners/focuslistener.h" #include "gui/base/widgets/textfield.hpp" diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index ade95eba5..3bdebff71 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -101,7 +101,7 @@ public: freeWidgets(); mPlayers.clear(); if (actorManager && botCheckerWindow - && botCheckerWindow->mEnabled) + && botCheckerWindow->mBotcheckerEnabled) { std::set beings = actorManager->getAll(); FOR_EACH (ActorSprites::iterator, i, beings) @@ -271,7 +271,7 @@ BotCheckerWindow::BotCheckerWindow(): mIncButton(new Button(this, _("Reset"), "reset", this)), mLastUpdateTime(0), mNeedUpdate(false), - mEnabled(false) + mBotcheckerEnabled(false) { const int w = 500; const int h = 250; @@ -346,7 +346,7 @@ BotCheckerWindow::BotCheckerWindow(): enableVisibleSound(true); config.addListener("enableBotCheker", this); - mEnabled = config.getBoolValue("enableBotCheker"); + mBotcheckerEnabled = config.getBoolValue("enableBotCheker"); } BotCheckerWindow::~BotCheckerWindow() @@ -358,7 +358,7 @@ BotCheckerWindow::~BotCheckerWindow() void BotCheckerWindow::slowLogic() { BLOCK_START("BotCheckerWindow::slowLogic") - if (mEnabled && mTableModel) + if (mBotcheckerEnabled && mTableModel) { const unsigned int nowTime = cur_time; if (nowTime - mLastUpdateTime > 5 && mNeedUpdate) @@ -417,7 +417,7 @@ void BotCheckerWindow::reset() void BotCheckerWindow::optionChanged(const std::string &name) { if (name == "enableBotCheker") - mEnabled = config.getBoolValue("enableBotCheker"); + mBotcheckerEnabled = config.getBoolValue("enableBotCheker"); } #ifdef USE_PROFILER diff --git a/src/gui/windows/botcheckerwindow.h b/src/gui/windows/botcheckerwindow.h index 25fd550fb..0c86b13b0 100644 --- a/src/gui/windows/botcheckerwindow.h +++ b/src/gui/windows/botcheckerwindow.h @@ -86,7 +86,7 @@ class BotCheckerWindow final : public Window, Button *mIncButton; int mLastUpdateTime; bool mNeedUpdate; - bool mEnabled; + bool mBotcheckerEnabled; }; extern BotCheckerWindow *botCheckerWindow; diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 52ddc9439..73098ee08 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -115,6 +115,11 @@ public: virtual void selectIndex(const unsigned num A_UNUSED) { } + virtual void buildCounter(const int online A_UNUSED = 0, + const int total A_UNUSED = 0) + { + } + protected: friend class SocialWindow; @@ -157,11 +162,6 @@ protected: socialWindow->setCounter(this, mCounterString); } - virtual void buildCounter(const int online A_UNUSED = 0, - const int total A_UNUSED = 0) - { - } - TextDialog *mInviteDialog; ConfirmDialog *mConfirmDialog; ScrollArea *mScroll; diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 3c7602a70..5acb11f93 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -33,6 +33,8 @@ #include "gui/widgets/listbox.h" #include "gui/widgets/scrollarea.h" +#include "gui/base/listmodel.hpp" + #include "net/loginhandler.h" #include "net/net.h" diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 2cd7c965e..933120080 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -74,6 +74,7 @@ #include "graphicsvertexes.h" #include "logger.h" +#include "resources/image.h" #include "resources/imagehelper.h" #include "resources/sdl2imagehelper.h" diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 8efd73d68..e6cce9c35 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -31,6 +31,7 @@ #include "graphicsvertexes.h" #include "logger.h" +#include "resources/image.h" #include "resources/imagehelper.h" #include "resources/sdl2softwareimagehelper.h" diff --git a/src/utils/files.cpp b/src/utils/files.cpp index 11ac222f5..d671cb0db 100644 --- a/src/utils/files.cpp +++ b/src/utils/files.cpp @@ -22,6 +22,8 @@ #if defined(ANDROID) || defined(__native_client__) #include "resources/resourcemanager.h" + +#include "utils/mkdir.h" #endif #include "utils/physfstools.h" diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index 692615688..a01858831 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -80,14 +80,14 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y, if (!surface) return; - int bpp = surface->format->BytesPerPixel; + const int bpp = surface->format->BytesPerPixel; SDL_LockSurface(surface); - Uint8 *p = static_cast(surface->pixels) + Uint8 *const p = static_cast(surface->pixels) + y * surface->pitch + x * bpp; - Uint32 pixel = SDL_MapRGB(surface->format, + const Uint32 pixel = SDL_MapRGB(surface->format, static_cast(color.r), static_cast(color.g), static_cast(color.b)); @@ -131,13 +131,14 @@ inline void SDLputPixel(SDL_Surface* surface, int x, int y, * @param dst the destination color. * @param a alpha. */ -inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, - unsigned char a) +inline unsigned int SDLAlpha32(const unsigned int src, + const unsigned int dst, + const unsigned char a) { - unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8; - unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) + const unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8; + const unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) * (255 - a)) >> 8; - unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) + const unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) * (255 - a)) >> 8; return (b & 0xff) | (g & 0xff00) | (r & 0xff0000); @@ -150,8 +151,10 @@ inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, * @param dst the destination color. * @param a alpha. */ -inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, - unsigned char a, const SDL_PixelFormat *f) +inline unsigned short SDLAlpha16(const unsigned short src, + const unsigned short dst, + const unsigned char a, + const SDL_PixelFormat *const f) { unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask) * (255 - a)) >> 8; @@ -174,14 +177,14 @@ inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, const gcn::Color& color) { - int bpp = surface->format->BytesPerPixel; + const int bpp = surface->format->BytesPerPixel; SDL_LockSurface(surface); - Uint8 *p = static_cast(surface->pixels) + Uint8 *const p = static_cast(surface->pixels) + y * surface->pitch + x * bpp; - Uint32 pixel = SDL_MapRGB(surface->format, + const Uint32 pixel = SDL_MapRGB(surface->format, static_cast(color.r), static_cast(color.g), static_cast(color.b)); -- cgit v1.2.3-70-g09d2 From 5809c2403e414a5ee9d17ca206557bde62ca21a1 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 21 Feb 2014 12:11:20 +0300 Subject: Fix upload commands showing to non general tab. --- src/commands.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/commands.cpp b/src/commands.cpp index 93e07b0f8..d4134c560 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1323,7 +1323,8 @@ static int uploadUpdate(void *ptr, static void uploadFile(const std::string &str, const std::string &fileName, - const std::string &addStr) + const std::string &addStr, + ChatTab *const tab) { UploadChatInfo *const info = new UploadChatInfo(); Net::Download *const upload = new Net::Download(info, @@ -1333,6 +1334,7 @@ static void uploadFile(const std::string &str, info->upload = upload; info->text = str; info->addStr = addStr; + info->tab = tab; upload->setFile(fileName); upload->start(); } @@ -1341,21 +1343,24 @@ impHandler0(uploadConfig) { uploadFile(_("Uploaded config into:"), config.getFileName(), - "?xml"); + "?xml", + tab); } impHandler0(uploadServerConfig) { uploadFile(_("Uploaded server config into:"), serverConfig.getFileName(), - "?xml"); + "?xml", + tab); } impHandler0(uploadLog) { uploadFile(_("Uploaded log into:"), client->getLogFileName(), - "?txt"); + "?txt", + tab); } impHandler0(testsdlfont) -- cgit v1.2.3-70-g09d2 From 126fa885664da8a8de86f3a38c04469f7006e447 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 21 Feb 2014 12:12:18 +0300 Subject: Remove debug log message. --- src/gui/windows/socialwindow.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 73098ee08..86b4b9ba3 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -1749,7 +1749,6 @@ void SocialWindow::slowLogic() const unsigned int nowTime = cur_time; if (mNeedUpdate && nowTime - mLastUpdateTime > 1) { - logger->log("soc update"); mPlayers->updateList(); mFriends->updateList(); mNeedUpdate = false; -- cgit v1.2.3-70-g09d2 From 1fcc02e803d83ae8415ff44f9696cb215f475daa Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 21 Feb 2014 13:30:39 +0300 Subject: fix signed shifts. --- src/being/playerrelations.h | 16 ++++++++-------- src/gui/base/color.cpp | 39 +++++++++++++++++++++------------------ src/gui/base/color.hpp | 15 +++++++++------ src/gui/theme.cpp | 2 +- src/gui/widgets/textfield.cpp | 2 +- src/net/ea/inventoryhandler.cpp | 2 +- src/net/eathena/messageout.cpp | 2 +- src/net/messagein.cpp | 4 ++-- src/net/tmwa/messageout.cpp | 2 +- src/render/sdlgraphics.h | 2 +- src/resources/dye.cpp | 2 +- src/resources/dye.h | 2 +- src/utils/mathutils.h | 6 +++--- src/utils/stringutils.cpp | 2 +- src/utils/stringutils.h | 2 +- 15 files changed, 53 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/being/playerrelations.h b/src/being/playerrelations.h index 3543d4221..c9a884d2e 100644 --- a/src/being/playerrelations.h +++ b/src/being/playerrelations.h @@ -35,14 +35,14 @@ class PlayerRelationsListener; struct PlayerRelation final { - static const unsigned int EMOTE = (1 << 0); - static const unsigned int SPEECH_FLOAT = (1 << 1); - static const unsigned int SPEECH_LOG = (1 << 2); - static const unsigned int WHISPER = (1 << 3); - static const unsigned int TRADE = (1 << 4); - static const unsigned int INVISIBLE = (1 << 5); - static const unsigned int BLACKLIST = (1 << 6); - static const unsigned int ENEMY = (1 << 7); + static const unsigned int EMOTE = (1U << 0); + static const unsigned int SPEECH_FLOAT = (1U << 1); + static const unsigned int SPEECH_LOG = (1U << 2); + static const unsigned int WHISPER = (1U << 3); + static const unsigned int TRADE = (1U << 4); + static const unsigned int INVISIBLE = (1U << 5); + static const unsigned int BLACKLIST = (1U << 6); + static const unsigned int ENEMY = (1U << 7); static const unsigned int RELATIONS_NR = 7; static const unsigned int RELATION_PERMISSIONS[RELATIONS_NR]; diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp index 764259efc..485367e6d 100644 --- a/src/gui/base/color.cpp +++ b/src/gui/base/color.cpp @@ -72,22 +72,25 @@ namespace gcn { Color::Color() : - r(0), - g(0), - b(0), - a(255) + r(0U), + g(0U), + b(0U), + a(255U) { } - Color::Color(const int color) : + Color::Color(const unsigned int color) : r((color >> 16) & 0xFF), g((color >> 8) & 0xFF), b(color & 0xFF), - a(255) + a(255U) { } - Color::Color(const int ar, const int ag, const int ab, const int aa) : + Color::Color(const unsigned int ar, + const unsigned int ag, + const unsigned int ab, + const unsigned int aa) : r(ar), g(ag), b(ab), @@ -100,11 +103,11 @@ namespace gcn Color result(r + color.r, g + color.g, b + color.b, - 255); + 255U); - result.r = (result.r>255?255:(result.r<0?0:result.r)); - result.g = (result.g>255?255:(result.g<0?0:result.g)); - result.b = (result.b>255?255:(result.b<0?0:result.b)); + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); return result; } @@ -114,11 +117,11 @@ namespace gcn Color result(r - color.r, g - color.g, b - color.b, - 255); + 255U); - result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); - result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); - result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); return result; } @@ -130,9 +133,9 @@ namespace gcn static_cast(static_cast(b) * value), a); - result.r = (result.r > 255 ? 255 : (result.r < 0 ? 0 : result.r)); - result.g = (result.g > 255 ? 255 : (result.g < 0 ? 0 : result.g)); - result.b = (result.b > 255 ? 255 : (result.b < 0 ? 0 : result.b)); + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); return result; } diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp index c32adb2e9..781b2cb60 100644 --- a/src/gui/base/color.hpp +++ b/src/gui/base/color.hpp @@ -93,7 +93,7 @@ namespace gcn * * @param color The color to initialise the object with. */ - explicit Color(const int color); + explicit Color(const unsigned int color); /** * Constructor. The default alpha value is 255. @@ -104,7 +104,10 @@ namespace gcn * @param a Alpha, used for transparency. A value of 0 means * totaly transparent, 255 is totaly opaque. */ - Color(const int r, const int g, const int b, const int a = 255); + Color(const unsigned int r, + const unsigned int g, + const unsigned int b, + const unsigned int a = 255); /** * Adds the RGB values of two colors together. The values will be @@ -169,23 +172,23 @@ namespace gcn /** * Holds the red color component (range 0-255). */ - int r; + unsigned int r; /** * Holds the green color component (range 0-255). */ - int g; + unsigned int g; /** * Holds the blue color component (range 0-255). */ - int b; + unsigned int b; /** * Holds the alpha color component. A value of 0 means totally * transparent while a value of 255 is considered opaque. */ - int a; + unsigned int a; }; } // namespace gcn diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 4218aff7c..2a1b0d624 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -982,7 +982,7 @@ static gcn::Color readColor(const std::string &description) return Palette::BLACK; } - int v = 0; + unsigned int v = 0; for (int i = 1; i < 7; ++i) { signed const char c = description[i]; diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index c30045c02..0d4d53dd3 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -251,7 +251,7 @@ void TextField::keyPressed(KeyEvent &keyEvent) } if (len > 1) - buf[0] |= static_cast(255 << (8 - len)); + buf[0] |= static_cast(255U << (8 - len)); mText.insert(mCaretPosition, std::string(buf, buf + len)); mCaretPosition += len; diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 3f4eb9228..d64050e1a 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -160,7 +160,7 @@ int InventoryHandler::getSlot(const int eAthenaSlot) const if (eAthenaSlot & 0x8000) return Equipment::EQUIP_PROJECTILE_SLOT; - int mask = 1; + unsigned int mask = 1; int position = 0; while (!(eAthenaSlot & mask)) { diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp index 3ac6a417e..ff16f5dd0 100644 --- a/src/net/eathena/messageout.cpp +++ b/src/net/eathena/messageout.cpp @@ -96,7 +96,7 @@ void MessageOut::writeCoordinates(const uint16_t x, mNetwork->mOutSize += 3; mPos += 3; - int16_t temp = x; + uint16_t temp = x; temp <<= 6; data[0] = 0; data[1] = 1; diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 9d9c68b94..81340ba33 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -115,7 +115,7 @@ void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y, if (mPos + 3 <= mLength) { const char *const data = mData + mPos; - int16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff); + uint16_t temp = MAKEWORD(data[1] & 0x00c0, data[0] & 0x00ff); x = static_cast(temp >> 6); temp = MAKEWORD(data[2] & 0x00f0, data[1] & 0x003f); y = static_cast(temp >> 4); @@ -147,7 +147,7 @@ void MessageIn::readCoordinatePair(uint16_t &restrict srcX, if (mPos + 5 <= mLength) { const char *const data = mData + mPos; - int16_t temp = MAKEWORD(data[3], data[2] & 0x000f); + uint16_t temp = MAKEWORD(data[3], data[2] & 0x000f); dstX = static_cast(temp >> 2); dstY = MAKEWORD(data[4], data[3] & 0x0003); diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 8dfbf2bd7..8c3ecb5ec 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -98,7 +98,7 @@ void MessageOut::writeCoordinates(const uint16_t x, mNetwork->mOutSize += 3; mPos += 3; - int16_t temp = x; + uint16_t temp = x; temp <<= 6; data[0] = 0; data[1] = 1; diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index 17b54db92..484b24e31 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -166,7 +166,7 @@ class SDLGraphics final : public Graphics void drawVLine(int x, int y1, int y2); uint32_t mOldPixel; - int mOldAlpha; + unsigned int mOldAlpha; private: void inline calcImageRect(ImageVertexes *const vert, diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index a1d925a1f..4f9e8a738 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -88,7 +88,7 @@ DyePalette::DyePalette(const std::string &description, logger->log("Error, invalid embedded palette: %s", description.c_str()); } -int DyePalette::hexDecode(const signed char c) +unsigned int DyePalette::hexDecode(const signed char c) { if ('0' <= c && c <= '9') return c - '0'; diff --git a/src/resources/dye.h b/src/resources/dye.h index a68839e47..b6003624b 100644 --- a/src/resources/dye.h +++ b/src/resources/dye.h @@ -82,7 +82,7 @@ class DyePalette final void replaceAOGLColor(uint32_t *restrict pixels, const int bufSize) const; - static int hexDecode(const signed char c) A_WARN_UNUSED; + static unsigned int hexDecode(const signed char c) A_WARN_UNUSED; private: std::vector mColors; diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h index 545a1cc4b..f5a3dc102 100644 --- a/src/utils/mathutils.h +++ b/src/utils/mathutils.h @@ -70,7 +70,7 @@ inline float fastSqrt(const float x) A_WARN_UNUSED; constexpr inline float weightedAverage(const float n1, const float n2, const float w) A_WARN_UNUSED; constexpr inline int roundDouble(const double v) A_WARN_UNUSED; -inline int powerOfTwo(const int input) A_WARN_UNUSED; +inline int powerOfTwo(const unsigned int input) A_WARN_UNUSED; inline uint16_t getCrc16(const std::string &str) { @@ -123,9 +123,9 @@ constexpr inline int roundDouble(const double v) return (v > 0.0) ? static_cast(v + 0.5) : static_cast(v - 0.5); } -inline int powerOfTwo(const int input) +inline int powerOfTwo(const unsigned int input) { - int value = 1; + unsigned int value = 1; while (value < input) value <<= 1; return value; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 224c2a8e8..f47f724a8 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -73,7 +73,7 @@ unsigned int atox(const std::string &str) return value; } -const char *ipToString(const int address) +const char *ipToString(const uint32_t address) { static char asciiIP[18]; diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 4a73b3e58..7cf924d98 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -90,7 +90,7 @@ std::string toStringPrint(const unsigned int val); * @param address the address to convert to a string * @return the string representation of the address */ -const char *ipToString(const int address) A_WARN_UNUSED; +const char *ipToString(const uint32_t address) A_WARN_UNUSED; /** * A safe version of sprintf that returns a std::string of the result. -- cgit v1.2.3-70-g09d2 From 48646db55005a0da079bd2c945875dc8225e2f86 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 14:21:27 +0300 Subject: Move color into gui dir. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 8 +- src/being/being.cpp | 2 +- src/being/being.h | 10 +- src/client.cpp | 2 +- src/flooritem.cpp | 8 +- src/gui/base/color.cpp | 168 --------------------------- src/gui/base/color.hpp | 195 -------------------------------- src/gui/base/widget.hpp | 3 +- src/gui/color.cpp | 165 +++++++++++++++++++++++++++ src/gui/color.h | 192 +++++++++++++++++++++++++++++++ src/gui/font.cpp | 16 +-- src/gui/font.h | 18 +-- src/gui/gui.h | 7 +- src/gui/palette.cpp | 30 ++--- src/gui/palette.h | 29 +++-- src/gui/popups/speechbubble.cpp | 4 +- src/gui/popups/speechbubble.h | 4 +- src/gui/theme.cpp | 10 +- src/gui/theme.h | 14 +-- src/gui/userpalette.cpp | 8 +- src/gui/userpalette.h | 9 +- src/gui/viewport.cpp | 4 +- src/gui/viewport.h | 2 +- src/gui/widgets/avatarlistbox.cpp | 5 +- src/gui/widgets/browserbox.cpp | 12 +- src/gui/widgets/browserbox.h | 22 ++-- src/gui/widgets/button.h | 16 +-- src/gui/widgets/colormodel.cpp | 4 +- src/gui/widgets/colormodel.h | 16 +-- src/gui/widgets/desktop.h | 4 +- src/gui/widgets/dropdown.h | 4 +- src/gui/widgets/dropshortcutcontainer.h | 8 +- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/itemcontainer.h | 8 +- src/gui/widgets/itemshortcutcontainer.h | 8 +- src/gui/widgets/label.cpp | 6 +- src/gui/widgets/label.h | 6 +- src/gui/widgets/listbox.h | 8 +- src/gui/widgets/progressbar.cpp | 6 +- src/gui/widgets/progressbar.h | 8 +- src/gui/widgets/shoplistbox.cpp | 4 +- src/gui/widgets/shoplistbox.h | 4 +- src/gui/widgets/skillinfo.h | 4 +- src/gui/widgets/tabs/setup_colors.cpp | 6 +- src/gui/widgets/tabs/tab.h | 40 +++---- src/gui/widgets/textbox.cpp | 6 +- src/gui/widgets/textbox.h | 6 +- src/gui/widgets/textfield.h | 2 +- src/gui/widgets/textpreview.cpp | 8 +- src/gui/widgets/textpreview.h | 16 +-- src/gui/widgets/widget2.h | 16 +-- src/gui/windows/equipmentwindow.h | 8 +- src/gui/windows/outfitwindow.h | 4 +- src/gui/windows/serverdialog.cpp | 4 +- src/gui/windows/skilldialog.cpp | 4 +- src/particle/particle.cpp | 4 +- src/particle/particle.h | 13 +-- src/particle/textparticle.cpp | 6 +- src/particle/textparticle.h | 4 +- src/render/graphics.h | 17 +-- src/render/mobileopenglgraphics.h | 2 +- src/render/normalopenglgraphics.h | 2 +- src/render/nullopenglgraphics.h | 2 +- src/render/openglgraphicsdef.hpp | 4 +- src/render/safeopenglgraphics.h | 2 +- src/text.cpp | 6 +- src/text.h | 12 +- src/utils/sdlpixel.h | 7 +- 69 files changed, 625 insertions(+), 643 deletions(-) delete mode 100644 src/gui/base/color.cpp delete mode 100644 src/gui/base/color.hpp create mode 100644 src/gui/color.cpp create mode 100644 src/gui/color.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cdc61aa91..cf8a905f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -767,7 +767,7 @@ SET(SRCS listeners/actionlistener.h gui/base/basiccontainer.hpp gui/base/cliprectangle.hpp - gui/base/color.hpp + gui/color.h listeners/deathlistener.h events/event.h listeners/focuslistener.h @@ -798,7 +798,7 @@ SET(SRCS gui/base/widgets/window.hpp gui/base/basiccontainer.cpp gui/base/cliprectangle.cpp - gui/base/color.cpp + gui/color.cpp gui/base/gui.cpp input/key.cpp gui/base/rectangle.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 246da6073..5a2fa34d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,11 +27,11 @@ endif dyecmd_CXXFLAGS = dyecmd_SOURCES = gui/base/cliprectangle.cpp \ - gui/base/color.cpp \ + gui/color.cpp \ gui/base/rectangle.cpp \ events/actionevent.h \ gui/base/cliprectangle.hpp \ - gui/base/color.hpp \ + gui/color.h \ events/event.h \ gui/base/rectangle.hpp @@ -152,7 +152,7 @@ manaplus_SOURCES += events/actionevent.h \ listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ gui/base/cliprectangle.hpp \ - gui/base/color.hpp \ + gui/color.h \ listeners/deathlistener.h \ events/event.h \ listeners/focuslistener.h \ @@ -184,7 +184,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/window.hpp \ gui/base/basiccontainer.cpp \ gui/base/cliprectangle.cpp \ - gui/base/color.cpp \ + gui/color.cpp \ gui/base/gui.cpp \ input/key.cpp \ gui/base/rectangle.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 76af509d3..485b439af 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -542,7 +542,7 @@ void Being::takeDamage(Being *const attacker, const int amount, // TRANSLATORS: hit or miss message in attacks const std::string damage = amount ? toString(amount) : type == FLEE ? _("dodge") : _("miss"); - const gcn::Color *color; + const Color *color; if (gui) font = gui->getInfoParticleFont(); diff --git a/src/being/being.h b/src/being/being.h index 4ef40d9fd..e427612f0 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -41,6 +41,7 @@ static const int DEFAULT_BEING_HEIGHT = 32; class AnimatedSprite; class BeingCacheEntry; +class Color; class Equipment; class FlashText; class Guild; @@ -52,11 +53,6 @@ class Text; struct ParticleInfo; -namespace gcn -{ - class Color; -} - extern volatile int cur_time; enum Gender @@ -969,7 +965,7 @@ class Being : public ActorSprite, public ConfigListener * Holds a text object when the being displays it's name, 0 otherwise */ FlashText *mDispName; - const gcn::Color *mNameColor; + const Color *mNameColor; /** Engine-related infos about weapon. */ const ItemInfo *mEquippedWeapon; @@ -979,7 +975,7 @@ class Being : public ActorSprite, public ConfigListener Path mPath; Text *mText; - const gcn::Color *mTextColor; + const Color *mTextColor; Vector mDest; /**< destination coordinates. */ diff --git a/src/client.cpp b/src/client.cpp index a08406d10..4aa5d4cd4 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -614,7 +614,7 @@ static void updateProgress(int cnt) { const int progress = cnt + loadingProgressCounter; const int h = mainGraphics->mHeight; - mainGraphics->setColor(gcn::Color(255, 255, 255)); + mainGraphics->setColor(Color(255, 255, 255)); const int maxSize = mainGraphics->mWidth - 100; const int width = maxSize * progress / 450; mainGraphics->fillRectangle(gcn::Rectangle(50, h - 100, width, 50)); diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 2592e6feb..6780b10fa 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -122,21 +122,21 @@ void FloorItem::draw(Graphics *const graphics, if (curTime > mDropTime + 28 && curTime < mDropTime + 50) { - graphics->setColor(gcn::Color(80, 200, 20, 200)); + graphics->setColor(Color(80, 200, 20, 200)); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime + 19 && curTime < mDropTime + 28) { - graphics->setColor(gcn::Color(200, 80, 20, + graphics->setColor(Color(200, 80, 20, 80 + 10 * (curTime - mDropTime - 18))); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime && curTime < mDropTime + 20) { - graphics->setColor(gcn::Color(20, 20, 255, + graphics->setColor(Color(20, 20, 255, 7 * (curTime - mDropTime))); graphics->fillRectangle(gcn::Rectangle( x, y, dx, dy)); @@ -153,7 +153,7 @@ void FloorItem::draw(Graphics *const graphics, { if (font && mAmount > 1) { -// graphics->setColor(gcn::Color(255, 255, 255, 100)); +// graphics->setColor(Color(255, 255, 255, 100)); graphics->setColor(userPalette->getColor( UserPalette::FLOOR_ITEM_TEXT)); font->drawString(graphics, toString(mAmount), x, y); diff --git a/src/gui/base/color.cpp b/src/gui/base/color.cpp deleted file mode 100644 index 485367e6d..000000000 --- a/src/gui/base/color.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/color.hpp" - -#include "debug.h" - -namespace gcn -{ - Color::Color() : - r(0U), - g(0U), - b(0U), - a(255U) - { - } - - Color::Color(const unsigned int color) : - r((color >> 16) & 0xFF), - g((color >> 8) & 0xFF), - b(color & 0xFF), - a(255U) - { - } - - Color::Color(const unsigned int ar, - const unsigned int ag, - const unsigned int ab, - const unsigned int aa) : - r(ar), - g(ag), - b(ab), - a(aa) - { - } - - Color Color::operator+(const Color& color) const - { - Color result(r + color.r, - g + color.g, - b + color.b, - 255U); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - Color Color::operator-(const Color& color) const - { - Color result(r - color.r, - g - color.g, - b - color.b, - 255U); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - Color Color::operator*(const float value) const - { - Color result(static_cast(static_cast(r) * value), - static_cast(static_cast(g) * value), - static_cast(static_cast(b) * value), - a); - - result.r = (result.r > 255U ? 255U : result.r); - result.g = (result.g > 255U ? 255U : result.g); - result.b = (result.b > 255U ? 255U : result.b); - - return result; - } - - bool Color::operator==(const Color& color) const - { - return r == color.r && g == color.g && b == color.b && a == color.a; - } - - bool Color::operator!=(const Color& color) const - { - return !(r == color.r && g == color.g && b == color.b && a == color.a); - } - - std::ostream& operator<<(std::ostream& out, - const Color& color) - { - out << "Color [r = " - << color.r - << ", g = " - << color.g - << ", b = " - << color.b - << ", a = " - << color.a - << "]"; - - return out; - } -} // namespace gcn diff --git a/src/gui/base/color.hpp b/src/gui/base/color.hpp deleted file mode 100644 index 781b2cb60..000000000 --- a/src/gui/base/color.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_COLOR_HPP -#define GCN_COLOR_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * Represents a color with red, green, blue and alpha components. - */ - class Color final - { - public: - /** - * Constructor. Initializes the color to black. - */ - Color(); - - /** - * Constructor. Constructs a color from the bytes in an integer. - * Call it with a hexadecimal constant for HTML-style color representation. - * The alpha component is 255 by default. - * - * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. - * - * NOTE: Because of this constructor, integers will be automatically - * casted to a color by your compiler. - * - * @param color The color to initialise the object with. - */ - explicit Color(const unsigned int color); - - /** - * Constructor. The default alpha value is 255. - * - * @param r Red color component (range 0-255). - * @param g Green color component (range 0-255). - * @param b Blue color component (range 0-255). - * @param a Alpha, used for transparency. A value of 0 means - * totaly transparent, 255 is totaly opaque. - */ - Color(const unsigned int r, - const unsigned int g, - const unsigned int b, - const unsigned int a = 255); - - /** - * Adds the RGB values of two colors together. The values will be - * clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to add to this color. - * @return The added colors with an alpha value set to 255. - */ - Color operator+(const Color& color) const; - - /** - * Subtracts the RGB values of one color from another. - * The values will be clamped if they go out of range. - * - * WARNING: This function will reset the alpha value of the - * returned color to 255. - * - * @param color A color to subtract from this color. - * @return The subtracted colors with an alpha value set to 255. - */ - Color operator-(const Color& color) const; - - /** - * Multiplies the RGB values of a color with a float value. - * The values will be clamped if they go out of range. - * - * @param value The value to multiply the color with. - * @return The multiplied colors. The alpha value will, unlike - * the add and subtract operations, be multiplied as - * well. - */ - Color operator*(const float value) const; - - /** - * Compares two colors. - * - * @return True if the two colors have the same RGBA components - * false otherwise. - */ - bool operator==(const Color& color) const; - - /** - * Compares two colors. - * - * @return True if the two colors have different RGBA components, - * false otherwise. - */ - bool operator!=(const Color& color) const; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param color The color to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Color& Color); - - /** - * Holds the red color component (range 0-255). - */ - unsigned int r; - - /** - * Holds the green color component (range 0-255). - */ - unsigned int g; - - /** - * Holds the blue color component (range 0-255). - */ - unsigned int b; - - /** - * Holds the alpha color component. A value of 0 means totally - * transparent while a value of 255 is considered opaque. - */ - unsigned int a; - }; -} // namespace gcn - -#endif // end GCN_COLOR_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index dd872d9a1..31d61312e 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -68,7 +68,8 @@ #include #include -#include "gui/base/color.hpp" +#include "gui/color.h" + #include "gui/base/rectangle.hpp" #include "gui/widgets/widget2.h" diff --git a/src/gui/color.cpp b/src/gui/color.cpp new file mode 100644 index 000000000..9a0034257 --- /dev/null +++ b/src/gui/color.cpp @@ -0,0 +1,165 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/color.h" + +#include "debug.h" + +Color::Color() : + r(0U), + g(0U), + b(0U), + a(255U) +{ +} + +Color::Color(const unsigned int color) : + r((color >> 16) & 0xFF), + g((color >> 8) & 0xFF), + b(color & 0xFF), + a(255U) +{ +} + +Color::Color(const unsigned int ar, + const unsigned int ag, + const unsigned int ab, + const unsigned int aa) : + r(ar), + g(ag), + b(ab), + a(aa) +{ +} + +Color Color::operator+(const Color& color) const +{ + Color result(r + color.r, + g + color.g, + b + color.b, + 255U); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +Color Color::operator-(const Color& color) const +{ + Color result(r - color.r, + g - color.g, + b - color.b, + 255U); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +Color Color::operator*(const float value) const +{ + Color result(static_cast(static_cast(r) * value), + static_cast(static_cast(g) * value), + static_cast(static_cast(b) * value), + a); + + result.r = (result.r > 255U ? 255U : result.r); + result.g = (result.g > 255U ? 255U : result.g); + result.b = (result.b > 255U ? 255U : result.b); + + return result; +} + +bool Color::operator==(const Color& color) const +{ + return r == color.r && g == color.g && b == color.b && a == color.a; +} + +bool Color::operator!=(const Color& color) const +{ + return !(r == color.r && g == color.g && b == color.b && a == color.a); +} + +std::ostream& operator<<(std::ostream& out, + const Color& color) +{ + out << "Color [r = " + << color.r + << ", g = " + << color.g + << ", b = " + << color.b + << ", a = " + << color.a + << "]"; + + return out; +} diff --git a/src/gui/color.h b/src/gui/color.h new file mode 100644 index 000000000..646680d96 --- /dev/null +++ b/src/gui/color.h @@ -0,0 +1,192 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_COLOR_H +#define GUI_COLOR_H + +#include + +#include "localconsts.h" + +/** + * Represents a color with red, green, blue and alpha components. + */ +class Color final +{ + public: + /** + * Constructor. Initializes the color to black. + */ + Color(); + + /** + * Constructor. Constructs a color from the bytes in an integer. + * Call it with a hexadecimal constant for HTML-style color representation. + * The alpha component is 255 by default. + * + * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. + * + * NOTE: Because of this constructor, integers will be automatically + * casted to a color by your compiler. + * + * @param color The color to initialise the object with. + */ + explicit Color(const unsigned int color); + + /** + * Constructor. The default alpha value is 255. + * + * @param r Red color component (range 0-255). + * @param g Green color component (range 0-255). + * @param b Blue color component (range 0-255). + * @param a Alpha, used for transparency. A value of 0 means + * totaly transparent, 255 is totaly opaque. + */ + Color(const unsigned int r, + const unsigned int g, + const unsigned int b, + const unsigned int a = 255); + + /** + * Adds the RGB values of two colors together. The values will be + * clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to add to this color. + * @return The added colors with an alpha value set to 255. + */ + Color operator+(const Color& color) const; + + /** + * Subtracts the RGB values of one color from another. + * The values will be clamped if they go out of range. + * + * WARNING: This function will reset the alpha value of the + * returned color to 255. + * + * @param color A color to subtract from this color. + * @return The subtracted colors with an alpha value set to 255. + */ + Color operator-(const Color& color) const; + + /** + * Multiplies the RGB values of a color with a float value. + * The values will be clamped if they go out of range. + * + * @param value The value to multiply the color with. + * @return The multiplied colors. The alpha value will, unlike + * the add and subtract operations, be multiplied as + * well. + */ + Color operator*(const float value) const; + + /** + * Compares two colors. + * + * @return True if the two colors have the same RGBA components + * false otherwise. + */ + bool operator==(const Color& color) const; + + /** + * Compares two colors. + * + * @return True if the two colors have different RGBA components, + * false otherwise. + */ + bool operator!=(const Color& color) const; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param color The color to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Color& Color); + + /** + * Holds the red color component (range 0-255). + */ + unsigned int r; + + /** + * Holds the green color component (range 0-255). + */ + unsigned int g; + + /** + * Holds the blue color component (range 0-255). + */ + unsigned int b; + + /** + * Holds the alpha color component. A value of 0 means totally + * transparent while a value of 255 is considered opaque. + */ + unsigned int a; +}; + +#endif // GUI_COLOR_H diff --git a/src/gui/font.cpp b/src/gui/font.cpp index fcc8e8344..e1d793ce1 100644 --- a/src/gui/font.cpp +++ b/src/gui/font.cpp @@ -99,8 +99,8 @@ int sdlTextChunkCnt = 0; #endif SDLTextChunkSmall::SDLTextChunkSmall(const std::string &text0, - const gcn::Color &color0, - const gcn::Color &color1) : + const Color &color0, + const Color &color1) : text(text0), color(color0), color2(color1) @@ -125,7 +125,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const if (chunk.text != text) return chunk.text > text; - const gcn::Color &c = chunk.color; + const Color &c = chunk.color; if (c.r != color.r) return c.r > color.r; if (c.g != color.g) @@ -133,7 +133,7 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const if (c.b != color.b) return c.b > color.b; - const gcn::Color &c2 = chunk.color2; + const Color &c2 = chunk.color2; if (c2.r != color2.r) return c2.r > color2.r; if (c2.g != color2.g) @@ -147,8 +147,8 @@ bool SDLTextChunkSmall::operator<(const SDLTextChunkSmall &chunk) const return false; } -SDLTextChunk::SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1) : +SDLTextChunk::SDLTextChunk(const std::string &text0, const Color &color0, + const Color &color1) : img(nullptr), text(text0), color(color0), @@ -499,8 +499,8 @@ void Font::drawString(Graphics *const graphics, if (!g) return; - gcn::Color col = g->getColor(); - const gcn::Color &col2 = g->getColor2(); + Color col = g->getColor(); + const Color &col2 = g->getColor2(); const float alpha = static_cast(col.a) / 255.0F; /* The alpha value is ignored at string generation so avoid caching the diff --git a/src/gui/font.h b/src/gui/font.h index 8740b4f3b..bdf81dadc 100644 --- a/src/gui/font.h +++ b/src/gui/font.h @@ -67,7 +67,7 @@ #ifndef GUI_FONT_H #define GUI_FONT_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include @@ -84,8 +84,8 @@ const unsigned int CACHES_NUMBER = 256; class SDLTextChunkSmall { public: - SDLTextChunkSmall(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); + SDLTextChunkSmall(const std::string &text0, const Color &color0, + const Color &color1); SDLTextChunkSmall(const SDLTextChunkSmall &old); @@ -93,15 +93,15 @@ class SDLTextChunkSmall bool operator<(const SDLTextChunkSmall &chunk) const; std::string text; - gcn::Color color; - gcn::Color color2; + Color color; + Color color2; }; class SDLTextChunk final { public: - SDLTextChunk(const std::string &text0, const gcn::Color &color0, - const gcn::Color &color1); + SDLTextChunk(const std::string &text0, const Color &color0, + const Color &color1); A_DELETE_COPY(SDLTextChunk) @@ -113,8 +113,8 @@ class SDLTextChunk final Image *img; std::string text; - gcn::Color color; - gcn::Color color2; + Color color; + Color color2; SDLTextChunk *prev; SDLTextChunk *next; }; diff --git a/src/gui/gui.h b/src/gui/gui.h index f6b4fbbf6..232d47a22 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -23,7 +23,8 @@ #ifndef GUI_GUI_H #define GUI_GUI_H -#include "gui/base/color.hpp" +#include "gui/color.h" + #include "gui/base/gui.hpp" #include "localconsts.h" @@ -198,8 +199,8 @@ class Gui final : public gcn::Gui typedef std::list FocusListenerList; typedef FocusListenerList::iterator FocusListenerIterator; FocusListenerList mFocusListeners; - gcn::Color mForegroundColor; - gcn::Color mForegroundColor2; + Color mForegroundColor; + Color mForegroundColor2; int mTime; bool mCustomCursor; /**< Show custom cursor */ bool mDoubleClick; diff --git a/src/gui/palette.cpp b/src/gui/palette.cpp index 9d6c19095..21e027d82 100644 --- a/src/gui/palette.cpp +++ b/src/gui/palette.cpp @@ -29,18 +29,18 @@ #include "debug.h" -const gcn::Color Palette::BLACK = gcn::Color(0, 0, 0); +const Color Palette::BLACK = Color(0, 0, 0); Palette::Palettes Palette::mInstances; -const gcn::Color Palette::RAINBOW_COLORS[7] = +const Color Palette::RAINBOW_COLORS[7] = { - gcn::Color(255, 0, 0), - gcn::Color(255, 153, 0), - gcn::Color(255, 255, 0), - gcn::Color(0, 153, 0), - gcn::Color(0, 204, 204), - gcn::Color(51, 0, 153), - gcn::Color(153, 0, 153) + Color(255, 0, 0), + Color(255, 153, 0), + Color(255, 255, 0), + Color(0, 153, 0), + Color(0, 204, 204), + Color(51, 0, 153), + Color(153, 0, 153) }; const int Palette::RAINBOW_COLOR_COUNT = 7; @@ -59,7 +59,7 @@ Palette::~Palette() mInstances.erase(this); } -const gcn::Color& Palette::getCharColor(const signed char c, bool &valid) const +const Color& Palette::getCharColor(const signed char c, bool &valid) const { const CharColors::const_iterator it = mCharColors.find(c); if (it != mCharColors.end()) @@ -128,7 +128,7 @@ void Palette::advanceGradient() else colIndex = gradIndex; - gcn::Color &color = elem->color; + Color &color = elem->color; int colVal; if (grad == PULSE) @@ -136,7 +136,7 @@ void Palette::advanceGradient() colVal = static_cast(255.0 * sin(M_PI * colIndex / numOfColors)); - const gcn::Color &col = elem->testColor; + const Color &col = elem->testColor; color.r = ((colVal * col.r) / 255) % (col.r + 1); color.g = ((colVal * col.g) / 255) % (col.g + 1); @@ -180,9 +180,9 @@ void Palette::advanceGradient() } else if (elem->grad == RAINBOW) { - const gcn::Color &startCol = RAINBOW_COLORS[colIndex]; - const gcn::Color &destCol = - RAINBOW_COLORS[(colIndex + 1) % numOfColors]; + const Color &startCol = RAINBOW_COLORS[colIndex]; + const Color &destCol + = RAINBOW_COLORS[(colIndex + 1) % numOfColors]; double startColVal; double destColVal; diff --git a/src/gui/palette.h b/src/gui/palette.h index 1377822ca..0dbb5d3ad 100644 --- a/src/gui/palette.h +++ b/src/gui/palette.h @@ -26,7 +26,7 @@ #include "logger.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #if defined __native_client__ #include @@ -49,7 +49,7 @@ class Palette { public: /** Black Color Constant */ - static const gcn::Color BLACK; + static const Color BLACK; /** Colors can be static or can alter over time. */ enum GradientType @@ -71,8 +71,8 @@ class Palette * * @return the requested color or Palette::BLACK */ - const gcn::Color &getCharColor(const signed char c, - bool &valid) const A_WARN_UNUSED; + const Color &getCharColor(const signed char c, + bool &valid) const A_WARN_UNUSED; int getIdByChar(const signed char c, bool &valid) const A_WARN_UNUSED; @@ -85,8 +85,8 @@ class Palette * * @return the requested color */ - inline const gcn::Color &getColor(int type, - const int alpha = 255) A_WARN_UNUSED + inline const Color &getColor(int type, + const int alpha = 255) A_WARN_UNUSED { if (type >= static_cast(mColors.size()) || type < 0) { @@ -94,15 +94,14 @@ class Palette type, static_cast(mColors.size())); type = 0; } - gcn::Color* col = &mColors[type].color; + Color* col = &mColors[type].color; col->a = alpha; return *col; } - inline const gcn::Color &getColorWithAlpha(const int type) - A_WARN_UNUSED + inline const Color &getColorWithAlpha(const int type) A_WARN_UNUSED { - gcn::Color* col = &mColors[type].color; + Color* col = &mColors[type].color; col->a = mColors[type].delay; return *col; } @@ -144,7 +143,7 @@ class Palette protected: /** Colors used for the rainbow gradient */ - static const gcn::Color RAINBOW_COLORS[7]; + static const Color RAINBOW_COLORS[7]; static const int RAINBOW_COLOR_COUNT; /** Time tick, that gradient-type colors were updated the last time. */ @@ -183,9 +182,9 @@ class Palette } int type; - gcn::Color color; - gcn::Color testColor; - gcn::Color committedColor; + Color color; + Color testColor; + Color committedColor; std::string text; signed char ch; GradientType grad; @@ -194,7 +193,7 @@ class Palette int delay; int committedDelay; - void set(const int type0, const gcn::Color &color0, + void set(const int type0, const Color &color0, const GradientType grad0, const int delay0) { type = type0; diff --git a/src/gui/popups/speechbubble.cpp b/src/gui/popups/speechbubble.cpp index 9bb6157bc..3d0250a78 100644 --- a/src/gui/popups/speechbubble.cpp +++ b/src/gui/popups/speechbubble.cpp @@ -57,8 +57,8 @@ void SpeechBubble::postInit() } void SpeechBubble::setCaption(const std::string &name, - const gcn::Color *const color1, - const gcn::Color *const color2) + const Color *const color1, + const Color *const color2) { mCaption->setCaption(name); mCaption->adjustSize(); diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h index 62da9b146..1bc5385a4 100644 --- a/src/gui/popups/speechbubble.h +++ b/src/gui/popups/speechbubble.h @@ -47,9 +47,9 @@ class SpeechBubble final : public Popup * Sets the name displayed for the speech bubble, and in what color. */ void setCaption(const std::string &name, - const gcn::Color *const color1 = + const Color *const color1 = &Theme::getThemeColor(Theme::BUBBLE_NAME), - const gcn::Color *const color2 = + const Color *const color2 = &Theme::getThemeColor(Theme::BUBBLE_NAME_OUTLINE)); /** diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 2a1b0d624..1a504f680 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -259,7 +259,7 @@ void Theme::deleteInstance() mInstance = nullptr; } -gcn::Color Theme::getProgressColor(const int type, const float progress) +Color Theme::getProgressColor(const int type, const float progress) { int color[3] = {0, 0, 0}; @@ -273,7 +273,7 @@ gcn::Color Theme::getProgressColor(const int type, const float progress) logger->log("color not found: " + toString(type)); } - return gcn::Color(color[0], color[1], color[2]); + return Color(color[0], color[1], color[2]); } Skin *Theme::load(const std::string &filename, const std::string &filename2, @@ -972,7 +972,7 @@ static int readColorType(const std::string &type) return -1; } -static gcn::Color readColor(const std::string &description) +static Color readColor(const std::string &description) { const int size = static_cast(description.length()); if (size < 7 || description[0] != '#') @@ -1010,7 +1010,7 @@ static gcn::Color readColor(const std::string &description) v = (v << 4) | n; } - return gcn::Color(v); + return Color(v); } static Palette::GradientType readColorGradient(const std::string &grad) @@ -1084,7 +1084,7 @@ void Theme::loadColors(std::string file) int type; std::string temp; - gcn::Color color; + Color color; GradientType grad; for_each_xml_child_node(paletteNode, root) diff --git a/src/gui/theme.h b/src/gui/theme.h index 826902004..86543ea64 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -450,21 +450,21 @@ class Theme final : public Palette, public ConfigListener * * @return the requested color */ - inline static const gcn::Color &getThemeColor(const int type, - const int alpha = 255) - A_WARN_UNUSED + inline static const Color &getThemeColor(const int type, + const int alpha = 255) + A_WARN_UNUSED { return mInstance->getColor(type, alpha); } - static const gcn::Color &getThemeCharColor(const signed char c, - bool &valid) A_WARN_UNUSED + static const Color &getThemeCharColor(const signed char c, + bool &valid) A_WARN_UNUSED { return mInstance->getCharColor(c, valid); } static int getThemeIdByChar(const signed char c, bool &valid) A_WARN_UNUSED { return mInstance->getIdByChar(c, valid); } - static gcn::Color getProgressColor(const int type, - const float progress) A_WARN_UNUSED; + static Color getProgressColor(const int type, + const float progress) A_WARN_UNUSED; /** * Loads a skin. diff --git a/src/gui/userpalette.cpp b/src/gui/userpalette.cpp index 69125f8e2..74d47203f 100644 --- a/src/gui/userpalette.cpp +++ b/src/gui/userpalette.cpp @@ -237,7 +237,7 @@ UserPalette::~UserPalette() void UserPalette::setColor(const int type, const int r, const int g, const int b) { - gcn::Color &color = mColors[type].color; + Color &color = mColors[type].color; color.r = r; color.g = g; color.b = b; @@ -296,14 +296,14 @@ void UserPalette::rollback() if (i->grad != i->committedGrad) setGradient(i->type, i->committedGrad); - const gcn::Color &committedColor = i->committedColor; + const Color &committedColor = i->committedColor; setGradientDelay(i->type, i->committedDelay); setColor(i->type, committedColor.r, committedColor.g, committedColor.b); if (i->grad == PULSE) { - gcn::Color &testColor = i->testColor; + Color &testColor = i->testColor; testColor.r = committedColor.r; testColor.g = committedColor.g; testColor.b = committedColor.b; @@ -342,7 +342,7 @@ void UserPalette::addColor(const unsigned type, const unsigned rgb, rgbValue = atox(rgbString); else rgbValue = atoi(rgbString.c_str()); - const gcn::Color &trueCol = gcn::Color(rgbValue); + const Color &trueCol = Color(rgbValue); grad = static_cast(config.getValue(configName + "Gradient", static_cast(grad))); delay = config.getValueInt(configName + "Delay", delay); diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index fbba415b8..e37eee0ca 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -100,8 +100,8 @@ class UserPalette final : public Palette, public gcn::ListModel * * @return the requested committed color */ - inline const gcn::Color &getCommittedColor(const int type) - const A_WARN_UNUSED + inline const Color &getCommittedColor(const int type) + const A_WARN_UNUSED { return mColors[type].committedColor; } @@ -113,8 +113,7 @@ class UserPalette final : public Palette, public gcn::ListModel * * @return the requested test color */ - inline const gcn::Color &getTestColor(const int type) - const A_WARN_UNUSED + inline const Color &getTestColor(const int type) const A_WARN_UNUSED { return mColors[type].testColor; } /** @@ -123,7 +122,7 @@ class UserPalette final : public Palette, public gcn::ListModel * @param type the color type requested * @param color the color that should be tested */ - inline void setTestColor(const int type, const gcn::Color &color) + inline void setTestColor(const int type, const Color &color) { mColors[type].testColor = color; } /** diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index ee64736eb..54619c3e6 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -121,7 +121,7 @@ void Viewport::draw(Graphics *graphics) if (!mMap || !player_node) { - graphics->setColor(gcn::Color(64, 64, 64)); + graphics->setColor(Color(64, 64, 64)); graphics->fillRectangle( gcn::Rectangle(0, 0, getWidth(), getHeight())); BLOCK_END("Viewport::draw 1") @@ -338,7 +338,7 @@ void Viewport::_drawDebugPath(Graphics *const graphics) } void Viewport::_drawPath(Graphics *const graphics, const Path &path, - const gcn::Color &color) const + const Color &color) const { graphics->setColor(color); Font *const font = getFont(); diff --git a/src/gui/viewport.h b/src/gui/viewport.h index 2b297de37..16d0e4e34 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -298,7 +298,7 @@ class Viewport final : public WindowContainer, * Draws the given path. */ void _drawPath(Graphics *const graphics, const Path &path, - const gcn::Color &color = gcn::Color(255, 0, 0)) const; + const Color &color = Color(255, 0, 0)) const; /** * Make the player go to the mouse position. diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 298ab657a..a71051b5d 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -154,7 +154,7 @@ void AvatarListBox::draw(Graphics *graphics) } if (parent && a->getMaxHp()) { - gcn::Color color = Theme::getProgressColor( + Color color = Theme::getProgressColor( Theme::PROG_HP, static_cast(a->getHp()) / static_cast(a->getMaxHp())); color.a = 80; @@ -180,8 +180,7 @@ void AvatarListBox::draw(Graphics *graphics) if (parent) { - gcn::Color color = Theme::getProgressColor(Theme::PROG_HP, - 1); + Color color = Theme::getProgressColor(Theme::PROG_HP, 1); color.a = 80; graphics->setColor(color); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index cc83d2b83..b6644cbc1 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -534,8 +534,8 @@ int BrowserBox::calcHeight() const char *const hyphen = "~"; const int hyphenWidth = font->getWidth(hyphen); - gcn::Color selColor[2] = {mForegroundColor, mForegroundColor2}; - const gcn::Color textColor[2] = {mForegroundColor, mForegroundColor2}; + Color selColor[2] = {mForegroundColor, mForegroundColor2}; + const Color textColor[2] = {mForegroundColor, mForegroundColor2}; ResourceManager *const resman = ResourceManager::getInstance(); mLineParts.clear(); @@ -581,7 +581,7 @@ int BrowserBox::calcHeight() continue; } - gcn::Color prevColor[2]; + Color prevColor[2]; prevColor[0] = selColor[0]; prevColor[1] = selColor[1]; bold = false; @@ -621,7 +621,7 @@ int BrowserBox::calcHeight() const signed char c = row.at(start + 2); bool valid(false); - const gcn::Color col[2] = + const Color col[2] = { getThemeCharColor(c, valid), getThemeCharColor(c | 0x80, valid) @@ -897,8 +897,8 @@ std::string BrowserBox::getTextAtPos(const int x, const int y) const return str; } -void BrowserBox::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void BrowserBox::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index 1f09dd0b1..a33c69698 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -58,8 +58,8 @@ struct BrowserLink final class LinePart final { public: - LinePart(const int x, const int y, const gcn::Color &color, - const gcn::Color &color2, const std::string &text, + LinePart(const int x, const int y, const Color &color, + const Color &color2, const std::string &text, const bool bold) : mX(x), mY(y), @@ -72,8 +72,8 @@ class LinePart final { } - LinePart(const int x, const int y, const gcn::Color &color, - const gcn::Color &color2, Image *const image) : + LinePart(const int x, const int y, const Color &color, + const Color &color2, Image *const image) : mX(x), mY(y), mColor(color), @@ -88,8 +88,8 @@ class LinePart final ~LinePart(); int mX, mY; - gcn::Color mColor; - gcn::Color mColor2; + Color mColor; + Color mColor2; std::string mText; unsigned char mType; Image *mImage; @@ -228,8 +228,8 @@ class BrowserBox final : public gcn::Widget, int getPadding() const A_WARN_UNUSED { return mPadding; } - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); int getDataWidth() const { return mDataWidth; } @@ -266,9 +266,9 @@ class BrowserBox final : public gcn::Widget, int mItemPadding; unsigned int mDataWidth; - gcn::Color mHighlightColor; - gcn::Color mHyperLinkColor; - gcn::Color mColors[2][COLORS_MAX]; + Color mHighlightColor; + Color mHyperLinkColor; + Color mColors[2][COLORS_MAX]; bool mOpaque; bool mUseLinksAndUserColors; diff --git a/src/gui/widgets/button.h b/src/gui/widgets/button.h index 4f2e9fd89..039475150 100644 --- a/src/gui/widgets/button.h +++ b/src/gui/widgets/button.h @@ -165,14 +165,14 @@ class Button final : public gcn::Button, std::string mDescription; ImageCollection *mVertexes2; - gcn::Color mEnabledColor; - gcn::Color mEnabledColor2; - gcn::Color mDisabledColor; - gcn::Color mDisabledColor2; - gcn::Color mHighlightedColor; - gcn::Color mHighlightedColor2; - gcn::Color mPressedColor; - gcn::Color mPressedColor2; + Color mEnabledColor; + Color mEnabledColor2; + Color mDisabledColor; + Color mDisabledColor2; + Color mHighlightedColor; + Color mHighlightedColor2; + Color mPressedColor; + Color mPressedColor2; Image **mImages; ImageSet *mImageSet; unsigned mClickCount; diff --git a/src/gui/widgets/colormodel.cpp b/src/gui/widgets/colormodel.cpp index 7e59553e3..3a71a93cc 100644 --- a/src/gui/widgets/colormodel.cpp +++ b/src/gui/widgets/colormodel.cpp @@ -56,8 +56,8 @@ const ColorPair *ColorModel::getColorAt(const int i) const return &mColors[i]; } -void ColorModel::add(const std::string &name, const gcn::Color *const color1, - const gcn::Color *const color2) +void ColorModel::add(const std::string &name, const Color *const color1, + const Color *const color2) { mNames.push_back(name); mColors.push_back(ColorPair(color1, color2)); diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h index c019d9aac..7386a856b 100644 --- a/src/gui/widgets/colormodel.h +++ b/src/gui/widgets/colormodel.h @@ -27,23 +27,19 @@ #include "localconsts.h" +class Color; class Widget2; -namespace gcn -{ - class Color; -} - struct ColorPair { - ColorPair(const gcn::Color* c1, const gcn::Color* c2) : + ColorPair(const Color* c1, const Color* c2) : color1(c1), color2(c2) { } - const gcn::Color* color1; - const gcn::Color* color2; + const Color* color1; + const Color* color2; }; class ColorModel : public gcn::ListModel @@ -67,8 +63,8 @@ class ColorModel : public gcn::ListModel size_t size() A_WARN_UNUSED { return mNames.size(); } - void add(const std::string &name, const gcn::Color *const color1, - const gcn::Color *const color2); + void add(const std::string &name, const Color *const color1, + const Color *const color2); static ColorModel *createDefault(const Widget2 *const widget); diff --git a/src/gui/widgets/desktop.h b/src/gui/widgets/desktop.h index ad07b0ff8..f0fd500ea 100644 --- a/src/gui/widgets/desktop.h +++ b/src/gui/widgets/desktop.h @@ -72,8 +72,8 @@ class Desktop final : public Container, Image *mWallpaper; Label *mVersionLabel; Skin *mSkin; - gcn::Color mBackgroundColor; - gcn::Color mBackgroundGrayColor; + Color mBackgroundColor; + Color mBackgroundGrayColor; bool mShowBackground; }; diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 9bb459d45..815e4a85d 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -144,8 +144,8 @@ class DropDown final : public ActionListener, void drawButton(Graphics *graphics); PopupList *mPopup; - gcn::Color mShadowColor; - gcn::Color mHighlightColor; + Color mShadowColor; + Color mHighlightColor; int mPadding; int mImagePadding; int mSpacing; diff --git a/src/gui/widgets/dropshortcutcontainer.h b/src/gui/widgets/dropshortcutcontainer.h index 236415b32..1888292de 100644 --- a/src/gui/widgets/dropshortcutcontainer.h +++ b/src/gui/widgets/dropshortcutcontainer.h @@ -79,10 +79,10 @@ class DropShortcutContainer final : public ShortcutContainer bool mItemClicked; ItemPopup *mItemPopup; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; }; #endif // GUI_WIDGETS_DROPSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 96f2a9532..b2c7c5620 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -188,7 +188,7 @@ private: /** * Holds the background color of the table. */ - gcn::Color mHighlightColor; + Color mHighlightColor; int mSelectedRow; int mSelectedColumn; diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index ab813b08f..32daa459b 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -181,10 +181,10 @@ class ItemContainer final : public gcn::Widget, ItemPopup *mItemPopup; int *mShowMatrix; Skin *mSkin; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; typedef std::list SelectionListenerList; typedef SelectionListenerList::iterator SelectionListenerIterator; SelectionListenerList mSelectionListeners; diff --git a/src/gui/widgets/itemshortcutcontainer.h b/src/gui/widgets/itemshortcutcontainer.h index dd95851a6..07c3ef822 100644 --- a/src/gui/widgets/itemshortcutcontainer.h +++ b/src/gui/widgets/itemshortcutcontainer.h @@ -83,10 +83,10 @@ class ItemShortcutContainer final : public ShortcutContainer ItemPopup *mItemPopup; SpellPopup *mSpellPopup; - gcn::Color mEquipedColor; - gcn::Color mEquipedColor2; - gcn::Color mUnEquipedColor; - gcn::Color mUnEquipedColor2; + Color mEquipedColor; + Color mEquipedColor2; + Color mUnEquipedColor; + Color mUnEquipedColor2; }; #endif // GUI_WIDGETS_ITEMSHORTCUTCONTAINER_H diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 0c19d03c3..c02f37adb 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -114,14 +114,14 @@ void Label::adjustSize() setHeight(font->getHeight() + pad2); } -void Label::setForegroundColor(const gcn::Color &color) +void Label::setForegroundColor(const Color &color) { mForegroundColor = color; mForegroundColor2 = color; } -void Label::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void Label::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index b63c9b10e..616f6cc79 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -62,10 +62,10 @@ class Label final : public gcn::Label void adjustSize(); - void setForegroundColor(const gcn::Color &color); + void setForegroundColor(const Color &color); - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); void resizeTo(const int maxSize, const int minSize); diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 625f21085..61e1596f7 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_LISTBOX_H #define GUI_WIDGETS_LISTBOX_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include "gui/base/widgets/listbox.hpp" @@ -115,9 +115,9 @@ class ListBox : public gcn::ListBox { mRowHeight = n; } protected: - gcn::Color mHighlightColor; - gcn::Color mForegroundSelectedColor; - gcn::Color mForegroundSelectedColor2; + Color mHighlightColor; + Color mForegroundSelectedColor; + Color mForegroundSelectedColor2; int mOldSelected; int mPadding; int mPressedIndex; diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index b44b6a1a0..7d2d00ad4 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -184,7 +184,7 @@ void ProgressBar::setProgressPalette(const int progressPalette) } } -void ProgressBar::setBackgroundColor(const gcn::Color &color) +void ProgressBar::setBackgroundColor(const Color &color) { mRedraw = true; mBackgroundColorToGo = color; @@ -193,7 +193,7 @@ void ProgressBar::setBackgroundColor(const gcn::Color &color) mBackgroundColor = color; } -void ProgressBar::setColor(const gcn::Color &color1, const gcn::Color &color2) +void ProgressBar::setColor(const Color &color1, const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; @@ -269,7 +269,7 @@ void ProgressBar::render(Graphics *graphics) // The label if (!mText.empty()) { - const gcn::Color oldColor = graphics->getColor(); + const Color oldColor = graphics->getColor(); Font *const font = gui->getFont(); const int textX = mDimension.width / 2; diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index a2c55e077..a4862882e 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -93,14 +93,14 @@ class ProgressBar final : public gcn::Widget, /** * Change the color of the progress bar. */ - void setBackgroundColor(const gcn::Color &color); + void setBackgroundColor(const Color &color); - void setColor(const gcn::Color &color1, const gcn::Color &color2); + void setColor(const Color &color1, const Color &color2); /** * Returns the color of the progress bar. */ - const gcn::Color &getBackgroundColor() const A_WARN_UNUSED + const Color &getBackgroundColor() const A_WARN_UNUSED { return mBackgroundColor; } /** @@ -145,7 +145,7 @@ class ProgressBar final : public gcn::Widget, float mProgress; float mProgressToGo; - gcn::Color mBackgroundColorToGo; + Color mBackgroundColorToGo; std::string mText; ImageCollection *mVertexes; diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 85ff90261..59ae1059e 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -106,8 +106,8 @@ void ShopListBox::draw(Graphics *graphics) ++i, y += mRowHeight) { bool needDraw(false); - gcn::Color temp; - gcn::Color* backgroundColor = &mBackgroundColor; + Color temp; + Color* backgroundColor = &mBackgroundColor; ShopItem *const item = mShopItems->at(i); if (item && ((mShopItems && mPlayerMoney < item->getPrice() diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 1cf628cca..38e209c33 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -94,8 +94,8 @@ class ShopListBox final : public ListBox ItemPopup *mItemPopup; - gcn::Color mBackgroundColor; - gcn::Color mWarningColor; + Color mBackgroundColor; + Color mWarningColor; bool mPriceCheck; bool mProtectItems; diff --git a/src/gui/widgets/skillinfo.h b/src/gui/widgets/skillinfo.h index a201f3274..f9baec6cc 100644 --- a/src/gui/widgets/skillinfo.h +++ b/src/gui/widgets/skillinfo.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_SKILLINFO_H #define GUI_WIDGETS_SKILLINFO_H -#include "gui/base/color.hpp" +#include "gui/color.h" #include #include @@ -43,7 +43,7 @@ struct SkillInfo final std::string skillLevel; std::string skillExp; float progress; - gcn::Color color; + Color color; SkillDataMap dataMap; SkillModel *model; SkillData *data; diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 9e78133f5..61219fa98 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -253,7 +253,7 @@ void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) mSelected = mColorBox->getSelected(); const int type = userPalette->getColorTypeAt(mSelected); - const gcn::Color *col = &userPalette->getColor(type); + const Color *col = &userPalette->getColor(type); const Palette::GradientType grad = userPalette->getGradientType(type); const int delay = userPalette->getGradientDelay(type); @@ -383,7 +383,7 @@ void Setup_Colors::cancel() userPalette->rollback(); const int type = userPalette->getColorTypeAt(mSelected); - const gcn::Color *const col = &userPalette->getColor(type); + const Color *const col = &userPalette->getColor(type); mGradTypeSlider->setValue2(userPalette->getGradientType(type)); const int delay = userPalette->getGradientDelay(type); setEntry(mGradDelaySlider, mGradDelayText, delay); @@ -444,7 +444,7 @@ void Setup_Colors::updateColor() } else if (grad == Palette::PULSE) { - userPalette->setTestColor(type, gcn::Color( + userPalette->setTestColor(type, Color( static_cast(mRedSlider->getValue()), static_cast(mGreenSlider->getValue()), static_cast(mBlueSlider->getValue()))); diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h index 463a6b668..1f52cde88 100644 --- a/src/gui/widgets/tabs/tab.h +++ b/src/gui/widgets/tabs/tab.h @@ -114,8 +114,8 @@ class Tab : public gcn::BasicContainer, /** * Set the normal color for the tab's text. */ - void setTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setTabColor(const Color *const color1, + const Color *const color2) { mTabColor = color1; mTabOutlineColor = color2; @@ -124,8 +124,8 @@ class Tab : public gcn::BasicContainer, /** * Set the highlighted color for the tab's text. */ - void setHighlightedTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setHighlightedTabColor(const Color *const color1, + const Color *const color2) { mTabHighlightedColor = color1; mTabHighlightedOutlineColor = color2; @@ -134,8 +134,8 @@ class Tab : public gcn::BasicContainer, /** * Set the selected color for the tab's text. */ - void setSelectedTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setSelectedTabColor(const Color *const color1, + const Color *const color2) { mTabSelectedColor = color1; mTabSelectedOutlineColor = color2; @@ -144,8 +144,8 @@ class Tab : public gcn::BasicContainer, /** * Set the flash color for the tab's text. */ - void setFlashTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setFlashTabColor(const Color *const color1, + const Color *const color2) { mFlashColor = color1; mFlashOutlineColor = color2; @@ -154,8 +154,8 @@ class Tab : public gcn::BasicContainer, /** * Set the player flash color for the tab's text. */ - void setPlayerFlashTabColor(const gcn::Color *const color1, - const gcn::Color *const color2) + void setPlayerFlashTabColor(const Color *const color1, + const Color *const color2) { mPlayerFlashColor = color1; mPlayerFlashOutlineColor = color2; @@ -214,16 +214,16 @@ class Tab : public gcn::BasicContainer, static int mInstances; /**< Number of tab instances */ static float mAlpha; - const gcn::Color *mTabColor; - const gcn::Color *mTabOutlineColor; - const gcn::Color *mTabHighlightedColor; - const gcn::Color *mTabHighlightedOutlineColor; - const gcn::Color *mTabSelectedColor; - const gcn::Color *mTabSelectedOutlineColor; - const gcn::Color *mFlashColor; - const gcn::Color *mFlashOutlineColor; - const gcn::Color *mPlayerFlashColor; - const gcn::Color *mPlayerFlashOutlineColor; + const Color *mTabColor; + const Color *mTabOutlineColor; + const Color *mTabHighlightedColor; + const Color *mTabHighlightedOutlineColor; + const Color *mTabSelectedColor; + const Color *mTabSelectedOutlineColor; + const Color *mFlashColor; + const Color *mFlashOutlineColor; + const Color *mPlayerFlashColor; + const Color *mPlayerFlashOutlineColor; int mFlash; ImageCollection *mVertexes; Image *mImage; diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index ec0d09a26..e0327e670 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -379,14 +379,14 @@ void TextBox::draw(Graphics* graphics) BLOCK_END("TextBox::draw") } -void TextBox::setForegroundColor(const gcn::Color &color) +void TextBox::setForegroundColor(const Color &color) { mForegroundColor = color; mForegroundColor2 = color; } -void TextBox::setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2) +void TextBox::setForegroundColorAll(const Color &color1, + const Color &color2) { mForegroundColor = color1; mForegroundColor2 = color2; diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 24dd57adb..3f78fd247 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -61,10 +61,10 @@ class TextBox final : public gcn::TextBox void draw(Graphics* graphics) override final; - void setForegroundColor(const gcn::Color &color); + void setForegroundColor(const Color &color); - void setForegroundColorAll(const gcn::Color &color1, - const gcn::Color &color2); + void setForegroundColorAll(const Color &color1, + const Color &color2); private: int mMinWidth; diff --git a/src/gui/widgets/textfield.h b/src/gui/widgets/textfield.h index b05a498dc..ccc1b16d6 100644 --- a/src/gui/widgets/textfield.h +++ b/src/gui/widgets/textfield.h @@ -159,7 +159,7 @@ class TextField : public gcn::TextField, static Skin *mSkin; private: - const gcn::Color *mCaretColor; + const Color *mCaretColor; PopupMenu *mPopupMenu; static int instances; static float mAlpha; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 1344c647a..462ba17d9 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -89,7 +89,7 @@ void TextPreview::draw(Graphics* graphics) if (mOpaque) { - graphics->setColor(gcn::Color(static_cast(mBGColor->r), + graphics->setColor(Color(static_cast(mBGColor->r), static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0F))); @@ -105,7 +105,7 @@ void TextPreview::draw(Graphics* graphics) + 2 * ((mOutline || mShadow) ? 1 :0); const int y = mFont->getHeight() + 1 + 2 * ((mOutline || mShadow) ? 1 : 0); - graphics->setColor(gcn::Color(static_cast(mTextBGColor->r), + graphics->setColor(Color(static_cast(mTextBGColor->r), static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), intAlpha)); @@ -113,9 +113,9 @@ void TextPreview::draw(Graphics* graphics) } } - graphics->setColorAll(gcn::Color(mTextColor->r, + graphics->setColorAll(Color(mTextColor->r, mTextColor->g, mTextColor->b, alpha), - gcn::Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); + Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha)); if (mOutline && mTextColor != mTextColor2) graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE)); diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 31f64f545..31768fa66 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -40,10 +40,10 @@ class TextPreview final : public gcn::Widget ~TextPreview(); - inline void setTextColor(const gcn::Color *color) + inline void setTextColor(const Color *color) { mTextColor = color; adjustSize(); } - inline void setTextColor2(const gcn::Color *color) + inline void setTextColor2(const Color *color) { mTextColor2 = color; adjustSize(); } /** @@ -60,7 +60,7 @@ class TextPreview final : public gcn::Widget * * @param color the color to set */ - inline void setTextBGColor(const gcn::Color *color) + inline void setTextBGColor(const Color *color) { mTextBGColor = color; } /** @@ -68,7 +68,7 @@ class TextPreview final : public gcn::Widget * * @param color the color to set */ - inline void setBGColor(const gcn::Color *color) + inline void setBGColor(const Color *color) { mBGColor = color; } /** @@ -123,10 +123,10 @@ class TextPreview final : public gcn::Widget private: Font *mFont; std::string mText; - const gcn::Color *mTextColor; - const gcn::Color *mTextColor2; - const gcn::Color *mBGColor; - const gcn::Color *mTextBGColor; + const Color *mTextColor; + const Color *mTextColor2; + const Color *mBGColor; + const Color *mTextBGColor; int mPadding; static int instances; static float mAlpha; diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h index c6317702f..ff565815f 100644 --- a/src/gui/widgets/widget2.h +++ b/src/gui/widgets/widget2.h @@ -32,16 +32,16 @@ class Widget2 { } - inline const gcn::Color &getThemeColor(const int type, - const int alpha = 255) - const A_WARN_UNUSED + inline const Color &getThemeColor(const int type, + const int alpha = 255) + const A_WARN_UNUSED { return Theme::getThemeColor(mPaletteOffset + type, alpha); } - inline const gcn::Color &getThemeCharColor(const signed char c, - bool &valid) - const A_WARN_UNUSED + inline const Color &getThemeCharColor(const signed char c, + bool &valid) + const A_WARN_UNUSED { const int colorId = Theme::getThemeIdByChar(c, valid); if (valid) @@ -71,7 +71,7 @@ class Widget2 } } - void setForegroundColor2(const gcn::Color &color) + void setForegroundColor2(const Color &color) { mForegroundColor2 = color; } @@ -85,7 +85,7 @@ class Widget2 } int mPaletteOffset; - gcn::Color mForegroundColor2; + Color mForegroundColor2; }; extern RenderType openGLMode; diff --git a/src/gui/windows/equipmentwindow.h b/src/gui/windows/equipmentwindow.h index c9ca12bbd..0ab4ca462 100644 --- a/src/gui/windows/equipmentwindow.h +++ b/src/gui/windows/equipmentwindow.h @@ -136,10 +136,10 @@ class EquipmentWindow final : public Window, ImageSet *mImageSet; Being *mBeing; std::vector mBoxes; - gcn::Color mHighlightColor; - gcn::Color mBorderColor; - gcn::Color mLabelsColor; - gcn::Color mLabelsColor2; + Color mHighlightColor; + Color mBorderColor; + Color mLabelsColor; + Color mLabelsColor2; Image *mSlotBackground; Image *mSlotHighlightedBackground; ImageCollection *mVertexes; diff --git a/src/gui/windows/outfitwindow.h b/src/gui/windows/outfitwindow.h index 909b84a41..55948f834 100644 --- a/src/gui/windows/outfitwindow.h +++ b/src/gui/windows/outfitwindow.h @@ -115,8 +115,8 @@ class OutfitWindow final : public Window, int mItems[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT]; int mAwayOutfit; - gcn::Color mBorderColor; - gcn::Color mBackgroundColor; + Color mBorderColor; + Color mBackgroundColor; unsigned char mItemColors[OUTFITS_COUNT + 1][OUTFIT_ITEM_COUNT]; bool mItemClicked; bool mItemsUnequip[OUTFITS_COUNT]; diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index a06257b10..cbab4710d 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -236,8 +236,8 @@ public: return 2 * getFont()->getHeight() + 5; } private: - gcn::Color mNotSupportedColor; - gcn::Color mNotSupportedColor2; + Color mNotSupportedColor; + Color mNotSupportedColor2; }; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 9cc952ec6..2e9a8be10 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -231,8 +231,8 @@ class SkillListBox final : public ListBox private: SkillModel *mModel; TextPopup *mPopup; - gcn::Color mTextColor; - gcn::Color mTextColor2; + Color mTextColor; + Color mTextColor2; int mTextPadding; int mSpacing; bool mSkillClicked; diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 83ec97521..c446fa177 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -414,7 +414,7 @@ Particle *Particle::addEffect(const std::string &particleEffectFile, Particle *Particle::addTextSplashEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) { @@ -438,7 +438,7 @@ Particle *Particle::addTextSplashEffect(const std::string &text, Particle *Particle::addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) { diff --git a/src/particle/particle.h b/src/particle/particle.h index f69770513..491232b17 100644 --- a/src/particle/particle.h +++ b/src/particle/particle.h @@ -30,16 +30,11 @@ #include #include +class Color; +class Font; class Particle; class ParticleEmitter; -namespace gcn -{ - class Color; -} - -class Font; - typedef std::list Particles; typedef Particles::iterator ParticleIterator; typedef Particles::const_iterator ParticleConstIterator; @@ -136,7 +131,7 @@ class Particle : public Actor */ Particle *addTextSplashEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); @@ -145,7 +140,7 @@ class Particle : public Actor */ Particle *addTextRiseFadeOutEffect(const std::string &text, const int x, const int y, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp index 1ac6ac6c2..41ea683f6 100644 --- a/src/particle/textparticle.cpp +++ b/src/particle/textparticle.cpp @@ -26,13 +26,13 @@ #include "gui/theme.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #include "gui/font.h" #include "debug.h" TextParticle::TextParticle(const std::string &text, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline) : Particle(), mText(text), @@ -74,7 +74,7 @@ void TextParticle::draw(Graphics *const graphics, / static_cast(mFadeIn); } - gcn::Color color = *mColor; + Color color = *mColor; color.a = static_cast(alpha); graphics->setColor(color); diff --git a/src/particle/textparticle.h b/src/particle/textparticle.h index 0d598508d..ec586c3a9 100644 --- a/src/particle/textparticle.h +++ b/src/particle/textparticle.h @@ -32,7 +32,7 @@ class TextParticle final : public Particle * Constructor. */ TextParticle(const std::string &text, - const gcn::Color *const color, + const Color *const color, Font *const font, const bool outline = false); A_DELETE_COPY(TextParticle) @@ -54,7 +54,7 @@ class TextParticle final : public Particle private: std::string mText; /**< Text of the particle. */ Font *mTextFont; /**< Font used for drawing the text. */ - const gcn::Color *mColor; /**< Color used for drawing the text. */ + const Color *mColor; /**< Color used for drawing the text. */ int mTextWidth; bool mOutline; /**< Make the text better readable */ }; diff --git a/src/render/graphics.h b/src/render/graphics.h index 53eb4af12..2356d2d31 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -70,10 +70,11 @@ #include "sdlshared.h" +#include "gui/color.h" + #include "render/renderers.h" #include "gui/base/cliprectangle.hpp" -#include "gui/base/color.hpp" #ifdef USE_SDL2 #include @@ -331,27 +332,27 @@ class Graphics virtual void initArrays() { } - virtual void setColor(const gcn::Color &color) + virtual void setColor(const Color &color) { mColor = color; mColor2 = color; mAlpha = (color.a != 255); } - void setColor2(const gcn::Color &color) + void setColor2(const Color &color) { mColor2 = color; } - void setColorAll(const gcn::Color &color, const gcn::Color &color2) + void setColorAll(const Color &color, const Color &color2) { mColor = color; mColor2 = color2; mAlpha = (color.a != 255); } - const gcn::Color &getColor() const + const Color &getColor() const { return mColor; } - const gcn::Color &getColor2() const + const Color &getColor2() const { return mColor2; } #ifdef DEBUG_DRAW_CALLS @@ -534,8 +535,8 @@ class Graphics int mStartFreeMem; bool mSync; int mScale; - gcn::Color mColor; - gcn::Color mColor2; + Color mColor; + Color mColor2; }; extern Graphics *mainGraphics; diff --git a/src/render/mobileopenglgraphics.h b/src/render/mobileopenglgraphics.h index f665f743b..0b9cd83e2 100644 --- a/src/render/mobileopenglgraphics.h +++ b/src/render/mobileopenglgraphics.h @@ -127,7 +127,7 @@ class MobileOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; GLuint mImageCached; float mFloatColor; int mMaxVertices; diff --git a/src/render/normalopenglgraphics.h b/src/render/normalopenglgraphics.h index 882ff5ed8..214954e3c 100644 --- a/src/render/normalopenglgraphics.h +++ b/src/render/normalopenglgraphics.h @@ -143,7 +143,7 @@ class NormalOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; GLuint mImageCached; float mFloatColor; int mMaxVertices; diff --git a/src/render/nullopenglgraphics.h b/src/render/nullopenglgraphics.h index cbab0614d..ee2a5d189 100644 --- a/src/render/nullopenglgraphics.h +++ b/src/render/nullopenglgraphics.h @@ -130,7 +130,7 @@ class NullOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; float mFloatColor; int mMaxVertices; bool mColorAlpha; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 89f8e63a9..99bf8e82a 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -92,14 +92,14 @@ void popClipArea() override final; - void setColor(const gcn::Color &color) override final + void setColor(const Color &color) override final { mColor = color; mColor2 = color; mColorAlpha = (color.a != 255); } - void setColorAll(const gcn::Color &color, const gcn::Color &color2) + void setColorAll(const Color &color, const Color &color2) { mColor = color; mColor2 = color2; diff --git a/src/render/safeopenglgraphics.h b/src/render/safeopenglgraphics.h index 28d61b59a..fbb156c6c 100644 --- a/src/render/safeopenglgraphics.h +++ b/src/render/safeopenglgraphics.h @@ -90,7 +90,7 @@ class SafeOpenGLGraphics final : public Graphics bool mTexture; bool mIsByteColor; - gcn::Color mByteColor; + Color mByteColor; float mFloatColor; bool mColorAlpha; FBOInfo mFbo; diff --git a/src/text.cpp b/src/text.cpp index dfc127598..27d794d33 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -39,7 +39,7 @@ ImageRect Text::mBubble; Text::Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, const bool isSpeech, + const Color *const color, const bool isSpeech, Font *const font) : mFont(font ? font : (gui ? gui->getFont() : nullptr)), mX(x), @@ -112,7 +112,7 @@ Text::~Text() } } -void Text::setColor(const gcn::Color *const color) +void Text::setColor(const Color *const color) { mColor = color; } @@ -152,7 +152,7 @@ void Text::draw(Graphics *const graphics, const int xOff, const int yOff) FlashText::FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, Font *const font) : + const Color *const color, Font *const font) : Text(text, x, y, alignment, color, false, font), mTime(0) { diff --git a/src/text.h b/src/text.h index cade9db18..497792091 100644 --- a/src/text.h +++ b/src/text.h @@ -26,7 +26,7 @@ #include "render/graphics.h" -#include "gui/base/color.hpp" +#include "gui/color.h" #include "localconsts.h" @@ -42,7 +42,7 @@ class Text */ Text(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, const bool isSpeech = false, + const Color *const color, const bool isSpeech = false, Font *const font = nullptr); A_DELETE_COPY(Text) @@ -52,7 +52,7 @@ class Text */ virtual ~Text(); - void setColor(const gcn::Color *const color); + void setColor(const Color *const color); int getWidth() const A_WARN_UNUSED { return mWidth; } @@ -80,8 +80,8 @@ class Text int mXOffset; /**< The offset of mX from the desired x. */ static int mInstances; /**< Instances of text. */ std::string mText; /**< The text to display. */ - const gcn::Color *mColor; /**< The color of the text. */ - const gcn::Color mOutlineColor; + const Color *mColor; /**< The color of the text. */ + const Color mOutlineColor; bool mIsSpeech; /**< Is this text a speech bubble? */ protected: @@ -93,7 +93,7 @@ class FlashText final : public Text public: FlashText(const std::string &text, const int x, const int y, const Graphics::Alignment alignment, - const gcn::Color *const color, + const Color *const color, Font *const font = nullptr); A_DELETE_COPY(FlashText) diff --git a/src/utils/sdlpixel.h b/src/utils/sdlpixel.h index a01858831..282b90afb 100644 --- a/src/utils/sdlpixel.h +++ b/src/utils/sdlpixel.h @@ -64,8 +64,9 @@ #ifndef UTILS_SDLPIXEL_H #define UTILS_SDLPIXEL_H +#include "gui/color.h" + #include "SDL.h" -#include "gui/base/color.hpp" /** * Puts a pixel on an SDL_Surface. @@ -75,7 +76,7 @@ * @param color the color the pixel should be in. */ inline void SDLputPixel(SDL_Surface* surface, int x, int y, - const gcn::Color& color) + const Color& color) { if (!surface) return; @@ -175,7 +176,7 @@ inline unsigned short SDLAlpha16(const unsigned short src, * @param color the color the pixel should be in. */ inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, - const gcn::Color& color) + const Color& color) { const int bpp = surface->format->BytesPerPixel; -- cgit v1.2.3-70-g09d2 From 63f0b730767b1185dc33f8892068d697e26a09bb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 14:59:26 +0300 Subject: Move Rectangle and ClipRectangle into gui directory. --- src/CMakeLists.txt | 8 +- src/Makefile.am | 16 +-- src/being/being.cpp | 17 ++- src/client.cpp | 2 +- src/flooritem.cpp | 7 +- src/gui/base/cliprectangle.cpp | 107 ------------------- src/gui/base/cliprectangle.hpp | 129 ----------------------- src/gui/base/rectangle.cpp | 156 --------------------------- src/gui/base/rectangle.hpp | 162 ----------------------------- src/gui/base/widget.hpp | 3 +- src/gui/cliprectangle.cpp | 104 ++++++++++++++++++ src/gui/cliprectangle.h | 126 ++++++++++++++++++++++ src/gui/popups/spellpopup.cpp | 2 +- src/gui/popups/textpopup.cpp | 2 +- src/gui/rectangle.cpp | 156 +++++++++++++++++++++++++++ src/gui/rectangle.h | 162 +++++++++++++++++++++++++++++ src/gui/viewport.cpp | 8 +- src/gui/widgets/avatarlistbox.cpp | 4 +- src/gui/widgets/browserbox.cpp | 8 +- src/gui/widgets/button.cpp | 4 +- src/gui/widgets/colorpage.cpp | 2 +- src/gui/widgets/desktop.cpp | 10 +- src/gui/widgets/dropdown.cpp | 10 +- src/gui/widgets/dropdown.h | 2 +- src/gui/widgets/extendedlistbox.cpp | 2 +- src/gui/widgets/guitable.cpp | 16 +-- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/label.cpp | 2 +- src/gui/widgets/layout.cpp | 2 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/listbox.cpp | 4 +- src/gui/widgets/popup.cpp | 4 +- src/gui/widgets/popup.h | 2 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/scrollarea.cpp | 82 +++++++-------- src/gui/widgets/scrollarea.h | 16 +-- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 4 +- src/gui/widgets/tabbedarea.h | 2 +- src/gui/widgets/tabs/chattab.cpp | 2 +- src/gui/widgets/tabs/setup_audio.cpp | 2 +- src/gui/widgets/tabs/setup_chat.cpp | 2 +- src/gui/widgets/tabs/setup_colors.cpp | 2 +- src/gui/widgets/tabs/setup_input.cpp | 2 +- src/gui/widgets/tabs/setup_joystick.cpp | 2 +- src/gui/widgets/tabs/setup_mods.cpp | 2 +- src/gui/widgets/tabs/setup_other.cpp | 2 +- src/gui/widgets/tabs/setup_perfomance.cpp | 2 +- src/gui/widgets/tabs/setup_players.cpp | 2 +- src/gui/widgets/tabs/setup_relations.cpp | 2 +- src/gui/widgets/tabs/setup_theme.cpp | 2 +- src/gui/widgets/tabs/setup_touch.cpp | 2 +- src/gui/widgets/tabs/setup_video.cpp | 2 +- src/gui/widgets/tabs/setup_visual.cpp | 2 +- src/gui/widgets/textbox.cpp | 2 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textpreview.cpp | 4 +- src/gui/widgets/window.cpp | 16 +-- src/gui/widgets/window.h | 8 +- src/gui/windowmenu.cpp | 6 +- src/gui/windows/charcreatedialog.cpp | 6 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/debugwindow.cpp | 10 +- src/gui/windows/debugwindow.h | 2 +- src/gui/windows/equipmentwindow.cpp | 12 +-- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/minimap.cpp | 14 +-- src/gui/windows/ministatuswindow.cpp | 8 +- src/gui/windows/ministatuswindow.h | 2 +- src/gui/windows/npcpostdialog.cpp | 2 +- src/gui/windows/outfitwindow.cpp | 6 +- src/gui/windows/selldialog.cpp | 2 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/setupwindow.cpp | 6 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/whoisonline.cpp | 6 +- src/map.cpp | 4 +- src/maplayer.cpp | 10 +- src/render/graphics.cpp | 12 +-- src/render/graphics.h | 14 +-- src/render/mobileopenglgraphics.cpp | 18 ++-- src/render/normalopenglgraphics.cpp | 18 ++-- src/render/nullopenglgraphics.cpp | 14 +-- src/render/openglgraphicsdef.hpp | 8 +- src/render/safeopenglgraphics.cpp | 16 +-- src/render/sdl2graphics.cpp | 36 +++---- src/render/sdl2graphics.h | 6 +- src/render/sdl2softwaregraphics.cpp | 38 +++---- src/render/sdl2softwaregraphics.h | 6 +- src/render/sdlgraphics.cpp | 38 +++---- src/render/sdlgraphics.h | 6 +- src/render/surfacegraphics.h | 6 +- src/touchmanager.cpp | 4 +- src/touchmanager.h | 6 +- 96 files changed, 879 insertions(+), 888 deletions(-) delete mode 100644 src/gui/base/cliprectangle.cpp delete mode 100644 src/gui/base/cliprectangle.hpp delete mode 100644 src/gui/base/rectangle.cpp delete mode 100644 src/gui/base/rectangle.hpp create mode 100644 src/gui/cliprectangle.cpp create mode 100644 src/gui/cliprectangle.h create mode 100644 src/gui/rectangle.cpp create mode 100644 src/gui/rectangle.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf8a905f2..69304d442 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -766,7 +766,7 @@ SET(SRCS events/actionevent.h listeners/actionlistener.h gui/base/basiccontainer.hpp - gui/base/cliprectangle.hpp + gui/cliprectangle.h gui/color.h listeners/deathlistener.h events/event.h @@ -779,7 +779,7 @@ SET(SRCS gui/base/listmodel.hpp events/mouseevent.h listeners/mouselistener.h - gui/base/rectangle.hpp + gui/rectangle.h events/selectionevent.h listeners/selectionlistener.h utils/sdlpixel.h @@ -797,11 +797,11 @@ SET(SRCS gui/base/widgets/textfield.hpp gui/base/widgets/window.hpp gui/base/basiccontainer.cpp - gui/base/cliprectangle.cpp + gui/cliprectangle.cpp gui/color.cpp gui/base/gui.cpp input/key.cpp - gui/base/rectangle.cpp + gui/rectangle.cpp gui/base/widget.cpp gui/base/widgets/button.cpp gui/base/widgets/checkbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 5a2fa34d7..0b03f22f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,14 +26,14 @@ manaplus_SOURCES = endif dyecmd_CXXFLAGS = -dyecmd_SOURCES = gui/base/cliprectangle.cpp \ +dyecmd_SOURCES = gui/cliprectangle.cpp \ gui/color.cpp \ - gui/base/rectangle.cpp \ + gui/rectangle.cpp \ events/actionevent.h \ - gui/base/cliprectangle.hpp \ + gui/cliprectangle.h \ gui/color.h \ events/event.h \ - gui/base/rectangle.hpp + gui/rectangle.h dyecmd_SOURCES += dyetool/dyemain.cpp \ animatedsprite.cpp \ @@ -151,7 +151,7 @@ endif manaplus_SOURCES += events/actionevent.h \ listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ - gui/base/cliprectangle.hpp \ + gui/cliprectangle.h \ gui/color.h \ listeners/deathlistener.h \ events/event.h \ @@ -165,7 +165,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/listmodel.hpp \ events/mouseevent.h \ listeners/mouselistener.h \ - gui/base/rectangle.hpp \ + gui/rectangle.h \ events/selectionevent.h \ listeners/selectionlistener.h \ utils/sdlpixel.h \ @@ -183,11 +183,11 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/textfield.hpp \ gui/base/widgets/window.hpp \ gui/base/basiccontainer.cpp \ - gui/base/cliprectangle.cpp \ + gui/cliprectangle.cpp \ gui/color.cpp \ gui/base/gui.cpp \ input/key.cpp \ - gui/base/rectangle.cpp \ + gui/rectangle.cpp \ gui/base/widget.cpp \ gui/base/widgets/button.cpp \ gui/base/widgets/checkbox.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index 485b439af..f1d8a7aa6 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2515,7 +2515,7 @@ void Being::drawSpriteAt(Graphics *const graphics, graphics->setColor(userPalette-> getColorWithAlpha(UserPalette::PORTAL_HIGHLIGHT)); - graphics->fillRectangle(gcn::Rectangle(x, y, + graphics->fillRectangle(Rectangle(x, y, mapTileSize, mapTileSize)); if (mDrawHotKeys && !mName.empty()) @@ -2541,7 +2541,7 @@ void Being::drawSpriteAt(Graphics *const graphics, graphics->setColor(userPalette->getColorWithAlpha( UserPalette::MONSTER_ATTACK_RANGE)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x - attackRange, y - attackRange, 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize)); } @@ -2606,14 +2606,14 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp, || (!hp && maxHP == damage)) { graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, dx, height)); return; } else if (width - dx <= 0) { graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, width, height)); return; } @@ -2623,26 +2623,25 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp, if (hp == maxHP) { graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, dx, height)); return; } else if (width - dx <= 0) { graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, width, height)); return; } } graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, dx, height)); graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(gcn::Rectangle( - x + dx, y, width - dx, height)); + graphics->fillRectangle(Rectangle(x + dx, y, width - dx, height)); } void Being::setHP(const int hp) diff --git a/src/client.cpp b/src/client.cpp index 4aa5d4cd4..0babef941 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -617,7 +617,7 @@ static void updateProgress(int cnt) mainGraphics->setColor(Color(255, 255, 255)); const int maxSize = mainGraphics->mWidth - 100; const int width = maxSize * progress / 450; - mainGraphics->fillRectangle(gcn::Rectangle(50, h - 100, width, 50)); + mainGraphics->fillRectangle(Rectangle(50, h - 100, width, 50)); mainGraphics->updateScreen(); } diff --git a/src/flooritem.cpp b/src/flooritem.cpp index 6780b10fa..fd6a6afd3 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -123,7 +123,7 @@ void FloorItem::draw(Graphics *const graphics, if (curTime > mDropTime + 28 && curTime < mDropTime + 50) { graphics->setColor(Color(80, 200, 20, 200)); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime + 19 @@ -131,15 +131,14 @@ void FloorItem::draw(Graphics *const graphics, { graphics->setColor(Color(200, 80, 20, 80 + 10 * (curTime - mDropTime - 18))); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x, y, dx, dy)); } else if (curTime > mDropTime && curTime < mDropTime + 20) { graphics->setColor(Color(20, 20, 255, 7 * (curTime - mDropTime))); - graphics->fillRectangle(gcn::Rectangle( - x, y, dx, dy)); + graphics->fillRectangle(Rectangle(x, y, dx, dy)); } } } diff --git a/src/gui/base/cliprectangle.cpp b/src/gui/base/cliprectangle.cpp deleted file mode 100644 index f52bc384a..000000000 --- a/src/gui/base/cliprectangle.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/cliprectangle.hpp" - -#include "debug.h" - -namespace gcn -{ - ClipRectangle::ClipRectangle() : - Rectangle(), - xOffset(0), - yOffset(0) - { - x = 0; - y = 0; - width = 0; - height = 0; - } - - ClipRectangle::ClipRectangle(const int x0, const int y0, - const int width0, const int height0, - const int xOffset0, const int yOffset0) : - Rectangle(), - xOffset(xOffset0), - yOffset(yOffset0) - { - x = x0; - y = y0; - width = width0; - height = height0; - } - - const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) - { - x = other.x; - y = other.y; - width = other.width; - height = other.height; - - return *this; - } -} // namespace gcn diff --git a/src/gui/base/cliprectangle.hpp b/src/gui/base/cliprectangle.hpp deleted file mode 100644 index 1fdbfbe8d..000000000 --- a/src/gui/base/cliprectangle.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_CLIPRECTANGLE_HPP -#define GCN_CLIPRECTANGLE_HPP - -#include "gui/base/rectangle.hpp" - -#include "localconsts.h" - -namespace gcn -{ - /** - * A rectangle used when dealing with clipping. A clip rectangle is - * a regular rectangle extended with variables for x offsets and y - * offsets. The offsets are used for calculations from relative - * screen coordinates to actual screen coordinates. - */ - class ClipRectangle final : public Rectangle - { - public: - /** - * Constructor. - */ - ClipRectangle(); - - /** - * Constructor. - * - * @param x0 The rectangle x coordinate. - * @param y0 The rectangle y coordinate. - * @param width0 The rectangle width. - * @param height0 The rectangle height. - * @param xOffset0 The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset0 The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - */ - ClipRectangle(const int x0, - const int y0, - const int width0, - const int height0, - const int xOffset0, - const int yOffset0); - - /** - * Copy constructor. Copies x, y, width and height - * field from a rectangle to a clip rectangle. - * - * @param other The rectangle to copy data from. - * @returns A clip rectangle with data copyied from a rectangle. - */ - const ClipRectangle& operator=(const Rectangle& other); - - /** - * Holds the x offset of the x coordinate. - */ - int xOffset; - - /** - * Holds the y offset of the y coordinate. - */ - int yOffset; - }; -} // namespace gcn - -#endif // end GCN_CLIPRECTANGLE_HPP diff --git a/src/gui/base/rectangle.cpp b/src/gui/base/rectangle.cpp deleted file mode 100644 index a29069b18..000000000 --- a/src/gui/base/rectangle.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/rectangle.hpp" - -#include "debug.h" - -namespace gcn -{ - Rectangle::Rectangle() - : x(0), - y(0), - width(0), - height(0) - { - } - - Rectangle::Rectangle(const int x_, const int y_, - const int width_, const int height_) : - x(x_), - y(y_), - width(width_), - height(height_) - { - } - - void Rectangle::setAll(int x_, int y_, int width_, int height_) - { - x = x_; - y = y_; - width = width_; - height = height_; - } - - bool Rectangle::isIntersecting(const Rectangle& rectangle) const - { - int x_ = x; - int y_ = y; - int width_ = width; - int height_ = height; - - x_ -= rectangle.x; - y_ -= rectangle.y; - - if (x_ < 0) - { - width_ += x_; -// x_ = 0; - } - else if (x_ + width_ > rectangle.width) - { - width_ = rectangle.width - x_; - } - - if (y_ < 0) - { - height_ += y_; -// y_ = 0; - } - else if (y_ + height_ > rectangle.height) - { - height_ = rectangle.height - y_; - } - - if (width_ <= 0 || height_ <= 0) - { - return false; - } - - return true; - } - - bool Rectangle::isPointInRect(int x_, int y_) const - { - return x_ >= x - && y_ >= y - && x_ < x + width - && y_ < y + height; - } - - std::ostream& operator<<(std::ostream& out, - const Rectangle& rectangle) - { - out << "Rectangle [x = " << rectangle.x - << ", y = " << rectangle.y - << ", width = " << rectangle.width - << ", height = " << rectangle.height - << "]"; - - return out; - } -} // namespace gcn diff --git a/src/gui/base/rectangle.hpp b/src/gui/base/rectangle.hpp deleted file mode 100644 index 299ce99b9..000000000 --- a/src/gui/base/rectangle.hpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_RECTANGLE_HPP -#define GCN_RECTANGLE_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * Represents a rectangle. - * - * @since 0.1.0 - */ - class Rectangle - { - public: - /** - * Constructor. The default rectangle is an empty rectangle - * at the coordinates (0,0). - */ - Rectangle(); - - /** - * Constructor. - * - * @param x The x coordinate of the rectangle. - * @param y The y coordinate of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @since 0.1.0 - */ - Rectangle(const int x, const int y, const int width, const int height); - - virtual ~Rectangle() - { } - - /** - * Sets the dimension of a rectangle. - * - * @param x The x coordinate of the rectangle. - * @param y The y coordinate of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @since 0.1.0 - */ - void setAll(int x, int y, int width, int height); - - /** - * Checks if another rectangle intersects with the rectangle. - * - * @param rectangle Another rectangle to check for intersection. - * @return True if the rectangles intersect, false otherwise. - * @since 0.1.0 - */ - bool isIntersecting(const Rectangle& rectangle) const A_WARN_UNUSED; - - /** - * Checks if a point is inside the rectangle - * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @return True if the point is inside the rectangle. - * @since 0.1.0 - */ - bool isPointInRect(int x, int y) const A_WARN_UNUSED; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param rectangle The rectangle to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Rectangle& rectangle); - - /** - * Holds the x coordinate of the rectangle. - */ - int x; - - /** - * Holds the x coordinate of the rectangle. - */ - int y; - - /** - * Holds the width of the rectangle. - */ - int width; - - /** - * Holds the height of the rectangle. - */ - int height; - }; -} // namespace gcn - -#endif // end GCN_RECTANGEL_HPP diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp index 31d61312e..a180cbd12 100644 --- a/src/gui/base/widget.hpp +++ b/src/gui/base/widget.hpp @@ -69,8 +69,7 @@ #include #include "gui/color.h" - -#include "gui/base/rectangle.hpp" +#include "gui/rectangle.h" #include "gui/widgets/widget2.h" diff --git a/src/gui/cliprectangle.cpp b/src/gui/cliprectangle.cpp new file mode 100644 index 000000000..ff393281c --- /dev/null +++ b/src/gui/cliprectangle.cpp @@ -0,0 +1,104 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/cliprectangle.h" + +#include "debug.h" + +ClipRectangle::ClipRectangle() : + Rectangle(), + xOffset(0), + yOffset(0) +{ + x = 0; + y = 0; + width = 0; + height = 0; +} + +ClipRectangle::ClipRectangle(const int x0, const int y0, + const int width0, const int height0, + const int xOffset0, const int yOffset0) : + Rectangle(), + xOffset(xOffset0), + yOffset(yOffset0) +{ + x = x0; + y = y0; + width = width0; + height = height0; +} + +const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) +{ + x = other.x; + y = other.y; + width = other.width; + height = other.height; + + return *this; +} diff --git a/src/gui/cliprectangle.h b/src/gui/cliprectangle.h new file mode 100644 index 000000000..776bc702f --- /dev/null +++ b/src/gui/cliprectangle.h @@ -0,0 +1,126 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_CLIPRECTANGLE_H +#define GUI_CLIPRECTANGLE_H + +#include "gui/rectangle.h" + +#include "localconsts.h" + +/** + * A rectangle used when dealing with clipping. A clip rectangle is + * a regular rectangle extended with variables for x offsets and y + * offsets. The offsets are used for calculations from relative + * screen coordinates to actual screen coordinates. + */ +class ClipRectangle final : public Rectangle +{ + public: + /** + * Constructor. + */ + ClipRectangle(); + + /** + * Constructor. + * + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + */ + ClipRectangle(const int x0, + const int y0, + const int width0, + const int height0, + const int xOffset0, + const int yOffset0); + + /** + * Copy constructor. Copies x, y, width and height + * field from a rectangle to a clip rectangle. + * + * @param other The rectangle to copy data from. + * @returns A clip rectangle with data copyied from a rectangle. + */ + const ClipRectangle& operator=(const Rectangle& other); + + /** + * Holds the x offset of the x coordinate. + */ + int xOffset; + + /** + * Holds the y offset of the y coordinate. + */ + int yOffset; +}; + +#endif // GUI_CLIPRECTANGLE_H diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index 07bcc2330..2dc1751d3 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -90,7 +90,7 @@ void SpellPopup::view(const int x, const int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; const int w = rect.width; const int h = rect.height; if (posX + w > mainGraphics->mWidth) diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 0ae53ac1f..72ac26f0f 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -86,7 +86,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1, setHeight(pad2 + mText[0]->getFont()->getHeight() * cnt); const int distance = 20; - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; int posX = std::max(0, x - rect.width / 2); int posY = y + distance; diff --git a/src/gui/rectangle.cpp b/src/gui/rectangle.cpp new file mode 100644 index 000000000..d7de61c39 --- /dev/null +++ b/src/gui/rectangle.cpp @@ -0,0 +1,156 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/rectangle.h" + +#include "debug.h" + +Rectangle::Rectangle() + : x(0), + y(0), + width(0), + height(0) +{ +} + +Rectangle::Rectangle(const int x_, const int y_, + const int width_, const int height_) : + x(x_), + y(y_), + width(width_), + height(height_) +{ +} + +void Rectangle::setAll(const int x0, + const int y0, + const int width0, + const int height0) +{ + x = x0; + y = y0; + width = width0; + height = height0; +} + +bool Rectangle::isIntersecting(const Rectangle& rectangle) const +{ + int x_ = x; + int y_ = y; + int width_ = width; + int height_ = height; + + x_ -= rectangle.x; + y_ -= rectangle.y; + + if (x_ < 0) + { + width_ += x_; +// x_ = 0; + } + else if (x_ + width_ > rectangle.width) + { + width_ = rectangle.width - x_; + } + + if (y_ < 0) + { + height_ += y_; +// y_ = 0; + } + else if (y_ + height_ > rectangle.height) + { + height_ = rectangle.height - y_; + } + + if (width_ <= 0 || height_ <= 0) + { + return false; + } + + return true; +} + +bool Rectangle::isPointInRect(int x_, int y_) const +{ + return x_ >= x + && y_ >= y + && x_ < x + width + && y_ < y + height; +} + +std::ostream& operator<<(std::ostream& out, + const Rectangle& rectangle) +{ + out << "Rectangle [x = " << rectangle.x + << ", y = " << rectangle.y + << ", width = " << rectangle.width + << ", height = " << rectangle.height + << "]"; + + return out; +} diff --git a/src/gui/rectangle.h b/src/gui/rectangle.h new file mode 100644 index 000000000..ae8364417 --- /dev/null +++ b/src/gui/rectangle.h @@ -0,0 +1,162 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_RECTANGLE_H +#define GUI_RECTANGLE_H + +#include + +#include "localconsts.h" + +/** + * Represents a rectangle. + * + * @since 0.1.0 + */ +class Rectangle +{ + public: + /** + * Constructor. The default rectangle is an empty rectangle + * at the coordinates (0,0). + */ + Rectangle(); + + /** + * Constructor. + * + * @param x The x coordinate of the rectangle. + * @param y The y coordinate of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @since 0.1.0 + */ + Rectangle(const int x, const int y, const int width, const int height); + + virtual ~Rectangle() + { } + + /** + * Sets the dimension of a rectangle. + * + * @param x The x coordinate of the rectangle. + * @param y The y coordinate of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @since 0.1.0 + */ + void setAll(const int x, + const int y, + const int width0, + const int height0); + + /** + * Checks if another rectangle intersects with the rectangle. + * + * @param rectangle Another rectangle to check for intersection. + * @return True if the rectangles intersect, false otherwise. + * @since 0.1.0 + */ + bool isIntersecting(const Rectangle& rectangle) const A_WARN_UNUSED; + + /** + * Checks if a point is inside the rectangle + * + * @param x The x coordinate of the point. + * @param y The y coordinate of the point. + * @return True if the point is inside the rectangle. + * @since 0.1.0 + */ + bool isPointInRect(int x, int y) const A_WARN_UNUSED; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param rectangle The rectangle to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Rectangle& rectangle); + + /** + * Holds the x coordinate of the rectangle. + */ + int x; + + /** + * Holds the x coordinate of the rectangle. + */ + int y; + + /** + * Holds the width of the rectangle. + */ + int width; + + /** + * Holds the height of the rectangle. + */ + int height; +}; + +#endif // GUI_RECTANGEL_H diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 54619c3e6..d9175a07f 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -123,7 +123,7 @@ void Viewport::draw(Graphics *graphics) { graphics->setColor(Color(64, 64, 64)); graphics->fillRectangle( - gcn::Rectangle(0, 0, getWidth(), getHeight())); + Rectangle(0, 0, getWidth(), getHeight())); BLOCK_END("Viewport::draw 1") return; } @@ -353,7 +353,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const int squareX = i->x * mapTileSize - mPixelViewX + 12; const int squareY = i->y * mapTileSize - mPixelViewY + 12; - graphics->fillRectangle(gcn::Rectangle(squareX, squareY, 8, 8)); + graphics->fillRectangle(Rectangle(squareX, squareY, 8, 8)); if (mMap) { const std::string str = toString(cnt); @@ -371,8 +371,8 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const int squareX = i->x - mPixelViewX; const int squareY = i->y - mPixelViewY; - graphics->fillRectangle(gcn::Rectangle(squareX - 4, squareY - 4, - 8, 8)); + graphics->fillRectangle(Rectangle( + squareX - 4, squareY - 4, 8, 8)); if (mMap) { const std::string str = toString(mMap->getMetaTile( diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index a71051b5d..4300f4ea8 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -160,7 +160,7 @@ void AvatarListBox::draw(Graphics *graphics) color.a = 80; graphics->setColor(color); - graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding, + graphics->fillRectangle(Rectangle(mPadding, y + mPadding, parent->getWidth() * a->getHp() / a->getMaxHp() - 2 * mPadding, fontHeight)); } @@ -184,7 +184,7 @@ void AvatarListBox::draw(Graphics *graphics) color.a = 80; graphics->setColor(color); - graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding, + graphics->fillRectangle(Rectangle(mPadding, y + mPadding, parent->getWidth() * a->getDamageHp() / 1024 - 2 * mPadding, fontHeight)); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index b6644cbc1..6e506eeeb 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -37,7 +37,7 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/base/cliprectangle.hpp" +#include "gui/cliprectangle.h" #include "render/graphics.h" @@ -448,7 +448,7 @@ void BrowserBox::mouseMoved(MouseEvent &event) void BrowserBox::draw(Graphics *graphics) { BLOCK_START("BrowserBox::draw") - const gcn::ClipRectangle *const cr = graphics->getCurrentClipArea(); + const ClipRectangle *const cr = graphics->getCurrentClipArea(); if (!cr) return; mYStart = cr->y - cr->yOffset; @@ -462,7 +462,7 @@ void BrowserBox::draw(Graphics *graphics) if (mOpaque) { graphics->setColor(mBackgroundColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); + graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); } if (mSelectedLink >= 0 && mSelectedLink @@ -471,7 +471,7 @@ void BrowserBox::draw(Graphics *graphics) if ((mHighMode & BACKGROUND)) { graphics->setColor(mHighlightColor); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, mLinks[mSelectedLink].x2 - mLinks[mSelectedLink].x1, diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index d7871503e..90c1706b5 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -380,7 +380,7 @@ void Button::draw(Graphics *graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - gcn::ClipRectangle &rect = graphics->getTopClip(); + ClipRectangle &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { recalc = true; @@ -420,7 +420,7 @@ void Button::draw(Graphics *graphics) int imageX = 0; int imageY = 0; int textX = 0; - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; Font *const font = getFont(); diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 6803fbe3c..2bc085208 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -64,7 +64,7 @@ void ColorPage::draw(Graphics *graphics) if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(mPadding, + graphics->fillRectangle(Rectangle(mPadding, rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 8e0496fea..a296fb49d 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -107,7 +107,7 @@ void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; if (mWallpaper) @@ -118,7 +118,7 @@ void Desktop::draw(Graphics *graphics) if (width > wallpWidth || height > wallpHeight) { graphics->setColor(mBackgroundGrayColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->fillRectangle(Rectangle(0, 0, width, height)); } if (imageHelper->useOpenGL() == RENDER_SOFTWARE) @@ -135,12 +135,12 @@ void Desktop::draw(Graphics *graphics) else { graphics->setColor(mBackgroundGrayColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->fillRectangle(Rectangle(0, 0, width, height)); } // Draw a thin border under the application version... graphics->setColor(mBackgroundColor); - graphics->fillRectangle(gcn::Rectangle(mVersionLabel->getDimension())); + graphics->fillRectangle(Rectangle(mVersionLabel->getDimension())); Container::draw(graphics); BLOCK_END("Desktop::draw") @@ -165,7 +165,7 @@ void Desktop::setBestFittingWallpaper() mWallpaper = nullptr; } - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 6189af75e..63f102f5a 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -267,7 +267,7 @@ void DropDown::draw(Graphics* graphics) if (isFocused()) { graphics->setColor(mHighlightColor); - graphics->drawRectangle(gcn::Rectangle(mPadding, mPadding, + graphics->drawRectangle(Rectangle(mPadding, mPadding, mDimension.width - h - pad, h - pad)); } @@ -290,7 +290,7 @@ void DropDown::drawFrame(Graphics *graphics) { BLOCK_START("DropDown::drawFrame") const int bs2 = getFrameSize(); - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; graphics->drawImageRect(0, 0, rect.width + bs2, rect.height + bs2, skinRect); @@ -512,16 +512,16 @@ void DropDown::action(const ActionEvent &actionEvent A_UNUSED) distributeActionEvent(); } -gcn::Rectangle DropDown::getChildrenArea() +Rectangle DropDown::getChildrenArea() { if (mDroppedDown) { // Calculate the children area (with the one pixel border in mind) - return gcn::Rectangle(1, mFoldedUpHeight + 1, + return Rectangle(1, mFoldedUpHeight + 1, mDimension.width - 2, mDimension.height - mFoldedUpHeight - 2); } - return gcn::Rectangle(); + return Rectangle(); } void DropDown::valueChanged(const SelectionEvent& event A_UNUSED) diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 815e4a85d..81e3b6e8f 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -129,7 +129,7 @@ class DropDown final : public ActionListener, void removeSelectionListener(SelectionListener* selectionListener); - gcn::Rectangle getChildrenArea() override; + Rectangle getChildrenArea() override; void action(const ActionEvent &actionEvent) override; diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 1fcbabd2b..53b7c7060 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -134,7 +134,7 @@ void ExtendedListBox::draw(Graphics *graphics) { mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); - graphics->fillRectangle(gcn::Rectangle(mPadding, minY + mPadding, + graphics->fillRectangle(Rectangle(mPadding, minY + mPadding, width - pad2, maxY - minY + height)); } diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 324d4b23e..7bd920046 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -304,7 +304,7 @@ void GuiTable::draw(Graphics* graphics) if (client->getGuiAlpha() != mAlpha) mAlpha = client->getGuiAlpha(); - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; const int width = rect.width; const int height = rect.height; const int y = rect.y; @@ -312,7 +312,7 @@ void GuiTable::draw(Graphics* graphics) { mBackgroundColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mBackgroundColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, width, height)); + graphics->fillRectangle(Rectangle(0, 0, width, height)); } // First, determine how many rows we need to draw, @@ -351,7 +351,7 @@ void GuiTable::draw(Graphics* graphics) const int cWidth = getColumnWidth(c); if (widget) { - gcn::Rectangle bounds(x_offset, y_offset, cWidth, rHeight); + Rectangle bounds(x_offset, y_offset, cWidth, rHeight); if (widget == mTopWidget) { @@ -369,14 +369,14 @@ void GuiTable::draw(Graphics* graphics) if (mLinewiseMode && r == static_cast( mSelectedRow) && c == 0) { - graphics->fillRectangle(gcn::Rectangle(0, y_offset, + graphics->fillRectangle(Rectangle(0, y_offset, width, rHeight)); } else if (!mLinewiseMode && mSelectedColumn > 0 && c == static_cast(mSelectedColumn) && r == static_cast(mSelectedRow)) { - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( x_offset, y_offset, cWidth, rHeight)); } } @@ -393,7 +393,7 @@ void GuiTable::draw(Graphics* graphics) if (mTopWidget) { - const gcn::Rectangle &bounds = mTopWidget->getDimension(); + const Rectangle &bounds = mTopWidget->getDimension(); graphics->pushClipArea(bounds); mTopWidget->draw(graphics); graphics->popClipArea(); @@ -414,9 +414,9 @@ void GuiTable::moveToBottom(gcn::Widget *widget) mTopWidget = nullptr; } -gcn::Rectangle GuiTable::getChildrenArea() +Rectangle GuiTable::getChildrenArea() { - return gcn::Rectangle(0, 0, mDimension.width, mDimension.height); + return Rectangle(0, 0, mDimension.width, mDimension.height); } // -- KeyListener notifications diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index b2c7c5620..055c6c5f2 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -93,7 +93,7 @@ public: void setWrappingEnabled(bool wrappingEnabled) { mWrappingEnabled = wrappingEnabled; } - gcn::Rectangle getChildrenArea() override final A_WARN_UNUSED; + Rectangle getChildrenArea() override final A_WARN_UNUSED; /** * Toggle whether to use linewise selection mode, in which the table selects diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index c02f37adb..5b1804667 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -80,7 +80,7 @@ void Label::draw(Graphics* graphics) { BLOCK_START("Label::draw") int textX; - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; const int textY = rect.height / 2 - getFont()->getHeight() / 2; Font *const font = getFont(); diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index f16f40322..4132741e4 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -80,7 +80,7 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh) if (mType == ARRAY) mArray->reflow(nx, ny, nw, nh); else - mWidget->setDimension(gcn::Rectangle(nx, ny, nw, nh)); + mWidget->setDimension(Rectangle(nx, ny, nw, nh)); } void LayoutCell::computeSizes() diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 7b8a428a9..e4b931c92 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -65,7 +65,7 @@ void LayoutHelper::reflowLayout(int w, int h) void LayoutHelper::widgetResized(const Event &event A_UNUSED) { - const gcn::Rectangle area = mContainer->getChildrenArea(); + const Rectangle area = mContainer->getChildrenArea(); int w = area.width; int h = area.height; mLayout.reflow(w, h); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index a57dc07cd..ebe1ca279 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -118,7 +118,7 @@ void ListBox::draw(Graphics *graphics) // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(mPadding, + graphics->fillRectangle(Rectangle(mPadding, rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); @@ -148,7 +148,7 @@ void ListBox::draw(Graphics *graphics) // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(mPadding, + graphics->fillRectangle(Rectangle(mPadding, rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 178695891..76eb3707a 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -122,10 +122,10 @@ void Popup::draw(Graphics *graphics) BLOCK_END("Popup::draw") } -gcn::Rectangle Popup::getChildrenArea() +Rectangle Popup::getChildrenArea() { const int pad2 = mPadding * 2; - return gcn::Rectangle(mPadding, mPadding, + return Rectangle(mPadding, mPadding, mDimension.width - pad2, mDimension.height - pad2); } diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index d64bc4b3f..d1709a328 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -152,7 +152,7 @@ class Popup : public Container, // Inherited from BasicContainer - virtual gcn::Rectangle getChildrenArea() override; + virtual Rectangle getChildrenArea() override; /** * Sets the location to display the popup. Tries to horizontally center diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 7d2d00ad4..db199a714 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -261,7 +261,7 @@ void ProgressBar::render(Graphics *graphics) { if (width > maxWidth) width = maxWidth; - graphics->fillRectangle(gcn::Rectangle(mFillPadding, mFillPadding, + graphics->fillRectangle(Rectangle(mFillPadding, mFillPadding, width, mDimension.height - pad)); } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 0cadee888..b508e2dd4 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -318,7 +318,7 @@ void ScrollArea::updateCalcFlag(Graphics *const graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - const gcn::ClipRectangle &rect = graphics->getTopClip(); + const ClipRectangle &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { mRedraw = true; @@ -381,7 +381,7 @@ void ScrollArea::drawButton(Graphics *const graphics, const BUTTON_DIR dir) { int state = 0; - gcn::Rectangle dim; + Rectangle dim; switch (dir) { @@ -416,7 +416,7 @@ void ScrollArea::calcButton(Graphics *const graphics, const BUTTON_DIR dir) { int state = 0; - gcn::Rectangle dim; + Rectangle dim; switch (dir) { @@ -452,7 +452,7 @@ void ScrollArea::calcButton(Graphics *const graphics, void ScrollArea::drawVBar(Graphics *const graphics) { - const gcn::Rectangle &dim = getVerticalBarDimension(); + const Rectangle &dim = getVerticalBarDimension(); if (vBackground.grid[4]) { @@ -475,7 +475,7 @@ void ScrollArea::drawVBar(Graphics *const graphics) void ScrollArea::calcVBar(Graphics *const graphics) { - const gcn::Rectangle &dim = getVerticalBarDimension(); + const Rectangle &dim = getVerticalBarDimension(); if (vBackground.grid[4]) { @@ -502,7 +502,7 @@ void ScrollArea::calcVBar(Graphics *const graphics) void ScrollArea::drawHBar(Graphics *const graphics) { - const gcn::Rectangle &dim = getHorizontalBarDimension(); + const Rectangle &dim = getHorizontalBarDimension(); if (hBackground.grid[4]) { @@ -530,7 +530,7 @@ void ScrollArea::drawHBar(Graphics *const graphics) void ScrollArea::calcHBar(Graphics *const graphics) { - const gcn::Rectangle &dim = getHorizontalBarDimension(); + const Rectangle &dim = getHorizontalBarDimension(); if (hBackground.grid[4]) { @@ -561,7 +561,7 @@ void ScrollArea::calcHBar(Graphics *const graphics) void ScrollArea::drawVMarker(Graphics *const graphics) { - const gcn::Rectangle &dim = getVerticalMarkerDimension(); + const Rectangle &dim = getVerticalMarkerDimension(); if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { @@ -579,7 +579,7 @@ void ScrollArea::drawVMarker(Graphics *const graphics) void ScrollArea::calcVMarker(Graphics *const graphics) { - const gcn::Rectangle &dim = getVerticalMarkerDimension(); + const Rectangle &dim = getVerticalMarkerDimension(); if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { @@ -599,7 +599,7 @@ void ScrollArea::calcVMarker(Graphics *const graphics) void ScrollArea::drawHMarker(Graphics *const graphics) { - const gcn::Rectangle dim = getHorizontalMarkerDimension(); + const Rectangle dim = getHorizontalMarkerDimension(); if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { @@ -618,7 +618,7 @@ void ScrollArea::drawHMarker(Graphics *const graphics) void ScrollArea::calcHMarker(Graphics *const graphics) { - const gcn::Rectangle dim = getHorizontalMarkerDimension(); + const Rectangle dim = getHorizontalMarkerDimension(); if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { @@ -811,7 +811,7 @@ void ScrollArea::mouseDragged(MouseEvent &event) { if (mIsVerticalMarkerDragged) { - const gcn::Rectangle barDim = getVerticalBarDimension(); + const Rectangle barDim = getVerticalBarDimension(); const int pos = event.getY() - barDim.y - mVerticalMarkerDragOffset; @@ -830,7 +830,7 @@ void ScrollArea::mouseDragged(MouseEvent &event) if (mIsHorizontalMarkerDragged) { - const gcn::Rectangle barDim = getHorizontalBarDimension(); + const Rectangle barDim = getHorizontalBarDimension(); const int pos = event.getX() - barDim.x - mHorizontalMarkerDragOffset; @@ -851,50 +851,50 @@ void ScrollArea::mouseDragged(MouseEvent &event) mRedraw = true; } -gcn::Rectangle ScrollArea::getVerticalBarDimension() const +Rectangle ScrollArea::getVerticalBarDimension() const { if (!mVBarVisible) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); const int height = (mVBarVisible && mShowButtons) ? mScrollbarWidth : 0; if (mHBarVisible) { - return gcn::Rectangle(mDimension.width - mScrollbarWidth, + return Rectangle(mDimension.width - mScrollbarWidth, height, mScrollbarWidth, mDimension.height - 2 * height - mScrollbarWidth); } - return gcn::Rectangle(mDimension.width - mScrollbarWidth, + return Rectangle(mDimension.width - mScrollbarWidth, height, mScrollbarWidth, mDimension.height - 2 * height); } -gcn::Rectangle ScrollArea::getHorizontalBarDimension() const +Rectangle ScrollArea::getHorizontalBarDimension() const { if (!mHBarVisible) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); const int width = mShowButtons ? mScrollbarWidth : 0; if (mVBarVisible) { - return gcn::Rectangle(width, + return Rectangle(width, mDimension.height - mScrollbarWidth, mDimension.width - 2 * width - mScrollbarWidth, mScrollbarWidth); } - return gcn::Rectangle(width, + return Rectangle(width, mDimension.height - mScrollbarWidth, mDimension.width - 2 * width, mScrollbarWidth); } -gcn::Rectangle ScrollArea::getVerticalMarkerDimension() +Rectangle ScrollArea::getVerticalMarkerDimension() { if (!mVBarVisible) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); int length, pos; int height; @@ -945,14 +945,14 @@ gcn::Rectangle ScrollArea::getVerticalMarkerDimension() pos = 0; } - return gcn::Rectangle(mDimension.width - mScrollbarWidth, h2 + pos, + return Rectangle(mDimension.width - mScrollbarWidth, h2 + pos, mScrollbarWidth, length); } -gcn::Rectangle ScrollArea::getHorizontalMarkerDimension() +Rectangle ScrollArea::getHorizontalMarkerDimension() { if (!mHBarVisible) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); int length, pos; int width; @@ -1007,61 +1007,61 @@ gcn::Rectangle ScrollArea::getHorizontalMarkerDimension() } } - return gcn::Rectangle(w2 + pos, mDimension.height - mScrollbarWidth, + return Rectangle(w2 + pos, mDimension.height - mScrollbarWidth, length, mScrollbarWidth); } -gcn::Rectangle ScrollArea::getUpButtonDimension() const +Rectangle ScrollArea::getUpButtonDimension() const { if (!mVBarVisible || !mShowButtons) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); - return gcn::Rectangle(mDimension.width - mScrollbarWidth, 0, + return Rectangle(mDimension.width - mScrollbarWidth, 0, mScrollbarWidth, mScrollbarWidth); } -gcn::Rectangle ScrollArea::getDownButtonDimension() const +Rectangle ScrollArea::getDownButtonDimension() const { if (!mVBarVisible || !mShowButtons) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); if (mVBarVisible && mHBarVisible) { - return gcn::Rectangle(mDimension.width - mScrollbarWidth, + return Rectangle(mDimension.width - mScrollbarWidth, mDimension.height - mScrollbarWidth*2, mScrollbarWidth, mScrollbarWidth); } - return gcn::Rectangle(mDimension.width - mScrollbarWidth, + return Rectangle(mDimension.width - mScrollbarWidth, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); } -gcn::Rectangle ScrollArea::getLeftButtonDimension() const +Rectangle ScrollArea::getLeftButtonDimension() const { if (!mHBarVisible || !mShowButtons) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); - return gcn::Rectangle(0, mDimension.height - mScrollbarWidth, + return Rectangle(0, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); } -gcn::Rectangle ScrollArea::getRightButtonDimension() const +Rectangle ScrollArea::getRightButtonDimension() const { if (!mHBarVisible || !mShowButtons) - return gcn::Rectangle(0, 0, 0, 0); + return Rectangle(0, 0, 0, 0); if (mVBarVisible && mHBarVisible) { - return gcn::Rectangle(mDimension.width - mScrollbarWidth*2, + return Rectangle(mDimension.width - mScrollbarWidth*2, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); } - return gcn::Rectangle(mDimension.width - mScrollbarWidth, + return Rectangle(mDimension.width - mScrollbarWidth, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index 39a7eea80..e5c9ffb79 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -119,21 +119,21 @@ class ScrollArea final : public gcn::ScrollArea, void widgetMoved(const Event &event) override final; - gcn::Rectangle getVerticalBarDimension() const; + Rectangle getVerticalBarDimension() const; - gcn::Rectangle getHorizontalBarDimension() const; + Rectangle getHorizontalBarDimension() const; - gcn::Rectangle getVerticalMarkerDimension(); + Rectangle getVerticalMarkerDimension(); - gcn::Rectangle getHorizontalMarkerDimension(); + Rectangle getHorizontalMarkerDimension(); - gcn::Rectangle getUpButtonDimension() const; + Rectangle getUpButtonDimension() const; - gcn::Rectangle getDownButtonDimension() const; + Rectangle getDownButtonDimension() const; - gcn::Rectangle getLeftButtonDimension() const; + Rectangle getLeftButtonDimension() const; - gcn::Rectangle getRightButtonDimension() const; + Rectangle getRightButtonDimension() const; protected: enum BUTTON_DIR diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 59ae1059e..28af43cec 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -144,7 +144,7 @@ void ShopListBox::draw(Graphics *graphics) if (needDraw) { graphics->setColor(*backgroundColor); - graphics->fillRectangle(gcn::Rectangle(mPadding, y + mPadding, + graphics->fillRectangle(Rectangle(mPadding, y + mPadding, width, mRowHeight)); } diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index 0482281ed..a8acb3f5f 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -73,7 +73,7 @@ void ShortcutContainer::widgetResized(const Event &event A_UNUSED) int ShortcutContainer::getIndexFromGrid(const int pointX, const int pointY) const { - const gcn::Rectangle tRect = gcn::Rectangle(0, 0, + const Rectangle tRect = Rectangle(0, 0, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth; diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 768206bdb..239fc6797 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -116,7 +116,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) const int itemId = getItemByIndex(i); if (selectedId >= 0 && itemId == selectedId) { - graphics->drawRectangle(gcn::Rectangle(itemX + 1, itemY + 1, + graphics->drawRectangle(Rectangle(itemX + 1, itemY + 1, mBoxWidth - 1, mBoxHeight - 1)); } diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 879ac8ec0..ce2c02886 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -457,7 +457,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) { if (mFollowDownScroll && height != 0) { - const gcn::Rectangle &rect = w->getDimension(); + const Rectangle &rect = w->getDimension(); if (rect.height != 0 && rect.height > height + 2) { if (scr->getVerticalScrollAmount() @@ -722,7 +722,7 @@ void TabbedArea::setSize(int width, int height) adjustSize(); } -void TabbedArea::setDimension(const gcn::Rectangle &dimension) +void TabbedArea::setDimension(const Rectangle &dimension) { gcn::Widget::setDimension(dimension); adjustSize(); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index a95438605..2affd7368 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -222,7 +222,7 @@ class TabbedArea final : public ActionListener, void setSize(int width, int height); - void setDimension(const gcn::Rectangle &dimension); + void setDimension(const Rectangle &dimension); void death(const Event &event); diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index b74dc53b8..70018f999 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -407,7 +407,7 @@ void ChatTab::chatInput(const std::string &message) void ChatTab::scroll(const int amount) { const int range = mScrollArea->getHeight() / 8 * amount; - gcn::Rectangle scr; + Rectangle scr; scr.y = mScrollArea->getVerticalScrollAmount() + range; scr.height = abs(range); mTextOutput->showPart(scr); diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index 1bb119ee4..d70e4e1b4 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -168,7 +168,7 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : new SetupItemCheckBox(_("Download music"), "", "download-music", this, "download-musicEvent"); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } Setup_Audio::~Setup_Audio() diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp index 3aa6d39d2..94a65163b 100644 --- a/src/gui/widgets/tabs/setup_chat.cpp +++ b/src/gui/widgets/tabs/setup_chat.cpp @@ -195,7 +195,7 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) : new SetupItemCheckBox(_("Show motd server message on start"), "", "showmotd", this, "showmotdEvent"); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } void Setup_Chat::apply() diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 61219fa98..41be92454 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -192,7 +192,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGradTypeText->setCaption(""); - setDimension(gcn::Rectangle(0, 0, 365, 350)); + setDimension(Rectangle(0, 0, 365, 350)); } Setup_Colors::~Setup_Colors() diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 03c8f31e3..24bf229ef 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -164,7 +164,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) : if (config.getIntValue("screenwidth") >= 730) width += 100; - setDimension(gcn::Rectangle(0, 0, width, 350)); + setDimension(Rectangle(0, 0, width, 350)); } Setup_Input::~Setup_Input() diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index 7f96ee468..aa1180cef 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -93,7 +93,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) : place(0, 4, mCalibrateLabel); place(0, 5, mCalibrateButton); - setDimension(gcn::Rectangle(0, 0, 365, 75)); + setDimension(Rectangle(0, 0, 365, 75)); } Setup_Joystick::~Setup_Joystick() diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp index ada0ef686..657d09658 100644 --- a/src/gui/widgets/tabs/setup_mods.cpp +++ b/src/gui/widgets/tabs/setup_mods.cpp @@ -44,7 +44,7 @@ Setup_Mods::Setup_Mods(const Widget2 *const widget) : ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } Setup_Mods::~Setup_Mods() diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp index 985baa744..4640150e4 100644 --- a/src/gui/widgets/tabs/setup_other.cpp +++ b/src/gui/widgets/tabs/setup_other.cpp @@ -390,7 +390,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) : new SetupItemDropDown(_("Screen density override"), "", "screenDensity", this, "screenDensityEvent", mDensityList, 100); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } Setup_Other::~Setup_Other() diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp index 271501e38..88cf6279c 100644 --- a/src/gui/widgets/tabs/setup_perfomance.cpp +++ b/src/gui/widgets/tabs/setup_perfomance.cpp @@ -153,7 +153,7 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) : "", "uselonglivesounds", this, "uselonglivesoundsEvent"); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } Setup_Perfomance::~Setup_Perfomance() diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index d4f29fa2c..a612a51c4 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -100,5 +100,5 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : new SetupItemCheckBox(_("Use special diagonal speed in players moving"), "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent"); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 35bd2094a..30e1c96bd 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -319,7 +319,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) : player_relations.addListener(this); - setDimension(gcn::Rectangle(0, 0, 500, 350)); + setDimension(Rectangle(0, 0, 500, 350)); } Setup_Relations::~Setup_Relations() diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index d27a095d5..b744eb0eb 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -389,7 +389,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : else if (size > maxWidth) size = maxWidth; - setDimension(gcn::Rectangle(0, 0, size, 500)); + setDimension(Rectangle(0, 0, size, 500)); } Setup_Theme::~Setup_Theme() diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index 2baae029e..1d9149fbd 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -119,7 +119,7 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) : key, this, event, mActionsList, 250); } - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } Setup_Touch::~Setup_Touch() diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index d2ef01378..4e4408ce6 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -304,7 +304,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : if (config.getIntValue("screenwidth") >= 730) width += 100; - setDimension(gcn::Rectangle(0, 0, width, 300)); + setDimension(Rectangle(0, 0, width, 300)); } Setup_Video::~Setup_Video() diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index ac608f756..d7c2ff788 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -202,7 +202,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : new SetupItemCheckBox(_("Allow screensaver to run"), "", "allowscreensaver", this, "allowscreensaverEvent"); - setDimension(gcn::Rectangle(0, 0, 550, 350)); + setDimension(Rectangle(0, 0, 550, 350)); } Setup_Visual::~Setup_Visual() diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index e0327e670..59e61f8d2 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -357,7 +357,7 @@ void TextBox::draw(Graphics* graphics) if (mOpaque) { graphics->setColor(mBackgroundColor); - graphics->fillRectangle(gcn::Rectangle(0, 0, getWidth(), getHeight())); + graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); } Font *const font = getFont(); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 0d4d53dd3..3b4c5302c 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -662,7 +662,7 @@ void TextField::handleCopy() const void TextField::drawCaret(Graphics* graphics, int x) { - const gcn::Rectangle *const clipArea = graphics->getCurrentClipArea(); + const Rectangle *const clipArea = graphics->getCurrentClipArea(); if (!clipArea) return; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 462ba17d9..0676dec25 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -93,7 +93,7 @@ void TextPreview::draw(Graphics* graphics) static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0F))); - graphics->fillRectangle(gcn::Rectangle(0, 0, + graphics->fillRectangle(Rectangle(0, 0, mDimension.width, mDimension.height)); } @@ -109,7 +109,7 @@ void TextPreview::draw(Graphics* graphics) static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), intAlpha)); - graphics->fillRectangle(gcn::Rectangle(mPadding, mPadding, x, y)); + graphics->fillRectangle(Rectangle(mPadding, mPadding, x, y)); } } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index d26580fc2..cccb1cdc7 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -487,7 +487,7 @@ void Window::setResizable(const bool r) void Window::widgetResized(const Event &event A_UNUSED) { - const gcn::Rectangle area = getChildrenArea(); + const Rectangle area = getChildrenArea(); if (mGrip) { @@ -794,7 +794,7 @@ void Window::mouseDragged(MouseEvent &event) { const int dx = event.getX() - mDragOffsetX; const int dy = event.getY() - mDragOffsetY; - gcn::Rectangle newDim = getDimension(); + Rectangle newDim = getDimension(); if (mouseResize & (TOP | BOTTOM)) { @@ -1192,7 +1192,7 @@ void Window::redraw() { if (mLayout) { - const gcn::Rectangle area = getChildrenArea(); + const Rectangle area = getChildrenArea(); int w = area.width; int h = area.height; mLayout->reflow(w, h); @@ -1228,12 +1228,12 @@ void Window::ensureOnScreen() mDimension.y = 0; } -gcn::Rectangle Window::getWindowArea() const +Rectangle Window::getWindowArea() const { - return gcn::Rectangle(mPadding, - mPadding, - mDimension.width - mPadding * 2, - mDimension.height - mPadding * 2); + return Rectangle(mPadding, + mPadding, + mDimension.width - mPadding * 2, + mDimension.height - mPadding * 2); } int Window::getOption(const std::string &name, const int def) const diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 37a9900ee..10c9123be 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -405,7 +405,7 @@ class Window : public gcn::Window, */ int getGuiAlpha() const A_WARN_UNUSED; - gcn::Rectangle getWindowArea() const A_WARN_UNUSED; + Rectangle getWindowArea() const A_WARN_UNUSED; bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; @@ -476,9 +476,9 @@ class Window : public gcn::Window, Image *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ Layout *mLayout; /**< Layout handler */ - gcn::Rectangle mCloseRect; /**< Close button rectangle */ - gcn::Rectangle mStickyRect; /**< Sticky button rectangle */ - gcn::Rectangle mGripRect; /**< Resize grip rectangle */ + Rectangle mCloseRect; /**< Close button rectangle */ + Rectangle mStickyRect; /**< Sticky button rectangle */ + Rectangle mGripRect; /**< Resize grip rectangle */ std::string mWindowName; /**< Name of the window */ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 27418b892..79ed7255d 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -168,7 +168,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : x += mPadding - mSpacing; if (mainGraphics) - setDimension(gcn::Rectangle(mainGraphics->mWidth - x, 0, x, h)); + setDimension(Rectangle(mainGraphics->mWidth - x, 0, x, h)); loadButtons(); @@ -293,7 +293,7 @@ void WindowMenu::mouseMoved(MouseEvent &event) const int x = event.getX(); const int y = event.getY(); const int key = btn->getTag(); - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; if (key != Input::KEY_NO_VALUE) { mTextPopup->show(x + rect.x, y + rect.y, btn->getDescription(), @@ -350,7 +350,7 @@ void WindowMenu::updateButtons() } x += mPadding - mSpacing; if (mainGraphics) - setDimension(gcn::Rectangle(mainGraphics->mWidth - x, 0, x, h)); + setDimension(Rectangle(mainGraphics->mWidth - x, 0, x, h)); } void WindowMenu::loadButtons() diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index fb407b9cc..1ddaaa7b2 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -208,13 +208,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, const int h = 350; setContentSize(w, h); - mPlayerBox->setDimension(gcn::Rectangle(360, 0, 110, 90)); + mPlayerBox->setDimension(Rectangle(360, 0, 110, 90)); mActionButton->setPosition(385, 100); mRotateButton->setPosition(415, 100); mNameLabel->setPosition(5, 2); mNameField->setDimension( - gcn::Rectangle(60, 2, 300, mNameField->getHeight())); + Rectangle(60, 2, 300, mNameField->getHeight())); const int leftX = 120; const int rightX = 300; @@ -530,7 +530,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels, add(mAttributeLabel[i]); mAttributeSlider[i] = new Slider(this, min, max); - mAttributeSlider[i]->setDimension(gcn::Rectangle(140, y + i * 24, + mAttributeSlider[i]->setDimension(Rectangle(140, y + i * 24, 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 565d3644a..1754ca0bf 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -377,7 +377,7 @@ void ChatWindow::updateTabsMargin() void ChatWindow::adjustTabSize() { - const gcn::Rectangle area = getChildrenArea(); + const Rectangle area = getChildrenArea(); const int aw = area.width; const int ah = area.height; diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 7e68aa6d8..2a227c4e2 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -75,7 +75,7 @@ DebugWindow::DebugWindow() : // TRANSLATORS: debug window tab mTabs->addTab(std::string(_("Net")), mNetWidget); - mTabs->setDimension(gcn::Rectangle(0, 0, 600, 300)); + mTabs->setDimension(Rectangle(0, 0, 600, 300)); const int w = mDimension.width; const int h = mDimension.height; @@ -151,7 +151,7 @@ void DebugWindow::widgetResized(const Event &event) { Window::widgetResized(event); - mTabs->setDimension(gcn::Rectangle(0, 0, + mTabs->setDimension(Rectangle(0, 0, mDimension.width, mDimension.height)); } @@ -267,7 +267,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) : #endif place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); - setDimension(gcn::Rectangle(0, 0, 600, 300)); + setDimension(Rectangle(0, 0, 600, 300)); } void MapDebugTab::logic() @@ -412,7 +412,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) : place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); - setDimension(gcn::Rectangle(0, 0, 600, 300)); + setDimension(Rectangle(0, 0, 600, 300)); } void TargetDebugTab::logic() @@ -531,7 +531,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) : place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); - setDimension(gcn::Rectangle(0, 0, 600, 300)); + setDimension(Rectangle(0, 0, 600, 300)); } void NetDebugTab::logic() diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h index aa7bdfe6c..194385b06 100644 --- a/src/gui/windows/debugwindow.h +++ b/src/gui/windows/debugwindow.h @@ -41,7 +41,7 @@ class DebugTab : public Container } void resize(const int x, const int y) - { setDimension(gcn::Rectangle(0, 0, x, y)); } + { setDimension(Rectangle(0, 0, x, y)); } protected: explicit DebugTab(const Widget2 *const widget) : diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index 01f74c50d..a50d0e9fa 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -92,7 +92,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, mBoxSize = 36; // Control that shows the Player - mPlayerBox->setDimension(gcn::Rectangle(50, 80, 74, 168)); + mPlayerBox->setDimension(Rectangle(50, 80, 74, 168)); mPlayerBox->setPlayer(being); if (foring) @@ -116,7 +116,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, void EquipmentWindow::postInit() { - const gcn::Rectangle &area = getChildrenArea(); + const Rectangle &area = getChildrenArea(); mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding, area.height - mUnequip->getHeight() - mButtonPadding); mUnequip->setEnabled(false); @@ -283,7 +283,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const const EquipmentBox *const box = *it; if (!box) continue; - const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); + const Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); @@ -321,7 +321,7 @@ void EquipmentWindow::mousePressed(MouseEvent& mouseEvent) if (!box) continue; const Item *const item = mEquipment->getEquipment(i); - const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); + const Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) { @@ -402,7 +402,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &mouseEvent) const EquipmentBox *const box = *it; if (!box) continue; - const gcn::Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); + const Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) return; @@ -514,7 +514,7 @@ void EquipmentWindow::fillBoxes() void EquipmentWindow::loadPlayerBox(const XmlNodePtr playerBoxNode) { - mPlayerBox->setDimension(gcn::Rectangle( + mPlayerBox->setDimension(Rectangle( XML::getProperty(playerBoxNode, "x", 50), XML::getProperty(playerBoxNode, "y", 80), XML::getProperty(playerBoxNode, "width", 74), diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 603b1b26d..bd6719df9 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -598,7 +598,7 @@ void InventoryWindow::mouseMoved(MouseEvent &event) { const int x = event.getX(); const int y = event.getY(); - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; mTextPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"), Units::formatCurrency(PlayerInfo::getAttribute( PlayerInfo::MONEY)).c_str())); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 0f0938e20..dd8a1d2b7 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -213,7 +213,7 @@ void Minimap::setMap(const Map *const map) setHeight(height); } - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; setDefaultSize(rect.x, rect.y, rect.width, rect.height); resetToDefaultSize(); @@ -244,7 +244,7 @@ void Minimap::draw(Graphics *graphics) return; } - const gcn::Rectangle a = getChildrenArea(); + const Rectangle a = getChildrenArea(); graphics->pushClipArea(a); @@ -346,7 +346,7 @@ void Minimap::draw(Graphics *graphics) dotSize - 1) * mWidthProportion); const Vector &pos = being->getPosition(); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( static_cast(pos.x * mWidthProportion) / 32 + mMapOriginX - offsetWidth, static_cast(pos.y * mHeightProportion) / 32 @@ -384,7 +384,7 @@ void Minimap::draw(Graphics *graphics) const int offsetWidth = static_cast( mWidthProportion); - graphics->fillRectangle(gcn::Rectangle( + graphics->fillRectangle(Rectangle( static_cast(member->getX() * mWidthProportion) + mMapOriginX - offsetWidth, static_cast(member->getY() @@ -429,7 +429,7 @@ void Minimap::draw(Graphics *graphics) } graphics->setColor(userPalette->getColor(UserPalette::PC)); - graphics->drawRectangle(gcn::Rectangle(x, y, w, h)); + graphics->drawRectangle(Rectangle(x, y, w, h)); graphics->popClipArea(); BLOCK_END("Minimap::draw") } @@ -463,7 +463,7 @@ void Minimap::mouseMoved(MouseEvent &event) Window::mouseMoved(event); const int x = event.getX(); const int y = event.getY(); - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; mTextPopup->show(x + rect.x, y + rect.y, mCaption); } @@ -475,7 +475,7 @@ void Minimap::mouseExited(MouseEvent &event) void Minimap::screenToMap(int &x, int &y) { - const gcn::Rectangle a = getChildrenArea(); + const Rectangle a = getChildrenArea(); x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion; y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion; } diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index b8f2fd7ea..655ccb277 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -322,7 +322,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) const int x = event.getX(); const int y = event.getY(); - const gcn::Rectangle &rect = mDimension; + const Rectangle &rect = mDimension; if (event.getSource() == mStatusBar) { mStatusPopup->view(x + rect.x, y + rect.y); @@ -535,12 +535,12 @@ void MiniStatusWindow::updateArrows() StatusWindow::updateArrowsBar(mArrowsBar); } -gcn::Rectangle MiniStatusWindow::getChildrenArea() +Rectangle MiniStatusWindow::getChildrenArea() { const int padding = mPadding; const int padding2 = padding * 2; - const gcn::Rectangle &rect = mDimension; - return gcn::Rectangle(padding, padding, + const Rectangle &rect = mDimension; + return Rectangle(padding, padding, rect.width - padding2, rect.height - padding2); } diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index bb1991c19..e061cbfae 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -88,7 +88,7 @@ class MiniStatusWindow final : public Popup, std::vector &getBars() A_WARN_UNUSED { return mBars; } - gcn::Rectangle getChildrenArea() override final A_WARN_UNUSED; + Rectangle getChildrenArea() override final A_WARN_UNUSED; #ifdef USE_PROFILER void logicChildren(); diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp index 23c21da0c..aa510b88e 100644 --- a/src/gui/windows/npcpostdialog.cpp +++ b/src/gui/windows/npcpostdialog.cpp @@ -76,7 +76,7 @@ void NpcPostDialog::postInit() // create scroll box for letter text ScrollArea *const scrollArea = new ScrollArea(this, mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - scrollArea->setDimension(gcn::Rectangle( + scrollArea->setDimension(Rectangle( 5, mSender->getHeight() + 5, 380, 140 - (mSender->getHeight() + sendButton->getHeight()))); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index d1413cc0a..acf681cf4 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -328,9 +328,9 @@ void OutfitWindow::draw(Graphics *graphics) + ((i / mGridWidth) * mBoxHeight); graphics->setColor(mBorderColor); - graphics->drawRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); + graphics->drawRectangle(Rectangle(itemX, itemY, 32, 32)); graphics->setColor(mBackgroundColor); - graphics->fillRectangle(gcn::Rectangle(itemX, itemY, 32, 32)); + graphics->fillRectangle(Rectangle(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) continue; @@ -483,7 +483,7 @@ void OutfitWindow::mouseReleased(MouseEvent &event) int OutfitWindow::getIndexFromGrid(const int pointX, const int pointY) const { - const gcn::Rectangle tRect = gcn::Rectangle(mPadding, mTitleBarHeight, + const Rectangle tRect = Rectangle(mPadding, mTitleBarHeight, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); if (!tRect.isPointInRect(pointX, pointY)) return -1; diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index dc932ca69..a89f7655a 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -291,7 +291,7 @@ void SellDialog::action(const ActionEvent &event) delete mShopItems->at(selectedItem); mShopItems->erase(selectedItem); - gcn::Rectangle scroll; + Rectangle scroll; scroll.y = mShopItemList->getRowHeight() * (selectedItem + 1); scroll.height = mShopItemList->getRowHeight(); mShopItemList->showPart(scroll); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index cbab4710d..a6e3637fb 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -177,7 +177,7 @@ public: // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(mPadding, + graphics->fillRectangle(Rectangle(mPadding, height * mSelected + mPadding, getWidth() - 2 * mPadding, height)); } diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 9878807d9..0f4468882 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -113,7 +113,7 @@ void SetupWindow::postInit() mResetWindows = btn; } - mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); + mPanel->setDimension(Rectangle(5, 5, width - 10, height - 40)); mPanel->enableScrollButtons(true); mTabs.push_back(new Setup_Video(this)); @@ -265,12 +265,12 @@ void SetupWindow::widgetResized(const Event &event) { Window::widgetResized(event); - const gcn::Rectangle area = getChildrenArea(); + const Rectangle area = getChildrenArea(); int x = area.width; const int height = area.height; const int width = area.width; const int buttonPadding = getOption("buttonPadding", 5); - mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); + mPanel->setDimension(Rectangle(5, 5, width - 10, height - 40)); FOR_EACH (std::vector::iterator, it, mButtons) { Button *const btn = *it; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 2e9a8be10..f5f233402 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -114,7 +114,7 @@ class SkillListBox final : public ListBox // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(gcn::Rectangle(mPadding, getRowHeight() + graphics->fillRectangle(Rectangle(mPadding, getRowHeight() * mSelected + mPadding, getWidth() - 2 * mPadding, getRowHeight())); } diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 76f12f795..70edccad1 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -116,10 +116,10 @@ void WhoIsOnline::postInit() setSaveVisible(true); mUpdateButton->setEnabled(false); - mUpdateButton->setDimension(gcn::Rectangle(5, 5, w - 10, 20 + 5)); + mUpdateButton->setDimension(Rectangle(5, 5, w - 10, 20 + 5)); mBrowserBox->setOpaque(false); - mScrollArea->setDimension(gcn::Rectangle(5, 20 + 10, w - 10, h - 10 - 30)); + mScrollArea->setDimension(Rectangle(5, 20 + 10, w - 10, h - 10 - 30)); mScrollArea->setSize(w - 10, h - 10 - 30); mBrowserBox->setLinkHandler(this); @@ -723,7 +723,7 @@ void WhoIsOnline::widgetResized(const Event &event) void WhoIsOnline::updateSize() { - const gcn::Rectangle area = getChildrenArea(); + const Rectangle area = getChildrenArea(); if (mUpdateButton) mUpdateButton->setWidth(area.width - 10); diff --git a/src/map.cpp b/src/map.cpp index 5dc1bfc0f..257516381 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -401,7 +401,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) graphics->setColor(userPalette->getColorWithAlpha( UserPalette::WALKABLE_HIGHLIGHT)); - graphics->fillRectangle(gcn::Rectangle(0, 0, + graphics->fillRectangle(Rectangle(0, 0, graphics->mWidth, graphics->mHeight)); } @@ -549,7 +549,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) {\ graphics->setColor(userPalette->getColorWithAlpha(\ UserPalette::color));\ - graphics->fillRectangle(gcn::Rectangle(\ + graphics->fillRectangle(Rectangle(\ x0 * mTileWidth - scrollX, \ y * mTileHeight - scrollY, \ width, mapTileSize));\ diff --git a/src/maplayer.cpp b/src/maplayer.cpp index b4fbc6da6..93434aca9 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -538,10 +538,10 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, { graphics->setColor(userPalette->getColorWithAlpha( UserPalette::ATTACK_RANGE)); - graphics->fillRectangle(gcn::Rectangle(x, y, w, h)); + graphics->fillRectangle(Rectangle(x, y, w, h)); graphics->setColor(userPalette->getColorWithAlpha( UserPalette::ATTACK_RANGE_BORDER)); - graphics->drawRectangle(gcn::Rectangle(x, y, w, h)); + graphics->drawRectangle(Rectangle(x, y, w, h)); } } } @@ -806,17 +806,17 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y, case CROSS: graphics->setColor(userPalette->getColorWithAlpha( UserPalette::ROAD_POINT)); - graphics->fillRectangle(gcn::Rectangle(x + dx / 3, y + dy / 3, + graphics->fillRectangle(Rectangle(x + dx / 3, y + dy / 3, dx / 3, dy / 3)); break; case HOME: { graphics->setColor(userPalette->getColorWithAlpha( UserPalette::HOME_PLACE)); - graphics->fillRectangle(gcn::Rectangle(x, y, dx, dy)); + graphics->fillRectangle(Rectangle(x, y, dx, dy)); graphics->setColor(userPalette->getColorWithAlpha( UserPalette::HOME_PLACE_BORDER)); - graphics->drawRectangle(gcn::Rectangle(x, y, dx, dy)); + graphics->drawRectangle(Rectangle(x, y, dx, dy)); break; } default: diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 653b4d4c0..bac987695 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -547,21 +547,21 @@ void Graphics::setWindowSize(const int width A_UNUSED, #endif } -bool Graphics::pushClipArea(gcn::Rectangle area) +bool Graphics::pushClipArea(Rectangle area) { // Ignore area with a negate width or height // by simple pushing an empty clip area // to the stack. if (area.width < 0 || area.height < 0) { - gcn::ClipRectangle carea; + ClipRectangle carea; mClipStack.push(carea); return true; } if (mClipStack.empty()) { - gcn::ClipRectangle carea; + ClipRectangle carea; carea.x = area.x; carea.y = area.y; carea.width = area.width; @@ -572,8 +572,8 @@ bool Graphics::pushClipArea(gcn::Rectangle area) return true; } - const gcn::ClipRectangle &top = mClipStack.top(); - gcn::ClipRectangle carea; + const ClipRectangle &top = mClipStack.top(); + ClipRectangle carea; carea = area; carea.xOffset = top.xOffset + carea.x; carea.yOffset = top.yOffset + carea.y; @@ -618,7 +618,7 @@ void Graphics::popClipArea() mClipStack.pop(); } -const gcn::ClipRectangle *Graphics::getCurrentClipArea() const +const ClipRectangle *Graphics::getCurrentClipArea() const { if (mClipStack.empty()) return nullptr; diff --git a/src/render/graphics.h b/src/render/graphics.h index 2356d2d31..35e2a3ba3 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -74,7 +74,7 @@ #include "render/renderers.h" -#include "gui/base/cliprectangle.hpp" +#include "gui/cliprectangle.h" #ifdef USE_SDL2 #include @@ -259,7 +259,7 @@ class Graphics const int w, const int h, const ImageRect &imgRect) = 0; - virtual void fillRectangle(const gcn::Rectangle& rectangle) = 0; + virtual void fillRectangle(const Rectangle& rectangle) = 0; /** * Updates the screen. This is done by either copying the buffer to the @@ -293,7 +293,7 @@ class Graphics const int x2, const int y2, const int width, const int height); - gcn::ClipRectangle &getTopClip() A_WARN_UNUSED + ClipRectangle &getTopClip() A_WARN_UNUSED { return mClipStack.top(); } void setRedraw(const bool n) @@ -410,7 +410,7 @@ class Graphics * @return False if the the new area lays outside the current clip * area. */ - virtual bool pushClipArea(gcn::Rectangle area); + virtual bool pushClipArea(Rectangle area); /** * Removes the top most clip area from the stack. @@ -434,7 +434,7 @@ class Graphics * * @param rectangle The rectangle to draw. */ - virtual void drawRectangle(const gcn::Rectangle &rectangle) = 0; + virtual void drawRectangle(const Rectangle &rectangle) = 0; /** * Gets the current clip area. Usefull if you want to do drawing @@ -442,7 +442,7 @@ class Graphics * * @return The current clip area. */ - virtual const gcn::ClipRectangle *getCurrentClipArea() const; + virtual const ClipRectangle *getCurrentClipArea() const; /** * Draws a single point/pixel. @@ -510,7 +510,7 @@ class Graphics /** * Holds the clip area stack. */ - std::stack mClipStack; + std::stack mClipStack; SDL_Window *mWindow; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 252dc0766..a2f7909ff 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -884,7 +884,7 @@ void MobileOpenGLGraphics::_beginDraw() // glScalef(0.5F, 0.5F, 0.5F); - pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); } void MobileOpenGLGraphics::_endDraw() @@ -951,21 +951,21 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot() return screenshot; } -bool MobileOpenGLGraphics::pushClipArea(gcn::Rectangle area) +bool MobileOpenGLGraphics::pushClipArea(Rectangle area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; @@ -986,7 +986,7 @@ void MobileOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &clipArea1 = mClipStack.top(); + const ClipRectangle &clipArea1 = mClipStack.top(); int transX = -clipArea1.xOffset; int transY = -clipArea1.yOffset; @@ -995,7 +995,7 @@ void MobileOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; if (transX || transY) @@ -1040,12 +1040,12 @@ void MobileOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) drawLineArrays(4); } -void MobileOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect) +void MobileOpenGLGraphics::drawRectangle(const Rectangle& rect) { drawRectangle(rect, false); } -void MobileOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect) +void MobileOpenGLGraphics::fillRectangle(const Rectangle& rect) { drawRectangle(rect, true); } @@ -1090,7 +1090,7 @@ void MobileOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void MobileOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect, +void MobileOpenGLGraphics::drawRectangle(const Rectangle& rect, const bool filled) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index aea3f5d24..67a18bde5 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -1145,7 +1145,7 @@ void NormalOpenGLGraphics::_beginDraw() #endif #endif - pushClipArea(gcn::Rectangle(0, 0, w, h)); + pushClipArea(Rectangle(0, 0, w, h)); } void NormalOpenGLGraphics::_endDraw() @@ -1211,21 +1211,21 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot() return screenshot; } -bool NormalOpenGLGraphics::pushClipArea(gcn::Rectangle area) +bool NormalOpenGLGraphics::pushClipArea(Rectangle area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; @@ -1247,7 +1247,7 @@ void NormalOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &clipArea1 = mClipStack.top(); + const ClipRectangle &clipArea1 = mClipStack.top(); int transX = -clipArea1.xOffset; int transY = -clipArea1.yOffset; @@ -1256,7 +1256,7 @@ void NormalOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; if (transX || transY) @@ -1297,12 +1297,12 @@ void NormalOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) drawLineArrayf(4); } -void NormalOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect) +void NormalOpenGLGraphics::drawRectangle(const Rectangle& rect) { drawRectangle(rect, false); } -void NormalOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect) +void NormalOpenGLGraphics::fillRectangle(const Rectangle& rect) { drawRectangle(rect, true); } @@ -1347,7 +1347,7 @@ void NormalOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void NormalOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect, +void NormalOpenGLGraphics::drawRectangle(const Rectangle& rect, const bool filled) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index d1c6ed0a6..6018247f9 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -918,7 +918,7 @@ void NullOpenGLGraphics::updateScreen() void NullOpenGLGraphics::_beginDraw() { - pushClipArea(gcn::Rectangle(0, 0, 640, 480)); + pushClipArea(Rectangle(0, 0, 640, 480)); } void NullOpenGLGraphics::_endDraw() @@ -935,21 +935,21 @@ SDL_Surface* NullOpenGLGraphics::getScreenshot() return nullptr; } -bool NullOpenGLGraphics::pushClipArea(gcn::Rectangle area) +bool NullOpenGLGraphics::pushClipArea(Rectangle area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; @@ -984,12 +984,12 @@ void NullOpenGLGraphics::drawLine(int x1, int y1, drawLineArrayf(4); } -void NullOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect) +void NullOpenGLGraphics::drawRectangle(const Rectangle& rect) { drawRectangle(rect, false); } -void NullOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect) +void NullOpenGLGraphics::fillRectangle(const Rectangle& rect) { drawRectangle(rect, true); } @@ -1017,7 +1017,7 @@ void NullOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void NullOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect A_UNUSED, +void NullOpenGLGraphics::drawRectangle(const Rectangle& rect A_UNUSED, const bool filled A_UNUSED) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 99bf8e82a..a582d9043 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -88,7 +88,7 @@ void _endDraw() override final; - bool pushClipArea(gcn::Rectangle area) override final; + bool pushClipArea(Rectangle area) override final; void popClipArea() override final; @@ -110,12 +110,12 @@ void drawLine(int x1, int y1, int x2, int y2) override final; - void drawRectangle(const gcn::Rectangle &rect, + void drawRectangle(const Rectangle &rect, const bool filled); - void drawRectangle(const gcn::Rectangle &rect) override final; + void drawRectangle(const Rectangle &rect) override final; - void fillRectangle(const gcn::Rectangle &rect) override final; + void fillRectangle(const Rectangle &rect) override final; static void dumpSettings(); diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index c27db4f47..c1c266464 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -459,7 +459,7 @@ void SafeOpenGLGraphics::_beginDraw() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); } void SafeOpenGLGraphics::_endDraw() @@ -523,21 +523,21 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot() return screenshot; } -bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area) +bool SafeOpenGLGraphics::pushClipArea(Rectangle area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); glPushMatrix(); glTranslatef(static_cast(transX + clipArea.xOffset), @@ -557,7 +557,7 @@ void SafeOpenGLGraphics::popClipArea() return; glPopMatrix(); - const gcn::ClipRectangle &clipArea = mClipStack.top(); + const ClipRectangle &clipArea = mClipStack.top(); glScissor(clipArea.x * mScale, (mRect.h - clipArea.y - clipArea.height) * mScale, clipArea.width * mScale, @@ -613,12 +613,12 @@ void SafeOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) glEnd(); } -void SafeOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect) +void SafeOpenGLGraphics::drawRectangle(const Rectangle& rect) { drawRectangle(rect, false); } -void SafeOpenGLGraphics::fillRectangle(const gcn::Rectangle& rect) +void SafeOpenGLGraphics::fillRectangle(const Rectangle& rect) { drawRectangle(rect, true); } @@ -661,7 +661,7 @@ void SafeOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void SafeOpenGLGraphics::drawRectangle(const gcn::Rectangle& rect, +void SafeOpenGLGraphics::drawRectangle(const Rectangle& rect, const bool filled) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 933120080..053049cef 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -136,7 +136,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, if (!image->mTexture) return false; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; const SDL_Rect srcRect = { @@ -171,7 +171,7 @@ bool SDLGraphics::drawImageInline(const Image *const image, if (!mWindow || !image || !image->mTexture) return false; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return false; @@ -203,7 +203,7 @@ void SDLGraphics::drawImageCached(const Image *const image, if (!mWindow || !image || !image->mTexture) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -238,7 +238,7 @@ void SDLGraphics::drawPatternCached(const Image *const image, if (!image->mTexture) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -296,7 +296,7 @@ void SDLGraphics::drawPatternInline(const Image *const image, if (!image->mTexture) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -347,7 +347,7 @@ void SDLGraphics::drawRescaledPattern(const Image *const image, if (scaledHeight == 0 || scaledWidth == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -407,7 +407,7 @@ void SDLGraphics::calcPatternInline(ImageVertexes* const vert, if (!vert || !mWindow || !image || !image->mTexture) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -492,7 +492,7 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const if (!vert || !vert->image || !vert->image->mTexture) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -638,9 +638,9 @@ void SDLGraphics::calcWindow(ImageCollection *const vertCol, calcImageRect(vert, x, y, w, h, imgRect); } -void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle) +void SDLGraphics::fillRectangle(const Rectangle &rectangle) { - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect rect = { static_cast(rectangle.x + top.xOffset), @@ -655,7 +655,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle &rectangle) void SDLGraphics::_beginDraw() { - pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); } void SDLGraphics::_endDraw() @@ -663,11 +663,11 @@ void SDLGraphics::_endDraw() popClipArea(); } -bool SDLGraphics::pushClipArea(gcn::Rectangle area) +bool SDLGraphics::pushClipArea(Rectangle area) { const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &carea = mClipStack.top(); + const ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -686,7 +686,7 @@ void SDLGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &carea = mClipStack.top(); + const ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -703,7 +703,7 @@ void SDLGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -722,9 +722,9 @@ void SDLGraphics::drawPoint(int x, int y) } -void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle) +void SDLGraphics::drawRectangle(const Rectangle &rectangle) { - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); @@ -746,7 +746,7 @@ void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle) void SDLGraphics::drawLine(int x1, int y1, int x2, int y2) { - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index 1e581dc39..cce15e270 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -101,7 +101,7 @@ class SDLGraphics final : public Graphics void _endDraw() override final; - bool pushClipArea(gcn::Rectangle rect) override final; + bool pushClipArea(Rectangle rect) override final; void popClipArea() override final; @@ -163,9 +163,9 @@ class SDLGraphics final : public Graphics const int w, const int h, const ImageRect &imgRect) override final; - void fillRectangle(const gcn::Rectangle &rect) override final; + void fillRectangle(const Rectangle &rect) override final; - void drawRectangle(const gcn::Rectangle &rect) override final; + void drawRectangle(const Rectangle &rect) override final; void drawPoint(int x, int y) override final; diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index e6cce9c35..05b1fa2ef 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -82,7 +82,7 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image, if (!tmpImage->mSDLSurface) return false; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Rect srcRect = @@ -123,7 +123,7 @@ bool SDL2SoftwareGraphics::drawImageInline(const Image *const image, if (!mSurface || !image || !image->mSDLSurface) return false; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -211,7 +211,7 @@ void SDL2SoftwareGraphics::drawImageCached(const Image *const image, if (!mSurface || !image || !image->mSDLSurface) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -307,7 +307,7 @@ void SDL2SoftwareGraphics::drawPatternCached(const Image *const image, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -428,7 +428,7 @@ void SDL2SoftwareGraphics::drawPatternInline(const Image *const image, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -547,7 +547,7 @@ void SDL2SoftwareGraphics::drawRescaledPattern(const Image *const image, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -610,7 +610,7 @@ void SDL2SoftwareGraphics::calcPatternInline(ImageVertexes* const vert, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -695,7 +695,7 @@ void SDL2SoftwareGraphics::calcTileSDL(ImageVertexes *const vert, return; const Image *const image = vert->image; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; DoubleRect *rect = new DoubleRect(); @@ -917,15 +917,15 @@ int SDL2SoftwareGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, return 0; } -void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle) +void SDL2SoftwareGraphics::fillRectangle(const Rectangle &rectangle) { FUNC_BLOCK("Graphics::fillRectangle", 1) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); - gcn::Rectangle area = rectangle; + Rectangle area = rectangle; area.x += top.xOffset; area.y += top.yOffset; @@ -1117,7 +1117,7 @@ void SDL2SoftwareGraphics::fillRectangle(const gcn::Rectangle &rectangle) void SDL2SoftwareGraphics::_beginDraw() { - pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); } void SDL2SoftwareGraphics::_endDraw() @@ -1125,11 +1125,11 @@ void SDL2SoftwareGraphics::_endDraw() popClipArea(); } -bool SDL2SoftwareGraphics::pushClipArea(gcn::Rectangle area) +bool SDL2SoftwareGraphics::pushClipArea(Rectangle area) { const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &carea = mClipStack.top(); + const ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1148,7 +1148,7 @@ void SDL2SoftwareGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &carea = mClipStack.top(); + const ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1165,7 +1165,7 @@ void SDL2SoftwareGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -1184,7 +1184,7 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); const int xOffset = top.xOffset; x1 += xOffset; @@ -1310,7 +1310,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); const int yOffset = top.yOffset; x += top.xOffset; @@ -1440,7 +1440,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) SDL_UnlockSurface(mSurface); } -void SDL2SoftwareGraphics::drawRectangle(const gcn::Rectangle &rectangle) +void SDL2SoftwareGraphics::drawRectangle(const Rectangle &rectangle) { const int x1 = rectangle.x; const int x2 = x1 + rectangle.width - 1; diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 3ac6cb212..270536e11 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -58,7 +58,7 @@ class SDL2SoftwareGraphics final : public Graphics void _endDraw(); - bool pushClipArea(gcn::Rectangle rect); + bool pushClipArea(Rectangle rect); void popClipArea(); @@ -120,9 +120,9 @@ class SDL2SoftwareGraphics final : public Graphics const int w, const int h, const ImageRect &imgRect) override final; - void fillRectangle(const gcn::Rectangle &rect) override final; + void fillRectangle(const Rectangle &rect) override final; - void drawRectangle(const gcn::Rectangle &rect) override final; + void drawRectangle(const Rectangle &rect) override final; void drawPoint(int x, int y) override final; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 2f4f6c0c2..9694eb0fb 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -76,7 +76,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, if (!tmpImage->mSDLSurface) return false; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Rect srcRect = @@ -117,7 +117,7 @@ bool SDLGraphics::drawImageInline(const Image *const image, if (!mWindow || !image || !image->mSDLSurface) return false; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -205,7 +205,7 @@ void SDLGraphics::drawImageCached(const Image *const image, if (!mWindow || !image || !image->mSDLSurface) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -301,7 +301,7 @@ void SDLGraphics::drawPatternCached(const Image *const image, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -422,7 +422,7 @@ void SDLGraphics::drawPatternInline(const Image *const image, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -541,7 +541,7 @@ void SDLGraphics::drawRescaledPattern(const Image *const image, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -604,7 +604,7 @@ void SDLGraphics::calcPatternInline(ImageVertexes* const vert, if (iw == 0 || ih == 0) return; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -688,7 +688,7 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const return; const Image *const image = vert->image; - const gcn::ClipRectangle &top = mClipStack.top(); + const ClipRectangle &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; DoubleRect *rect = new DoubleRect(); @@ -914,15 +914,15 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, return 0; } -void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle) +void SDLGraphics::fillRectangle(const Rectangle& rectangle) { FUNC_BLOCK("Graphics::fillRectangle", 1) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); - gcn::Rectangle area = rectangle; + Rectangle area = rectangle; area.x += top.xOffset; area.y += top.yOffset; @@ -1114,7 +1114,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle) void SDLGraphics::_beginDraw() { - pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); } void SDLGraphics::_endDraw() @@ -1122,10 +1122,10 @@ void SDLGraphics::_endDraw() popClipArea(); } -bool SDLGraphics::pushClipArea(gcn::Rectangle area) +bool SDLGraphics::pushClipArea(Rectangle area) { const bool result = Graphics::pushClipArea(area); - const gcn::ClipRectangle &carea = mClipStack.top(); + const ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1145,7 +1145,7 @@ void SDLGraphics::popClipArea() if (mClipStack.empty()) return; - const gcn::ClipRectangle &carea = mClipStack.top(); + const ClipRectangle &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1162,7 +1162,7 @@ void SDLGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -1181,7 +1181,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); const int xOffset = top.xOffset; x1 += xOffset; @@ -1307,7 +1307,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) if (mClipStack.empty()) return; - const gcn::ClipRectangle& top = mClipStack.top(); + const ClipRectangle& top = mClipStack.top(); const int yOffset = top.yOffset; x += top.xOffset; @@ -1437,7 +1437,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) SDL_UnlockSurface(mWindow); } -void SDLGraphics::drawRectangle(const gcn::Rectangle &rectangle) +void SDLGraphics::drawRectangle(const Rectangle &rectangle) { const int x1 = rectangle.x; const int x2 = x1 + rectangle.width - 1; diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index 484b24e31..f5ca099de 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -58,7 +58,7 @@ class SDLGraphics final : public Graphics void _endDraw() override final; - bool pushClipArea(gcn::Rectangle rect) override final; + bool pushClipArea(Rectangle rect) override final; void popClipArea() override final; @@ -120,9 +120,9 @@ class SDLGraphics final : public Graphics const int w, const int h, const ImageRect &imgRect) override final; - void fillRectangle(const gcn::Rectangle &rect) override final; + void fillRectangle(const Rectangle &rect) override final; - void drawRectangle(const gcn::Rectangle &rect) override final; + void drawRectangle(const Rectangle &rect) override final; void drawPoint(int x, int y) override final; diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index c3e6cb2ee..cadd19876 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -63,7 +63,7 @@ class SurfaceGraphics final : public Graphics void _endDraw() override final { } - bool pushClipArea(gcn::Rectangle rect A_UNUSED) override final + bool pushClipArea(Rectangle rect A_UNUSED) override final { return true; } void popClipArea() override final @@ -158,10 +158,10 @@ class SurfaceGraphics final : public Graphics BlitMode getBlitMode() const A_WARN_UNUSED { return mBlitMode; } - void fillRectangle(const gcn::Rectangle &rect A_UNUSED) override final + void fillRectangle(const Rectangle &rect A_UNUSED) override final { } - void drawRectangle(const gcn::Rectangle &rect A_UNUSED) override final + void drawRectangle(const Rectangle &rect A_UNUSED) override final { } void drawPoint(int x A_UNUSED, int y A_UNUSED) override final diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 49a5a0d3d..f560b8817 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -163,7 +163,7 @@ void TouchManager::loadTouchItem(TouchItem **item, const std::string &name, default: break; } - *item = new TouchItem(text, gcn::Rectangle(x + diff, y + diff, + *item = new TouchItem(text, Rectangle(x + diff, y + diff, width + border2, height + border2), type, eventPressed, eventReleased, images, icon, x + pad, y + pad, width, height, @@ -270,7 +270,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) const TouchItem *const item = *it; if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard))) continue; - const gcn::Rectangle &rect = item->rect; + const Rectangle &rect = item->rect; if (rect.isPointInRect(x, y)) { MouseInput event = mouseInput; diff --git a/src/touchmanager.h b/src/touchmanager.h index 09eaabad5..7e670b1a6 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -25,7 +25,7 @@ #include "input/keydata.h" -#include "gui/base/rectangle.hpp" +#include "gui/rectangle.h" #include #include @@ -45,7 +45,7 @@ const int buttonsCount = 12; struct TouchItem final { TouchItem(const std::string &text0, - const gcn::Rectangle &rect0, const int type0, + const Rectangle &rect0, const int type0, const std::string &eventPressed0, const std::string &eventReleased0, ImageRect *const images0, Image *const icon0, @@ -73,7 +73,7 @@ struct TouchItem final A_DELETE_COPY(TouchItem) std::string text; - gcn::Rectangle rect; + Rectangle rect; int type; std::string eventPressed; std::string eventReleased; -- cgit v1.2.3-70-g09d2 From 2c110bf45eb53807378bbd2abf70268aa0c2197f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 15:18:30 +0300 Subject: fix tests. --- src/gui/sdlfont_unittest.cc | 90 ++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/sdlfont_unittest.cc index b9d08037c..e0f536c01 100644 --- a/src/gui/sdlfont_unittest.cc +++ b/src/gui/sdlfont_unittest.cc @@ -43,7 +43,7 @@ TEST(TextChunkList, add1) TextChunkList list; SDLTextChunk *chunk = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 3, 4)); + Color(1, 2, 3), Color(2, 3, 4)); list.insertFirst(chunk); @@ -66,9 +66,9 @@ TEST(TextChunkList, add2) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(3, 4, 5)); + Color(1, 2, 3), Color(3, 4, 5)); SDLTextChunk *chunk2 = new SDLTextChunk("test", - gcn::Color(2, 3, 4), gcn::Color(4, 5, 6)); + Color(2, 3, 4), Color(4, 5, 6)); list.insertFirst(chunk2); list.insertFirst(chunk1); @@ -96,7 +96,7 @@ TEST(TextChunkList, addRemoveBack1) TextChunkList list; SDLTextChunk *chunk = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); list.insertFirst(chunk); list.removeBack(); @@ -113,9 +113,9 @@ TEST(TextChunkList, addRemoveBack2) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunk *chunk2 = new SDLTextChunk("test2", - gcn::Color(1, 2, 4), gcn::Color(1, 2, 5)); + Color(1, 2, 4), Color(1, 2, 5)); list.insertFirst(chunk2); list.insertFirst(chunk1); @@ -140,9 +140,9 @@ TEST(TextChunkList, addRemoveBack3) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunk *chunk2 = new SDLTextChunk("test2", - gcn::Color(2, 3, 4), gcn::Color(2, 3, 4)); + Color(2, 3, 4), Color(2, 3, 4)); list.insertFirst(chunk2); list.insertFirst(chunk1); @@ -161,11 +161,11 @@ TEST(TextChunkList, addRemoveBack4) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunk *chunk2 = new SDLTextChunk("test2", - gcn::Color(2, 3, 4), gcn::Color(2, 3, 4)); + Color(2, 3, 4), Color(2, 3, 4)); SDLTextChunk *chunk3 = new SDLTextChunk("test", - gcn::Color(3, 4, 5), gcn::Color(3, 4, 5)); + Color(3, 4, 5), Color(3, 4, 5)); list.insertFirst(chunk3); list.insertFirst(chunk2); @@ -191,7 +191,7 @@ TEST(TextChunkList, moveToFirst1) TextChunkList list; SDLTextChunk *chunk = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 3, 4)); + Color(1, 2, 3), Color(2, 3, 4)); list.insertFirst(chunk); list.moveToFirst(chunk); @@ -208,9 +208,9 @@ TEST(TextChunkList, moveToFirst2) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunk *chunk2 = new SDLTextChunk("test", - gcn::Color(2, 3, 4), gcn::Color(1, 2, 3)); + Color(2, 3, 4), Color(1, 2, 3)); list.insertFirst(chunk1); list.insertFirst(chunk2); @@ -230,11 +230,11 @@ TEST(TextChunkList, moveToFirst3) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunk *chunk2 = new SDLTextChunk("test", - gcn::Color(1, 2, 4), gcn::Color(1, 2, 3)); + Color(1, 2, 4), Color(1, 2, 3)); SDLTextChunk *chunk3 = new SDLTextChunk("test", - gcn::Color(1, 2, 5), gcn::Color(1, 2, 3)); + Color(1, 2, 5), Color(1, 2, 3)); list.insertFirst(chunk3); list.insertFirst(chunk1); @@ -257,11 +257,11 @@ TEST(TextChunkList, moveToFirst4) TextChunkList list; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(), gcn::Color()); + Color(), Color()); SDLTextChunk *chunk2 = new SDLTextChunk("test2", - gcn::Color(), gcn::Color()); + Color(), Color()); SDLTextChunk *chunk3 = new SDLTextChunk("test3", - gcn::Color(), gcn::Color()); + Color(), Color()); list.insertFirst(chunk1); list.insertFirst(chunk3); @@ -284,7 +284,7 @@ TEST(TextChunkList, clear1) TextChunkList list; int chunksLeft = sdlTextChunkCnt; - SDLTextChunk *chunk = new SDLTextChunk("test", gcn::Color(), gcn::Color()); + SDLTextChunk *chunk = new SDLTextChunk("test", Color(), Color()); list.insertFirst(chunk); list.clear(); @@ -303,11 +303,11 @@ TEST(TextChunkList, clear2) int chunksLeft = sdlTextChunkCnt; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 0)); + Color(1, 2, 3), Color(2, 0, 0)); SDLTextChunk *chunk2 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 1)); + Color(1, 2, 3), Color(2, 0, 1)); SDLTextChunk *chunk3 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 2)); + Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); @@ -328,11 +328,11 @@ TEST(TextChunkList, clear3) int chunksLeft = sdlTextChunkCnt; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 0)); + Color(1, 2, 3), Color(2, 0, 0)); SDLTextChunk *chunk2 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 1)); + Color(1, 2, 3), Color(2, 0, 1)); SDLTextChunk *chunk3 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 2)); + Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); @@ -359,11 +359,11 @@ TEST(TextChunkList, clear4) int chunksLeft = sdlTextChunkCnt; SDLTextChunk *chunk1 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 0)); + Color(1, 2, 3), Color(2, 0, 0)); SDLTextChunk *chunk2 = new SDLTextChunk("test", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 1)); + Color(1, 2, 3), Color(2, 0, 1)); SDLTextChunk *chunk3 = new SDLTextChunk("test3", - gcn::Color(1, 2, 3), gcn::Color(2, 0, 2)); + Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); @@ -387,11 +387,11 @@ TEST(TextChunkList, clear4) TEST(TextChunkList, sort1) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item3("test line2", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); EXPECT_EQ(false, item1 < item2); EXPECT_EQ(false, item2 < item1); EXPECT_EQ(true, item1 < item3); @@ -401,9 +401,9 @@ TEST(TextChunkList, sort1) TEST(TextChunkList, sort2) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(2, 3, 4), gcn::Color(1, 2, 3)); + Color(2, 3, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); } @@ -411,9 +411,9 @@ TEST(TextChunkList, sort2) TEST(TextChunkList, sort3) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(1, 3, 4), gcn::Color(1, 2, 3)); + Color(1, 3, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); } @@ -421,9 +421,9 @@ TEST(TextChunkList, sort3) TEST(TextChunkList, sort4) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(1, 2, 4), gcn::Color(1, 2, 3)); + Color(1, 2, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); } @@ -431,9 +431,9 @@ TEST(TextChunkList, sort4) TEST(TextChunkList, sort5) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(1, 2, 3), gcn::Color(2, 2, 3)); + Color(1, 2, 3), Color(2, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); } @@ -441,9 +441,9 @@ TEST(TextChunkList, sort5) TEST(TextChunkList, sort6) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 3, 3)); + Color(1, 2, 3), Color(1, 3, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); } @@ -451,9 +451,9 @@ TEST(TextChunkList, sort6) TEST(TextChunkList, sort7) { SDLTextChunkSmall item1("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 3)); + Color(1, 2, 3), Color(1, 2, 3)); SDLTextChunkSmall item2("test line1", - gcn::Color(1, 2, 3), gcn::Color(1, 2, 4)); + Color(1, 2, 3), Color(1, 2, 4)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); } -- cgit v1.2.3-70-g09d2 From 4e7a7c79f41a5aa509fa639f0d3e972ab7db6b06 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 15:43:12 +0300 Subject: Move Widget into gui/widgets directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/events/actionevent.h | 7 +- src/events/event.h | 11 +- src/events/inputguievent.h | 2 +- src/events/keyevent.h | 7 +- src/events/mouseevent.h | 5 +- src/events/selectionevent.h | 7 +- src/gui/base/basiccontainer.hpp | 2 +- src/gui/base/gui.cpp | 2 +- src/gui/base/gui.hpp | 3 +- src/gui/base/widget.cpp | 679 ---------------- src/gui/base/widget.hpp | 1231 ------------------------------ src/gui/base/widgets/button.cpp | 4 +- src/gui/base/widgets/button.hpp | 2 +- src/gui/base/widgets/checkbox.cpp | 4 +- src/gui/base/widgets/checkbox.hpp | 2 +- src/gui/base/widgets/label.cpp | 4 +- src/gui/base/widgets/label.hpp | 2 +- src/gui/base/widgets/listbox.cpp | 4 +- src/gui/base/widgets/listbox.hpp | 2 +- src/gui/base/widgets/radiobutton.cpp | 4 +- src/gui/base/widgets/radiobutton.hpp | 2 +- src/gui/base/widgets/slider.cpp | 4 +- src/gui/base/widgets/slider.hpp | 2 +- src/gui/base/widgets/textbox.cpp | 4 +- src/gui/base/widgets/textbox.hpp | 2 +- src/gui/base/widgets/textfield.cpp | 4 +- src/gui/base/widgets/textfield.hpp | 2 +- src/gui/focushandler.cpp | 56 +- src/gui/focushandler.h | 68 +- src/gui/gui.cpp | 22 +- src/gui/gui.h | 6 +- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/browserbox.h | 5 +- src/gui/widgets/browserbox_unittest.cc | 2 +- src/gui/widgets/container.cpp | 2 +- src/gui/widgets/container.h | 2 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/emotepage.h | 4 +- src/gui/widgets/flowcontainer.cpp | 2 +- src/gui/widgets/flowcontainer.h | 2 +- src/gui/widgets/guitable.cpp | 30 +- src/gui/widgets/guitable.h | 12 +- src/gui/widgets/horizontcontainer.cpp | 4 +- src/gui/widgets/horizontcontainer.h | 4 +- src/gui/widgets/icon.cpp | 4 +- src/gui/widgets/icon.h | 4 +- src/gui/widgets/itemcontainer.cpp | 4 +- src/gui/widgets/itemcontainer.h | 4 +- src/gui/widgets/layout.cpp | 4 +- src/gui/widgets/layout.h | 11 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/layouthelper.h | 2 +- src/gui/widgets/popup.cpp | 2 +- src/gui/widgets/popup.h | 2 +- src/gui/widgets/popuplist.cpp | 2 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/progressbar.h | 4 +- src/gui/widgets/progressindicator.cpp | 2 +- src/gui/widgets/progressindicator.h | 4 +- src/gui/widgets/radiogroup.cpp | 2 +- src/gui/widgets/radiogroup.h | 6 +- src/gui/widgets/scrollarea.cpp | 10 +- src/gui/widgets/scrollarea.h | 2 +- src/gui/widgets/setupitem.cpp | 2 +- src/gui/widgets/setupitem.h | 10 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/shortcutcontainer.h | 5 +- src/gui/widgets/tabbedarea.cpp | 34 +- src/gui/widgets/tabbedarea.h | 16 +- src/gui/widgets/tablemodel.cpp | 8 +- src/gui/widgets/tablemodel.h | 13 +- src/gui/widgets/tabs/setup_joystick.cpp | 2 +- src/gui/widgets/tabs/setup_relations.cpp | 6 +- src/gui/widgets/tabstrip.cpp | 4 +- src/gui/widgets/tabstrip.h | 6 +- src/gui/widgets/textbox.cpp | 4 +- src/gui/widgets/textpreview.cpp | 2 +- src/gui/widgets/textpreview.h | 4 +- src/gui/widgets/vertcontainer.cpp | 6 +- src/gui/widgets/vertcontainer.h | 6 +- src/gui/widgets/widget.cpp | 676 ++++++++++++++++ src/gui/widgets/widget.h | 1228 +++++++++++++++++++++++++++++ src/gui/widgets/widgetgroup.cpp | 2 +- src/gui/widgets/widgetgroup.h | 2 +- src/gui/widgets/window.cpp | 6 +- src/gui/widgets/window.h | 6 +- src/gui/widgets/windowcontainer.cpp | 6 +- src/gui/widgets/windowcontainer.h | 8 +- src/gui/windows/botcheckerwindow.cpp | 8 +- src/gui/windows/charselectdialog.cpp | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/socialwindow.cpp | 2 +- 96 files changed, 2185 insertions(+), 2207 deletions(-) delete mode 100644 src/gui/base/widget.cpp delete mode 100644 src/gui/base/widget.hpp create mode 100644 src/gui/widgets/widget.cpp create mode 100644 src/gui/widgets/widget.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 69304d442..cfab9cccb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -783,7 +783,7 @@ SET(SRCS events/selectionevent.h listeners/selectionlistener.h utils/sdlpixel.h - gui/base/widget.hpp + gui/widgets/widget.h listeners/widgetlistener.h gui/base/widgets/button.hpp gui/base/widgets/checkbox.hpp @@ -802,7 +802,7 @@ SET(SRCS gui/base/gui.cpp input/key.cpp gui/rectangle.cpp - gui/base/widget.cpp + gui/widgets/widget.cpp gui/base/widgets/button.cpp gui/base/widgets/checkbox.cpp gui/base/widgets/container.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 0b03f22f0..eba67d244 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -169,7 +169,7 @@ manaplus_SOURCES += events/actionevent.h \ events/selectionevent.h \ listeners/selectionlistener.h \ utils/sdlpixel.h \ - gui/base/widget.hpp \ + gui/widgets/widget.h \ listeners/widgetlistener.h \ gui/base/widgets/button.hpp \ gui/base/widgets/checkbox.hpp \ @@ -188,7 +188,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/gui.cpp \ input/key.cpp \ gui/rectangle.cpp \ - gui/base/widget.cpp \ + gui/widgets/widget.cpp \ gui/base/widgets/button.cpp \ gui/base/widgets/checkbox.cpp \ gui/base/widgets/container.cpp \ diff --git a/src/events/actionevent.h b/src/events/actionevent.h index 3164955e6..25f936cdd 100644 --- a/src/events/actionevent.h +++ b/src/events/actionevent.h @@ -70,10 +70,7 @@ #include "localconsts.h" -namespace GCN -{ - class Widget; -} +class Widget; /** * Represents an action event. An action event is an event @@ -106,7 +103,7 @@ class ActionEvent final : public Event * @param source The source widget of the event. * @param id An identifier of the event. */ - ActionEvent(gcn::Widget *const source, const std::string &id) : + ActionEvent(Widget *const source, const std::string &id) : Event(source), mId(id) { diff --git a/src/events/event.h b/src/events/event.h index b71d0edd4..63ccb207d 100644 --- a/src/events/event.h +++ b/src/events/event.h @@ -66,10 +66,7 @@ #include "localconsts.h" -namespace gcn -{ - class Widget; -} +class Widget; /** * Base class for all events. All events in Guichan should @@ -86,7 +83,7 @@ class Event * * @param source The source widget of the event. */ - explicit Event(gcn::Widget *const source) : + explicit Event(Widget *const source) : mSource(source) { } @@ -104,14 +101,14 @@ class Event * * @return The source widget of the event. */ - gcn::Widget* getSource() const A_WARN_UNUSED + Widget* getSource() const A_WARN_UNUSED { return mSource; } protected: /** * Holds the source widget of the event. */ - gcn::Widget* mSource; + Widget* mSource; }; #endif // EVENTS_EVENT_H diff --git a/src/events/inputguievent.h b/src/events/inputguievent.h index 8523959ed..2e5136ea2 100644 --- a/src/events/inputguievent.h +++ b/src/events/inputguievent.h @@ -84,7 +84,7 @@ class InputGuiEvent: public Event * @param isAltPressed True if alt is pressed, false otherwise. * @param isMetaPressed True if meta is pressed, false otherwise. */ - InputGuiEvent(gcn::Widget *const source, + InputGuiEvent(Widget *const source, const bool shiftPressed, const bool controlPressed, const bool altPressed, diff --git a/src/events/keyevent.h b/src/events/keyevent.h index 6ca3d87d8..360d229d7 100644 --- a/src/events/keyevent.h +++ b/src/events/keyevent.h @@ -69,10 +69,7 @@ #include -namespace gcn -{ - class Widget; -} +class Widget; /** * Represents a key event. @@ -102,7 +99,7 @@ class KeyEvent: public InputGuiEvent * false otherwise. * @param key The key of the event. */ - KeyEvent(gcn::Widget *const source, + KeyEvent(Widget *const source, const bool shiftPressed, const bool controlPressed, const bool altPressed, diff --git a/src/events/mouseevent.h b/src/events/mouseevent.h index fc8088341..a717980f9 100644 --- a/src/events/mouseevent.h +++ b/src/events/mouseevent.h @@ -69,9 +69,10 @@ namespace gcn { class Gui; - class Widget; } +class Widget; + /** * Represents a mouse event. * @@ -96,7 +97,7 @@ class MouseEvent: public InputGuiEvent * @param clickCount The number of clicks generated with the same button. * It's set to zero if another button is used. */ - MouseEvent(gcn::Widget *const source, + MouseEvent(Widget *const source, const bool shiftPressed, const bool controlPressed, const bool altPressed, diff --git a/src/events/selectionevent.h b/src/events/selectionevent.h index b2e91e04f..927b66f77 100644 --- a/src/events/selectionevent.h +++ b/src/events/selectionevent.h @@ -68,10 +68,7 @@ #include "localconsts.h" -namespace gcn -{ - class Widget; -} +class Widget; /** * Represents a selection event. @@ -87,7 +84,7 @@ class SelectionEvent final: public Event * * @param source source The widget of the selection event. */ - explicit SelectionEvent(gcn::Widget *const source) : + explicit SelectionEvent(Widget *const source) : Event(source) { } diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp index fd28ef7b6..6d30db100 100644 --- a/src/gui/base/basiccontainer.hpp +++ b/src/gui/base/basiccontainer.hpp @@ -66,7 +66,7 @@ #include -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "listeners/deathlistener.h" diff --git a/src/gui/base/gui.cpp b/src/gui/base/gui.cpp index d5b23e960..8985ec062 100644 --- a/src/gui/base/gui.cpp +++ b/src/gui/base/gui.cpp @@ -67,7 +67,7 @@ #include "gui/base/gui.hpp" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "gui/focushandler.h" diff --git a/src/gui/base/gui.hpp b/src/gui/base/gui.hpp index 8c4ac4db0..4ea923400 100644 --- a/src/gui/base/gui.hpp +++ b/src/gui/base/gui.hpp @@ -76,11 +76,10 @@ class KeyEvent; class KeyListener; class MouseInput; class SDLInput; +class Widget; namespace gcn { - class Widget; - // The following comment will appear in the doxygen main page. /** * @mainpage diff --git a/src/gui/base/widget.cpp b/src/gui/base/widget.cpp deleted file mode 100644 index 692ea479c..000000000 --- a/src/gui/base/widget.cpp +++ /dev/null @@ -1,679 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/widget.hpp" - -#include "events/actionevent.h" - -#include "events/event.h" - -#include "gui/focushandler.h" - -#include "listeners/actionlistener.h" -#include "listeners/deathlistener.h" -#include "listeners/widgetlistener.h" - -#include "render/graphics.h" - -#include "debug.h" - -namespace gcn -{ - Font* Widget::mGlobalFont = nullptr; - std::list Widget::mWidgets; - std::set Widget::mWidgetsSet; - - Widget::Widget(const Widget2 *const widget) : - Widget2(widget), - mMouseListeners(), - mKeyListeners(), - mActionListeners(), - mDeathListeners(), - mFocusListeners(), - mWidgetListeners(), - mForegroundColor(0x000000), - mBackgroundColor(0xffffff), - mBaseColor(0x808090), - mSelectionColor(0xc3d9ff), - mFocusHandler(nullptr), - mInternalFocusHandler(nullptr), - mParent(nullptr), - mDimension(), - mFrameSize(0), - mActionEventId(), - mFocusable(false), - mVisible(true), - mTabIn(true), - mTabOut(true), - mEnabled(true), - mId(), - mCurrentFont(nullptr) - { - mWidgets.push_back(this); - mWidgetsSet.insert(this); - } - - Widget::~Widget() - { - for (DeathListenerIterator iter = mDeathListeners.begin(); - iter != mDeathListeners.end(); - ++iter) - { - Event event(this); - (*iter)->death(event); - } - - _setFocusHandler(nullptr); - - mWidgets.remove(this); - mWidgetsSet.erase(this); - } - - void Widget::drawFrame(Graphics* graphics) - { - BLOCK_START("Widget::drawFrame") - const Color &faceColor = getBaseColor(); - Color highlightColor = faceColor + Color(0x303030); - Color shadowColor = faceColor - Color(0x303030); - const int alpha = getBaseColor().a; - const int width = getWidth() + getFrameSize() * 2 - 1; - const int height = getHeight() + getFrameSize() * 2 - 1; - highlightColor.a = alpha; - shadowColor.a = alpha; - - for (unsigned int i = 0; i < getFrameSize(); ++i) - { - graphics->setColor(shadowColor); - graphics->drawLine(i, i, width - i, i); - graphics->drawLine(i, i + 1, i, height - i - 1); - graphics->setColor(highlightColor); - graphics->drawLine(width - i, i + 1, width - i, height - i); - graphics->drawLine(i, height - i, width - i - 1, height - i); - } - BLOCK_END("Widget::drawFrame") - } - - void Widget::_setParent(Widget* parent) - { - mParent = parent; - } - - void Widget::setWidth(int width) - { - Rectangle newDimension = mDimension; - newDimension.width = width; - - setDimension(newDimension); - } - - void Widget::setHeight(int height) - { - Rectangle newDimension = mDimension; - newDimension.height = height; - - setDimension(newDimension); - } - - void Widget::setX(int x) - { - Rectangle newDimension = mDimension; - newDimension.x = x; - - setDimension(newDimension); - } - - void Widget::setY(int y) - { - Rectangle newDimension = mDimension; - newDimension.y = y; - - setDimension(newDimension); - } - - void Widget::setPosition(int x, int y) - { - Rectangle newDimension = mDimension; - newDimension.x = x; - newDimension.y = y; - - setDimension(newDimension); - } - - void Widget::setDimension(const Rectangle& dimension) - { - const Rectangle oldDimension = mDimension; - mDimension = dimension; - - if (mDimension.width != oldDimension.width - || mDimension.height != oldDimension.height) - { - distributeResizedEvent(); - } - - if (mDimension.x != oldDimension.x - || mDimension.y != oldDimension.y) - { - distributeMovedEvent(); - } - } - - void Widget::setFrameSize(unsigned int frameSize) - { - mFrameSize = frameSize; - } - - unsigned int Widget::getFrameSize() const - { - return mFrameSize; - } - - const Rectangle& Widget::getDimension() const - { - return mDimension; - } - - const std::string& Widget::getActionEventId() const - { - return mActionEventId; - } - - void Widget::setActionEventId(const std::string& actionEventId) - { - mActionEventId = actionEventId; - } - - bool Widget::isFocused() const - { - if (!mFocusHandler) - return false; - - return (mFocusHandler->isFocused(this)); - } - - void Widget::setFocusable(bool focusable) - { - if (!focusable && isFocused()) - { - mFocusHandler->focusNone(); - } - - mFocusable = focusable; - } - - bool Widget::isFocusable() const - { - return mFocusable && isVisible() && isEnabled(); - } - - void Widget::requestFocus() - { - if (!mFocusHandler) - return; - - if (isFocusable()) - mFocusHandler->requestFocus(this); - } - - void Widget::requestMoveToTop() - { - if (mParent) - mParent->moveToTop(this); - } - - void Widget::requestMoveToBottom() - { - if (mParent) - mParent->moveToBottom(this); - } - - void Widget::setVisible(bool visible) - { - if (!visible && isFocused()) - mFocusHandler->focusNone(); - - if (visible) - distributeShownEvent(); - else - distributeHiddenEvent(); - - mVisible = visible; - } - - void Widget::setBaseColor(const Color& color) - { - mBaseColor = color; - } - - const Color& Widget::getBaseColor() const - { - return mBaseColor; - } - - void Widget::setForegroundColor(const Color& color) - { - mForegroundColor = color; - } - - const Color& Widget::getForegroundColor() const - { - return mForegroundColor; - } - - void Widget::setBackgroundColor(const Color& color) - { - mBackgroundColor = color; - } - - const Color& Widget::getBackgroundColor() const - { - return mBackgroundColor; - } - - void Widget::setSelectionColor(const Color& color) - { - mSelectionColor = color; - } - - const Color& Widget::getSelectionColor() const - { - return mSelectionColor; - } - - void Widget::_setFocusHandler(FocusHandler* focusHandler) - { - if (mFocusHandler) - { - releaseModalFocus(); - mFocusHandler->remove(this); - } - - if (focusHandler) - focusHandler->add(this); - - mFocusHandler = focusHandler; - } - - FocusHandler* Widget::_getFocusHandler() - { - return mFocusHandler; - } - - void Widget::addActionListener(ActionListener* actionListener) - { - mActionListeners.push_back(actionListener); - } - - void Widget::removeActionListener(ActionListener* actionListener) - { - mActionListeners.remove(actionListener); - } - - void Widget::addDeathListener(DeathListener* deathListener) - { - mDeathListeners.push_back(deathListener); - } - - void Widget::removeDeathListener(DeathListener* deathListener) - { - mDeathListeners.remove(deathListener); - } - - void Widget::addKeyListener(KeyListener* keyListener) - { - mKeyListeners.push_back(keyListener); - } - - void Widget::removeKeyListener(KeyListener* keyListener) - { - mKeyListeners.remove(keyListener); - } - - void Widget::addFocusListener(FocusListener* focusListener) - { - mFocusListeners.push_back(focusListener); - } - - void Widget::removeFocusListener(FocusListener* focusListener) - { - mFocusListeners.remove(focusListener); - } - - void Widget::addMouseListener(MouseListener* mouseListener) - { - mMouseListeners.push_back(mouseListener); - } - - void Widget::removeMouseListener(MouseListener* mouseListener) - { - mMouseListeners.remove(mouseListener); - } - - void Widget::addWidgetListener(WidgetListener* widgetListener) - { - mWidgetListeners.push_back(widgetListener); - } - - void Widget::removeWidgetListener(WidgetListener* widgetListener) - { - mWidgetListeners.remove(widgetListener); - } - - void Widget::getAbsolutePosition(int& x, int& y) const - { - if (!mParent) - { - x = mDimension.x; - y = mDimension.y; - return; - } - - int parentX; - int parentY; - - mParent->getAbsolutePosition(parentX, parentY); - - const Rectangle &rect = mParent->getChildrenArea(); - x = parentX + mDimension.x + rect.x; - y = parentY + mDimension.y + rect.y; - } - - Font* Widget::getFont() const - { - if (!mCurrentFont) - return mGlobalFont; - return mCurrentFont; - } - - void Widget::setGlobalFont(Font* font) - { - mGlobalFont = font; - - for (std::list::const_iterator iter = mWidgets.begin(); - iter != mWidgets.end(); ++iter) - { - if (!(*iter)->mCurrentFont) - (*iter)->fontChanged(); - } - } - - void Widget::setFont(Font* font) - { - mCurrentFont = font; - fontChanged(); - } - - bool Widget::widgetExists(const Widget* widget) - { - return mWidgetsSet.find(const_cast(widget)) - != mWidgetsSet.end(); - } - - bool Widget::isTabInEnabled() const - { - return mTabIn; - } - - void Widget::setTabInEnabled(bool enabled) - { - mTabIn = enabled; - } - - bool Widget::isTabOutEnabled() const - { - return mTabOut; - } - - void Widget::setTabOutEnabled(bool enabled) - { - mTabOut = enabled; - } - - void Widget::setSize(int width, int height) - { - Rectangle newDimension = mDimension; - newDimension.width = width; - newDimension.height = height; - - setDimension(newDimension); - } - - void Widget::setEnabled(bool enabled) - { - mEnabled = enabled; - } - - bool Widget::isEnabled() const - { - return mEnabled && isVisible(); - } - - void Widget::requestModalFocus() - { - if (!mFocusHandler) - return; - - mFocusHandler->requestModalFocus(this); - } - - void Widget::requestModalMouseInputFocus() - { - if (!mFocusHandler) - return; - - mFocusHandler->requestModalMouseInputFocus(this); - } - - void Widget::releaseModalFocus() - { - if (!mFocusHandler) - return; - - mFocusHandler->releaseModalFocus(this); - } - - void Widget::releaseModalMouseInputFocus() - { - if (!mFocusHandler) - return; - - mFocusHandler->releaseModalMouseInputFocus(this); - } - - bool Widget::isModalFocused() const - { - if (!mFocusHandler) - return false; - - if (mParent) - { - return (mFocusHandler->getModalFocused() == this) - || mParent->isModalFocused(); - } - - return mFocusHandler->getModalFocused() == this; - } - - bool Widget::isModalMouseInputFocused() const - { - if (!mFocusHandler) - return false; - - if (mParent) - { - return (mFocusHandler->getModalMouseInputFocused() == this) - || mParent->isModalMouseInputFocused(); - } - - return mFocusHandler->getModalMouseInputFocused() == this; - } - - Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED) - { - return nullptr; - } - - const std::list& Widget::_getMouseListeners() - { - return mMouseListeners; - } - - const std::list& Widget::_getKeyListeners() - { - return mKeyListeners; - } - - const std::list& Widget::_getFocusListeners() - { - return mFocusListeners; - } - - Rectangle Widget::getChildrenArea() - { - return Rectangle(0, 0, 0, 0); - } - - FocusHandler* Widget::_getInternalFocusHandler() - { - return mInternalFocusHandler; - } - - void Widget::setInternalFocusHandler(FocusHandler* focusHandler) - { - mInternalFocusHandler = focusHandler; - } - - void Widget::setId(const std::string& id) - { - mId = id; - } - - const std::string& Widget::getId() - { - return mId; - } - - void Widget::distributeResizedEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++ iter) - { - Event event(this); - (*iter)->widgetResized(event); - } - } - - void Widget::distributeMovedEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++ iter) - { - Event event(this); - (*iter)->widgetMoved(event); - } - } - - void Widget::distributeHiddenEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++ iter) - { - Event event(this); - (*iter)->widgetHidden(event); - } - } - - void Widget::distributeActionEvent() - { - for (ActionListenerIterator iter = mActionListeners.begin(); - iter != mActionListeners.end(); - ++iter) - { - ActionEvent actionEvent(this, mActionEventId); - (*iter)->action(actionEvent); - } - } - - void Widget::distributeShownEvent() - { - for (WidgetListenerIterator iter = mWidgetListeners.begin(); - iter != mWidgetListeners.end(); - ++iter) - { - Event event(this); - (*iter)->widgetShown(event); - } - } - - void Widget::showPart(Rectangle rectangle) - { - if (mParent) - mParent->showWidgetPart(this, rectangle); - } -} // namespace gcn diff --git a/src/gui/base/widget.hpp b/src/gui/base/widget.hpp deleted file mode 100644 index a180cbd12..000000000 --- a/src/gui/base/widget.hpp +++ /dev/null @@ -1,1231 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_WIDGET_HPP -#define GCN_WIDGET_HPP - -#include -#include -#include - -#include "gui/color.h" -#include "gui/rectangle.h" - -#include "gui/widgets/widget2.h" - -#include "localconsts.h" - -class ActionListener; -class DeathListener; -class FocusHandler; -class FocusListener; -class Font; -class Graphics; -class KeyListener; -class MouseListener; -class WidgetListener; - -namespace gcn -{ - /** - * Abstract class for widgets of Guichan. It contains basic functions - * every widget should have. - * - * NOTE: Functions begining with underscore "_" should not - * be overloaded unless you know what you are doing - * - * @author Olof Naessén - * @author Per Larsson. - * @since 0.1.0 - */ - class Widget : public Widget2 - { - public: - /** - * Constructor. Resets member variables. Noteable, a widget is not - * focusable as default, therefore, widgets that are supposed to be - * focusable should overide this default in their own constructor. - */ - explicit Widget(const Widget2 *const widget); - - A_DELETE_COPY(Widget) - - /** - * Default destructor. - */ - virtual ~Widget(); - - /** - * Draws the widget. It is called by the parent widget when it is time - * for the widget to draw itself. The graphics object is set up so - * that all drawing is relative to the widget, i.e coordinate (0,0) is - * the top left corner of the widget. It is not possible to draw - * outside of a widget's dimension. - * - * @param graphics aA graphics object to draw with. - * @since 0.1.0 - */ - virtual void draw(Graphics* graphics) = 0; - - /** - * Called when a widget is given a chance to draw a frame around itself. - * The frame is not considered a part of the widget, it only allows a frame - * to be drawn around the widget, thus a frame will never be included when - * calculating if a widget should receive events from user input. Also - * a widget's frame will never be included when calculating a widget's - * position. - * - * The size of the frame is calculated using the widget's frame size. - * If a widget has a frame size of 10 pixels than the area the drawFrame - * function can draw to will be the size of the widget with an additional - * extension of 10 pixels in each direction. - * - * An example when drawFrame is a useful function is if a widget needs - * a glow around itself. - * - * @param graphics A graphics object to draw with. - * @see setFrameSize, getFrameSize - * @since 0.8.0 - */ - virtual void drawFrame(Graphics* graphics); - - /** - * Sets the size of the widget's frame. The frame is not considered a part of - * the widget, it only allows a frame to be drawn around the widget, thus a frame - * will never be included when calculating if a widget should receive events - * from user input. Also a widget's frame will never be included when calculating - * a widget's position. - * - * A frame size of 0 means that the widget has no frame. The default frame size - * is 0. - * - * @param frameSize The size of the widget's frame. - * @see getFrameSize, drawFrame - * @since 0.8.0 - */ - void setFrameSize(unsigned int frameSize); - - /** - * Gets the size of the widget's frame. The frame is not considered a part of - * the widget, it only allows a frame to be drawn around the widget, thus a frame - * will never be included when calculating if a widget should receive events - * from user input. Also a widget's frame will never be included when calculating - * a widget's position. - * - * A frame size of 0 means that the widget has no frame. The default frame size - * is 0. - * - * @return The size of the widget's frame. - * @see setFrameSize, drawFrame - * @since 0.8.0 - */ - unsigned int getFrameSize() const A_WARN_UNUSED; - - /** - * Called for all widgets in the gui each time Gui::logic is called. - * You can do logic stuff here like playing an animation. - * - * @see Gui::logic - * @since 0.1.0 - */ - virtual void logic() - { } - - /** - * Gets the widget's parent container. - * - * @return The widget's parent container. NULL if the widget - * has no parent. - * @since 0.1.0 - */ - virtual Widget* getParent() const A_WARN_UNUSED - { return mParent; } - - /** - * Sets the width of the widget. - * - * @param width The width of the widget. - * @see getWidth, setHeight, getHeight, setSize, - * setDimension, getDimensi - * @since 0.1.0 - */ - void setWidth(int width); - - /** - * Gets the width of the widget. - * - * @return The width of the widget. - * @see setWidth, setHeight, getHeight, setSize, - * setDimension, getDimension - * @since 0.1.0 - */ - int getWidth() const A_WARN_UNUSED - { return mDimension.width; } - - /** - * Sets the height of the widget. - * - * @param height The height of the widget. - * @see getHeight, setWidth, getWidth, setSize, - * setDimension, getDimension - * @since 0.1.0 - */ - void setHeight(int height); - - /** - * Gets the height of the widget. - * - * @return The height of the widget. - * @see setHeight, setWidth, getWidth, setSize, - * setDimension, getDimension - * @since 0.1.0 - */ - int getHeight() const A_WARN_UNUSED - { return mDimension.height; } - - /** - * Sets the size of the widget. - * - * @param width The width of the widget. - * @param height The height of the widget. - * @see setWidth, setHeight, getWidth, getHeight, - * setDimension, getDimension - * @since 0.1.0 - */ - void setSize(int width, int height); - - /** - * Sets the x coordinate of the widget. The coordinate is - * relateive to the widget's parent. - * - * @param x The x coordinate of the widget. - * @see getX, setY, getY, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - void setX(int x); - - /** - * Gets the x coordinate of the widget. The coordinate is - * relative to the widget's parent. - * - * @return The x coordinate of the widget. - * @see setX, setY, getY, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - int getX() const A_WARN_UNUSED - { return mDimension.x; } - - /** - * Sets the y coordinate of the widget. The coordinate is - * relative to the widget's parent. - * - * @param y The y coordinate of the widget. - * @see setY, setX, getX, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - void setY(int y); - - /** - * Gets the y coordinate of the widget. The coordinate is - * relative to the widget's parent. - * - * @return The y coordinate of the widget. - * @see setY, setX, getX, setPosition, setDimension, getDimension - * @since 0.1.0 - */ - int getY() const A_WARN_UNUSED - { return mDimension.y; } - - /** - * Sets position of the widget. The position is relative - * to the widget's parent. - * - * @param x The x coordinate of the widget. - * @param y The y coordinate of the widget. - * @see setX, getX, setY, getY, setDimension, getDimension - * @since 0.1.0 - */ - void setPosition(int x, int y); - - /** - * Sets the dimension of the widget. The dimension is - * relative to the widget's parent. - * - * @param dimension The dimension of the widget. - * @see getDimension, setX, getX, setY, getY, setPosition - * @since 0.1.0 - */ - void setDimension(const Rectangle& dimension); - - /** - * Gets the dimension of the widget. The dimension is - * relative to the widget's parent. - * - * @return The dimension of the widget. - * @see getDimension, setX, getX, setY, getY, setPosition - * @since 0.1.0 - */ - const Rectangle& getDimension() const A_WARN_UNUSED; - - /** - * Sets the widget to be fosusable, or not. - * - * @param focusable True if the widget should be focusable, - * false otherwise. - * @see isFocusable - * @since 0.1.0 - */ - void setFocusable(bool focusable); - - /** - * Checks if a widget is focsable. - * - * @return True if the widget should be focusable, false otherwise. - * @see setFocusable - * @since 0.1.0 - */ - bool isFocusable() const A_WARN_UNUSED; - - /** - * Checks if the widget is focused. - * - * @return True if the widget is focused, false otherwise. - * @since 0.1.0 - */ - virtual bool isFocused() const A_WARN_UNUSED; - - /** - * Sets the widget to enabled, or not. A disabled - * widget will never recieve mouse or key events. - * - * @param enabled True if widget should be enabled, - * false otherwise. - * @see isEnabled - * @since 0.1.0 - */ - void setEnabled(bool enabled); - - /** - * Checks if the widget is enabled. A disabled - * widget will never recieve mouse or key events. - * - * @return True if widget is enabled, false otherwise. - * @see setEnabled - * @since 0.1.0 - */ - bool isEnabled() const A_WARN_UNUSED; - - /** - * Sets the widget to be visible, or not. - * - * @param visible True if widget should be visible, false otherwise. - * @see isVisible - * @since 0.1.0 - */ - void setVisible(bool visible); - - /** - * Checks if the widget is visible. - * - * @return True if widget is be visible, false otherwise. - * @see setVisible - * @since 0.1.0 - */ - bool isVisible() const A_WARN_UNUSED - { return mVisible && (!mParent || mParent->isVisible()); } - - /** - * Sets the base color of the widget. - * - * @param color The baseground color. - * @see getBaseColor - * @since 0.1.0 - */ - void setBaseColor(const Color& color); - - /** - * Gets the base color. - * - * @return The base color. - * @see setBaseColor - * @since 0.1.0 - */ - const Color& getBaseColor() const A_WARN_UNUSED; - - /** - * Sets the foreground color. - * - * @param color The foreground color. - * @see getForegroundColor - * @since 0.1.0 - */ - void setForegroundColor(const Color& color); - - /** - * Gets the foreground color. - * - * @see setForegroundColor - * @since 0.1.0 - */ - const Color& getForegroundColor() const A_WARN_UNUSED; - - /** - * Sets the background color. - * - * @param color The background Color. - * @see setBackgroundColor - * @since 0.1.0 - */ - void setBackgroundColor(const Color& color); - - /** - * Gets the background color. - * - * @see setBackgroundColor - * @since 0.1.0 - */ - const Color& getBackgroundColor() const A_WARN_UNUSED; - - /** - * Sets the selection color. - * - * @param color The selection color. - * @see getSelectionColor - * @since 0.6.0 - */ - void setSelectionColor(const Color& color); - - /** - * Gets the selection color. - * - * @return The selection color. - * @see setSelectionColor - * @since 0.6.0 - */ - const Color& getSelectionColor() const A_WARN_UNUSED; - - /** - * Requests focus for the widget. A widget will only recieve focus - * if it is focusable. - */ - virtual void requestFocus(); - - /** - * Requests a move to the top in the parent widget. - */ - virtual void requestMoveToTop(); - - /** - * Requests a move to the bottom in the parent widget. - */ - virtual void requestMoveToBottom(); - - /** - * Sets the focus handler to be used. - * - * WARNING: This function is used internally and should not - * be called or overloaded unless you know what you - * are doing. - * - * @param focusHandler The focus handler to use. - * @see _getFocusHandler - * @since 0.1.0 - */ - virtual void _setFocusHandler(FocusHandler* focusHandler); - - /** - * Gets the focus handler used. - * - * WARNING: This function is used internally and should not - * be called or overloaded unless you know what you - * are doing. - * - * @return The focus handler used. - * @see _setFocusHandler - * @since 0.1.0 - */ - virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED; - - /** - * Adds an action listener to the widget. When an action event - * is fired by the widget the action listeners of the widget - * will get notified. - * - * @param actionListener The action listener to add. - * @see removeActionListener - * @since 0.1.0 - */ - void addActionListener(ActionListener* actionListener); - - /** - * Removes an added action listener from the widget. - * - * @param actionListener The action listener to remove. - * @see addActionListener - * @since 0.1.0 - */ - void removeActionListener(ActionListener* actionListener); - - /** - * Adds a death listener to the widget. When a death event is - * fired by the widget the death listeners of the widget will - * get notified. - * - * @param deathListener The death listener to add. - * @see removeDeathListener - * @since 0.1.0 - */ - void addDeathListener(DeathListener* deathListener); - - /** - * Removes an added death listener from the widget. - * - * @param deathListener The death listener to remove. - * @see addDeathListener - * @since 0.1.0 - */ - void removeDeathListener(DeathListener* deathListener); - - /** - * Adds a mouse listener to the widget. When a mouse event is - * fired by the widget the mouse listeners of the widget will - * get notified. - * - * @param mouseListener The mouse listener to add. - * @see removeMouseListener - * @since 0.1.0 - */ - void addMouseListener(MouseListener* mouseListener); - - /** - * Removes an added mouse listener from the widget. - * - * @param mouseListener The mouse listener to remove. - * @see addMouseListener - * @since 0.1.0 - */ - void removeMouseListener(MouseListener* mouseListener); - - /** - * Adds a key listener to the widget. When a key event is - * fired by the widget the key listeners of the widget will - * get notified. - * - * @param keyListener The key listener to add. - * @see removeKeyListener - * @since 0.1.0 - */ - void addKeyListener(KeyListener* keyListener); - - /** - * Removes an added key listener from the widget. - * - * @param keyListener The key listener to remove. - * @see addKeyListener - * @since 0.1.0 - */ - void removeKeyListener(KeyListener* keyListener); - - /** - * Adds a focus listener to the widget. When a focus event is - * fired by the widget the key listeners of the widget will - * get notified. - * - * @param focusListener The focus listener to add. - * @see removeFocusListener - * @since 0.7.0 - */ - void addFocusListener(FocusListener* focusListener); - - /** - * Removes an added focus listener from the widget. - * - * @param focusListener The focus listener to remove. - * @see addFocusListener - * @since 0.7.0 - */ - void removeFocusListener(FocusListener* focusListener); - - /** - * Adds a widget listener to the widget. When a widget event is - * fired by the widget the key listeners of the widget will - * get notified. - * - * @param widgetListener The widget listener to add. - * @see removeWidgetListener - * @since 0.8.0 - */ - void addWidgetListener(WidgetListener* widgetListener); - - /** - * Removes an added widget listener from the widget. - * - * @param widgetListener The widget listener to remove. - * @see addWidgetListener - * @since 0.8.0 - */ - void removeWidgetListener(WidgetListener* widgetListener); - - /** - * Sets the action event identifier of the widget. The identifier is - * used to be able to identify which action has occured. - * - * NOTE: An action event identifier should not be used to identify a - * certain widget but rather a certain event in your application. - * Several widgets can have the same action event identifer. - * - * @param actionEventId The action event identifier. - * @see getActionEventId - * @since 0.6.0 - */ - void setActionEventId(const std::string& actionEventId); - - /** - * Gets the action event identifier of the widget. - * - * @return The action event identifier of the widget. - * @see setActionEventId - * @since 0.6.0 - */ - const std::string& getActionEventId() const; - - /** - * Gets the absolute position on the screen for the widget. - * - * @param x The absolute x coordinate will be stored in this parameter. - * @param y The absolute y coordinate will be stored in this parameter. - * @since 0.1.0 - */ - virtual void getAbsolutePosition(int& x, int& y) const; - - /** - * Sets the parent of the widget. A parent must be a BasicContainer. - * - * WARNING: This function is used internally and should not - * be called or overloaded unless you know what you - * are doing. - * - * @param parent The parent of the widget. - * @see getParent - * @since 0.1.0 - */ - virtual void _setParent(Widget* parent); - - /** - * Gets the font set for the widget. If no font has been set, - * the global font will be returned. If no global font has been set, - * the default font will be returend. - * - * @return The font set for the widget. - * @see setFont, setGlobalFont - * @since 0.1.0 - */ - Font *getFont() const A_WARN_UNUSED; - - /** - * Sets the global font to be used by default for all widgets. - * - * @param font The global font. - * @see getGlobalFont - * @since 0.1.0 - */ - static void setGlobalFont(Font* font); - - /** - * Sets the font for the widget. If NULL is passed, the global font - * will be used. - * - * @param font The font to set for the widget. - * @see getFont - * @since 0.1.0 - */ - void setFont(Font* font); - - /** - * Called when the font has changed. If the change is global, - * this function will only be called if the widget doesn't have a - * font already set. - * - * @since 0.1.0 - */ - virtual void fontChanged() - { } - - /** - * Checks if a widget exists or not, that is if it still exists - * an instance of the object. - * - * @param widget The widget to check. - * @return True if an instance of the widget exists, false otherwise. - * @since 0.1.0 - */ - static bool widgetExists(const Widget* widget) A_WARN_UNUSED; - - /** - * Checks if tab in is enabled. Tab in means that you can set focus - * to this widget by pressing the tab button. If tab in is disabled - * then the focus handler will skip this widget and focus the next - * in its focus order. - * - * @return True if tab in is enabled, false otherwise. - * @see setTabInEnabled - * @since 0.1.0 - */ - bool isTabInEnabled() const A_WARN_UNUSED; - - /** - * Sets tab in enabled, or not. Tab in means that you can set focus - * to this widget by pressing the tab button. If tab in is disabled - * then the FocusHandler will skip this widget and focus the next - * in its focus order. - * - * @param enabled True if tab in should be enabled, false otherwise. - * @see isTabInEnabled - * @since 0.1.0 - */ - void setTabInEnabled(bool enabled); - - /** - * Checks if tab out is enabled. Tab out means that you can lose - * focus to this widget by pressing the tab button. If tab out is - * disabled then the FocusHandler ignores tabbing and focus will - * stay with this widget. - * - * @return True if tab out is enabled, false otherwise. - * @see setTabOutEnabled - * @since 0.1.0 - */ - bool isTabOutEnabled() const A_WARN_UNUSED; - - /** - * Sets tab out enabled. Tab out means that you can lose - * focus to this widget by pressing the tab button. If tab out is - * disabled then the FocusHandler ignores tabbing and focus will - * stay with this widget. - * - * @param enabled True if tab out should be enabled, false otherwise. - * @see isTabOutEnabled - * @since 0.1.0 - */ - void setTabOutEnabled(bool enabled); - - /** - * Requests modal focus. When a widget has modal focus, only that - * widget and it's children may recieve input. - * - * @throws Exception if another widget already has modal focus. - * @see releaseModalFocus, isModalFocused - * @since 0.4.0 - */ - virtual void requestModalFocus(); - - /** - * Requests modal mouse input focus. When a widget has modal input focus - * that widget will be the only widget receiving input even if the input - * occurs outside of the widget and no matter what the input is. - * - * @throws Exception if another widget already has modal focus. - * @see releaseModalMouseInputFocus, isModalMouseInputFocused - * @since 0.6.0 - */ - virtual void requestModalMouseInputFocus(); - - /** - * Releases modal focus. Modal focus will only be released if the - * widget has modal focus. - * - * @see requestModalFocus, isModalFocused - * @since 0.4.0 - */ - virtual void releaseModalFocus(); - - /** - * Releases modal mouse input focus. Modal mouse input focus will only - * be released if the widget has modal mouse input focus. - * - * @see requestModalMouseInputFocus, isModalMouseInputFocused - * @since 0.6.0 - */ - virtual void releaseModalMouseInputFocus(); - - /** - * Checks if the widget or it's parent has modal focus. - * - * @return True if the widget has modal focus, false otherwise. - * @see requestModalFocus, releaseModalFocus - * @since 0.8.0 - */ - virtual bool isModalFocused() const A_WARN_UNUSED; - - /** - * Checks if the widget or it's parent has modal mouse input focus. - * - * @return True if the widget has modal mouse input focus, false - * otherwise. - * @see requestModalMouseInputFocus, releaseModalMouseInputFocus - * @since 0.8.0 - */ - virtual bool isModalMouseInputFocused() const A_WARN_UNUSED; - - /** - * Gets a widget from a certain position in the widget. - * This function is used to decide which gets mouse input, - * thus it can be overloaded to change that behaviour. - * - * NOTE: This always returns NULL if the widget is not - * a container. - * - * @param x The x coordinate of the widget to get. - * @param y The y coordinate of the widget to get. - * @return The widget at the specified coodinate, NULL - * if no widget is found. - * @since 0.6.0 - */ - virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED; - - /** - * Gets the mouse listeners of the widget. - * - * @return The mouse listeners of the widget. - * @since 0.6.0 - */ - virtual const std::list& _getMouseListeners() - A_WARN_UNUSED; - - /** - * Gets the key listeners of the widget. - * - * @return The key listeners of the widget. - * @since 0.6.0 - */ - virtual const std::list& _getKeyListeners() - A_WARN_UNUSED; - - /** - * Gets the focus listeners of the widget. - * - * @return The focus listeners of the widget. - * @since 0.7.0 - */ - virtual const std::list& _getFocusListeners() - A_WARN_UNUSED; - - /** - * Gets the area of the widget occupied by the widget's children. - * By default this method returns an empty rectangle as not all - * widgets are containers. If you want to make a container this - * method should return the area where the children resides. This - * method is used when drawing children of a widget when computing - * clip rectangles for the children. - * - * An example of a widget that overloads this method is ScrollArea. - * A ScrollArea has a view of its contant and that view is the - * children area. The size of a ScrollArea's children area might - * vary depending on if the scroll bars of the ScrollArea is shown - * or not. - * - * @return The area of the widget occupied by the widget's children. - * @see BasicContainer - * @see BasicContainer::getChildrenArea - * @see BasicContainer::drawChildren - * @since 0.1.0 - */ - virtual Rectangle getChildrenArea() A_WARN_UNUSED; - - /** - * Gets the internal focus handler used. - * - * @return the internalFocusHandler used. If no internal focus handler - * is used, NULL will be returned. - * @see setInternalFocusHandler - * @since 0.1.0 - */ - virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED; - - /** - * Sets the internal focus handler. An internal focus handler is - * needed if both a widget in the widget and the widget itself - * should be foucsed at the same time. - * - * @param focusHandler The internal focus handler to be used. - * @see getInternalFocusHandler - * @since 0.1.0 - */ - void setInternalFocusHandler(FocusHandler* internalFocusHandler); - - /** - * Moves a widget to the top of this widget. The moved widget will be - * drawn above all other widgets in this widget. - * - * @param widget The widget to move to the top. - * @see moveToBottom - * @since 0.1.0 - */ - virtual void moveToTop(Widget* widget A_UNUSED) - { } - - /** - * Moves a widget in this widget to the bottom of this widget. - * The moved widget will be drawn below all other widgets in this widget. - * - * @param widget The widget to move to the bottom. - * @see moveToTop - * @since 0.1.0 - */ - virtual void moveToBottom(Widget* widget A_UNUSED) - { } - - /** - * Focuses the next widget in the widget. - * - * @see moveToBottom - * @since 0.1.0 - */ - virtual void focusNext() - { } - - /** - * Focuses the previous widget in the widget. - * - * @see moveToBottom - * @since 0.1.0 - */ - virtual void focusPrevious() - { } - - /** - * Tries to show a specific part of a widget by moving it. Used if the - * widget should act as a container. - * - * @param widget The target widget. - * @param area The area to show. - * @since 0.1.0 - */ - virtual void showWidgetPart(Widget* widget A_UNUSED, - Rectangle area A_UNUSED) - { } - - /** - * Sets an id of a widget. An id can be useful if a widget needs to be - * identified in a container. For example, if widgets are created by an - * XML document, a certain widget can be retrieved given that the widget - * has an id. - * - * @param id The id to set to the widget. - * @see getId, BasicContainer::findWidgetById - * @since 0.8.0 - */ - void setId(const std::string& id); - - /** - * Gets the id of a widget. An id can be useful if a widget needs to be - * identified in a container. For example, if widgets are created by an - * XML document, a certain widget can be retrieved given that the widget - * has an id. - * - * @param id The id to set to the widget. - * @see setId, BasicContainer::findWidgetById - * @since 0.8.0 - */ - const std::string& getId() A_WARN_UNUSED; - - /** - * Shows a certain part of a widget in the widget's parent. - * Used when widgets want a specific part to be visible in - * its parent. An example is a TextArea that wants a specific - * part of its text to be visible when a TextArea is a child - * of a ScrollArea. - * - * @param rectangle The rectangle to be shown. - * @since 0.8.0 - */ - virtual void showPart(Rectangle rectangle); - - protected: - /** - * Distributes an action event to all action listeners - * of the widget. - * - * @since 0.8.0 - */ - void distributeActionEvent(); - - /** - * Distributes resized events to all of the widget's listeners. - * - * @since 0.8.0 - */ - void distributeResizedEvent(); - - /** - * Distributes moved events to all of the widget's listeners. - * - * @since 0.8.0 - */ - void distributeMovedEvent(); - - /** - * Distributes hidden events to all of the widget's listeners. - * - * @since 0.8.0 - * @author Olof Naessén - */ - void distributeHiddenEvent(); - - /** - * Distributes shown events to all of the widget's listeners. - * - * @since 0.8.0 - * @author Olof Naessén - */ - void distributeShownEvent(); - - /** - * Typdef. - */ - typedef std::list MouseListenerList; - - /** - * Typdef. - */ - typedef MouseListenerList::iterator MouseListenerIterator; - - /** - * Holds the mouse listeners of the widget. - */ - MouseListenerList mMouseListeners; - - /** - * Typdef. - */ - typedef std::list KeyListenerList; - - /** - * Holds the key listeners of the widget. - */ - KeyListenerList mKeyListeners; - - /** - * Typdef. - */ - typedef KeyListenerList::iterator KeyListenerIterator; - - /** - * Typdef. - */ - typedef std::list ActionListenerList; - - /** - * Holds the action listeners of the widget. - */ - ActionListenerList mActionListeners; - - /** - * Typdef. - */ - typedef ActionListenerList::iterator ActionListenerIterator; - - /** - * Typdef. - */ - typedef std::list DeathListenerList; - - /** - * Holds the death listeners of the widget. - */ - DeathListenerList mDeathListeners; - - /** - * Typdef. - */ - typedef DeathListenerList::iterator DeathListenerIterator; - - /** - * Typdef. - */ - typedef std::list FocusListenerList; - - /** - * Holds the focus listeners of the widget. - */ - FocusListenerList mFocusListeners; - - /** - * Typdef. - */ - typedef FocusListenerList::iterator FocusListenerIterator; - - typedef std::list WidgetListenerList; - - /** - * Holds the widget listeners of the widget. - */ - WidgetListenerList mWidgetListeners; - - /** - * Typdef. - */ - typedef WidgetListenerList::iterator WidgetListenerIterator; - - /** - * Holds the foreground color of the widget. - */ - Color mForegroundColor; - - /** - * Holds the background color of the widget. - */ - Color mBackgroundColor; - - /** - * Holds the base color of the widget. - */ - Color mBaseColor; - - /** - * Holds the selection color of the widget. - */ - Color mSelectionColor; - - /** - * Holds the focus handler used by the widget. - */ - FocusHandler* mFocusHandler; - - /** - * Holds the focus handler used by the widget. NULL - * if no internal focus handler is used. - */ - FocusHandler* mInternalFocusHandler; - - /** - * Holds the parent of the widget. NULL if the widget - * has no parent. - */ - Widget* mParent; - - /** - * Holds the dimension of the widget. - */ - Rectangle mDimension; - - /** - * Holds the frame size of the widget. - */ - unsigned int mFrameSize; - - /** - * Holds the action event of the widget. - */ - std::string mActionEventId; - - /** - * True if the widget focusable, false otherwise. - */ - bool mFocusable; - - /** - * True if the widget visible, false otherwise. - */ - bool mVisible; - - /** - * True if the widget has tab in enabled, false otherwise. - */ - bool mTabIn; - - /** - * True if the widget has tab in enabled, false otherwise. - */ - bool mTabOut; - - /** - * True if the widget is enabled, false otherwise. - */ - bool mEnabled; - - /** - * Holds the id of the widget. - */ - std::string mId; - - /** - * Holds the font used by the widget. - */ - Font* mCurrentFont; - - /** - * Holds the global font used by the widget. - */ - static Font* mGlobalFont; - - /** - * Holds a list of all instances of widgets. - */ - static std::list mWidgets; - - static std::set mWidgetsSet; - }; -} // namespace gcn - -#endif // end GCN_WIDGET_HPP diff --git a/src/gui/base/widgets/button.cpp b/src/gui/base/widgets/button.cpp index 5187c625b..2d6afa672 100644 --- a/src/gui/base/widgets/button.cpp +++ b/src/gui/base/widgets/button.cpp @@ -76,7 +76,7 @@ namespace gcn { Button::Button(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), FocusListener(), @@ -98,7 +98,7 @@ namespace gcn Button::Button(const Widget2 *const widget, const std::string& caption) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), FocusListener(), diff --git a/src/gui/base/widgets/button.hpp b/src/gui/base/widgets/button.hpp index fea175362..99e5db4f4 100644 --- a/src/gui/base/widgets/button.hpp +++ b/src/gui/base/widgets/button.hpp @@ -70,7 +70,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/checkbox.cpp b/src/gui/base/widgets/checkbox.cpp index a5ec72dfa..476fb3c6b 100644 --- a/src/gui/base/widgets/checkbox.cpp +++ b/src/gui/base/widgets/checkbox.cpp @@ -73,7 +73,7 @@ namespace gcn { CheckBox::CheckBox(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mSelected(false), @@ -87,7 +87,7 @@ namespace gcn CheckBox::CheckBox(const Widget2 *const widget, const std::string &caption, bool selected) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mSelected(selected), diff --git a/src/gui/base/widgets/checkbox.hpp b/src/gui/base/widgets/checkbox.hpp index c79ccaff9..6fcb04767 100644 --- a/src/gui/base/widgets/checkbox.hpp +++ b/src/gui/base/widgets/checkbox.hpp @@ -69,7 +69,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" namespace gcn { diff --git a/src/gui/base/widgets/label.cpp b/src/gui/base/widgets/label.cpp index 84ba87d84..d2293a957 100644 --- a/src/gui/base/widgets/label.cpp +++ b/src/gui/base/widgets/label.cpp @@ -76,7 +76,7 @@ namespace gcn { Label::Label(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), mCaption(), mAlignment(Graphics::LEFT) { @@ -84,7 +84,7 @@ namespace gcn Label::Label(const Widget2 *const widget, const std::string& caption) : - gcn::Widget(widget), + Widget(widget), mCaption(caption), mAlignment(Graphics::LEFT) { diff --git a/src/gui/base/widgets/label.hpp b/src/gui/base/widgets/label.hpp index 399e4202a..fd0d54f8e 100644 --- a/src/gui/base/widgets/label.hpp +++ b/src/gui/base/widgets/label.hpp @@ -66,7 +66,7 @@ #include -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "render/graphics.h" diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 765878834..9aca373b9 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -78,7 +78,7 @@ namespace gcn { ListBox::ListBox(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mSelected(-1), @@ -95,7 +95,7 @@ namespace gcn ListBox::ListBox(const Widget2 *const widget, ListModel *listModel) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mSelected(-1), diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index c46aca6ae..4046f5ddf 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -66,7 +66,7 @@ #include -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/base/widgets/radiobutton.cpp b/src/gui/base/widgets/radiobutton.cpp index e17b9f776..f9d68555a 100644 --- a/src/gui/base/widgets/radiobutton.cpp +++ b/src/gui/base/widgets/radiobutton.cpp @@ -74,7 +74,7 @@ namespace gcn RadioButton::GroupMap RadioButton::mGroupMap; RadioButton::RadioButton(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mSelected(false), @@ -92,7 +92,7 @@ namespace gcn const std::string &caption, const std::string &group, bool selected) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mSelected(false), diff --git a/src/gui/base/widgets/radiobutton.hpp b/src/gui/base/widgets/radiobutton.hpp index f4bfd53fa..a86a4eed3 100644 --- a/src/gui/base/widgets/radiobutton.hpp +++ b/src/gui/base/widgets/radiobutton.hpp @@ -70,7 +70,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" namespace gcn { diff --git a/src/gui/base/widgets/slider.cpp b/src/gui/base/widgets/slider.cpp index 4e9df0341..40c73ceb5 100644 --- a/src/gui/base/widgets/slider.cpp +++ b/src/gui/base/widgets/slider.cpp @@ -73,7 +73,7 @@ namespace gcn { Slider::Slider(const Widget2 *const widget, const double scaleEnd) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mDragged(false), @@ -94,7 +94,7 @@ namespace gcn Slider::Slider(const Widget2 *const widget, const double scaleStart, const double scaleEnd) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mDragged(false), diff --git a/src/gui/base/widgets/slider.hpp b/src/gui/base/widgets/slider.hpp index f29ad5950..9d5adc6d8 100644 --- a/src/gui/base/widgets/slider.hpp +++ b/src/gui/base/widgets/slider.hpp @@ -67,7 +67,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" namespace gcn { diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index bb22a6f46..04b506c59 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -76,7 +76,7 @@ namespace gcn { TextBox::TextBox(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mTextRows(), @@ -95,7 +95,7 @@ namespace gcn TextBox::TextBox(const Widget2 *const widget, const std::string& text) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mTextRows(), diff --git a/src/gui/base/widgets/textbox.hpp b/src/gui/base/widgets/textbox.hpp index 151af8c00..148b4f007 100644 --- a/src/gui/base/widgets/textbox.hpp +++ b/src/gui/base/widgets/textbox.hpp @@ -70,7 +70,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" namespace gcn { diff --git a/src/gui/base/widgets/textfield.cpp b/src/gui/base/widgets/textfield.cpp index ddcbec1b4..c2cead500 100644 --- a/src/gui/base/widgets/textfield.cpp +++ b/src/gui/base/widgets/textfield.cpp @@ -74,7 +74,7 @@ namespace gcn { TextField::TextField(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mText(), @@ -89,7 +89,7 @@ namespace gcn TextField::TextField(const Widget2 *const widget, const std::string& text) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mText(text), diff --git a/src/gui/base/widgets/textfield.hpp b/src/gui/base/widgets/textfield.hpp index aa5f210c5..e9df238ba 100644 --- a/src/gui/base/widgets/textfield.hpp +++ b/src/gui/base/widgets/textfield.hpp @@ -67,7 +67,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include diff --git a/src/gui/focushandler.cpp b/src/gui/focushandler.cpp index 0d45b6432..928b3b72e 100644 --- a/src/gui/focushandler.cpp +++ b/src/gui/focushandler.cpp @@ -87,7 +87,7 @@ FocusHandler::FocusHandler() : { } -void FocusHandler::requestModalFocus(gcn::Widget *widget) +void FocusHandler::requestModalFocus(Widget *widget) { /* If there is another widget with modal focus, remove its modal focus * and put it on the modal widget stack. @@ -103,7 +103,7 @@ void FocusHandler::requestModalFocus(gcn::Widget *widget) focusNone(); } -void FocusHandler::releaseModalFocus(gcn::Widget *widget) +void FocusHandler::releaseModalFocus(Widget *widget) { mModalStack.remove(widget); @@ -123,7 +123,7 @@ void FocusHandler::releaseModalFocus(gcn::Widget *widget) } } -void FocusHandler::remove(gcn::Widget *widget) +void FocusHandler::remove(Widget *widget) { releaseModalFocus(widget); @@ -217,7 +217,7 @@ void FocusHandler::tabNext() if (focusedWidget == focused) return; - const gcn::Widget *const widget = mWidgets.at(focusedWidget); + const Widget *const widget = mWidgets.at(focusedWidget); if (widget->isFocusable() && widget->isTabInEnabled() && (!mModalFocusedWidget || widget->isModalFocused())) { @@ -288,7 +288,7 @@ void FocusHandler::tabPrevious() if (focusedWidget == focused) return; - const gcn::Widget *const widget = mWidgets.at(focusedWidget); + const Widget *const widget = mWidgets.at(focusedWidget); if (widget->isFocusable() && widget->isTabInEnabled() && (!mModalFocusedWidget || widget->isModalFocused())) { @@ -317,7 +317,7 @@ void FocusHandler::checkForWindow() const { if (mFocusedWidget) { - gcn::Widget *widget = mFocusedWidget->getParent(); + Widget *widget = mFocusedWidget->getParent(); while (widget) { @@ -339,7 +339,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) if (gui) gui->distributeGlobalFocusGainedEvent(focusEvent); - gcn::Widget *const sourceWidget = focusEvent.getSource(); + Widget *const sourceWidget = focusEvent.getSource(); std::list focusListeners = sourceWidget->_getFocusListeners(); @@ -354,7 +354,7 @@ void FocusHandler::distributeFocusGainedEvent(const Event &focusEvent) } } -void FocusHandler::requestFocus(gcn::Widget* widget) +void FocusHandler::requestFocus(Widget* widget) { if (!widget || widget == mFocusedWidget) return; @@ -373,7 +373,7 @@ void FocusHandler::requestFocus(gcn::Widget* widget) if (toBeFocusedIndex < 0) return; - gcn::Widget *const oldFocused = mFocusedWidget; + Widget *const oldFocused = mFocusedWidget; if (oldFocused != widget) { @@ -390,7 +390,7 @@ void FocusHandler::requestFocus(gcn::Widget* widget) } } -void FocusHandler::requestModalMouseInputFocus(gcn::Widget* widget) +void FocusHandler::requestModalMouseInputFocus(Widget* widget) { if (mModalMouseInputFocusedWidget && mModalMouseInputFocusedWidget != widget) @@ -401,23 +401,23 @@ void FocusHandler::requestModalMouseInputFocus(gcn::Widget* widget) mModalMouseInputFocusedWidget = widget; } -void FocusHandler::releaseModalMouseInputFocus(gcn::Widget* widget) +void FocusHandler::releaseModalMouseInputFocus(Widget* widget) { if (mModalMouseInputFocusedWidget == widget) mModalMouseInputFocusedWidget = nullptr; } -gcn::Widget* FocusHandler::getFocused() const +Widget* FocusHandler::getFocused() const { return mFocusedWidget; } -gcn::Widget* FocusHandler::getModalFocused() const +Widget* FocusHandler::getModalFocused() const { return mModalFocusedWidget; } -gcn::Widget* FocusHandler::getModalMouseInputFocused() const +Widget* FocusHandler::getModalMouseInputFocused() const { return mModalMouseInputFocusedWidget; } @@ -527,12 +527,12 @@ void FocusHandler::focusPrevious() } } -bool FocusHandler::isFocused(const gcn::Widget* widget) const +bool FocusHandler::isFocused(const Widget* widget) const { return mFocusedWidget == widget; } -void FocusHandler::add(gcn::Widget* widget) +void FocusHandler::add(Widget* widget) { mWidgets.push_back(widget); } @@ -541,7 +541,7 @@ void FocusHandler::focusNone() { if (mFocusedWidget) { - gcn::Widget *const focused = mFocusedWidget; + Widget *const focused = mFocusedWidget; mFocusedWidget = nullptr; Event focusEvent(focused); @@ -551,7 +551,7 @@ void FocusHandler::focusNone() void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) { - gcn::Widget *const sourceWidget = focusEvent.getSource(); + Widget *const sourceWidget = focusEvent.getSource(); std::list focusListeners = sourceWidget->_getFocusListeners(); @@ -566,52 +566,52 @@ void FocusHandler::distributeFocusLostEvent(const Event& focusEvent) } } -gcn::Widget* FocusHandler::getDraggedWidget() +Widget* FocusHandler::getDraggedWidget() { return mDraggedWidget; } -void FocusHandler::setDraggedWidget(gcn::Widget* draggedWidget) +void FocusHandler::setDraggedWidget(Widget* draggedWidget) { mDraggedWidget = draggedWidget; } -gcn::Widget* FocusHandler::getLastWidgetWithMouse() +Widget* FocusHandler::getLastWidgetWithMouse() { return mLastWidgetWithMouse; } -void FocusHandler::setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse) +void FocusHandler::setLastWidgetWithMouse(Widget* lastWidgetWithMouse) { mLastWidgetWithMouse = lastWidgetWithMouse; } -gcn::Widget* FocusHandler::getLastWidgetWithModalFocus() +Widget* FocusHandler::getLastWidgetWithModalFocus() { return mLastWidgetWithModalFocus; } -void FocusHandler::setLastWidgetWithModalFocus(gcn::Widget* widget) +void FocusHandler::setLastWidgetWithModalFocus(Widget* widget) { mLastWidgetWithModalFocus = widget; } -gcn::Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() +Widget* FocusHandler::getLastWidgetWithModalMouseInputFocus() { return mLastWidgetWithModalMouseInputFocus; } -void FocusHandler::setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget) +void FocusHandler::setLastWidgetWithModalMouseInputFocus(Widget* widget) { mLastWidgetWithModalMouseInputFocus = widget; } -gcn::Widget* FocusHandler::getLastWidgetPressed() +Widget* FocusHandler::getLastWidgetPressed() { return mLastWidgetPressed; } -void FocusHandler::setLastWidgetPressed(gcn::Widget* lastWidgetPressed) +void FocusHandler::setLastWidgetPressed(Widget* lastWidgetPressed) { mLastWidgetPressed = lastWidgetPressed; } diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index c8885ef2c..ed3a08e98 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -74,11 +74,7 @@ #include "localconsts.h" class Event; - -namespace gcn -{ - class Widget; -} +class Widget; /** * The focus handler. This focus handler does exactly the same as the Guichan @@ -101,7 +97,7 @@ class FocusHandler final * @param widget The widget to request focus for. * @see isFocused, Widget::requestFocus */ - void requestFocus(gcn::Widget* widget); + void requestFocus(Widget* widget); /** * Requests modal focus for a widget. Focus will only be granted @@ -112,7 +108,7 @@ class FocusHandler final * @throws Exception when another widget already has modal focus. * @see releaseModalFocus, Widget::requestModalFocus */ - void requestModalFocus(gcn::Widget* widget); + void requestModalFocus(Widget* widget); /** * Requests modal mouse input focus for a widget. Focus will only @@ -129,7 +125,7 @@ class FocusHandler final * focus. * @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus */ - void requestModalMouseInputFocus(gcn::Widget* widget); + void requestModalMouseInputFocus(Widget* widget); /** * Releases modal focus if the widget has modal focus. @@ -138,7 +134,7 @@ class FocusHandler final * @param widget The widget to release modal focus for. * @see reuqestModalFocus, Widget::releaseModalFocus */ - void releaseModalFocus(gcn::Widget* widget); + void releaseModalFocus(Widget* widget); /** * Releases modal mouse input focus if the widget has modal mouse input @@ -148,7 +144,7 @@ class FocusHandler final * @param widget the widget to release modal mouse input focus for. * @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus */ - void releaseModalMouseInputFocus(gcn::Widget* widget); + void releaseModalMouseInputFocus(Widget* widget); /** * Checks if a widget is focused. @@ -157,14 +153,14 @@ class FocusHandler final * @return True if the widget is focused, false otherwise. * @see Widget::isFocused */ - bool isFocused(const gcn::Widget* widget) const; + bool isFocused(const Widget* widget) const; /** * Gets the widget with focus. * * @return The widget with focus. NULL if no widget has focus. */ - gcn::Widget* getFocused() const A_WARN_UNUSED; + Widget* getFocused() const A_WARN_UNUSED; /** * Gets the widget with modal focus. @@ -172,7 +168,7 @@ class FocusHandler final * @return The widget with modal focus. NULL if no widget has * modal focus. */ - gcn::Widget* getModalFocused() const A_WARN_UNUSED; + Widget* getModalFocused() const A_WARN_UNUSED; /** * Gets the widget with modal mouse input focus. @@ -180,7 +176,7 @@ class FocusHandler final * @return The widget with modal mouse input focus. NULL if * no widget has modal mouse input focus. */ - gcn::Widget* getModalMouseInputFocused() const A_WARN_UNUSED; + Widget* getModalMouseInputFocused() const A_WARN_UNUSED; /** * Focuses the next widget added to a conainer. @@ -208,7 +204,7 @@ class FocusHandler final * @param widget The widget to add. * @see remove */ - void add(gcn::Widget* widget); + void add(Widget* widget); /** * Removes a widget from the focus handler. @@ -216,7 +212,7 @@ class FocusHandler final * @param widget The widget to remove. * @see add */ - void remove(gcn::Widget* widget); + void remove(Widget* widget); /** * Focuses nothing. A focus event will also be sent to the @@ -247,7 +243,7 @@ class FocusHandler final * @return the widget being dragged. * @see setDraggedWidget */ - gcn::Widget* getDraggedWidget() A_WARN_UNUSED; + Widget* getDraggedWidget() A_WARN_UNUSED; /** * Sets the widget being dragged. Used by the Gui class to @@ -256,7 +252,7 @@ class FocusHandler final * @param draggedWidget The widget being dragged. * @see getDraggedWidget */ - void setDraggedWidget(gcn::Widget* draggedWidget); + void setDraggedWidget(Widget* draggedWidget); /** * Gets the last widget with the mouse. Used by the Gui class @@ -265,7 +261,7 @@ class FocusHandler final * @return The last widget with the mouse. * @see setLastWidgetWithMouse */ - gcn::Widget* getLastWidgetWithMouse() A_WARN_UNUSED; + Widget* getLastWidgetWithMouse() A_WARN_UNUSED; /** * Sets the last widget with the mouse. Used by the Gui class @@ -274,7 +270,7 @@ class FocusHandler final * @param lastWidgetWithMouse The last widget with the mouse. * @see getLastWidgetWithMouse */ - void setLastWidgetWithMouse(gcn::Widget* lastWidgetWithMouse); + void setLastWidgetWithMouse(Widget* lastWidgetWithMouse); /** * Gets the last widget with modal focus. @@ -282,7 +278,7 @@ class FocusHandler final * @return The last widget with modal focus. * @see setLastWidgetWithModalFocus */ - gcn::Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; + Widget* getLastWidgetWithModalFocus() A_WARN_UNUSED; /** * Sets the last widget with modal focus. @@ -290,7 +286,7 @@ class FocusHandler final * @param widget The last widget with modal focus. * @see getLastWidgetWithModalFocus */ - void setLastWidgetWithModalFocus(gcn::Widget* widget); + void setLastWidgetWithModalFocus(Widget* widget); /** * Gets the last widget with modal mouse input focus. @@ -298,7 +294,7 @@ class FocusHandler final * @return The last widget with modal mouse input focus. * @see setLastWidgetWithModalMouseInputFocus */ - gcn::Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; + Widget* getLastWidgetWithModalMouseInputFocus() A_WARN_UNUSED; /** * Sets the last widget with modal mouse input focus. @@ -306,7 +302,7 @@ class FocusHandler final * @param widget The last widget with modal mouse input focus. * @see getLastWidgetWithModalMouseInputFocus */ - void setLastWidgetWithModalMouseInputFocus(gcn::Widget* widget); + void setLastWidgetWithModalMouseInputFocus(Widget* widget); /** * Gets the last widget pressed. Used by the Gui class to keep track @@ -315,7 +311,7 @@ class FocusHandler final * @return The last widget pressed. * @see setLastWidgetPressed */ - gcn::Widget* getLastWidgetPressed() A_WARN_UNUSED; + Widget* getLastWidgetPressed() A_WARN_UNUSED; /** * Sets the last widget pressed. Used by the Gui class to keep track @@ -324,7 +320,7 @@ class FocusHandler final * @param lastWidgetPressed The last widget pressed. * @see getLastWidgetPressed */ - void setLastWidgetPressed(gcn::Widget* lastWidgetPressed); + void setLastWidgetPressed(Widget* lastWidgetPressed); private: /** @@ -352,7 +348,7 @@ class FocusHandler final /** * Typedef. */ - typedef std::vector WidgetVector; + typedef std::vector WidgetVector; /** * Typedef. @@ -368,50 +364,50 @@ class FocusHandler final /** * Holds the focused widget. NULL if no widget has focus. */ - gcn::Widget* mFocusedWidget; + Widget* mFocusedWidget; /** * Holds the modal focused widget. NULL if no widget has * modal focused. */ - gcn::Widget* mModalFocusedWidget; + Widget* mModalFocusedWidget; /** * Holds the modal mouse input focused widget. NULL if no widget * is being dragged. */ - gcn::Widget* mModalMouseInputFocusedWidget; + Widget* mModalMouseInputFocusedWidget; /** * Holds the dragged widget. NULL if no widget is * being dragged. */ - gcn::Widget* mDraggedWidget; + Widget* mDraggedWidget; /** * Holds the last widget with the mouse. */ - gcn::Widget* mLastWidgetWithMouse; + Widget* mLastWidgetWithMouse; /** * Holds the last widget with modal focus. */ - gcn::Widget* mLastWidgetWithModalFocus; + Widget* mLastWidgetWithModalFocus; /** * Holds the last widget with modal mouse input focus. */ - gcn::Widget* mLastWidgetWithModalMouseInputFocus; + Widget* mLastWidgetWithModalMouseInputFocus; /** * Holds the last widget pressed. */ - gcn::Widget* mLastWidgetPressed; + Widget* mLastWidgetPressed; /** * Stack of widgets that have requested modal forcus. */ - std::list mModalStack; + std::list mModalStack; }; #endif // GUI_FOCUSHANDLER_H diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index fdaa299af..07aca0c81 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -223,7 +223,7 @@ void Gui::postInit(Graphics *const graphics) mNpcFont = new Font(fontFile, npcFontSize); - gcn::Widget::setGlobalFont(mGuiFont); + Widget::setGlobalFont(mGuiFont); // Initialize mouse cursor and listen for changes to the option setUseCustomCursor(config.getBoolValue("customcursor")); @@ -538,7 +538,7 @@ void Gui::handleMousePressed(const MouseInput &mouseInput) const unsigned int button = mouseInput.getButton(); const int timeStamp = mouseInput.getTimeStamp(); - gcn::Widget *sourceWidget = getMouseEventSource(x, y); + Widget *sourceWidget = getMouseEventSource(x, y); if (mFocusHandler->getDraggedWidget()) sourceWidget = mFocusHandler->getDraggedWidget(); @@ -601,14 +601,14 @@ void Gui::updateFonts() mNpcFont->loadFont(fontFile, npcFontSize); } -void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, +void Gui::distributeMouseEvent(Widget* source, int type, int button, int x, int y, bool force, bool toSourceOnly) { if (!source || !mFocusHandler) return; - gcn::Widget* widget = source; + Widget* widget = source; if (!force && mFocusHandler->getModalFocused() != nullptr && !widget->isModalFocused()) @@ -626,12 +626,12 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, mAltPressed, mMetaPressed, type, button, x, y, mClickCount); - gcn::Widget* parent = source; + Widget* parent = source; while (parent) { // If the widget has been removed due to input // cancel the distribution. - if (!gcn::Widget::widgetExists(widget)) + if (!Widget::widgetExists(widget)) break; parent = widget->getParent(); @@ -691,7 +691,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, break; } - const gcn::Widget *const swap = widget; + const Widget *const swap = widget; widget = parent; parent = swap->getParent(); @@ -740,7 +740,7 @@ MouseEvent *Gui::createMouseEvent(Window *const widget) mouseX - x, mouseY - y, mClickCount); } -void Gui::getAbsolutePosition(gcn::Widget *restrict widget, +void Gui::getAbsolutePosition(Widget *restrict widget, int &restrict x, int &restrict y) { x = 0; @@ -806,7 +806,7 @@ void Gui::handleMouseInput() void Gui::handleMouseReleased(const MouseInput &mouseInput) { - gcn::Widget *sourceWidget = getMouseEventSource( + Widget *sourceWidget = getMouseEventSource( mouseInput.getX(), mouseInput.getY()); int sourceWidgetX, sourceWidgetY; @@ -815,7 +815,7 @@ void Gui::handleMouseReleased(const MouseInput &mouseInput) if (sourceWidget != mFocusHandler->getLastWidgetPressed()) mFocusHandler->setLastWidgetPressed(nullptr); - gcn::Widget *oldWidget = sourceWidget; + Widget *oldWidget = sourceWidget; sourceWidget = mFocusHandler->getDraggedWidget(); if (oldWidget != sourceWidget) { @@ -876,7 +876,7 @@ void Gui::distributeGlobalFocusGainedEvent(const Event &focusEvent) } } -void Gui::removeDragged(gcn::Widget *widget) +void Gui::removeDragged(Widget *widget) { if (!mFocusHandler) return; diff --git a/src/gui/gui.h b/src/gui/gui.h index 232d47a22..4038bbec4 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -148,7 +148,7 @@ class Gui final : public gcn::Gui MouseEvent *createMouseEvent(Window *const widget) A_WARN_UNUSED; - static void getAbsolutePosition(gcn::Widget *restrict widget, + static void getAbsolutePosition(Widget *restrict widget, int &restrict x, int &restrict y); @@ -158,7 +158,7 @@ class Gui final : public gcn::Gui void distributeGlobalFocusGainedEvent(const Event &focusEvent); - void removeDragged(gcn::Widget *widget); + void removeDragged(Widget *widget); int getLastMouseX() const { return mLastMouseX; } @@ -177,7 +177,7 @@ class Gui final : public gcn::Gui void handleMouseInput(); - void distributeMouseEvent(gcn::Widget* source, int type, int button, + void distributeMouseEvent(Widget* source, int type, int button, int x, int y, bool force = false, bool toSourceOnly = false); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 4300f4ea8..46b6ea20f 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -103,7 +103,7 @@ void AvatarListBox::draw(Graphics *graphics) Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); - const gcn::Widget *const parent = mParent; + const Widget *const parent = mParent; const std::string name = player_node->getName(); // Draw the list elements diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 6e506eeeb..cfc26da0e 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -52,7 +52,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode, const bool opaque, const std::string &skin) : - gcn::Widget(widget), + Widget(widget), MouseListener(), mTextRows(), mTextRowLinksCount(), diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h index a33c69698..8202fa548 100644 --- a/src/gui/widgets/browserbox.h +++ b/src/gui/widgets/browserbox.h @@ -25,7 +25,8 @@ #define GUI_WIDGETS_BROWSERBOX_H #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" + +#include "gui/widgets/widget.h" #include #include @@ -100,7 +101,7 @@ class LinePart final * A simple browser box able to handle links and forward events to the * parent conteiner. */ -class BrowserBox final : public gcn::Widget, +class BrowserBox final : public Widget, public MouseListener { public: diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index 7bf674037..2acc5f5d3 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -51,7 +51,7 @@ TEST(browserbox, test1) logger = new Logger(); imageHelper = new SDLImageHelper(); Theme *theme = Theme::instance(); - gcn::Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/" + Widget::setGlobalFont(new Font("/usr/share/fonts/truetype/" "ttf-dejavu/DejaVuSans-Oblique.ttf", 18)); BrowserBox *box = new BrowserBox(nullptr, BrowserBox::AUTO_WRAP, true, ""); box->setWidth(100); diff --git a/src/gui/widgets/container.cpp b/src/gui/widgets/container.cpp index 2d8aad965..93d74dc8d 100644 --- a/src/gui/widgets/container.cpp +++ b/src/gui/widgets/container.cpp @@ -45,7 +45,7 @@ void Container::removeControls() delete mWidgets.front(); } -bool Container::safeRemove(gcn::Widget *const widget) +bool Container::safeRemove(Widget *const widget) { for (WidgetListConstIterator iter = mWidgets.begin(); iter != mWidgets.end(); ++iter) diff --git a/src/gui/widgets/container.h b/src/gui/widgets/container.h index 36d7cce86..17d6b2af4 100644 --- a/src/gui/widgets/container.h +++ b/src/gui/widgets/container.h @@ -41,7 +41,7 @@ class Container : public gcn::Container virtual ~Container(); - bool safeRemove(gcn::Widget *const widget); + bool safeRemove(Widget *const widget); void removeControls(); }; diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 1ebcb4841..2aff81955 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -34,7 +34,7 @@ namespace } // namespace EmotePage::EmotePage(const Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), MouseListener(), WidgetListener(), mEmotes(ResourceManager::getInstance()->getImageSet( diff --git a/src/gui/widgets/emotepage.h b/src/gui/widgets/emotepage.h index 8a508bd26..2ce50f1fc 100644 --- a/src/gui/widgets/emotepage.h +++ b/src/gui/widgets/emotepage.h @@ -24,11 +24,11 @@ #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "localconsts.h" -class EmotePage final : public gcn::Widget, +class EmotePage final : public Widget, public MouseListener, public WidgetListener { diff --git a/src/gui/widgets/flowcontainer.cpp b/src/gui/widgets/flowcontainer.cpp index 06fb731c4..e9b5c1e0c 100644 --- a/src/gui/widgets/flowcontainer.cpp +++ b/src/gui/widgets/flowcontainer.cpp @@ -86,7 +86,7 @@ void FlowContainer::widgetResized(const Event &event A_UNUSED) } } -void FlowContainer::add(gcn::Widget *widget) +void FlowContainer::add(Widget *widget) { if (!widget) return; diff --git a/src/gui/widgets/flowcontainer.h b/src/gui/widgets/flowcontainer.h index 8e96204ae..7266bb06a 100644 --- a/src/gui/widgets/flowcontainer.h +++ b/src/gui/widgets/flowcontainer.h @@ -64,7 +64,7 @@ class FlowContainer final : public Container, int getBoxHeight() const A_WARN_UNUSED { return mBoxHeight; } - void add(gcn::Widget *widget) override final; + void add(Widget *widget) override final; private: int mBoxWidth; diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 7bd920046..98e7e5f23 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -44,7 +44,7 @@ class GuiTableActionListener final : public ActionListener { public: GuiTableActionListener(GuiTable *restrict _table, - gcn::Widget *restrict _widget, + Widget *restrict _widget, int _row, int _column); A_DELETE_COPY(GuiTableActionListener) @@ -57,12 +57,12 @@ protected: GuiTable *mTable; int mRow; int mColumn; - gcn::Widget *mWidget; + Widget *mWidget; }; GuiTableActionListener::GuiTableActionListener(GuiTable *restrict table, - gcn::Widget *restrict widget, + Widget *restrict widget, int row, int column) : ActionListener(), mTable(table), @@ -96,7 +96,7 @@ void GuiTableActionListener::action(const ActionEvent &actionEvent A_UNUSED) GuiTable::GuiTable(const Widget2 *const widget, TableModel *const initial_model, const bool opacity) : - gcn::Widget(widget), + Widget(widget), MouseListener(), KeyListener(), mModel(nullptr), @@ -282,7 +282,7 @@ void GuiTable::installActionListeners() { for (int column = 0; column < columns; ++column) { - gcn::Widget *const widget = mModel->getElementAt(row, column); + Widget *const widget = mModel->getElementAt(row, column); if (widget) { mActionListeners.push_back(new GuiTableActionListener( @@ -347,7 +347,7 @@ void GuiTable::draw(Graphics* graphics) for (unsigned c = first_column; c + 1 <= last_column1; ++c) { - gcn::Widget *const widget = mModel->getElementAt(r, c); + Widget *const widget = mModel->getElementAt(r, c); const int cWidth = getColumnWidth(c); if (widget) { @@ -401,15 +401,15 @@ void GuiTable::draw(Graphics* graphics) BLOCK_END("GuiTable::draw") } -void GuiTable::moveToTop(gcn::Widget *widget) +void GuiTable::moveToTop(Widget *widget) { - gcn::Widget::moveToTop(widget); + Widget::moveToTop(widget); mTopWidget = widget; } -void GuiTable::moveToBottom(gcn::Widget *widget) +void GuiTable::moveToBottom(Widget *widget) { - gcn::Widget::moveToBottom(widget); + Widget::moveToBottom(widget); if (widget == mTopWidget) mTopWidget = nullptr; } @@ -532,7 +532,7 @@ void GuiTable::modelUpdated(const bool completed) } } -gcn::Widget *GuiTable::getWidgetAt(int x, int y) +Widget *GuiTable::getWidgetAt(int x, int y) { const int row = getRowForY(y); const int column = getColumnForX(x); @@ -542,7 +542,7 @@ gcn::Widget *GuiTable::getWidgetAt(int x, int y) if (mModel && row > -1 && column > -1) { - gcn::Widget *const w = mModel->getElementAt(row, column); + Widget *const w = mModel->getElementAt(row, column); if (w && w->isFocusable()) return w; else @@ -595,7 +595,7 @@ void GuiTable::_setFocusHandler(FocusHandler* focusHandler) if (!mModel || !focusHandler) return; - gcn::Widget::_setFocusHandler(focusHandler); + Widget::_setFocusHandler(focusHandler); const int rows = mModel->getRows(); const int cols = mModel->getColumns(); @@ -603,7 +603,7 @@ void GuiTable::_setFocusHandler(FocusHandler* focusHandler) { for (int c = 0; c < cols ; ++c) { - gcn::Widget *const w = mModel->getElementAt(r, c); + Widget *const w = mModel->getElementAt(r, c); if (w) w->_setFocusHandler(focusHandler); } @@ -614,5 +614,5 @@ void GuiTable::requestFocus() { if (!mFocusHandler) return; - gcn::Widget::requestFocus(); + Widget::requestFocus(); } diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 055c6c5f2..23185a903 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -30,7 +30,7 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include @@ -45,7 +45,7 @@ class GuiTableActionListener; * * \ingroup GUI */ -class GuiTable final : public gcn::Widget, +class GuiTable final : public Widget, public MouseListener, public KeyListener, public TableModelListener @@ -114,11 +114,11 @@ public: // Inherited from Widget void draw(Graphics* graphics) override final; - gcn::Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED; + Widget *getWidgetAt(int x, int y) override final A_WARN_UNUSED; - void moveToTop(gcn::Widget *child) override final; + void moveToTop(Widget *child) override final; - void moveToBottom(gcn::Widget *child) override final; + void moveToBottom(Widget *child) override final; void _setFocusHandler(FocusHandler* focusHandler) override final; @@ -180,7 +180,7 @@ private: TableModel *mModel; /** If someone moves a fresh widget to the top, we must display it. */ - gcn::Widget *mTopWidget; + Widget *mTopWidget; /** Vector for compactness; used as a list in practice. */ std::vector mActionListeners; diff --git a/src/gui/widgets/horizontcontainer.cpp b/src/gui/widgets/horizontcontainer.cpp index 5d0e14903..8e3be9662 100644 --- a/src/gui/widgets/horizontcontainer.cpp +++ b/src/gui/widgets/horizontcontainer.cpp @@ -36,12 +36,12 @@ HorizontContainer::HorizontContainer(const Widget2 *const widget, addWidgetListener(this); } -void HorizontContainer::add(gcn::Widget *widget) +void HorizontContainer::add(Widget *widget) { add(widget, mSpacing); } -void HorizontContainer::add(gcn::Widget *const widget, const int spacing) +void HorizontContainer::add(Widget *const widget, const int spacing) { if (!widget) return; diff --git a/src/gui/widgets/horizontcontainer.h b/src/gui/widgets/horizontcontainer.h index 9a873272c..bef3d0b00 100644 --- a/src/gui/widgets/horizontcontainer.h +++ b/src/gui/widgets/horizontcontainer.h @@ -43,9 +43,9 @@ class HorizontContainer final : public Container, A_DELETE_COPY(HorizontContainer) - void add(gcn::Widget *widget) override final; + void add(Widget *widget) override final; - void add(gcn::Widget *const widget, const int spacing); + void add(Widget *const widget, const int spacing); void clear() override; diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 73c0db76c..53be9ef91 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -31,7 +31,7 @@ Icon::Icon(const Widget2 *const widget, const std::string &file) : - gcn::Widget(widget), + Widget(widget), mImage(ResourceManager::getInstance()->getImage(file)) { if (mImage) @@ -43,7 +43,7 @@ Icon::Icon(const Widget2 *const widget, Icon::Icon(const Widget2 *const widget, Image *const image) : - gcn::Widget(widget), + Widget(widget), mImage(image) { if (mImage) diff --git a/src/gui/widgets/icon.h b/src/gui/widgets/icon.h index dffdb8e8c..1e015f8e6 100644 --- a/src/gui/widgets/icon.h +++ b/src/gui/widgets/icon.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_ICON_H #define GUI_WIDGETS_ICON_H -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "localconsts.h" @@ -34,7 +34,7 @@ class Image; * * \ingroup GUI */ -class Icon final : public gcn::Widget +class Icon final : public Widget { public: /** diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 85f020af4..0ea3adef1 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -158,7 +158,7 @@ namespace ItemContainer::ItemContainer(const Widget2 *const widget, Inventory *const inventory, const bool forceQuantity) : - gcn::Widget(widget), + Widget(widget), KeyListener(), MouseListener(), WidgetListener(), @@ -226,7 +226,7 @@ ItemContainer::~ItemContainer() void ItemContainer::logic() { BLOCK_START("ItemContainer::logic") - gcn::Widget::logic(); + Widget::logic(); if (!mInventory) { diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 32daa459b..f7bc44849 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -27,7 +27,7 @@ #include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include @@ -44,7 +44,7 @@ class SelectionListener; * * \ingroup GUI */ -class ItemContainer final : public gcn::Widget, +class ItemContainer final : public Widget, public KeyListener, public MouseListener, public WidgetListener diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 4132741e4..2af27a21c 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -36,7 +36,7 @@ ContainerPlacer ContainerPlacer::at(const int x, const int y) } LayoutCell &ContainerPlacer::operator() - (const int x, const int y, gcn::Widget *const wg, const int w, const int h) + (const int x, const int y, Widget *const wg, const int w, const int h) { mContainer->add(wg); return mCell->place(wg, x, y, w, h); @@ -203,7 +203,7 @@ void LayoutArray::extend(const int x, const int y, const int w, const int h) cell.mExtent[1] = h; } -LayoutCell &LayoutArray::place(gcn::Widget *const widget, const int x, +LayoutCell &LayoutArray::place(Widget *const widget, const int x, const int y, const int w, const int h) { LayoutCell &cell = at(x, y, w, h); diff --git a/src/gui/widgets/layout.h b/src/gui/widgets/layout.h index 85998d8e7..288c282a0 100644 --- a/src/gui/widgets/layout.h +++ b/src/gui/widgets/layout.h @@ -32,9 +32,10 @@ class LayoutCell; namespace gcn { class Container; - class Widget; } +class Widget; + /** * This class is a helper for adding widgets to nested tables in a window. */ @@ -61,7 +62,7 @@ class ContainerPlacer final * Adds the given widget to the container and places it in the layout. * @see LayoutArray::place */ - LayoutCell &operator()(const int x, const int y, gcn::Widget *const wg, + LayoutCell &operator()(const int x, const int y, Widget *const wg, const int w = 1, const int h = 1); private: @@ -94,7 +95,7 @@ class LayoutArray final * @note When @a w is 1, the width of column @a x is reset to zero if * it was AUTO_DEF. Similarly for @a h. */ - LayoutCell &place(gcn::Widget *const widget, const int x, const int y, + LayoutCell &place(Widget *const widget, const int x, const int y, const int w = 1, const int h = 1); /** @@ -220,7 +221,7 @@ class LayoutCell /** * @see LayoutArray::place */ - LayoutCell &place(gcn::Widget *wg, int x, int y, int w = 1, int h = 1) + LayoutCell &place(Widget *wg, int x, int y, int w = 1, int h = 1) { return getArray().place(wg, x, y, w, h); } /** @@ -298,7 +299,7 @@ class LayoutCell union { - gcn::Widget *mWidget; + Widget *mWidget; LayoutArray *mArray; }; diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index e4b931c92..83e6d050a 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -45,7 +45,7 @@ const Layout &LayoutHelper::getLayout() const } LayoutCell &LayoutHelper::place(const int x, const int y, - gcn::Widget *const wg, + Widget *const wg, const int w, const int h) { mContainer->add(wg); diff --git a/src/gui/widgets/layouthelper.h b/src/gui/widgets/layouthelper.h index d5a94e656..32e3d9e34 100644 --- a/src/gui/widgets/layouthelper.h +++ b/src/gui/widgets/layouthelper.h @@ -67,7 +67,7 @@ class LayoutHelper final : public WidgetListener /** * Adds a widget to the container and sets it at given cell. */ - LayoutCell &place(const int x, const int y, gcn::Widget *const wg, + LayoutCell &place(const int x, const int y, Widget *const wg, const int w = 1, const int h = 1); /** diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 76eb3707a..9a0a38013 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -148,7 +148,7 @@ void Popup::setContentSize(int width, int height) mRedraw = true; } -void Popup::setLocationRelativeTo(const gcn::Widget *const widget) +void Popup::setLocationRelativeTo(const Widget *const widget) { if (!widget) return; diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index d1709a328..3c8947fce 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -86,7 +86,7 @@ class Popup : public Container, /** * Sets the location relative to the given widget. */ - void setLocationRelativeTo(const gcn::Widget *const widget); + void setLocationRelativeTo(const Widget *const widget); void mouseMoved(MouseEvent &event) override; diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index 133cbd2ca..8ad4bd0c4 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -156,7 +156,7 @@ void PopupList::mouseReleased(MouseEvent& mouseEvent) void PopupList::focusGained(const Event& event) { - const gcn::Widget *const source = event.getSource(); + const Widget *const source = event.getSource(); if (!mVisible || source == this || source == mListBox || source == mScrollArea || source == mDropDown) { diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index db199a714..1a1b8dc0e 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -40,7 +40,7 @@ ProgressBar::ProgressBar(const Widget2 *const widget, const int backColor, const std::string &skin, const std::string &skinFill): - gcn::Widget(widget), + Widget(widget), WidgetListener(), mFillRect(), mSkin(nullptr), diff --git a/src/gui/widgets/progressbar.h b/src/gui/widgets/progressbar.h index a4862882e..fef9bf11d 100644 --- a/src/gui/widgets/progressbar.h +++ b/src/gui/widgets/progressbar.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_PROGRESSBAR_H #define GUI_WIDGETS_PROGRESSBAR_H -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "listeners/widgetlistener.h" @@ -39,7 +39,7 @@ class Skin; * * \ingroup GUI */ -class ProgressBar final : public gcn::Widget, +class ProgressBar final : public Widget, public WidgetListener { public: diff --git a/src/gui/widgets/progressindicator.cpp b/src/gui/widgets/progressindicator.cpp index f5b295ec8..8e86417bd 100644 --- a/src/gui/widgets/progressindicator.cpp +++ b/src/gui/widgets/progressindicator.cpp @@ -31,7 +31,7 @@ #include "debug.h" ProgressIndicator::ProgressIndicator(Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), mIndicator(nullptr) { ImageSet *const images = Theme::getImageSetFromTheme( diff --git a/src/gui/widgets/progressindicator.h b/src/gui/widgets/progressindicator.h index e62e7ec90..447c3d4e4 100644 --- a/src/gui/widgets/progressindicator.h +++ b/src/gui/widgets/progressindicator.h @@ -22,7 +22,7 @@ #ifndef GUI_WIDGETS_PROGRESSINDICATOR_H #define GUI_WIDGETS_PROGRESSINDICATOR_H -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "localconsts.h" @@ -32,7 +32,7 @@ class SimpleAnimation; * A widget that indicates progress. Suitable to use instead of a progress bar * in cases where it is unknown how long something is going to take. */ -class ProgressIndicator final : public gcn::Widget +class ProgressIndicator final : public Widget { public: explicit ProgressIndicator(Widget2 *const widget); diff --git a/src/gui/widgets/radiogroup.cpp b/src/gui/widgets/radiogroup.cpp index d2f130c1b..9bb4f40c5 100644 --- a/src/gui/widgets/radiogroup.cpp +++ b/src/gui/widgets/radiogroup.cpp @@ -31,7 +31,7 @@ RadioGroup::RadioGroup(const Widget2 *const widget, { } -gcn::Widget *RadioGroup::createWidget(const std::string &text) const +Widget *RadioGroup::createWidget(const std::string &text) const { RadioButton *const widget = new RadioButton( this, text, mGroup, mCount == 0); diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h index d0bf18532..b553c629a 100644 --- a/src/gui/widgets/radiogroup.h +++ b/src/gui/widgets/radiogroup.h @@ -23,7 +23,7 @@ #include "gui/widgets/widgetgroup.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" class RadioGroup final : public WidgetGroup { @@ -35,8 +35,8 @@ class RadioGroup final : public WidgetGroup A_DELETE_COPY(RadioGroup) - gcn::Widget *createWidget(const std::string &name) - const override final A_WARN_UNUSED; + Widget *createWidget(const std::string &name) + const override final A_WARN_UNUSED; }; #endif // GUI_WIDGETS_RADIOGROUP_H diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index b508e2dd4..2ca851254 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -50,7 +50,7 @@ static std::string const buttonFiles[2] = }; ScrollArea::ScrollArea(Widget2 *const widget2, - gcn::Widget *const widget, + Widget *const widget, const bool opaque, const std::string &skin) : gcn::ScrollArea(widget2, widget), @@ -179,7 +179,7 @@ void ScrollArea::logic() } gcn::ScrollArea::logic(); - gcn::Widget *const content = getContent(); + Widget *const content = getContent(); // When no scrollbar in a certain direction, adapt content size to match // the content dimension exactly. @@ -656,7 +656,7 @@ void ScrollArea::widgetResized(const Event &event A_UNUSED) { mRedraw = true; const unsigned int frameSize = 2 * mFrameSize; - gcn::Widget *const content = getContent(); + Widget *const content = getContent(); if (content) { content->setSize(mDimension.width - frameSize, @@ -900,7 +900,7 @@ Rectangle ScrollArea::getVerticalMarkerDimension() int height; const int h2 = mShowButtons ? mScrollbarWidth : mMarkerSize / 2; - const gcn::Widget *content; + const Widget *content; if (!mWidgets.empty()) content = *mWidgets.begin(); else @@ -958,7 +958,7 @@ Rectangle ScrollArea::getHorizontalMarkerDimension() int width; const int w2 = mShowButtons ? mScrollbarWidth : mMarkerSize / 2; - const gcn::Widget *content; + const Widget *content; if (!mWidgets.empty()) content = *mWidgets.begin(); else diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index e5c9ffb79..a6081e506 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -51,7 +51,7 @@ class ScrollArea final : public gcn::ScrollArea, * @param content the initial content to show in the scroll area */ ScrollArea(Widget2 *const widget2, - gcn::Widget *const widget, + Widget *const widget, const bool opaque = true, const std::string &skin = ""); diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 1f5d48d06..3e40b902e 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -191,7 +191,7 @@ void SetupItem::externalUnloaded(const std::string &eventName A_UNUSED) { } -void SetupItem::fixFirstItemSize(gcn::Widget *const widget) +void SetupItem::fixFirstItemSize(Widget *const widget) { const int maxSize = mParent->getPreferredFirstItemSize(); if (widget->getWidth() < maxSize) diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 502d85d21..18e838cdf 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -70,10 +70,10 @@ class SetupItem : public ActionListener, virtual void toWidget() = 0; - void setWidget(gcn::Widget *widget) + void setWidget(Widget *widget) { mWidget = widget; } - gcn::Widget *getWidget() const A_WARN_UNUSED + Widget *getWidget() const A_WARN_UNUSED { return mWidget; } Configuration *getConfig() const A_WARN_UNUSED; @@ -95,7 +95,7 @@ class SetupItem : public ActionListener, bool isMainConfig() const A_WARN_UNUSED { return mMainConfig; } - void fixFirstItemSize(gcn::Widget *const widget); + void fixFirstItemSize(Widget *const widget); virtual void rereadValue(); @@ -138,9 +138,9 @@ class SetupItem : public ActionListener, std::string mDefault; - gcn::Widget *mWidget; + Widget *mWidget; - std::list mTempWidgets; + std::list mTempWidgets; int mValueType; diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index a8acb3f5f..a7e166da3 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -31,7 +31,7 @@ float ShortcutContainer::mAlpha = 1.0; ShortcutContainer::ShortcutContainer(Widget2 *const widget) : - gcn::Widget(widget), + Widget(widget), WidgetListener(), MouseListener(), mBackgroundImg(nullptr), diff --git a/src/gui/widgets/shortcutcontainer.h b/src/gui/widgets/shortcutcontainer.h index 115298081..81392097b 100644 --- a/src/gui/widgets/shortcutcontainer.h +++ b/src/gui/widgets/shortcutcontainer.h @@ -23,8 +23,9 @@ #ifndef GUI_WIDGETS_SHORTCUTCONTAINER_H #define GUI_WIDGETS_SHORTCUTCONTAINER_H +#include "gui/widgets/widget.h" + #include "listeners/mouselistener.h" -#include "gui/base/widget.hpp" #include "listeners/widgetlistener.h" class Image; @@ -35,7 +36,7 @@ class ImageCollection; * * \ingroup GUI */ -class ShortcutContainer : public gcn::Widget, +class ShortcutContainer : public Widget, public WidgetListener, public MouseListener { diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index ce2c02886..7f58a061e 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -197,7 +197,7 @@ void TabbedArea::draw(Graphics *graphics) BLOCK_END("TabbedArea::draw") } -gcn::Widget *TabbedArea::getWidget(const std::string &name) const +Widget *TabbedArea::getWidget(const std::string &name) const { TabContainer::const_iterator itr = mTabs.begin(); const TabContainer::const_iterator itr_end = mTabs.end(); @@ -212,7 +212,7 @@ gcn::Widget *TabbedArea::getWidget(const std::string &name) const return nullptr; } -gcn::Widget *TabbedArea::getCurrentWidget() const +Widget *TabbedArea::getCurrentWidget() const { const Tab *const tab = getSelectedTab(); @@ -223,7 +223,7 @@ gcn::Widget *TabbedArea::getCurrentWidget() const } void TabbedArea::addTab(Tab *const tab, - gcn::Widget *const widget) + Widget *const widget) { if (!tab || !widget) return; @@ -232,7 +232,7 @@ void TabbedArea::addTab(Tab *const tab, tab->addActionListener(this); mTabContainer->add(tab); - mTabs.push_back(std::pair(tab, widget)); + mTabs.push_back(std::pair(tab, widget)); if (!mSelectedTab) setSelectedTab(tab); @@ -248,14 +248,14 @@ void TabbedArea::addTab(Tab *const tab, updateArrowEnableState(); } -void TabbedArea::adjustWidget(gcn::Widget *const widget) const +void TabbedArea::adjustWidget(Widget *const widget) const { const int frameSize = 2 * mFrameSize; widget->setSize(getWidth() - frameSize, getHeight() - frameSize - mTabContainer->getHeight()); } -void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget) +void TabbedArea::addTab(const std::string &caption, Widget *const widget) { Tab *const tab = new Tab(this); tab->setCaption(caption); @@ -264,7 +264,7 @@ void TabbedArea::addTab(const std::string &caption, gcn::Widget *const widget) addTab(tab, widget); } -void TabbedArea::addTab(Image *const image, gcn::Widget *const widget) +void TabbedArea::addTab(Image *const image, Widget *const widget) { Tab *const tab = new Tab(this); tab->setImage(image); @@ -375,7 +375,7 @@ void TabbedArea::mousePressed(MouseEvent &mouseEvent) if (mouseEvent.getButton() == MouseEvent::LEFT) { - gcn::Widget *const widget = mTabContainer->getWidgetAt( + Widget *const widget = mTabContainer->getWidgetAt( mouseEvent.getX(), mouseEvent.getY()); Tab *const tab = dynamic_cast(widget); @@ -449,7 +449,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) const int height = h1 - frameSize - mWidgetContainer->getY() - widgetFrameSize; - gcn::Widget *const w = getCurrentWidget(); + Widget *const w = getCurrentWidget(); if (w) { ScrollArea *const scr = dynamic_cast(w); @@ -545,7 +545,7 @@ void TabbedArea::adjustSize() mWidgetContainer->setPosition(0, maxTabHeight); mWidgetContainer->setSize(width, height - maxTabHeight); - gcn::Widget *const w = getCurrentWidget(); + Widget *const w = getCurrentWidget(); if (w) { const int wFrameSize = w->getFrameSize(); @@ -605,7 +605,7 @@ void TabbedArea::adjustTabPositions() void TabbedArea::action(const ActionEvent& actionEvent) { - gcn::Widget *const source = actionEvent.getSource(); + Widget *const source = actionEvent.getSource(); Tab *const tab = dynamic_cast(source); if (tab) @@ -677,7 +677,7 @@ Tab *TabbedArea::getTabByIndex(const int index) const return static_cast(mTabs[index].first); } -gcn::Widget *TabbedArea::getWidgetByIndex(const int index) const +Widget *TabbedArea::getWidgetByIndex(const int index) const { if (index < 0 || index >= static_cast(mTabs.size())) return nullptr; @@ -694,7 +694,7 @@ void TabbedArea::removeAll(const bool del) { const int idx = getNumberOfTabs() - 1; Tab *tab = mTabs[idx].first; - gcn::Widget *widget = mTabs[idx].second; + Widget *widget = mTabs[idx].second; removeTab(tab); if (del) { @@ -706,25 +706,25 @@ void TabbedArea::removeAll(const bool del) void TabbedArea::setWidth(int width) { - gcn::Widget::setWidth(width); + Widget::setWidth(width); adjustSize(); } void TabbedArea::setHeight(int height) { - gcn::Widget::setHeight(height); + Widget::setHeight(height); adjustSize(); } void TabbedArea::setSize(int width, int height) { - gcn::Widget::setSize(width, height); + Widget::setSize(width, height); adjustSize(); } void TabbedArea::setDimension(const Rectangle &dimension) { - gcn::Widget::setDimension(dimension); + Widget::setDimension(dimension); adjustSize(); } diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 2affd7368..0ad4fbbe6 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -118,17 +118,17 @@ class TabbedArea final : public ActionListener, Tab *getTabByIndex(const int index) const A_WARN_UNUSED; - gcn::Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED; + Widget *getWidgetByIndex(const int index) const A_WARN_UNUSED; /** * Returns the widget with the tab that has specified caption */ - gcn::Widget *getWidget(const std::string &name) const A_WARN_UNUSED; + Widget *getWidget(const std::string &name) const A_WARN_UNUSED; /** * Returns the widget for the current tab */ - gcn::Widget *getCurrentWidget() const A_WARN_UNUSED; + Widget *getCurrentWidget() const A_WARN_UNUSED; /** * Add a tab. Overridden since it needs to size the widget. @@ -136,11 +136,11 @@ class TabbedArea final : public ActionListener, * @param tab The tab widget for the tab. * @param widget The widget to view when the tab is selected. */ - void addTab(Tab *const tab, gcn::Widget *const widget); + void addTab(Tab *const tab, Widget *const widget); - void addTab(const std::string &caption, gcn::Widget *const widget); + void addTab(const std::string &caption, Widget *const widget); - void addTab(Image *const image, gcn::Widget *const widget); + void addTab(Image *const image, Widget *const widget); bool isTabSelected(const unsigned int index) const A_WARN_UNUSED; @@ -229,14 +229,14 @@ class TabbedArea final : public ActionListener, void setResizeHeight(bool b) { mResizeHeight = b; } - void adjustWidget(gcn::Widget *const widget) const; + void adjustWidget(Widget *const widget) const; void selectNextTab(); void selectPrevTab(); private: - typedef std::vector > TabContainer; + typedef std::vector > TabContainer; /** The tab arrows */ Button *mArrowButton[2]; diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp index 7b6b8048e..82b249d0f 100644 --- a/src/gui/widgets/tablemodel.cpp +++ b/src/gui/widgets/tablemodel.cpp @@ -24,7 +24,7 @@ #include "utils/dtor.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "debug.h" @@ -89,7 +89,7 @@ void StaticTableModel::resize() } void StaticTableModel::set(const int row, const int column, - gcn::Widget *const widget) + Widget *const widget) { if (!widget || row >= mRows || row < 0 || column >= mColumns || column < 0) @@ -119,8 +119,8 @@ void StaticTableModel::set(const int row, const int column, signalAfterUpdate(); } -gcn::Widget *StaticTableModel::getElementAt(const int row, - const int column) const +Widget *StaticTableModel::getElementAt(const int row, + const int column) const { return mTableModel[WIDGET_AT(row, column)]; } diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h index 1273c6873..48bd336af 100644 --- a/src/gui/widgets/tablemodel.h +++ b/src/gui/widgets/tablemodel.h @@ -28,10 +28,7 @@ #include "localconsts.h" -namespace gcn -{ - class Widget; -} +class Widget; class TableModelListener { @@ -83,7 +80,7 @@ public: /** * Retrieves the widget stored at the specified location within the table. */ - virtual gcn::Widget *getElementAt(const int row, const int column) + virtual Widget *getElementAt(const int row, const int column) const A_WARN_UNUSED = 0; virtual void installListener(TableModelListener *const listener); @@ -125,7 +122,7 @@ public: * The model is resized to accomodate the widget's width and height, * unless column width / row height have been fixed. */ - void set(const int row, const int column, gcn::Widget *const widget); + void set(const int row, const int column, Widget *const widget); /** * Fixes the column width for a given column; this overrides dynamic width @@ -153,14 +150,14 @@ public: int getWidth() const A_WARN_UNUSED; int getHeight() const A_WARN_UNUSED; int getColumnWidth(const int index) const override final A_WARN_UNUSED; - gcn::Widget *getElementAt(const int row, + Widget *getElementAt(const int row, const int column) const override final A_WARN_UNUSED; protected: int mRows, mColumns; int mHeight; - std::vector mTableModel; + std::vector mTableModel; std::vector mWidths; }; diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index aa1180cef..e2e66c6fc 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -104,7 +104,7 @@ Setup_Joystick::~Setup_Joystick() void Setup_Joystick::action(const ActionEvent &event) { - const gcn::Widget *const source = event.getSource(); + const Widget *const source = event.getSource(); if (source == mJoystickEnabled) { setTempEnabled(mJoystickEnabled->isSelected()); diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 30e1c96bd..dd08d437b 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -165,7 +165,7 @@ public: player_names->size()); r < sz; ++r) { const std::string name = (*player_names)[r]; - gcn::Widget *const widget = new Label(this, name); + Widget *const widget = new Label(this, name); mWidgets.push_back(widget); DropDown *const choicebox = new DropDown(this, mListModel); @@ -186,7 +186,7 @@ public: } - gcn::Widget *getElementAt(int row, int column) const override final + Widget *getElementAt(int row, int column) const override final { return mWidgets[WIDGET_AT(row, column)]; } @@ -209,7 +209,7 @@ public: protected: StringVect *mPlayers; - std::vector mWidgets; + std::vector mWidgets; PlayerRelationListModel *mListModel; }; diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index 4a72d7ccd..57520afce 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -39,7 +39,7 @@ TabStrip::TabStrip(const Widget2 *const widget, { } -gcn::Widget *TabStrip::createWidget(const std::string &text) const +Widget *TabStrip::createWidget(const std::string &text) const { Button *const widget = new Button(this); widget->setStick(true); @@ -55,7 +55,7 @@ void TabStrip::action(const ActionEvent &event) WidgetGroup::action(event); if (event.getSource()) { - gcn::Widget *const widget = event.getSource(); + Widget *const widget = event.getSource(); if (static_cast(widget)->isPressed2()) { FOR_EACH (WidgetListConstIterator, iter, mWidgets) diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index 57a178ff0..b2dfc99e2 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -23,7 +23,7 @@ #include "gui/widgets/widgetgroup.h" -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" class TabStrip final : public WidgetGroup { @@ -39,8 +39,8 @@ class TabStrip final : public WidgetGroup A_DELETE_COPY(TabStrip) - gcn::Widget *createWidget(const std::string &name) - const override final A_WARN_UNUSED; + Widget *createWidget(const std::string &name) + const override final A_WARN_UNUSED; void action(const ActionEvent &event) override final; }; diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 59e61f8d2..6fce77641 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -292,7 +292,7 @@ void TextBox::keyPressed(KeyEvent& keyEvent) case Input::KEY_GUI_PAGE_UP: { - gcn::Widget *const par = getParent(); + Widget *const par = getParent(); if (par) { @@ -308,7 +308,7 @@ void TextBox::keyPressed(KeyEvent& keyEvent) case Input::KEY_GUI_PAGE_DOWN: { - gcn::Widget *const par = getParent(); + Widget *const par = getParent(); if (par) { diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 0676dec25..3772f3bbc 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -35,7 +35,7 @@ Skin *TextPreview::mSkin = nullptr; TextPreview::TextPreview(const Widget2 *const widget, const std::string &text) : - gcn::Widget(widget), + Widget(widget), mFont(gui->getFont()), mText(text), mTextColor(&getThemeColor(Theme::TEXT)), diff --git a/src/gui/widgets/textpreview.h b/src/gui/widgets/textpreview.h index 31768fa66..5a09e1148 100644 --- a/src/gui/widgets/textpreview.h +++ b/src/gui/widgets/textpreview.h @@ -23,14 +23,14 @@ #ifndef GUI_WIDGETS_TEXTPREVIEW_H #define GUI_WIDGETS_TEXTPREVIEW_H -#include "gui/base/widget.hpp" +#include "gui/widgets/widget.h" #include "localconsts.h" /** * Preview widget for particle colors, etc. */ -class TextPreview final : public gcn::Widget +class TextPreview final : public Widget { public: TextPreview(const Widget2 *const widget, diff --git a/src/gui/widgets/vertcontainer.cpp b/src/gui/widgets/vertcontainer.cpp index 9d596d620..b86aa3e5f 100644 --- a/src/gui/widgets/vertcontainer.cpp +++ b/src/gui/widgets/vertcontainer.cpp @@ -40,12 +40,12 @@ VertContainer::VertContainer(const Widget2 *const widget, addWidgetListener(this); } -void VertContainer::add1(gcn::Widget *const widget, const int spacing) +void VertContainer::add1(Widget *const widget, const int spacing) { add2(widget, mResizable, spacing); } -void VertContainer::add2(gcn::Widget *const widget, const bool resizable, +void VertContainer::add2(Widget *const widget, const bool resizable, const int spacing) { if (!widget) @@ -82,6 +82,6 @@ void VertContainer::clear() void VertContainer::widgetResized(const Event &event A_UNUSED) { - FOR_EACH (std::vector::const_iterator, it, mResizableWidgets) + FOR_EACH (std::vector::const_iterator, it, mResizableWidgets) (*it)->setWidth(getWidth()); } diff --git a/src/gui/widgets/vertcontainer.h b/src/gui/widgets/vertcontainer.h index 5fb212b48..05ba2e32f 100644 --- a/src/gui/widgets/vertcontainer.h +++ b/src/gui/widgets/vertcontainer.h @@ -46,17 +46,17 @@ class VertContainer final : public Container, A_DELETE_COPY(VertContainer) - void add2(gcn::Widget *const widget, const bool resizable, + void add2(Widget *const widget, const bool resizable, const int spacing = -1); - void add1(gcn::Widget *const widget, const int spacing = -1); + void add1(Widget *const widget, const int spacing = -1); void clear(); void widgetResized(const Event &event) override final; private: - std::vector mResizableWidgets; + std::vector mResizableWidgets; int mVerticalItemSize; int mCount; int mNextY; diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp new file mode 100644 index 000000000..f93107bc5 --- /dev/null +++ b/src/gui/widgets/widget.cpp @@ -0,0 +1,676 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/widgets/widget.h" + +#include "events/actionevent.h" + +#include "events/event.h" + +#include "gui/focushandler.h" + +#include "listeners/actionlistener.h" +#include "listeners/deathlistener.h" +#include "listeners/widgetlistener.h" + +#include "render/graphics.h" + +#include "debug.h" + +Font* Widget::mGlobalFont = nullptr; +std::list Widget::mWidgets; +std::set Widget::mWidgetsSet; + +Widget::Widget(const Widget2 *const widget) : + Widget2(widget), + mMouseListeners(), + mKeyListeners(), + mActionListeners(), + mDeathListeners(), + mFocusListeners(), + mWidgetListeners(), + mForegroundColor(0x000000), + mBackgroundColor(0xffffff), + mBaseColor(0x808090), + mSelectionColor(0xc3d9ff), + mFocusHandler(nullptr), + mInternalFocusHandler(nullptr), + mParent(nullptr), + mDimension(), + mFrameSize(0), + mActionEventId(), + mFocusable(false), + mVisible(true), + mTabIn(true), + mTabOut(true), + mEnabled(true), + mId(), + mCurrentFont(nullptr) +{ + mWidgets.push_back(this); + mWidgetsSet.insert(this); +} + +Widget::~Widget() +{ + for (DeathListenerIterator iter = mDeathListeners.begin(); + iter != mDeathListeners.end(); + ++iter) + { + Event event(this); + (*iter)->death(event); + } + + _setFocusHandler(nullptr); + + mWidgets.remove(this); + mWidgetsSet.erase(this); +} + +void Widget::drawFrame(Graphics* graphics) +{ + BLOCK_START("Widget::drawFrame") + const Color &faceColor = getBaseColor(); + Color highlightColor = faceColor + Color(0x303030); + Color shadowColor = faceColor - Color(0x303030); + const int alpha = getBaseColor().a; + const int width = getWidth() + getFrameSize() * 2 - 1; + const int height = getHeight() + getFrameSize() * 2 - 1; + highlightColor.a = alpha; + shadowColor.a = alpha; + + for (unsigned int i = 0; i < getFrameSize(); ++i) + { + graphics->setColor(shadowColor); + graphics->drawLine(i, i, width - i, i); + graphics->drawLine(i, i + 1, i, height - i - 1); + graphics->setColor(highlightColor); + graphics->drawLine(width - i, i + 1, width - i, height - i); + graphics->drawLine(i, height - i, width - i - 1, height - i); + } + BLOCK_END("Widget::drawFrame") +} + +void Widget::_setParent(Widget* parent) +{ + mParent = parent; +} + +void Widget::setWidth(int width) +{ + Rectangle newDimension = mDimension; + newDimension.width = width; + + setDimension(newDimension); +} + +void Widget::setHeight(int height) +{ + Rectangle newDimension = mDimension; + newDimension.height = height; + + setDimension(newDimension); +} + +void Widget::setX(int x) +{ + Rectangle newDimension = mDimension; + newDimension.x = x; + + setDimension(newDimension); +} + +void Widget::setY(int y) +{ + Rectangle newDimension = mDimension; + newDimension.y = y; + + setDimension(newDimension); +} + +void Widget::setPosition(int x, int y) +{ + Rectangle newDimension = mDimension; + newDimension.x = x; + newDimension.y = y; + + setDimension(newDimension); +} + +void Widget::setDimension(const Rectangle& dimension) +{ + const Rectangle oldDimension = mDimension; + mDimension = dimension; + + if (mDimension.width != oldDimension.width + || mDimension.height != oldDimension.height) + { + distributeResizedEvent(); + } + + if (mDimension.x != oldDimension.x + || mDimension.y != oldDimension.y) + { + distributeMovedEvent(); + } +} + +void Widget::setFrameSize(unsigned int frameSize) +{ + mFrameSize = frameSize; +} + +unsigned int Widget::getFrameSize() const +{ + return mFrameSize; +} + +const Rectangle& Widget::getDimension() const +{ + return mDimension; +} + +const std::string& Widget::getActionEventId() const +{ + return mActionEventId; +} + +void Widget::setActionEventId(const std::string& actionEventId) +{ + mActionEventId = actionEventId; +} + +bool Widget::isFocused() const +{ + if (!mFocusHandler) + return false; + + return (mFocusHandler->isFocused(this)); +} + +void Widget::setFocusable(bool focusable) +{ + if (!focusable && isFocused()) + { + mFocusHandler->focusNone(); + } + + mFocusable = focusable; +} + +bool Widget::isFocusable() const +{ + return mFocusable && isVisible() && isEnabled(); +} + +void Widget::requestFocus() +{ + if (!mFocusHandler) + return; + + if (isFocusable()) + mFocusHandler->requestFocus(this); +} + +void Widget::requestMoveToTop() +{ + if (mParent) + mParent->moveToTop(this); +} + +void Widget::requestMoveToBottom() +{ + if (mParent) + mParent->moveToBottom(this); +} + +void Widget::setVisible(bool visible) +{ + if (!visible && isFocused()) + mFocusHandler->focusNone(); + + if (visible) + distributeShownEvent(); + else + distributeHiddenEvent(); + + mVisible = visible; +} + +void Widget::setBaseColor(const Color& color) +{ + mBaseColor = color; +} + +const Color& Widget::getBaseColor() const +{ + return mBaseColor; +} + +void Widget::setForegroundColor(const Color& color) +{ + mForegroundColor = color; +} + +const Color& Widget::getForegroundColor() const +{ + return mForegroundColor; +} + +void Widget::setBackgroundColor(const Color& color) +{ + mBackgroundColor = color; +} + +const Color& Widget::getBackgroundColor() const +{ + return mBackgroundColor; +} + +void Widget::setSelectionColor(const Color& color) +{ + mSelectionColor = color; +} + +const Color& Widget::getSelectionColor() const +{ + return mSelectionColor; +} + +void Widget::_setFocusHandler(FocusHandler* focusHandler) +{ + if (mFocusHandler) + { + releaseModalFocus(); + mFocusHandler->remove(this); + } + + if (focusHandler) + focusHandler->add(this); + + mFocusHandler = focusHandler; +} + +FocusHandler* Widget::_getFocusHandler() +{ + return mFocusHandler; +} + +void Widget::addActionListener(ActionListener* actionListener) +{ + mActionListeners.push_back(actionListener); +} + +void Widget::removeActionListener(ActionListener* actionListener) +{ + mActionListeners.remove(actionListener); +} + +void Widget::addDeathListener(DeathListener* deathListener) +{ + mDeathListeners.push_back(deathListener); +} + +void Widget::removeDeathListener(DeathListener* deathListener) +{ + mDeathListeners.remove(deathListener); +} + +void Widget::addKeyListener(KeyListener* keyListener) +{ + mKeyListeners.push_back(keyListener); +} + +void Widget::removeKeyListener(KeyListener* keyListener) +{ + mKeyListeners.remove(keyListener); +} + +void Widget::addFocusListener(FocusListener* focusListener) +{ + mFocusListeners.push_back(focusListener); +} + +void Widget::removeFocusListener(FocusListener* focusListener) +{ + mFocusListeners.remove(focusListener); +} + +void Widget::addMouseListener(MouseListener* mouseListener) +{ + mMouseListeners.push_back(mouseListener); +} + +void Widget::removeMouseListener(MouseListener* mouseListener) +{ + mMouseListeners.remove(mouseListener); +} + +void Widget::addWidgetListener(WidgetListener* widgetListener) +{ + mWidgetListeners.push_back(widgetListener); +} + +void Widget::removeWidgetListener(WidgetListener* widgetListener) +{ + mWidgetListeners.remove(widgetListener); +} + +void Widget::getAbsolutePosition(int& x, int& y) const +{ + if (!mParent) + { + x = mDimension.x; + y = mDimension.y; + return; + } + + int parentX; + int parentY; + + mParent->getAbsolutePosition(parentX, parentY); + + const Rectangle &rect = mParent->getChildrenArea(); + x = parentX + mDimension.x + rect.x; + y = parentY + mDimension.y + rect.y; +} + +Font* Widget::getFont() const +{ + if (!mCurrentFont) + return mGlobalFont; + return mCurrentFont; +} + +void Widget::setGlobalFont(Font* font) +{ + mGlobalFont = font; + + for (std::list::const_iterator iter = mWidgets.begin(); + iter != mWidgets.end(); ++iter) + { + if (!(*iter)->mCurrentFont) + (*iter)->fontChanged(); + } +} + +void Widget::setFont(Font* font) +{ + mCurrentFont = font; + fontChanged(); +} + +bool Widget::widgetExists(const Widget* widget) +{ + return mWidgetsSet.find(const_cast(widget)) + != mWidgetsSet.end(); +} + +bool Widget::isTabInEnabled() const +{ + return mTabIn; +} + +void Widget::setTabInEnabled(bool enabled) +{ + mTabIn = enabled; +} + +bool Widget::isTabOutEnabled() const +{ + return mTabOut; +} + +void Widget::setTabOutEnabled(bool enabled) +{ + mTabOut = enabled; +} + +void Widget::setSize(int width, int height) +{ + Rectangle newDimension = mDimension; + newDimension.width = width; + newDimension.height = height; + + setDimension(newDimension); +} + +void Widget::setEnabled(bool enabled) +{ + mEnabled = enabled; +} + +bool Widget::isEnabled() const +{ + return mEnabled && isVisible(); +} + +void Widget::requestModalFocus() +{ + if (!mFocusHandler) + return; + + mFocusHandler->requestModalFocus(this); +} + +void Widget::requestModalMouseInputFocus() +{ + if (!mFocusHandler) + return; + + mFocusHandler->requestModalMouseInputFocus(this); +} + +void Widget::releaseModalFocus() +{ + if (!mFocusHandler) + return; + + mFocusHandler->releaseModalFocus(this); +} + +void Widget::releaseModalMouseInputFocus() +{ + if (!mFocusHandler) + return; + + mFocusHandler->releaseModalMouseInputFocus(this); +} + +bool Widget::isModalFocused() const +{ + if (!mFocusHandler) + return false; + + if (mParent) + { + return (mFocusHandler->getModalFocused() == this) + || mParent->isModalFocused(); + } + + return mFocusHandler->getModalFocused() == this; +} + +bool Widget::isModalMouseInputFocused() const +{ + if (!mFocusHandler) + return false; + + if (mParent) + { + return (mFocusHandler->getModalMouseInputFocused() == this) + || mParent->isModalMouseInputFocused(); + } + + return mFocusHandler->getModalMouseInputFocused() == this; +} + +Widget *Widget::getWidgetAt(int x A_UNUSED, int y A_UNUSED) +{ + return nullptr; +} + +const std::list& Widget::_getMouseListeners() +{ + return mMouseListeners; +} + +const std::list& Widget::_getKeyListeners() +{ + return mKeyListeners; +} + +const std::list& Widget::_getFocusListeners() +{ + return mFocusListeners; +} + +Rectangle Widget::getChildrenArea() +{ + return Rectangle(0, 0, 0, 0); +} + +FocusHandler* Widget::_getInternalFocusHandler() +{ + return mInternalFocusHandler; +} + +void Widget::setInternalFocusHandler(FocusHandler* focusHandler) +{ + mInternalFocusHandler = focusHandler; +} + +void Widget::setId(const std::string& id) +{ + mId = id; +} + +const std::string& Widget::getId() +{ + return mId; +} + +void Widget::distributeResizedEvent() +{ + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++ iter) + { + Event event(this); + (*iter)->widgetResized(event); + } +} + +void Widget::distributeMovedEvent() +{ + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++ iter) + { + Event event(this); + (*iter)->widgetMoved(event); + } +} + +void Widget::distributeHiddenEvent() +{ + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++ iter) + { + Event event(this); + (*iter)->widgetHidden(event); + } +} + +void Widget::distributeActionEvent() +{ + for (ActionListenerIterator iter = mActionListeners.begin(); + iter != mActionListeners.end(); + ++iter) + { + ActionEvent actionEvent(this, mActionEventId); + (*iter)->action(actionEvent); + } +} + +void Widget::distributeShownEvent() +{ + for (WidgetListenerIterator iter = mWidgetListeners.begin(); + iter != mWidgetListeners.end(); + ++iter) + { + Event event(this); + (*iter)->widgetShown(event); + } +} + +void Widget::showPart(Rectangle rectangle) +{ + if (mParent) + mParent->showWidgetPart(this, rectangle); +} diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h new file mode 100644 index 000000000..08f1456b0 --- /dev/null +++ b/src/gui/widgets/widget.h @@ -0,0 +1,1228 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_WIDGETS_WIDGET_H +#define GUI_WIDGETS_WIDGET_H + +#include +#include +#include + +#include "gui/color.h" +#include "gui/rectangle.h" + +#include "gui/widgets/widget2.h" + +#include "localconsts.h" + +class ActionListener; +class DeathListener; +class FocusHandler; +class FocusListener; +class Font; +class Graphics; +class KeyListener; +class MouseListener; +class WidgetListener; + +/** + * Abstract class for widgets of Guichan. It contains basic functions + * every widget should have. + * + * NOTE: Functions begining with underscore "_" should not + * be overloaded unless you know what you are doing + * + * @author Olof Naessén + * @author Per Larsson. + * @since 0.1.0 + */ +class Widget : public Widget2 +{ + public: + /** + * Constructor. Resets member variables. Noteable, a widget is not + * focusable as default, therefore, widgets that are supposed to be + * focusable should overide this default in their own constructor. + */ + explicit Widget(const Widget2 *const widget); + + A_DELETE_COPY(Widget) + + /** + * Default destructor. + */ + virtual ~Widget(); + + /** + * Draws the widget. It is called by the parent widget when it is time + * for the widget to draw itself. The graphics object is set up so + * that all drawing is relative to the widget, i.e coordinate (0,0) is + * the top left corner of the widget. It is not possible to draw + * outside of a widget's dimension. + * + * @param graphics aA graphics object to draw with. + * @since 0.1.0 + */ + virtual void draw(Graphics* graphics) = 0; + + /** + * Called when a widget is given a chance to draw a frame around itself. + * The frame is not considered a part of the widget, it only allows a frame + * to be drawn around the widget, thus a frame will never be included when + * calculating if a widget should receive events from user input. Also + * a widget's frame will never be included when calculating a widget's + * position. + * + * The size of the frame is calculated using the widget's frame size. + * If a widget has a frame size of 10 pixels than the area the drawFrame + * function can draw to will be the size of the widget with an additional + * extension of 10 pixels in each direction. + * + * An example when drawFrame is a useful function is if a widget needs + * a glow around itself. + * + * @param graphics A graphics object to draw with. + * @see setFrameSize, getFrameSize + * @since 0.8.0 + */ + virtual void drawFrame(Graphics* graphics); + + /** + * Sets the size of the widget's frame. The frame is not considered a part of + * the widget, it only allows a frame to be drawn around the widget, thus a frame + * will never be included when calculating if a widget should receive events + * from user input. Also a widget's frame will never be included when calculating + * a widget's position. + * + * A frame size of 0 means that the widget has no frame. The default frame size + * is 0. + * + * @param frameSize The size of the widget's frame. + * @see getFrameSize, drawFrame + * @since 0.8.0 + */ + void setFrameSize(unsigned int frameSize); + + /** + * Gets the size of the widget's frame. The frame is not considered a part of + * the widget, it only allows a frame to be drawn around the widget, thus a frame + * will never be included when calculating if a widget should receive events + * from user input. Also a widget's frame will never be included when calculating + * a widget's position. + * + * A frame size of 0 means that the widget has no frame. The default frame size + * is 0. + * + * @return The size of the widget's frame. + * @see setFrameSize, drawFrame + * @since 0.8.0 + */ + unsigned int getFrameSize() const A_WARN_UNUSED; + + /** + * Called for all widgets in the gui each time Gui::logic is called. + * You can do logic stuff here like playing an animation. + * + * @see Gui::logic + * @since 0.1.0 + */ + virtual void logic() + { } + + /** + * Gets the widget's parent container. + * + * @return The widget's parent container. NULL if the widget + * has no parent. + * @since 0.1.0 + */ + virtual Widget* getParent() const A_WARN_UNUSED + { return mParent; } + + /** + * Sets the width of the widget. + * + * @param width The width of the widget. + * @see getWidth, setHeight, getHeight, setSize, + * setDimension, getDimensi + * @since 0.1.0 + */ + void setWidth(int width); + + /** + * Gets the width of the widget. + * + * @return The width of the widget. + * @see setWidth, setHeight, getHeight, setSize, + * setDimension, getDimension + * @since 0.1.0 + */ + int getWidth() const A_WARN_UNUSED + { return mDimension.width; } + + /** + * Sets the height of the widget. + * + * @param height The height of the widget. + * @see getHeight, setWidth, getWidth, setSize, + * setDimension, getDimension + * @since 0.1.0 + */ + void setHeight(int height); + + /** + * Gets the height of the widget. + * + * @return The height of the widget. + * @see setHeight, setWidth, getWidth, setSize, + * setDimension, getDimension + * @since 0.1.0 + */ + int getHeight() const A_WARN_UNUSED + { return mDimension.height; } + + /** + * Sets the size of the widget. + * + * @param width The width of the widget. + * @param height The height of the widget. + * @see setWidth, setHeight, getWidth, getHeight, + * setDimension, getDimension + * @since 0.1.0 + */ + void setSize(int width, int height); + + /** + * Sets the x coordinate of the widget. The coordinate is + * relateive to the widget's parent. + * + * @param x The x coordinate of the widget. + * @see getX, setY, getY, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + void setX(int x); + + /** + * Gets the x coordinate of the widget. The coordinate is + * relative to the widget's parent. + * + * @return The x coordinate of the widget. + * @see setX, setY, getY, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + int getX() const A_WARN_UNUSED + { return mDimension.x; } + + /** + * Sets the y coordinate of the widget. The coordinate is + * relative to the widget's parent. + * + * @param y The y coordinate of the widget. + * @see setY, setX, getX, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + void setY(int y); + + /** + * Gets the y coordinate of the widget. The coordinate is + * relative to the widget's parent. + * + * @return The y coordinate of the widget. + * @see setY, setX, getX, setPosition, setDimension, getDimension + * @since 0.1.0 + */ + int getY() const A_WARN_UNUSED + { return mDimension.y; } + + /** + * Sets position of the widget. The position is relative + * to the widget's parent. + * + * @param x The x coordinate of the widget. + * @param y The y coordinate of the widget. + * @see setX, getX, setY, getY, setDimension, getDimension + * @since 0.1.0 + */ + void setPosition(int x, int y); + + /** + * Sets the dimension of the widget. The dimension is + * relative to the widget's parent. + * + * @param dimension The dimension of the widget. + * @see getDimension, setX, getX, setY, getY, setPosition + * @since 0.1.0 + */ + void setDimension(const Rectangle& dimension); + + /** + * Gets the dimension of the widget. The dimension is + * relative to the widget's parent. + * + * @return The dimension of the widget. + * @see getDimension, setX, getX, setY, getY, setPosition + * @since 0.1.0 + */ + const Rectangle& getDimension() const A_WARN_UNUSED; + + /** + * Sets the widget to be fosusable, or not. + * + * @param focusable True if the widget should be focusable, + * false otherwise. + * @see isFocusable + * @since 0.1.0 + */ + void setFocusable(bool focusable); + + /** + * Checks if a widget is focsable. + * + * @return True if the widget should be focusable, false otherwise. + * @see setFocusable + * @since 0.1.0 + */ + bool isFocusable() const A_WARN_UNUSED; + + /** + * Checks if the widget is focused. + * + * @return True if the widget is focused, false otherwise. + * @since 0.1.0 + */ + virtual bool isFocused() const A_WARN_UNUSED; + + /** + * Sets the widget to enabled, or not. A disabled + * widget will never recieve mouse or key events. + * + * @param enabled True if widget should be enabled, + * false otherwise. + * @see isEnabled + * @since 0.1.0 + */ + void setEnabled(bool enabled); + + /** + * Checks if the widget is enabled. A disabled + * widget will never recieve mouse or key events. + * + * @return True if widget is enabled, false otherwise. + * @see setEnabled + * @since 0.1.0 + */ + bool isEnabled() const A_WARN_UNUSED; + + /** + * Sets the widget to be visible, or not. + * + * @param visible True if widget should be visible, false otherwise. + * @see isVisible + * @since 0.1.0 + */ + void setVisible(bool visible); + + /** + * Checks if the widget is visible. + * + * @return True if widget is be visible, false otherwise. + * @see setVisible + * @since 0.1.0 + */ + bool isVisible() const A_WARN_UNUSED + { return mVisible && (!mParent || mParent->isVisible()); } + + /** + * Sets the base color of the widget. + * + * @param color The baseground color. + * @see getBaseColor + * @since 0.1.0 + */ + void setBaseColor(const Color& color); + + /** + * Gets the base color. + * + * @return The base color. + * @see setBaseColor + * @since 0.1.0 + */ + const Color& getBaseColor() const A_WARN_UNUSED; + + /** + * Sets the foreground color. + * + * @param color The foreground color. + * @see getForegroundColor + * @since 0.1.0 + */ + void setForegroundColor(const Color& color); + + /** + * Gets the foreground color. + * + * @see setForegroundColor + * @since 0.1.0 + */ + const Color& getForegroundColor() const A_WARN_UNUSED; + + /** + * Sets the background color. + * + * @param color The background Color. + * @see setBackgroundColor + * @since 0.1.0 + */ + void setBackgroundColor(const Color& color); + + /** + * Gets the background color. + * + * @see setBackgroundColor + * @since 0.1.0 + */ + const Color& getBackgroundColor() const A_WARN_UNUSED; + + /** + * Sets the selection color. + * + * @param color The selection color. + * @see getSelectionColor + * @since 0.6.0 + */ + void setSelectionColor(const Color& color); + + /** + * Gets the selection color. + * + * @return The selection color. + * @see setSelectionColor + * @since 0.6.0 + */ + const Color& getSelectionColor() const A_WARN_UNUSED; + + /** + * Requests focus for the widget. A widget will only recieve focus + * if it is focusable. + */ + virtual void requestFocus(); + + /** + * Requests a move to the top in the parent widget. + */ + virtual void requestMoveToTop(); + + /** + * Requests a move to the bottom in the parent widget. + */ + virtual void requestMoveToBottom(); + + /** + * Sets the focus handler to be used. + * + * WARNING: This function is used internally and should not + * be called or overloaded unless you know what you + * are doing. + * + * @param focusHandler The focus handler to use. + * @see _getFocusHandler + * @since 0.1.0 + */ + virtual void _setFocusHandler(FocusHandler* focusHandler); + + /** + * Gets the focus handler used. + * + * WARNING: This function is used internally and should not + * be called or overloaded unless you know what you + * are doing. + * + * @return The focus handler used. + * @see _setFocusHandler + * @since 0.1.0 + */ + virtual FocusHandler* _getFocusHandler() A_WARN_UNUSED; + + /** + * Adds an action listener to the widget. When an action event + * is fired by the widget the action listeners of the widget + * will get notified. + * + * @param actionListener The action listener to add. + * @see removeActionListener + * @since 0.1.0 + */ + void addActionListener(ActionListener* actionListener); + + /** + * Removes an added action listener from the widget. + * + * @param actionListener The action listener to remove. + * @see addActionListener + * @since 0.1.0 + */ + void removeActionListener(ActionListener* actionListener); + + /** + * Adds a death listener to the widget. When a death event is + * fired by the widget the death listeners of the widget will + * get notified. + * + * @param deathListener The death listener to add. + * @see removeDeathListener + * @since 0.1.0 + */ + void addDeathListener(DeathListener* deathListener); + + /** + * Removes an added death listener from the widget. + * + * @param deathListener The death listener to remove. + * @see addDeathListener + * @since 0.1.0 + */ + void removeDeathListener(DeathListener* deathListener); + + /** + * Adds a mouse listener to the widget. When a mouse event is + * fired by the widget the mouse listeners of the widget will + * get notified. + * + * @param mouseListener The mouse listener to add. + * @see removeMouseListener + * @since 0.1.0 + */ + void addMouseListener(MouseListener* mouseListener); + + /** + * Removes an added mouse listener from the widget. + * + * @param mouseListener The mouse listener to remove. + * @see addMouseListener + * @since 0.1.0 + */ + void removeMouseListener(MouseListener* mouseListener); + + /** + * Adds a key listener to the widget. When a key event is + * fired by the widget the key listeners of the widget will + * get notified. + * + * @param keyListener The key listener to add. + * @see removeKeyListener + * @since 0.1.0 + */ + void addKeyListener(KeyListener* keyListener); + + /** + * Removes an added key listener from the widget. + * + * @param keyListener The key listener to remove. + * @see addKeyListener + * @since 0.1.0 + */ + void removeKeyListener(KeyListener* keyListener); + + /** + * Adds a focus listener to the widget. When a focus event is + * fired by the widget the key listeners of the widget will + * get notified. + * + * @param focusListener The focus listener to add. + * @see removeFocusListener + * @since 0.7.0 + */ + void addFocusListener(FocusListener* focusListener); + + /** + * Removes an added focus listener from the widget. + * + * @param focusListener The focus listener to remove. + * @see addFocusListener + * @since 0.7.0 + */ + void removeFocusListener(FocusListener* focusListener); + + /** + * Adds a widget listener to the widget. When a widget event is + * fired by the widget the key listeners of the widget will + * get notified. + * + * @param widgetListener The widget listener to add. + * @see removeWidgetListener + * @since 0.8.0 + */ + void addWidgetListener(WidgetListener* widgetListener); + + /** + * Removes an added widget listener from the widget. + * + * @param widgetListener The widget listener to remove. + * @see addWidgetListener + * @since 0.8.0 + */ + void removeWidgetListener(WidgetListener* widgetListener); + + /** + * Sets the action event identifier of the widget. The identifier is + * used to be able to identify which action has occured. + * + * NOTE: An action event identifier should not be used to identify a + * certain widget but rather a certain event in your application. + * Several widgets can have the same action event identifer. + * + * @param actionEventId The action event identifier. + * @see getActionEventId + * @since 0.6.0 + */ + void setActionEventId(const std::string& actionEventId); + + /** + * Gets the action event identifier of the widget. + * + * @return The action event identifier of the widget. + * @see setActionEventId + * @since 0.6.0 + */ + const std::string& getActionEventId() const; + + /** + * Gets the absolute position on the screen for the widget. + * + * @param x The absolute x coordinate will be stored in this parameter. + * @param y The absolute y coordinate will be stored in this parameter. + * @since 0.1.0 + */ + virtual void getAbsolutePosition(int& x, int& y) const; + + /** + * Sets the parent of the widget. A parent must be a BasicContainer. + * + * WARNING: This function is used internally and should not + * be called or overloaded unless you know what you + * are doing. + * + * @param parent The parent of the widget. + * @see getParent + * @since 0.1.0 + */ + virtual void _setParent(Widget* parent); + + /** + * Gets the font set for the widget. If no font has been set, + * the global font will be returned. If no global font has been set, + * the default font will be returend. + * + * @return The font set for the widget. + * @see setFont, setGlobalFont + * @since 0.1.0 + */ + Font *getFont() const A_WARN_UNUSED; + + /** + * Sets the global font to be used by default for all widgets. + * + * @param font The global font. + * @see getGlobalFont + * @since 0.1.0 + */ + static void setGlobalFont(Font* font); + + /** + * Sets the font for the widget. If NULL is passed, the global font + * will be used. + * + * @param font The font to set for the widget. + * @see getFont + * @since 0.1.0 + */ + void setFont(Font* font); + + /** + * Called when the font has changed. If the change is global, + * this function will only be called if the widget doesn't have a + * font already set. + * + * @since 0.1.0 + */ + virtual void fontChanged() + { } + + /** + * Checks if a widget exists or not, that is if it still exists + * an instance of the object. + * + * @param widget The widget to check. + * @return True if an instance of the widget exists, false otherwise. + * @since 0.1.0 + */ + static bool widgetExists(const Widget* widget) A_WARN_UNUSED; + + /** + * Checks if tab in is enabled. Tab in means that you can set focus + * to this widget by pressing the tab button. If tab in is disabled + * then the focus handler will skip this widget and focus the next + * in its focus order. + * + * @return True if tab in is enabled, false otherwise. + * @see setTabInEnabled + * @since 0.1.0 + */ + bool isTabInEnabled() const A_WARN_UNUSED; + + /** + * Sets tab in enabled, or not. Tab in means that you can set focus + * to this widget by pressing the tab button. If tab in is disabled + * then the FocusHandler will skip this widget and focus the next + * in its focus order. + * + * @param enabled True if tab in should be enabled, false otherwise. + * @see isTabInEnabled + * @since 0.1.0 + */ + void setTabInEnabled(bool enabled); + + /** + * Checks if tab out is enabled. Tab out means that you can lose + * focus to this widget by pressing the tab button. If tab out is + * disabled then the FocusHandler ignores tabbing and focus will + * stay with this widget. + * + * @return True if tab out is enabled, false otherwise. + * @see setTabOutEnabled + * @since 0.1.0 + */ + bool isTabOutEnabled() const A_WARN_UNUSED; + + /** + * Sets tab out enabled. Tab out means that you can lose + * focus to this widget by pressing the tab button. If tab out is + * disabled then the FocusHandler ignores tabbing and focus will + * stay with this widget. + * + * @param enabled True if tab out should be enabled, false otherwise. + * @see isTabOutEnabled + * @since 0.1.0 + */ + void setTabOutEnabled(bool enabled); + + /** + * Requests modal focus. When a widget has modal focus, only that + * widget and it's children may recieve input. + * + * @throws Exception if another widget already has modal focus. + * @see releaseModalFocus, isModalFocused + * @since 0.4.0 + */ + virtual void requestModalFocus(); + + /** + * Requests modal mouse input focus. When a widget has modal input focus + * that widget will be the only widget receiving input even if the input + * occurs outside of the widget and no matter what the input is. + * + * @throws Exception if another widget already has modal focus. + * @see releaseModalMouseInputFocus, isModalMouseInputFocused + * @since 0.6.0 + */ + virtual void requestModalMouseInputFocus(); + + /** + * Releases modal focus. Modal focus will only be released if the + * widget has modal focus. + * + * @see requestModalFocus, isModalFocused + * @since 0.4.0 + */ + virtual void releaseModalFocus(); + + /** + * Releases modal mouse input focus. Modal mouse input focus will only + * be released if the widget has modal mouse input focus. + * + * @see requestModalMouseInputFocus, isModalMouseInputFocused + * @since 0.6.0 + */ + virtual void releaseModalMouseInputFocus(); + + /** + * Checks if the widget or it's parent has modal focus. + * + * @return True if the widget has modal focus, false otherwise. + * @see requestModalFocus, releaseModalFocus + * @since 0.8.0 + */ + virtual bool isModalFocused() const A_WARN_UNUSED; + + /** + * Checks if the widget or it's parent has modal mouse input focus. + * + * @return True if the widget has modal mouse input focus, false + * otherwise. + * @see requestModalMouseInputFocus, releaseModalMouseInputFocus + * @since 0.8.0 + */ + virtual bool isModalMouseInputFocused() const A_WARN_UNUSED; + + /** + * Gets a widget from a certain position in the widget. + * This function is used to decide which gets mouse input, + * thus it can be overloaded to change that behaviour. + * + * NOTE: This always returns NULL if the widget is not + * a container. + * + * @param x The x coordinate of the widget to get. + * @param y The y coordinate of the widget to get. + * @return The widget at the specified coodinate, NULL + * if no widget is found. + * @since 0.6.0 + */ + virtual Widget *getWidgetAt(int x, int y) A_WARN_UNUSED; + + /** + * Gets the mouse listeners of the widget. + * + * @return The mouse listeners of the widget. + * @since 0.6.0 + */ + virtual const std::list& _getMouseListeners() + A_WARN_UNUSED; + + /** + * Gets the key listeners of the widget. + * + * @return The key listeners of the widget. + * @since 0.6.0 + */ + virtual const std::list& _getKeyListeners() + A_WARN_UNUSED; + + /** + * Gets the focus listeners of the widget. + * + * @return The focus listeners of the widget. + * @since 0.7.0 + */ + virtual const std::list& _getFocusListeners() + A_WARN_UNUSED; + + /** + * Gets the area of the widget occupied by the widget's children. + * By default this method returns an empty rectangle as not all + * widgets are containers. If you want to make a container this + * method should return the area where the children resides. This + * method is used when drawing children of a widget when computing + * clip rectangles for the children. + * + * An example of a widget that overloads this method is ScrollArea. + * A ScrollArea has a view of its contant and that view is the + * children area. The size of a ScrollArea's children area might + * vary depending on if the scroll bars of the ScrollArea is shown + * or not. + * + * @return The area of the widget occupied by the widget's children. + * @see BasicContainer + * @see BasicContainer::getChildrenArea + * @see BasicContainer::drawChildren + * @since 0.1.0 + */ + virtual Rectangle getChildrenArea() A_WARN_UNUSED; + + /** + * Gets the internal focus handler used. + * + * @return the internalFocusHandler used. If no internal focus handler + * is used, NULL will be returned. + * @see setInternalFocusHandler + * @since 0.1.0 + */ + virtual FocusHandler* _getInternalFocusHandler() A_WARN_UNUSED; + + /** + * Sets the internal focus handler. An internal focus handler is + * needed if both a widget in the widget and the widget itself + * should be foucsed at the same time. + * + * @param focusHandler The internal focus handler to be used. + * @see getInternalFocusHandler + * @since 0.1.0 + */ + void setInternalFocusHandler(FocusHandler* internalFocusHandler); + + /** + * Moves a widget to the top of this widget. The moved widget will be + * drawn above all other widgets in this widget. + * + * @param widget The widget to move to the top. + * @see moveToBottom + * @since 0.1.0 + */ + virtual void moveToTop(Widget* widget A_UNUSED) + { } + + /** + * Moves a widget in this widget to the bottom of this widget. + * The moved widget will be drawn below all other widgets in this widget. + * + * @param widget The widget to move to the bottom. + * @see moveToTop + * @since 0.1.0 + */ + virtual void moveToBottom(Widget* widget A_UNUSED) + { } + + /** + * Focuses the next widget in the widget. + * + * @see moveToBottom + * @since 0.1.0 + */ + virtual void focusNext() + { } + + /** + * Focuses the previous widget in the widget. + * + * @see moveToBottom + * @since 0.1.0 + */ + virtual void focusPrevious() + { } + + /** + * Tries to show a specific part of a widget by moving it. Used if the + * widget should act as a container. + * + * @param widget The target widget. + * @param area The area to show. + * @since 0.1.0 + */ + virtual void showWidgetPart(Widget* widget A_UNUSED, + Rectangle area A_UNUSED) + { } + + /** + * Sets an id of a widget. An id can be useful if a widget needs to be + * identified in a container. For example, if widgets are created by an + * XML document, a certain widget can be retrieved given that the widget + * has an id. + * + * @param id The id to set to the widget. + * @see getId, BasicContainer::findWidgetById + * @since 0.8.0 + */ + void setId(const std::string& id); + + /** + * Gets the id of a widget. An id can be useful if a widget needs to be + * identified in a container. For example, if widgets are created by an + * XML document, a certain widget can be retrieved given that the widget + * has an id. + * + * @param id The id to set to the widget. + * @see setId, BasicContainer::findWidgetById + * @since 0.8.0 + */ + const std::string& getId() A_WARN_UNUSED; + + /** + * Shows a certain part of a widget in the widget's parent. + * Used when widgets want a specific part to be visible in + * its parent. An example is a TextArea that wants a specific + * part of its text to be visible when a TextArea is a child + * of a ScrollArea. + * + * @param rectangle The rectangle to be shown. + * @since 0.8.0 + */ + virtual void showPart(Rectangle rectangle); + + protected: + /** + * Distributes an action event to all action listeners + * of the widget. + * + * @since 0.8.0 + */ + void distributeActionEvent(); + + /** + * Distributes resized events to all of the widget's listeners. + * + * @since 0.8.0 + */ + void distributeResizedEvent(); + + /** + * Distributes moved events to all of the widget's listeners. + * + * @since 0.8.0 + */ + void distributeMovedEvent(); + + /** + * Distributes hidden events to all of the widget's listeners. + * + * @since 0.8.0 + * @author Olof Naessén + */ + void distributeHiddenEvent(); + + /** + * Distributes shown events to all of the widget's listeners. + * + * @since 0.8.0 + * @author Olof Naessén + */ + void distributeShownEvent(); + + /** + * Typdef. + */ + typedef std::list MouseListenerList; + + /** + * Typdef. + */ + typedef MouseListenerList::iterator MouseListenerIterator; + + /** + * Holds the mouse listeners of the widget. + */ + MouseListenerList mMouseListeners; + + /** + * Typdef. + */ + typedef std::list KeyListenerList; + + /** + * Holds the key listeners of the widget. + */ + KeyListenerList mKeyListeners; + + /** + * Typdef. + */ + typedef KeyListenerList::iterator KeyListenerIterator; + + /** + * Typdef. + */ + typedef std::list ActionListenerList; + + /** + * Holds the action listeners of the widget. + */ + ActionListenerList mActionListeners; + + /** + * Typdef. + */ + typedef ActionListenerList::iterator ActionListenerIterator; + + /** + * Typdef. + */ + typedef std::list DeathListenerList; + + /** + * Holds the death listeners of the widget. + */ + DeathListenerList mDeathListeners; + + /** + * Typdef. + */ + typedef DeathListenerList::iterator DeathListenerIterator; + + /** + * Typdef. + */ + typedef std::list FocusListenerList; + + /** + * Holds the focus listeners of the widget. + */ + FocusListenerList mFocusListeners; + + /** + * Typdef. + */ + typedef FocusListenerList::iterator FocusListenerIterator; + + typedef std::list WidgetListenerList; + + /** + * Holds the widget listeners of the widget. + */ + WidgetListenerList mWidgetListeners; + + /** + * Typdef. + */ + typedef WidgetListenerList::iterator WidgetListenerIterator; + + /** + * Holds the foreground color of the widget. + */ + Color mForegroundColor; + + /** + * Holds the background color of the widget. + */ + Color mBackgroundColor; + + /** + * Holds the base color of the widget. + */ + Color mBaseColor; + + /** + * Holds the selection color of the widget. + */ + Color mSelectionColor; + + /** + * Holds the focus handler used by the widget. + */ + FocusHandler* mFocusHandler; + + /** + * Holds the focus handler used by the widget. NULL + * if no internal focus handler is used. + */ + FocusHandler* mInternalFocusHandler; + + /** + * Holds the parent of the widget. NULL if the widget + * has no parent. + */ + Widget* mParent; + + /** + * Holds the dimension of the widget. + */ + Rectangle mDimension; + + /** + * Holds the frame size of the widget. + */ + unsigned int mFrameSize; + + /** + * Holds the action event of the widget. + */ + std::string mActionEventId; + + /** + * True if the widget focusable, false otherwise. + */ + bool mFocusable; + + /** + * True if the widget visible, false otherwise. + */ + bool mVisible; + + /** + * True if the widget has tab in enabled, false otherwise. + */ + bool mTabIn; + + /** + * True if the widget has tab in enabled, false otherwise. + */ + bool mTabOut; + + /** + * True if the widget is enabled, false otherwise. + */ + bool mEnabled; + + /** + * Holds the id of the widget. + */ + std::string mId; + + /** + * Holds the font used by the widget. + */ + Font* mCurrentFont; + + /** + * Holds the global font used by the widget. + */ + static Font* mGlobalFont; + + /** + * Holds a list of all instances of widgets. + */ + static std::list mWidgets; + + static std::set mWidgetsSet; +}; + +#endif // GUI_WIDGETS_WIDGET_H diff --git a/src/gui/widgets/widgetgroup.cpp b/src/gui/widgets/widgetgroup.cpp index 4a0065ca8..07c4df43c 100644 --- a/src/gui/widgets/widgetgroup.cpp +++ b/src/gui/widgets/widgetgroup.cpp @@ -67,7 +67,7 @@ void WidgetGroup::action(const ActionEvent &event) } } -void WidgetGroup::add(gcn::Widget *const widget, const int spacing) +void WidgetGroup::add(Widget *const widget, const int spacing) { if (!widget) return; diff --git a/src/gui/widgets/widgetgroup.h b/src/gui/widgets/widgetgroup.h index 37523fcdc..051234cda 100644 --- a/src/gui/widgets/widgetgroup.h +++ b/src/gui/widgets/widgetgroup.h @@ -42,7 +42,7 @@ class WidgetGroup : public Container, void action(const ActionEvent &event) override; - virtual void add(gcn::Widget *const widget, + virtual void add(Widget *const widget, const int spacing); virtual void clear(); diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index cccb1cdc7..8388ae64e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -343,7 +343,7 @@ void Window::setContentSize(int width, int height) setSize(width, height); } -void Window::setLocationRelativeTo(const gcn::Widget *const widget) +void Window::setLocationRelativeTo(const Widget *const widget) { if (!widget) return; @@ -360,7 +360,7 @@ void Window::setLocationRelativeTo(const gcn::Widget *const widget) - mDimension.height) / 2 - y)); } -void Window::setLocationHorisontallyRelativeTo(const gcn::Widget *const widget) +void Window::setLocationHorisontallyRelativeTo(const Widget *const widget) { if (!widget) return; @@ -1165,7 +1165,7 @@ void Window::clearLayout() } } -LayoutCell &Window::place(const int x, const int y, gcn::Widget *const wg, +LayoutCell &Window::place(const int x, const int y, Widget *const wg, const int w, const int h) { add(wg); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 10c9123be..50babfce4 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -87,12 +87,12 @@ class Window : public gcn::Window, /** * Sets the location relative to the given widget. */ - void setLocationRelativeTo(const gcn::Widget *const widget); + void setLocationRelativeTo(const Widget *const widget); /** * Sets the location relative to the given widget (only horisontally) */ - void setLocationHorisontallyRelativeTo(const gcn::Widget + void setLocationHorisontallyRelativeTo(const Widget *const widget); /** @@ -370,7 +370,7 @@ class Window : public gcn::Window, /** * Adds a widget to the window and sets it at given cell. */ - LayoutCell &place(const int x, const int y, gcn::Widget *const wg, + LayoutCell &place(const int x, const int y, Widget *const wg, const int w = 1, const int h = 1); /** diff --git a/src/gui/widgets/windowcontainer.cpp b/src/gui/widgets/windowcontainer.cpp index 5adde3cae..a9b556410 100644 --- a/src/gui/widgets/windowcontainer.cpp +++ b/src/gui/widgets/windowcontainer.cpp @@ -42,7 +42,7 @@ void WindowContainer::slowLogic() mDeathList.clear(); } -void WindowContainer::scheduleDelete(gcn::Widget *const widget) +void WindowContainer::scheduleDelete(Widget *const widget) { if (widget) mDeathList.push_back(widget); @@ -58,8 +58,8 @@ void WindowContainer::adjustAfterResize(const int oldScreenWidth, } } -void WindowContainer::moveWidgetAfter(gcn::Widget *const after, - gcn::Widget *const widget) +void WindowContainer::moveWidgetAfter(Widget *const after, + Widget *const widget) { const WidgetListIterator widgetIter = std::find( mWidgets.begin(), mWidgets.end(), widget); diff --git a/src/gui/widgets/windowcontainer.h b/src/gui/widgets/windowcontainer.h index d940a4e91..a822fadb5 100644 --- a/src/gui/widgets/windowcontainer.h +++ b/src/gui/widgets/windowcontainer.h @@ -44,7 +44,7 @@ class WindowContainer : public Container * Schedule a widget for deletion. It will be deleted at the start of * the next logic update. */ - void scheduleDelete(gcn::Widget *const widget); + void scheduleDelete(Widget *const widget); /** * Ensures that all visible windows are on the screen after the screen @@ -53,8 +53,8 @@ class WindowContainer : public Container void adjustAfterResize(const int oldScreenWidth, const int oldScreenHeight); - void moveWidgetAfter(gcn::Widget *const before, - gcn::Widget *const widget); + void moveWidgetAfter(Widget *const before, + Widget *const widget); #ifdef USE_PROFILER void draw(Graphics* graphics); @@ -64,7 +64,7 @@ class WindowContainer : public Container /** * List of widgets that are scheduled to be deleted. */ - typedef std::vector Widgets; + typedef std::vector Widgets; typedef Widgets::iterator WidgetIterator; Widgets mDeathList; }; diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index 3bdebff71..d1fc0e7bd 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -125,7 +125,7 @@ public: continue; const Being *const player = mPlayers.at(r); - gcn::Widget *widget = new Label(this, player->getName()); + Widget *widget = new Label(this, player->getName()); mWidgets.push_back(widget); @@ -235,14 +235,14 @@ public: { } - gcn::Widget *getElementAt(const int row, const int column) const + Widget *getElementAt(const int row, const int column) const { return mWidgets[WIDGET_AT(row, column)]; } void freeWidgets() { - for (std::vector::const_iterator it = mWidgets.begin(); + for (std::vector::const_iterator it = mWidgets.begin(); it != mWidgets.end(); ++it) { delete *it; @@ -253,7 +253,7 @@ public: protected: std::vector mPlayers; - std::vector mWidgets; + std::vector mWidgets; }; diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 12a78ce10..d67c15bf0 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -210,7 +210,7 @@ void CharSelectDialog::postInit() void CharSelectDialog::action(const ActionEvent &event) { // Check if a button of a character was pressed - const gcn::Widget *const sourceParent = event.getSource()->getParent(); + const Widget *const sourceParent = event.getSource()->getParent(); int selected = -1; for (unsigned int i = 0, sz = static_cast( mCharacterEntries.size()); i < sz; ++i) diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 1754ca0bf..acd4c50bd 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -424,7 +424,7 @@ void ChatWindow::adjustTabSize() const ChatTab *const tab = getFocused(); if (tab) { - gcn::Widget *const content = tab->mScrollArea; + Widget *const content = tab->mScrollArea; if (content) { const int contentFrame2 = 2 * content->getFrameSize(); diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index bd6719df9..0b0e6c6de 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -593,7 +593,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event) void InventoryWindow::mouseMoved(MouseEvent &event) { Window::mouseMoved(event); - const gcn::Widget *const src = event.getSource(); + const Widget *const src = event.getSource(); if (src == mSlotsBar || src == mWeightBar) { const int x = event.getX(); diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 86b4b9ba3..3dbfa566d 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -1261,7 +1261,7 @@ public: setVisible(false); } - void show(gcn::Widget *parent) + void show(Widget *parent) { if (!parent) return; -- cgit v1.2.3-70-g09d2 From 5fc6d9e0f9637e3aaa71972478bee9febbe78ca7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 16:26:52 +0300 Subject: Move listmodel into gui/modesl directory. --- Android.mk | 1 + src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/base/listmodel.hpp | 106 ------------------------------- src/gui/base/widgets/listbox.cpp | 2 +- src/gui/base/widgets/listbox.hpp | 3 +- src/gui/models/listmodel.h | 103 ++++++++++++++++++++++++++++++ src/gui/popups/popupmenu.cpp | 4 +- src/gui/popups/popupmenu.h | 8 +-- src/gui/userpalette.h | 4 +- src/gui/widgets/avatarlistbox.h | 4 +- src/gui/widgets/colormodel.h | 4 +- src/gui/widgets/colorpage.cpp | 2 +- src/gui/widgets/colorpage.h | 2 +- src/gui/widgets/dropdown.cpp | 12 ++-- src/gui/widgets/dropdown.h | 12 ++-- src/gui/widgets/extendedlistbox.cpp | 4 +- src/gui/widgets/extendedlistbox.h | 2 +- src/gui/widgets/extendedlistmodel.h | 4 +- src/gui/widgets/listbox.cpp | 4 +- src/gui/widgets/listbox.h | 7 +- src/gui/widgets/namesmodel.h | 4 +- src/gui/widgets/popuplist.cpp | 4 +- src/gui/widgets/popuplist.h | 14 ++-- src/gui/widgets/setupitem.cpp | 12 ++-- src/gui/widgets/setupitem.h | 22 +++---- src/gui/widgets/shopitems.h | 4 +- src/gui/widgets/shoplistbox.cpp | 6 +- src/gui/widgets/shoplistbox.h | 4 +- src/gui/widgets/skillmodel.h | 4 +- src/gui/widgets/sliderlist.cpp | 4 +- src/gui/widgets/sliderlist.h | 10 +-- src/gui/widgets/tabs/setup_audio.h | 2 +- src/gui/widgets/tabs/setup_input.cpp | 4 +- src/gui/widgets/tabs/setup_relations.cpp | 4 +- src/gui/widgets/tabs/setup_relations.h | 8 +-- src/gui/widgets/tabs/setup_theme.cpp | 2 +- src/gui/widgets/tabs/setup_video.cpp | 6 +- src/gui/windows/buydialog.cpp | 2 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/editserverdialog.h | 4 +- src/gui/windows/inventorywindow.cpp | 4 +- src/gui/windows/itemamountwindow.cpp | 4 +- src/gui/windows/logindialog.cpp | 6 +- src/gui/windows/serverdialog.h | 4 +- src/gui/windows/textcommandeditor.cpp | 8 +-- src/gui/windows/worldselectdialog.cpp | 4 +- 47 files changed, 207 insertions(+), 237 deletions(-) delete mode 100644 src/gui/base/listmodel.hpp create mode 100644 src/gui/models/listmodel.h (limited to 'src') diff --git a/Android.mk b/Android.mk index 5622bed69..2f9dad11c 100644 --- a/Android.mk +++ b/Android.mk @@ -32,6 +32,7 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \ $(wildcard $(LOCAL_PATH)/src/being/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/events/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/gui/*.cpp) \ + $(wildcard $(LOCAL_PATH)/src/gui/models/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/gui/popups/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/gui/widgets/*.cpp) \ $(wildcard $(LOCAL_PATH)/src/gui/widgets/tabs/*.cpp) \ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cfab9cccb..497b66cd9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -776,7 +776,7 @@ SET(SRCS input/key.h events/keyevent.h listeners/keylistener.h - gui/base/listmodel.hpp + gui/models/listmodel.h events/mouseevent.h listeners/mouselistener.h gui/rectangle.h diff --git a/src/Makefile.am b/src/Makefile.am index eba67d244..b7f6e8bc4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -162,7 +162,7 @@ manaplus_SOURCES += events/actionevent.h \ input/key.h \ events/keyevent.h \ listeners/keylistener.h \ - gui/base/listmodel.hpp \ + gui/models/listmodel.h \ events/mouseevent.h \ listeners/mouselistener.h \ gui/rectangle.h \ diff --git a/src/gui/base/listmodel.hpp b/src/gui/base/listmodel.hpp deleted file mode 100644 index 4b98f46fe..000000000 --- a/src/gui/base/listmodel.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_LISTMODEL_HPP -#define GCN_LISTMODEL_HPP - -#include - -#include "localconsts.h" - -namespace gcn -{ - /** - * An interface for a model that represents a list. It is - * used in certain widgets, like the ListBox, to handle a - * lists with string elements. If you want to use widgets - * like ListBox, make a derived class from this class that - * represents your list. - */ - class ListModel - { - public: - /** - * Destructor. - */ - virtual ~ListModel() - { } - - /** - * Gets the number of elements in the list. - * - * @return The number of elements in the list - */ - virtual int getNumberOfElements() A_WARN_UNUSED = 0; - - /** - * Gets an element at a certain index in the list. - * - * @param i An index in the list. - * @return An element as a string at the a certain index. - */ - virtual std::string getElementAt(int i) A_WARN_UNUSED = 0; - }; -} // namespace gcn - -#endif // end GCN_LISTMODEL_HPP diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 9aca373b9..62a3062a5 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -69,7 +69,7 @@ #include "gui/font.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "listeners/selectionlistener.h" diff --git a/src/gui/base/widgets/listbox.hpp b/src/gui/base/widgets/listbox.hpp index 4046f5ddf..079e5a7d5 100644 --- a/src/gui/base/widgets/listbox.hpp +++ b/src/gui/base/widgets/listbox.hpp @@ -71,12 +71,11 @@ #include "listeners/keylistener.h" #include "listeners/mouselistener.h" +class ListModel; class SelectionListener; namespace gcn { - class ListModel; - /** * An implementation of a list box where an item can be selected. * diff --git a/src/gui/models/listmodel.h b/src/gui/models/listmodel.h new file mode 100644 index 000000000..dfce6d4d5 --- /dev/null +++ b/src/gui/models/listmodel.h @@ -0,0 +1,103 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_MODELS_LISTMODEL_H +#define GUI_MODELS_LISTMODEL_H + +#include + +#include "localconsts.h" + +/** + * An interface for a model that represents a list. It is + * used in certain widgets, like the ListBox, to handle a + * lists with string elements. If you want to use widgets + * like ListBox, make a derived class from this class that + * represents your list. + */ +class ListModel +{ + public: + /** + * Destructor. + */ + virtual ~ListModel() + { } + + /** + * Gets the number of elements in the list. + * + * @return The number of elements in the list + */ + virtual int getNumberOfElements() A_WARN_UNUSED = 0; + + /** + * Gets an element at a certain index in the list. + * + * @param i An index in the list. + * @return An element as a string at the a certain index. + */ + virtual std::string getElementAt(int i) A_WARN_UNUSED = 0; +}; + +#endif // GUI_MODELS_LISTMODEL_H diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index a37994884..3905d91e6 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -81,7 +81,7 @@ #include "utils/gettext.h" #include "utils/process.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "debug.h" @@ -2685,7 +2685,7 @@ void PopupMenu::addPickupFilter(const std::string &name) } void PopupMenu::showPopup(const int x, const int y, - gcn::ListModel *const model) + ListModel *const model) { if (!model) return; diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h index 1ce274122..7eb38dc15 100644 --- a/src/gui/popups/popupmenu.h +++ b/src/gui/popups/popupmenu.h @@ -37,6 +37,7 @@ class Button; class ChatTab; class FloorItem; class Item; +class ListModel; class MapItem; class ScrollArea; class TextCommand; @@ -45,11 +46,6 @@ class TextField; class ProgressBar; class Window; -namespace gcn -{ - class ListModel; -} - class RenameListener final : public ActionListener { public: @@ -176,7 +172,7 @@ class PopupMenu final : public Popup, public LinkHandler void showChangePos(const int x, const int y); - void showPopup(const int x, const int y, gcn::ListModel *const model); + void showPopup(const int x, const int y, ListModel *const model); void showTextFieldPopup(int x, int y, TextField *const input); diff --git a/src/gui/userpalette.h b/src/gui/userpalette.h index e37eee0ca..7bab5bed9 100644 --- a/src/gui/userpalette.h +++ b/src/gui/userpalette.h @@ -26,12 +26,12 @@ #include "gui/palette.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" /** * Class controlling the game's color palette. */ -class UserPalette final : public Palette, public gcn::ListModel +class UserPalette final : public Palette, public ListModel { public: /** List of all colors that are configurable. */ diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index e2ab3bf83..e98cee368 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -28,13 +28,13 @@ #include "gui/widgets/listbox.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include class Image; -class AvatarListModel : public gcn::ListModel +class AvatarListModel : public ListModel { public: virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0; diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h index 7386a856b..ba68e94e2 100644 --- a/src/gui/widgets/colormodel.h +++ b/src/gui/widgets/colormodel.h @@ -23,7 +23,7 @@ #include "utils/stringvector.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "localconsts.h" @@ -42,7 +42,7 @@ struct ColorPair const Color* color2; }; -class ColorModel : public gcn::ListModel +class ColorModel : public ListModel { public: ColorModel(); diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 2bc085208..8196dead4 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -27,7 +27,7 @@ #include "debug.h" ColorPage::ColorPage(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const std::string &skin) : ListBox(widget, listModel, skin) { diff --git a/src/gui/widgets/colorpage.h b/src/gui/widgets/colorpage.h index 84a3011a9..88182e4f2 100644 --- a/src/gui/widgets/colorpage.h +++ b/src/gui/widgets/colorpage.h @@ -29,7 +29,7 @@ class ColorPage final : public ListBox { public: ColorPage(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const std::string &skin); A_DELETE_COPY(ColorPage) diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 63f102f5a..ec9a2e22f 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -53,7 +53,7 @@ static std::string const dropdownFiles[2] = }; DropDown::DropDown(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const bool extended, const bool modal, ActionListener *const listener, @@ -232,7 +232,7 @@ void DropDown::draw(Graphics* graphics) mHighlightColor.a = alpha; mShadowColor.a = alpha; - gcn::ListModel *const model = mPopup->getListModel(); + ListModel *const model = mPopup->getListModel(); if (model && mPopup->getSelected() >= 0) { Font *const font = getFont(); @@ -418,7 +418,7 @@ void DropDown::mouseWheelMovedDown(MouseEvent& mouseEvent) void DropDown::setSelectedString(const std::string &str) { - gcn::ListModel *const listModel = mPopup->getListModel(); + ListModel *const listModel = mPopup->getListModel(); if (!listModel) return; @@ -434,7 +434,7 @@ void DropDown::setSelectedString(const std::string &str) std::string DropDown::getSelectedString() const { - gcn::ListModel *const listModel = mPopup->getListModel(); + ListModel *const listModel = mPopup->getListModel(); if (!listModel) return ""; @@ -491,7 +491,7 @@ void DropDown::setSelected(int selected) mPopup->setSelected(selected); } -void DropDown::setListModel(gcn::ListModel *const listModel) +void DropDown::setListModel(ListModel *const listModel) { mPopup->setListModel(listModel); @@ -501,7 +501,7 @@ void DropDown::setListModel(gcn::ListModel *const listModel) adjustHeight(); } -gcn::ListModel *DropDown::getListModel() +ListModel *DropDown::getListModel() { return mPopup->getListModel(); } diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index 81e3b6e8f..b8c3e7150 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -34,14 +34,10 @@ #include "localconsts.h" class Image; +class ListModel; class PopupList; class Skin; -namespace gcn -{ - class ListModel; -} - /** * A drop down box from which you can select different values. * @@ -66,7 +62,7 @@ class DropDown final : public ActionListener, * @see ListModel, ScrollArea, ListBox. */ DropDown(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const bool extended = false, const bool modal = false, ActionListener *const listener = nullptr, @@ -121,9 +117,9 @@ class DropDown final : public ActionListener, void setSelected(int selected); - void setListModel(gcn::ListModel *const listModel); + void setListModel(ListModel *const listModel); - gcn::ListModel *getListModel(); + ListModel *getListModel(); void addSelectionListener(SelectionListener* listener); diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 53b7c7060..c507f986c 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -24,14 +24,14 @@ #include "gui/font.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "render/graphics.h" #include "debug.h" ExtendedListBox::ExtendedListBox(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const std::string &skin, const int rowHeight) : ListBox(widget, listModel, skin), diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 9fa14fa9e..ae94cde02 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -48,7 +48,7 @@ class ExtendedListBox final : public ListBox * Constructor. */ ExtendedListBox(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const std::string &skin, const int rowHeight = 13); diff --git a/src/gui/widgets/extendedlistmodel.h b/src/gui/widgets/extendedlistmodel.h index 0b9c4d819..c3cd26b90 100644 --- a/src/gui/widgets/extendedlistmodel.h +++ b/src/gui/widgets/extendedlistmodel.h @@ -23,9 +23,9 @@ #include "resources/image.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" -class ExtendedListModel : public gcn::ListModel +class ExtendedListModel : public ListModel { public: virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0; diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index ebe1ca279..949c52455 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -32,7 +32,7 @@ #include "gui/font.h" #include "gui/gui.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "render/graphics.h" @@ -41,7 +41,7 @@ float ListBox::mAlpha = 1.0; ListBox::ListBox(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const std::string &skin) : gcn::ListBox(widget, listModel), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 61e1596f7..0c3a62609 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -33,13 +33,10 @@ class Skin; class KeyEvent; +class ListModel; class MouseEvent; class Widget2; -namespace gcn -{ - class ListModel; -} /** * A list box, meant to be used inside a scroll area. Same as the Guichan list * box except this one doesn't have a background, instead completely relying @@ -54,7 +51,7 @@ class ListBox : public gcn::ListBox * Constructor. */ ListBox(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, const std::string &skin); A_DELETE_COPY(ListBox) diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h index 5e8b47d23..4018a3755 100644 --- a/src/gui/widgets/namesmodel.h +++ b/src/gui/widgets/namesmodel.h @@ -23,11 +23,11 @@ #include "utils/stringvector.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "localconsts.h" -class NamesModel : public gcn::ListModel +class NamesModel : public ListModel { public: NamesModel(); diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index 8ad4bd0c4..cfb973384 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -29,7 +29,7 @@ #include "debug.h" PopupList::PopupList(DropDown *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, bool extended, bool modal): Popup("PopupList", "popuplist.xml"), FocusListener(), @@ -112,7 +112,7 @@ int PopupList::getSelected() const return mListBox->getSelected(); } -void PopupList::setListModel(gcn::ListModel *const model) +void PopupList::setListModel(ListModel *const model) { if (mListBox) mListBox->setListModel(model); diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index a495d7c46..32a9dfc47 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -29,19 +29,15 @@ class DropDown; class ListBox; +class ListModel; class ScrollArea; -namespace gcn -{ - class ListModel; -} - class PopupList final : public Popup, public FocusListener { public: PopupList(DropDown *const widget, - gcn::ListModel *const listModel, bool extended, + ListModel *const listModel, bool extended, bool modal = false); ~PopupList(); @@ -58,9 +54,9 @@ class PopupList final : public Popup, int getSelected() const; - void setListModel(gcn::ListModel *const model); + void setListModel(ListModel *const model); - gcn::ListModel *getListModel() const + ListModel *getListModel() const { return mListModel; } void adjustSize(); @@ -74,7 +70,7 @@ class PopupList final : public Popup, void mouseReleased(MouseEvent& mouseEvent) override final; private: - gcn::ListModel *mListModel; + ListModel *mListModel; ListBox *mListBox; ScrollArea *mScrollArea; DropDown *mDropDown; diff --git a/src/gui/widgets/setupitem.cpp b/src/gui/widgets/setupitem.cpp index 3e40b902e..218efe8a2 100644 --- a/src/gui/widgets/setupitem.cpp +++ b/src/gui/widgets/setupitem.cpp @@ -625,7 +625,7 @@ SetupItemDropDown::SetupItemDropDown(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width, const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), @@ -644,7 +644,7 @@ SetupItemDropDown::SetupItemDropDown(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width, const std::string &restrict def, const bool mainConfig) : @@ -1004,7 +1004,7 @@ SetupItemSliderList::SetupItemSliderList(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width, const bool onTheFly, const bool mainConfig) : SetupItem(text, description, keyName, parent, eventName, mainConfig), @@ -1024,7 +1024,7 @@ SetupItemSliderList::SetupItemSliderList(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const std::string &restrict def, const int width, const bool onTheFly, @@ -1109,7 +1109,7 @@ SetupItemSound::SetupItemSound(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width, const bool onTheFly, const bool mainConfig) : SetupItemSliderList(text, description, keyName, parent, eventName, @@ -1147,7 +1147,7 @@ SetupItemSliderInt::SetupItemSliderInt(const std::string &restrict text, const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int min, const int width, const bool onTheFly, diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 18e838cdf..51f2eb94e 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -36,16 +36,12 @@ class EditDialog; class HorizontContainer; class IntTextField; class Label; +class ListModel; class SetupTabScroll; class Slider; class SliderList; class TextField; -namespace gcn -{ - class ListModel; -} - class SetupItem : public ActionListener, public Widget2 { @@ -315,7 +311,7 @@ class SetupItemDropDown final : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width, const bool mainConfig = true); SetupItemDropDown(const std::string &restrict text, @@ -323,7 +319,7 @@ class SetupItemDropDown final : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width, const std::string &restrict def, const bool mainConfig = true); @@ -341,7 +337,7 @@ class SetupItemDropDown final : public SetupItem protected: HorizontContainer *mHorizont; Label *mLabel; - gcn::ListModel *mModel; + ListModel *mModel; DropDown *mDropDown; int mWidth; }; @@ -483,7 +479,7 @@ class SetupItemSliderList : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width = 150, const bool onTheFly = false, const bool mainConfig = true); @@ -492,7 +488,7 @@ class SetupItemSliderList : public SetupItem const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const std::string &restrict def, const int width = 150, const bool onTheFly = false, @@ -501,7 +497,7 @@ class SetupItemSliderList : public SetupItem HorizontContainer *mHorizont; Label *mLabel; SliderList *mSlider; - gcn::ListModel *mModel; + ListModel *mModel; int mWidth; bool mOnTheFly; }; @@ -514,7 +510,7 @@ class SetupItemSound final : public SetupItemSliderList const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int width = 150, const bool onTheFly = false, const bool mainConfig = true); @@ -537,7 +533,7 @@ class SetupItemSliderInt final : public SetupItemSliderList const std::string &restrict keyName, SetupTabScroll *restrict const parent, const std::string &restrict eventName, - gcn::ListModel *restrict const model, + ListModel *restrict const model, const int min, const int width = 150, const bool onTheFly = false, diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h index 54de95cc0..d1fa1ca98 100644 --- a/src/gui/widgets/shopitems.h +++ b/src/gui/widgets/shopitems.h @@ -23,7 +23,7 @@ #ifndef GUI_WIDGETS_SHOPITEMS_H #define GUI_WIDGETS_SHOPITEMS_H -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include #include @@ -41,7 +41,7 @@ class ShopItem; * * This functionality can be enabled in the constructor. */ -class ShopItems final : public gcn::ListModel +class ShopItems final : public ListModel { public: /** diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 28af43cec..ff45e5297 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -36,14 +36,14 @@ #include "resources/image.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "debug.h" const int ITEM_ICON_SIZE = 32; ShopListBox::ShopListBox(const Widget2 *const widget, - gcn::ListModel *const listModel) : + ListModel *const listModel) : ListBox(widget, listModel, "shoplistbox.xml"), mPlayerMoney(0), mShopItems(nullptr), @@ -60,7 +60,7 @@ ShopListBox::ShopListBox(const Widget2 *const widget, } ShopListBox::ShopListBox(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, ShopItems *const shopListModel) : ListBox(widget, listModel, "shoplistbox.xml"), mPlayerMoney(0), diff --git a/src/gui/widgets/shoplistbox.h b/src/gui/widgets/shoplistbox.h index 38e209c33..17c1ed4d5 100644 --- a/src/gui/widgets/shoplistbox.h +++ b/src/gui/widgets/shoplistbox.h @@ -42,13 +42,13 @@ class ShopListBox final : public ListBox * Constructor. */ ShopListBox(const Widget2 *const widget, - gcn::ListModel *const listModel); + ListModel *const listModel); /** * Constructor with shopitems */ ShopListBox(const Widget2 *const widget, - gcn::ListModel *const listModel, + ListModel *const listModel, ShopItems *const shopListModel); A_DELETE_COPY(ShopListBox) diff --git a/src/gui/widgets/skillmodel.h b/src/gui/widgets/skillmodel.h index b1a682fd9..38e36c2f1 100644 --- a/src/gui/widgets/skillmodel.h +++ b/src/gui/widgets/skillmodel.h @@ -24,13 +24,13 @@ #define GUI_WIDGETS_SKILLMODEL_H #include "gui/widgets/skillinfo.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include #include "localconsts.h" -class SkillModel final : public gcn::ListModel +class SkillModel final : public ListModel { public: SkillModel(); diff --git a/src/gui/widgets/sliderlist.cpp b/src/gui/widgets/sliderlist.cpp index c5791f1c2..03f0c4ed2 100644 --- a/src/gui/widgets/sliderlist.cpp +++ b/src/gui/widgets/sliderlist.cpp @@ -23,7 +23,7 @@ #include "gui/font.h" #include "gui/gui.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "gui/widgets/button.h" #include "gui/widgets/label.h" @@ -35,7 +35,7 @@ static const int buttonSpace = 30; static const int sliderHeight = 30; SliderList::SliderList(const Widget2 *const widget, - gcn::ListModel *const listModel) : + ListModel *const listModel) : Container(widget), ActionListener(), MouseListener(), diff --git a/src/gui/widgets/sliderlist.h b/src/gui/widgets/sliderlist.h index 9adba8080..84f96ebe4 100644 --- a/src/gui/widgets/sliderlist.h +++ b/src/gui/widgets/sliderlist.h @@ -30,11 +30,7 @@ class Button; class Label; - -namespace gcn -{ - class ListModel; -} +class ListModel; class SliderList final : public Container, public ActionListener, @@ -42,7 +38,7 @@ class SliderList final : public Container, { public: SliderList(const Widget2 *const widget, - gcn::ListModel *const listModel); + ListModel *const listModel); A_DELETE_COPY(SliderList) @@ -81,7 +77,7 @@ class SliderList final : public Container, Button *mButtons[2]; Label *mLabel; - gcn::ListModel *mListModel; + ListModel *mListModel; std::string mPrevEventId; std::string mNextEventId; int mOldWidth; diff --git a/src/gui/widgets/tabs/setup_audio.h b/src/gui/widgets/tabs/setup_audio.h index aaadebf32..b3736e814 100644 --- a/src/gui/widgets/tabs/setup_audio.h +++ b/src/gui/widgets/tabs/setup_audio.h @@ -39,7 +39,7 @@ class Setup_Audio final : public SetupTabScroll void apply() override final; private: - gcn::ListModel *mSoundModel; + ListModel *mSoundModel; SetupItemNames *mChannelsList; }; diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index 24bf229ef..ed371b364 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -39,7 +39,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabstrip.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "debug.h" @@ -51,7 +51,7 @@ static const int setupGroups = 9; * * \ingroup Interface */ -class KeyListModel final : public gcn::ListModel +class KeyListModel final : public ListModel { public: KeyListModel() : diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index dd08d437b..1af4e1769 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -78,7 +78,7 @@ static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] = N_("Enemy") }; -class PlayerRelationListModel final : public gcn::ListModel +class PlayerRelationListModel final : public ListModel { public: ~PlayerRelationListModel() @@ -216,7 +216,7 @@ protected: /** * Class for choosing one of the various `what to do when ignoring a player' options */ -class IgnoreChoicesListModel final : public gcn::ListModel +class IgnoreChoicesListModel final : public ListModel { public: ~IgnoreChoicesListModel() diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h index e32889008..9fc197ffc 100644 --- a/src/gui/widgets/tabs/setup_relations.h +++ b/src/gui/widgets/tabs/setup_relations.h @@ -33,15 +33,11 @@ class Button; class CheckBox; class DropDown; class GuiTable; +class ListModel; class PlayerTableModel; class ScrollArea; class StaticTableModel; -namespace gcn -{ - class ListModel; -} - class Setup_Relations final : public SetupTab, public PlayerRelationsListener { @@ -78,7 +74,7 @@ private: Button *mDeleteButton; - gcn::ListModel *mIgnoreActionChoicesModel; + ListModel *mIgnoreActionChoicesModel; DropDown *mIgnoreActionChoicesBox; }; diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index b744eb0eb..1d5f0f910 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -116,7 +116,7 @@ const char *SIZE_NAME[maxFontSizes] = N_("Huge (23)"), }; -class FontSizeChoiceListModel final : public gcn::ListModel +class FontSizeChoiceListModel final : public ListModel { public: ~FontSizeChoiceListModel() diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index 4e4408ce6..b587e8d5d 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -46,7 +46,7 @@ #include "test/testmain.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include @@ -54,7 +54,7 @@ extern Graphics *mainGraphics; -class ModeListModel final : public gcn::ListModel +class ModeListModel final : public ListModel { public: ModeListModel(); @@ -159,7 +159,7 @@ int ModeListModel::getIndexOf(const std::string &widthXHeightMode) return -1; } -class OpenGLListModel final : public gcn::ListModel +class OpenGLListModel final : public ListModel { public: ~OpenGLListModel() diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index cd593bf92..ac8187fc3 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -69,7 +69,7 @@ static const char *const SORT_NAME_BUY[7] = N_("by type") }; -class SortListModelBuy final : public gcn::ListModel +class SortListModelBuy final : public ListModel { public: ~SortListModelBuy() diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index acd4c50bd..eb4a0fb44 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -177,7 +177,7 @@ const char *COLOR_NAME[14] = }; -class ColorListModel final : public gcn::ListModel +class ColorListModel final : public ListModel { public: ~ColorListModel() diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 8907a2846..a3f649f0d 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -34,12 +34,12 @@ class ServerDialog; #include "listeners/actionlistener.h" #include "listeners/keylistener.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" /** * Server Type List Model */ -class TypeListModel : public gcn::ListModel +class TypeListModel : public ListModel { public: TypeListModel() diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 0b0e6c6de..be1487566 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -36,7 +36,7 @@ #include "gui/gui.h" #include "gui/viewport.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "gui/popups/textpopup.h" @@ -81,7 +81,7 @@ static const char *const SORT_NAME_INVENTORY[6] = N_("by type") }; -class SortListModelInv final : public gcn::ListModel +class SortListModelInv final : public ListModel { public: ~SortListModelInv() diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index c63157e27..b65d5481f 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -33,7 +33,7 @@ #include "net/net.h" #include "gui/viewport.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "gui/popups/itempopup.h" @@ -52,7 +52,7 @@ #include "debug.h" -class ItemsModal final : public gcn::ListModel +class ItemsModal final : public ListModel { public: ItemsModal() : diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index bfa20af62..ac060817d 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -84,7 +84,7 @@ const char *UPDATE_TYPE_TEXT[3] = N_("Skip"), }; -class UpdateTypeModel final : public gcn::ListModel +class UpdateTypeModel final : public ListModel { public: UpdateTypeModel() @@ -108,11 +108,11 @@ class UpdateTypeModel final : public gcn::ListModel } }; -class UpdateListModel final : public gcn::ListModel +class UpdateListModel final : public ListModel { public: explicit UpdateListModel(LoginData *const data) : - gcn::ListModel(), + ListModel(), mLoginData(data) { } diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 3f63562f7..2d0ada344 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -34,7 +34,7 @@ #include "listeners/keylistener.h" #include "listeners/selectionlistener.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include #include @@ -48,7 +48,7 @@ class ServerDialog; /** * Server and Port List Model */ -class ServersListModel final : public gcn::ListModel +class ServersListModel final : public ListModel { public: typedef std::pair VersionString; diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 82d1c9ef6..358077021 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -27,7 +27,7 @@ #include "input/keyboardconfig.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" @@ -44,7 +44,7 @@ #include "debug.h" -class IconsModal final : public gcn::ListModel +class IconsModal final : public ListModel { public: IconsModal() : @@ -121,7 +121,7 @@ const char *MAGIC_SCHOOL_TEXT[6] = N_("Astral Magic") }; -class TargetTypeModel final : public gcn::ListModel +class TargetTypeModel final : public ListModel { public: ~TargetTypeModel() @@ -140,7 +140,7 @@ public: } }; -class MagicSchoolModel final : public gcn::ListModel +class MagicSchoolModel final : public ListModel { public: ~MagicSchoolModel() diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index 5acb11f93..e588e5eb0 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -33,7 +33,7 @@ #include "gui/widgets/listbox.h" #include "gui/widgets/scrollarea.h" -#include "gui/base/listmodel.hpp" +#include "gui/models/listmodel.h" #include "net/loginhandler.h" #include "net/net.h" @@ -47,7 +47,7 @@ extern WorldInfo **server_info; /** * The list model for the server list. */ -class WorldListModel final : public gcn::ListModel +class WorldListModel final : public ListModel { public: explicit WorldListModel(Worlds worlds) : -- cgit v1.2.3-70-g09d2 From 7432738d75d02147e2aaa1d577383d26a9e18296 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 16:30:34 +0300 Subject: Move colormodel into gui/models directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/gui/models/colormodel.cpp | 94 +++++++++++++++++++++++++++++++++++++++++ src/gui/models/colormodel.h | 76 +++++++++++++++++++++++++++++++++ src/gui/widgets/colormodel.cpp | 94 ----------------------------------------- src/gui/widgets/colormodel.h | 76 --------------------------------- src/gui/widgets/colorpage.cpp | 2 +- src/gui/windows/emotewindow.cpp | 3 +- 8 files changed, 177 insertions(+), 176 deletions(-) create mode 100644 src/gui/models/colormodel.cpp create mode 100644 src/gui/models/colormodel.h delete mode 100644 src/gui/widgets/colormodel.cpp delete mode 100644 src/gui/widgets/colormodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 497b66cd9..d2d7effde 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -124,8 +124,8 @@ SET(SRCS gui/widgets/tabs/chattab.h gui/widgets/checkbox.cpp gui/widgets/checkbox.h - gui/widgets/colormodel.cpp - gui/widgets/colormodel.h + gui/models/colormodel.cpp + gui/models/colormodel.h gui/widgets/colorpage.cpp gui/widgets/colorpage.h gui/widgets/container.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b7f6e8bc4..b06506604 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -220,8 +220,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabs/chattab.h \ gui/widgets/checkbox.cpp \ gui/widgets/checkbox.h \ - gui/widgets/colormodel.cpp \ - gui/widgets/colormodel.h \ + gui/models/colormodel.cpp \ + gui/models/colormodel.h \ gui/widgets/colorpage.cpp \ gui/widgets/colorpage.h \ gui/widgets/container.cpp \ diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp new file mode 100644 index 000000000..47486d735 --- /dev/null +++ b/src/gui/models/colormodel.cpp @@ -0,0 +1,94 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/models/colormodel.h" + +#include "gui/widgets/widget2.h" + +#include "utils/gettext.h" + +#include "debug.h" + +ColorModel::ColorModel() : + mNames(), + mColors() +{ +} + +ColorModel::~ColorModel() +{ +} + +int ColorModel::getNumberOfElements() +{ + return static_cast(mNames.size()); +} + +std::string ColorModel::getElementAt(int i) +{ + if (i >= getNumberOfElements() || i < 0) + return "???"; + return mNames[i]; +} + +const ColorPair *ColorModel::getColorAt(const int i) const +{ + if (i >= static_cast(mColors.size()) || i < 0) + return nullptr; + + return &mColors[i]; +} + +void ColorModel::add(const std::string &name, const Color *const color1, + const Color *const color2) +{ + mNames.push_back(name); + mColors.push_back(ColorPair(color1, color2)); +} + +#define addColor(name, color) \ + model->add(name, &widget->getThemeColor(Theme::color), \ + &widget->getThemeColor(Theme::color##_OUTLINE)); + +ColorModel *ColorModel::createDefault(const Widget2 *const widget) +{ + ColorModel *const model = new ColorModel(); + // TRANSLATORS: color name + addColor(_("black"), BLACK); + // TRANSLATORS: color name + addColor(_("red"), RED); + // TRANSLATORS: color name + addColor(_("green"), GREEN); + // TRANSLATORS: color name + addColor(_("blue"), BLUE); + // TRANSLATORS: color name + addColor(_("gold"), ORANGE); + // TRANSLATORS: color name + addColor(_("yellow"), YELLOW); + // TRANSLATORS: color name + addColor(_("pink"), PINK); + // TRANSLATORS: color name + addColor(_("purple"), PURPLE); + // TRANSLATORS: color name + addColor(_("grey"), GRAY); + // TRANSLATORS: color name + addColor(_("brown"), BROWN); + return model; +} diff --git a/src/gui/models/colormodel.h b/src/gui/models/colormodel.h new file mode 100644 index 000000000..f3d6f3617 --- /dev/null +++ b/src/gui/models/colormodel.h @@ -0,0 +1,76 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_COLORMODEL_H +#define GUI_MODELS_COLORMODEL_H + +#include "utils/stringvector.h" + +#include "gui/models/listmodel.h" + +#include "localconsts.h" + +class Color; +class Widget2; + +struct ColorPair +{ + ColorPair(const Color* c1, const Color* c2) : + color1(c1), + color2(c2) + { + } + + const Color* color1; + const Color* color2; +}; + +class ColorModel : public ListModel +{ + public: + ColorModel(); + + A_DELETE_COPY(ColorModel) + + virtual ~ColorModel(); + + virtual int getNumberOfElements() override final A_WARN_UNUSED; + + virtual std::string getElementAt(int i) override final A_WARN_UNUSED; + + virtual const ColorPair *getColorAt(const int i) const A_WARN_UNUSED; + + StringVect &getNames() A_WARN_UNUSED + { return mNames; } + + size_t size() A_WARN_UNUSED + { return mNames.size(); } + + void add(const std::string &name, const Color *const color1, + const Color *const color2); + + static ColorModel *createDefault(const Widget2 *const widget); + + protected: + StringVect mNames; + std::vector mColors; +}; + +#endif // GUI_MODELS_COLORMODEL_H diff --git a/src/gui/widgets/colormodel.cpp b/src/gui/widgets/colormodel.cpp deleted file mode 100644 index 3a71a93cc..000000000 --- a/src/gui/widgets/colormodel.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/colormodel.h" - -#include "gui/widgets/widget2.h" - -#include "utils/gettext.h" - -#include "debug.h" - -ColorModel::ColorModel() : - mNames(), - mColors() -{ -} - -ColorModel::~ColorModel() -{ -} - -int ColorModel::getNumberOfElements() -{ - return static_cast(mNames.size()); -} - -std::string ColorModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[i]; -} - -const ColorPair *ColorModel::getColorAt(const int i) const -{ - if (i >= static_cast(mColors.size()) || i < 0) - return nullptr; - - return &mColors[i]; -} - -void ColorModel::add(const std::string &name, const Color *const color1, - const Color *const color2) -{ - mNames.push_back(name); - mColors.push_back(ColorPair(color1, color2)); -} - -#define addColor(name, color) \ - model->add(name, &widget->getThemeColor(Theme::color), \ - &widget->getThemeColor(Theme::color##_OUTLINE)); - -ColorModel *ColorModel::createDefault(const Widget2 *const widget) -{ - ColorModel *const model = new ColorModel(); - // TRANSLATORS: color name - addColor(_("black"), BLACK); - // TRANSLATORS: color name - addColor(_("red"), RED); - // TRANSLATORS: color name - addColor(_("green"), GREEN); - // TRANSLATORS: color name - addColor(_("blue"), BLUE); - // TRANSLATORS: color name - addColor(_("gold"), ORANGE); - // TRANSLATORS: color name - addColor(_("yellow"), YELLOW); - // TRANSLATORS: color name - addColor(_("pink"), PINK); - // TRANSLATORS: color name - addColor(_("purple"), PURPLE); - // TRANSLATORS: color name - addColor(_("grey"), GRAY); - // TRANSLATORS: color name - addColor(_("brown"), BROWN); - return model; -} diff --git a/src/gui/widgets/colormodel.h b/src/gui/widgets/colormodel.h deleted file mode 100644 index ba68e94e2..000000000 --- a/src/gui/widgets/colormodel.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_COLORMODEL_H -#define GUI_WIDGETS_COLORMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -class Color; -class Widget2; - -struct ColorPair -{ - ColorPair(const Color* c1, const Color* c2) : - color1(c1), - color2(c2) - { - } - - const Color* color1; - const Color* color2; -}; - -class ColorModel : public ListModel -{ - public: - ColorModel(); - - A_DELETE_COPY(ColorModel) - - virtual ~ColorModel(); - - virtual int getNumberOfElements() override final A_WARN_UNUSED; - - virtual std::string getElementAt(int i) override final A_WARN_UNUSED; - - virtual const ColorPair *getColorAt(const int i) const A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - size_t size() A_WARN_UNUSED - { return mNames.size(); } - - void add(const std::string &name, const Color *const color1, - const Color *const color2); - - static ColorModel *createDefault(const Widget2 *const widget); - - protected: - StringVect mNames; - std::vector mColors; -}; - -#endif // GUI_WIDGETS_COLORMODEL_H diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 8196dead4..5e10b885c 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -20,7 +20,7 @@ #include "gui/widgets/colorpage.h" -#include "gui/widgets/colormodel.h" +#include "gui/models/colormodel.h" #include "gui/font.h" diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index d94344090..97ce9b5c7 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -20,7 +20,8 @@ #include "gui/windows/emotewindow.h" -#include "gui/widgets/colormodel.h" +#include "gui/models/colormodel.h" + #include "gui/widgets/colorpage.h" #include "gui/widgets/emotepage.h" #include "gui/widgets/namesmodel.h" -- cgit v1.2.3-70-g09d2 From 775810f943f7f6540d3bb180fdb91a074fdbaa75 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 16:54:00 +0300 Subject: Move extendedlistmodel into gui/models directory. --- src/CMakeLists.txt | 2 +- src/Makefile.am | 2 +- src/gui/models/extendedlistmodel.h | 34 ++++++++++++++++++++++++++++++++++ src/gui/widgets/dropdown.cpp | 3 ++- src/gui/widgets/extendedlistbox.cpp | 2 +- src/gui/widgets/extendedlistmodel.h | 34 ---------------------------------- src/gui/widgets/extendednamesmodel.h | 2 +- src/gui/widgets/tabs/setup_theme.cpp | 3 ++- src/gui/windows/npcdialog.h | 3 ++- 9 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 src/gui/models/extendedlistmodel.h delete mode 100644 src/gui/widgets/extendedlistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2d7effde..72bff6ee1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -138,7 +138,7 @@ SET(SRCS gui/widgets/emoteshortcutcontainer.h gui/widgets/extendedlistbox.cpp gui/widgets/extendedlistbox.h - gui/widgets/extendedlistmodel.h + gui/models/extendedlistmodel.h gui/widgets/extendednamesmodel.cpp gui/widgets/extendednamesmodel.h gui/widgets/flowcontainer.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b06506604..2179818d7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -234,7 +234,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/emoteshortcutcontainer.h \ gui/widgets/extendedlistbox.cpp \ gui/widgets/extendedlistbox.h \ - gui/widgets/extendedlistmodel.h \ + gui/models/extendedlistmodel.h \ gui/widgets/extendednamesmodel.cpp \ gui/widgets/extendednamesmodel.h \ gui/widgets/flowcontainer.cpp \ diff --git a/src/gui/models/extendedlistmodel.h b/src/gui/models/extendedlistmodel.h new file mode 100644 index 000000000..5d859e781 --- /dev/null +++ b/src/gui/models/extendedlistmodel.h @@ -0,0 +1,34 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_EXTENDEDLISTMODEL_H +#define GUI_MODELS_EXTENDEDLISTMODEL_H + +#include "resources/image.h" + +#include "gui/models/listmodel.h" + +class ExtendedListModel : public ListModel +{ + public: + virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0; +}; + +#endif // GUI_MODELS_EXTENDEDLISTMODEL_H diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index ec9a2e22f..763cf47a5 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -28,7 +28,8 @@ #include "input/keydata.h" -#include "gui/widgets/extendedlistmodel.h" +#include "gui/models/extendedlistmodel.h" + #include "gui/widgets/popuplist.h" #include "resources/image.h" diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index c507f986c..13fb70f28 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -20,7 +20,7 @@ #include "gui/widgets/extendedlistbox.h" -#include "gui/widgets/extendedlistmodel.h" +#include "gui/models/extendedlistmodel.h" #include "gui/font.h" diff --git a/src/gui/widgets/extendedlistmodel.h b/src/gui/widgets/extendedlistmodel.h deleted file mode 100644 index c3cd26b90..000000000 --- a/src/gui/widgets/extendedlistmodel.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_EXTENDEDLISTMODEL_H -#define GUI_WIDGETS_EXTENDEDLISTMODEL_H - -#include "resources/image.h" - -#include "gui/models/listmodel.h" - -class ExtendedListModel : public ListModel -{ - public: - virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0; -}; - -#endif // GUI_WIDGETS_EXTENDEDLISTMODEL_H diff --git a/src/gui/widgets/extendednamesmodel.h b/src/gui/widgets/extendednamesmodel.h index 93e87cfa0..3c38c48ed 100644 --- a/src/gui/widgets/extendednamesmodel.h +++ b/src/gui/widgets/extendednamesmodel.h @@ -23,7 +23,7 @@ #include "utils/stringvector.h" -#include "gui/widgets/extendedlistmodel.h" +#include "gui/models/extendedlistmodel.h" class ExtendedNamesModel : public ExtendedListModel { diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 1d5f0f910..8d5b234e1 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -26,9 +26,10 @@ #include "gui/windows/okdialog.h" +#include "gui/models/extendedlistmodel.h" + #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" -#include "gui/widgets/extendedlistmodel.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/namesmodel.h" diff --git a/src/gui/windows/npcdialog.h b/src/gui/windows/npcdialog.h index b9fa1aab8..5188c2fe2 100644 --- a/src/gui/windows/npcdialog.h +++ b/src/gui/windows/npcdialog.h @@ -25,7 +25,8 @@ #include "listeners/configlistener.h" -#include "gui/widgets/extendedlistmodel.h" +#include "gui/models/extendedlistmodel.h" + #include "gui/widgets/window.h" #include "utils/stringvector.h" -- cgit v1.2.3-70-g09d2 From ab5a67829ec6c80accfeb4f186a70886c82c8dba Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 16:59:58 +0300 Subject: Move extendednamesmodel into gui/models directory. --- src/CMakeLists.txt | 4 +-- src/Makefile.am | 4 +-- src/gui/models/extendednamesmodel.cpp | 65 ++++++++++++++++++++++++++++++++++ src/gui/models/extendednamesmodel.h | 59 ++++++++++++++++++++++++++++++ src/gui/widgets/extendednamesmodel.cpp | 65 ---------------------------------- src/gui/widgets/extendednamesmodel.h | 59 ------------------------------ src/gui/windows/questswindow.cpp | 3 +- 7 files changed, 130 insertions(+), 129 deletions(-) create mode 100644 src/gui/models/extendednamesmodel.cpp create mode 100644 src/gui/models/extendednamesmodel.h delete mode 100644 src/gui/widgets/extendednamesmodel.cpp delete mode 100644 src/gui/widgets/extendednamesmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72bff6ee1..9e13f9098 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,8 +139,8 @@ SET(SRCS gui/widgets/extendedlistbox.cpp gui/widgets/extendedlistbox.h gui/models/extendedlistmodel.h - gui/widgets/extendednamesmodel.cpp - gui/widgets/extendednamesmodel.h + gui/models/extendednamesmodel.cpp + gui/models/extendednamesmodel.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h gui/widgets/tabs/gmtab.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 2179818d7..5622d0a42 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -235,8 +235,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/extendedlistbox.cpp \ gui/widgets/extendedlistbox.h \ gui/models/extendedlistmodel.h \ - gui/widgets/extendednamesmodel.cpp \ - gui/widgets/extendednamesmodel.h \ + gui/models/extendednamesmodel.cpp \ + gui/models/extendednamesmodel.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ gui/widgets/tabs/gmtab.cpp \ diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp new file mode 100644 index 000000000..c986085db --- /dev/null +++ b/src/gui/models/extendednamesmodel.cpp @@ -0,0 +1,65 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/models/extendednamesmodel.h" + +#include "debug.h" + +ExtendedNamesModel::ExtendedNamesModel() : + mNames(), + mImages() +{ +} + +ExtendedNamesModel::~ExtendedNamesModel() +{ + clear(); +} + +int ExtendedNamesModel::getNumberOfElements() +{ + return static_cast(mNames.size()); +} + +std::string ExtendedNamesModel::getElementAt(int i) +{ + if (i >= getNumberOfElements() || i < 0) + return "???"; + return mNames[i]; +} + +const Image *ExtendedNamesModel::getImageAt(int i) +{ + if (i >= static_cast(mImages.size()) || i < 0) + return nullptr; + + return mImages[i]; +} + +void ExtendedNamesModel::clear() +{ + mNames.clear(); + FOR_EACH (std::vector::iterator, it, mImages) + { + if (*it) + (*it)->decRef(); + } + mImages.clear(); +} diff --git a/src/gui/models/extendednamesmodel.h b/src/gui/models/extendednamesmodel.h new file mode 100644 index 000000000..383a93951 --- /dev/null +++ b/src/gui/models/extendednamesmodel.h @@ -0,0 +1,59 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_EXTENDEDNAMESMODEL_H +#define GUI_MODELS_EXTENDEDNAMESMODEL_H + +#include "utils/stringvector.h" + +#include "gui/models/extendedlistmodel.h" + +class ExtendedNamesModel : public ExtendedListModel +{ + public: + ExtendedNamesModel(); + + A_DELETE_COPY(ExtendedNamesModel) + + virtual ~ExtendedNamesModel(); + + virtual int getNumberOfElements() override final A_WARN_UNUSED; + + virtual std::string getElementAt(int i) override final A_WARN_UNUSED; + + virtual const Image *getImageAt(int i) override final A_WARN_UNUSED; + + StringVect &getNames() A_WARN_UNUSED + { return mNames; } + + std::vector &getImages() A_WARN_UNUSED + { return mImages; } + + size_t size() A_WARN_UNUSED + { return mNames.size(); } + + void clear(); + + protected: + StringVect mNames; + std::vector mImages; +}; + +#endif // GUI_MODELS_EXTENDEDNAMESMODEL_H diff --git a/src/gui/widgets/extendednamesmodel.cpp b/src/gui/widgets/extendednamesmodel.cpp deleted file mode 100644 index a8a21d98d..000000000 --- a/src/gui/widgets/extendednamesmodel.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/extendednamesmodel.h" - -#include "debug.h" - -ExtendedNamesModel::ExtendedNamesModel() : - mNames(), - mImages() -{ -} - -ExtendedNamesModel::~ExtendedNamesModel() -{ - clear(); -} - -int ExtendedNamesModel::getNumberOfElements() -{ - return static_cast(mNames.size()); -} - -std::string ExtendedNamesModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[i]; -} - -const Image *ExtendedNamesModel::getImageAt(int i) -{ - if (i >= static_cast(mImages.size()) || i < 0) - return nullptr; - - return mImages[i]; -} - -void ExtendedNamesModel::clear() -{ - mNames.clear(); - FOR_EACH (std::vector::iterator, it, mImages) - { - if (*it) - (*it)->decRef(); - } - mImages.clear(); -} diff --git a/src/gui/widgets/extendednamesmodel.h b/src/gui/widgets/extendednamesmodel.h deleted file mode 100644 index 3c38c48ed..000000000 --- a/src/gui/widgets/extendednamesmodel.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_EXTENDEDNAMESMODEL_H -#define GUI_WIDGETS_EXTENDEDNAMESMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/extendedlistmodel.h" - -class ExtendedNamesModel : public ExtendedListModel -{ - public: - ExtendedNamesModel(); - - A_DELETE_COPY(ExtendedNamesModel) - - virtual ~ExtendedNamesModel(); - - virtual int getNumberOfElements() override final A_WARN_UNUSED; - - virtual std::string getElementAt(int i) override final A_WARN_UNUSED; - - virtual const Image *getImageAt(int i) override final A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - std::vector &getImages() A_WARN_UNUSED - { return mImages; } - - size_t size() A_WARN_UNUSED - { return mNames.size(); } - - void clear(); - - protected: - StringVect mNames; - std::vector mImages; -}; - -#endif // GUI_WIDGETS_EXTENDEDNAMESMODEL_H diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index d62ca36ad..1ee78e563 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -29,11 +29,12 @@ #include "gui/font.h" #include "gui/gui.h" +#include "gui/models/extendednamesmodel.h" + #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" #include "gui/widgets/layout.h" #include "gui/widgets/extendedlistbox.h" -#include "gui/widgets/extendednamesmodel.h" #include "gui/widgets/itemlinkhandler.h" #include "gui/widgets/scrollarea.h" -- cgit v1.2.3-70-g09d2 From 2f0c3a26431ed87be273b182b341d9c167f92eca Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 17:13:32 +0300 Subject: Move namesmodel into gui/models directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/gui/models/namesmodel.cpp | 52 ++++++++++++++++++++++++++ src/gui/models/namesmodel.h | 61 +++++++++++++++++++++++++++++++ src/gui/widgets/namesmodel.cpp | 52 -------------------------- src/gui/widgets/namesmodel.h | 61 ------------------------------- src/gui/widgets/setuptouchitem.h | 3 +- src/gui/widgets/tabs/setup_audio.cpp | 3 +- src/gui/widgets/tabs/setup_joystick.cpp | 3 +- src/gui/widgets/tabs/setup_other.cpp | 3 +- src/gui/widgets/tabs/setup_perfomance.cpp | 3 +- src/gui/widgets/tabs/setup_theme.cpp | 2 +- src/gui/widgets/tabs/setup_touch.cpp | 3 +- src/gui/widgets/tabs/setup_visual.cpp | 3 +- src/gui/windows/emotewindow.cpp | 2 +- 15 files changed, 133 insertions(+), 126 deletions(-) create mode 100644 src/gui/models/namesmodel.cpp create mode 100644 src/gui/models/namesmodel.h delete mode 100644 src/gui/widgets/namesmodel.cpp delete mode 100644 src/gui/widgets/namesmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9e13f9098..42c1e5b85 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -176,8 +176,8 @@ SET(SRCS gui/widgets/linkhandler.h gui/widgets/listbox.cpp gui/widgets/listbox.h - gui/widgets/namesmodel.cpp - gui/widgets/namesmodel.h + gui/models/namesmodel.cpp + gui/models/namesmodel.h gui/widgets/passwordfield.cpp gui/widgets/passwordfield.h gui/widgets/playerbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 5622d0a42..7051ae052 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -274,8 +274,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/linkhandler.h \ gui/widgets/listbox.cpp \ gui/widgets/listbox.h \ - gui/widgets/namesmodel.cpp \ - gui/widgets/namesmodel.h \ + gui/models/namesmodel.cpp \ + gui/models/namesmodel.h \ gui/widgets/passwordfield.cpp \ gui/widgets/passwordfield.h \ gui/widgets/playerbox.cpp \ diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp new file mode 100644 index 000000000..54a10c2cf --- /dev/null +++ b/src/gui/models/namesmodel.cpp @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/models/namesmodel.h" + +#include "utils/gettext.h" + +#include "debug.h" + +NamesModel::NamesModel() : + mNames() +{ +} + +NamesModel::~NamesModel() +{ +} + +int NamesModel::getNumberOfElements() +{ + return static_cast(mNames.size()); +} + +std::string NamesModel::getElementAt(int i) +{ + if (i >= getNumberOfElements() || i < 0) + return "???"; + return mNames[i]; +} + +void NamesModel::fillFromArray(const char *const *const arr, std::size_t sz) +{ + for (size_t f = 0; f < sz; f ++) + mNames.push_back(gettext(arr[f])); +} diff --git a/src/gui/models/namesmodel.h b/src/gui/models/namesmodel.h new file mode 100644 index 000000000..96d16de36 --- /dev/null +++ b/src/gui/models/namesmodel.h @@ -0,0 +1,61 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_NAMESMODEL_H +#define GUI_MODELS_NAMESMODEL_H + +#include "utils/stringvector.h" + +#include "gui/models/listmodel.h" + +#include "localconsts.h" + +class NamesModel : public ListModel +{ + public: + NamesModel(); + + A_DELETE_COPY(NamesModel) + + virtual ~NamesModel(); + + virtual int getNumberOfElements() override final A_WARN_UNUSED; + + virtual std::string getElementAt(int i) override final A_WARN_UNUSED; + + StringVect &getNames() A_WARN_UNUSED + { return mNames; } + + size_t size() const A_WARN_UNUSED + { return mNames.size(); } + + void clear() + { mNames.clear(); } + + void add(const std::string &str) + { mNames.push_back(str); } + + void fillFromArray(const char *const *const arr, std::size_t size); + + protected: + StringVect mNames; +}; + +#endif // GUI_MODELS_NAMESMODEL_H diff --git a/src/gui/widgets/namesmodel.cpp b/src/gui/widgets/namesmodel.cpp deleted file mode 100644 index 339f835d5..000000000 --- a/src/gui/widgets/namesmodel.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/namesmodel.h" - -#include "utils/gettext.h" - -#include "debug.h" - -NamesModel::NamesModel() : - mNames() -{ -} - -NamesModel::~NamesModel() -{ -} - -int NamesModel::getNumberOfElements() -{ - return static_cast(mNames.size()); -} - -std::string NamesModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[i]; -} - -void NamesModel::fillFromArray(const char *const *const arr, std::size_t sz) -{ - for (size_t f = 0; f < sz; f ++) - mNames.push_back(gettext(arr[f])); -} diff --git a/src/gui/widgets/namesmodel.h b/src/gui/widgets/namesmodel.h deleted file mode 100644 index 4018a3755..000000000 --- a/src/gui/widgets/namesmodel.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_NAMESMODEL_H -#define GUI_WIDGETS_NAMESMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -class NamesModel : public ListModel -{ - public: - NamesModel(); - - A_DELETE_COPY(NamesModel) - - virtual ~NamesModel(); - - virtual int getNumberOfElements() override final A_WARN_UNUSED; - - virtual std::string getElementAt(int i) override final A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - size_t size() const A_WARN_UNUSED - { return mNames.size(); } - - void clear() - { mNames.clear(); } - - void add(const std::string &str) - { mNames.push_back(str); } - - void fillFromArray(const char *const *const arr, std::size_t size); - - protected: - StringVect mNames; -}; - -#endif // GUI_WIDGETS_NAMESMODEL_H diff --git a/src/gui/widgets/setuptouchitem.h b/src/gui/widgets/setuptouchitem.h index f15c0d43d..b84b15f81 100644 --- a/src/gui/widgets/setuptouchitem.h +++ b/src/gui/widgets/setuptouchitem.h @@ -21,7 +21,8 @@ #ifndef GUI_WIDGETS_SETUPTOUCHITEM_H #define GUI_WIDGETS_SETUPTOUCHITEM_H -#include "gui/widgets/namesmodel.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/setupitem.h" class TouchActionsModel final : public NamesModel diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index d70e4e1b4..e7c49723a 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -30,8 +30,9 @@ #include "gui/viewport.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "gui/widgets/scrollarea.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index e2e66c6fc..ba5c37b5a 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -26,12 +26,13 @@ #include "input/joystick.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp index 4640150e4..678dc2672 100644 --- a/src/gui/widgets/tabs/setup_other.cpp +++ b/src/gui/widgets/tabs/setup_other.cpp @@ -22,8 +22,9 @@ #include "gui/widgets/tabs/setup_other.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "gui/widgets/setupitem.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp index 88cf6279c..cd92c8542 100644 --- a/src/gui/widgets/tabs/setup_perfomance.cpp +++ b/src/gui/widgets/tabs/setup_perfomance.cpp @@ -22,8 +22,9 @@ #include "gui/widgets/tabs/setup_perfomance.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/setupitem.h" diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 8d5b234e1..99deda940 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -27,12 +27,12 @@ #include "gui/windows/okdialog.h" #include "gui/models/extendedlistmodel.h" +#include "gui/models/namesmodel.h" #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/label.h" #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "configuration.h" diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index 1d9149fbd..e26716973 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -20,8 +20,9 @@ #include "gui/widgets/tabs/setup_touch.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "gui/widgets/setuptouchitem.h" #include "gui/widgets/scrollarea.h" diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index d7c2ff788..525d73d07 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -21,8 +21,9 @@ #include "gui/widgets/tabs/setup_visual.h" +#include "gui/models/namesmodel.h" + #include "gui/widgets/layouthelper.h" -#include "gui/widgets/namesmodel.h" #include "gui/widgets/scrollarea.h" #include "client.h" diff --git a/src/gui/windows/emotewindow.cpp b/src/gui/windows/emotewindow.cpp index 97ce9b5c7..3a7141533 100644 --- a/src/gui/windows/emotewindow.cpp +++ b/src/gui/windows/emotewindow.cpp @@ -21,10 +21,10 @@ #include "gui/windows/emotewindow.h" #include "gui/models/colormodel.h" +#include "gui/models/namesmodel.h" #include "gui/widgets/colorpage.h" #include "gui/widgets/emotepage.h" -#include "gui/widgets/namesmodel.h" #include "gui/widgets/scrollarea.h" #include "gui/widgets/tabbedarea.h" -- cgit v1.2.3-70-g09d2 From 23e954851812b1121d6f3d98a6b7b396bca17dc9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 17:20:21 +0300 Subject: Move skillmodel into gui/models directory. --- src/CMakeLists.txt | 4 +-- src/Makefile.am | 4 +-- src/gui/models/skillmodel.cpp | 62 +++++++++++++++++++++++++++++++++++++++++ src/gui/models/skillmodel.h | 55 ++++++++++++++++++++++++++++++++++++ src/gui/widgets/skillinfo.cpp | 3 +- src/gui/widgets/skillmodel.cpp | 62 ----------------------------------------- src/gui/widgets/skillmodel.h | 55 ------------------------------------ src/gui/windows/skilldialog.cpp | 3 +- 8 files changed, 125 insertions(+), 123 deletions(-) create mode 100644 src/gui/models/skillmodel.cpp create mode 100644 src/gui/models/skillmodel.h delete mode 100644 src/gui/widgets/skillmodel.cpp delete mode 100644 src/gui/widgets/skillmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 42c1e5b85..0a9fafdec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -214,8 +214,8 @@ SET(SRCS gui/widgets/skilldata.h gui/widgets/skillinfo.cpp gui/widgets/skillinfo.h - gui/widgets/skillmodel.cpp - gui/widgets/skillmodel.h + gui/models/skillmodel.cpp + gui/models/skillmodel.h gui/widgets/slider.cpp gui/widgets/slider.h gui/widgets/sliderlist.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 7051ae052..7caa67529 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -312,8 +312,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/skilldata.h \ gui/widgets/skillinfo.cpp \ gui/widgets/skillinfo.h \ - gui/widgets/skillmodel.cpp \ - gui/widgets/skillmodel.h \ + gui/models/skillmodel.cpp \ + gui/models/skillmodel.h \ gui/widgets/slider.cpp \ gui/widgets/slider.h \ gui/widgets/sliderlist.cpp \ diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp new file mode 100644 index 000000000..706bbdee2 --- /dev/null +++ b/src/gui/models/skillmodel.cpp @@ -0,0 +1,62 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/models/skillmodel.h" + +#include "gui/widgets/skilldata.h" + +#include + +#include "debug.h" + +SkillModel::SkillModel() : + mSkills(), + mVisibleSkills() +{ +} + +SkillInfo *SkillModel::getSkillAt(const int i) const +{ + if (i < 0 || i >= static_cast(mVisibleSkills.size())) + return nullptr; + return mVisibleSkills.at(i); +} + +std::string SkillModel::getElementAt(int i) +{ + const SkillInfo *const info = getSkillAt(i); + if (info) + return info->data->name; + else + return std::string(); +} + +void SkillModel::updateVisibilities() +{ + mVisibleSkills.clear(); + + FOR_EACH (SkillList::const_iterator, it, mSkills) + { + if ((*it) && (*it)->visible) + mVisibleSkills.push_back((*it)); + } +} diff --git a/src/gui/models/skillmodel.h b/src/gui/models/skillmodel.h new file mode 100644 index 000000000..11746118e --- /dev/null +++ b/src/gui/models/skillmodel.h @@ -0,0 +1,55 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_SKILLMODEL_H +#define GUI_MODELS_SKILLMODEL_H + +#include "gui/widgets/skillinfo.h" +#include "gui/models/listmodel.h" + +#include + +#include "localconsts.h" + +class SkillModel final : public ListModel +{ + public: + SkillModel(); + + SkillInfo *getSkillAt(const int i) const; + + std::string getElementAt(int i) override final; + + int getNumberOfElements() override final + { return static_cast(mVisibleSkills.size()); } + + void addSkill(SkillInfo *const info) + { mSkills.push_back(info); } + + void updateVisibilities(); + + private: + SkillList mSkills; + SkillList mVisibleSkills; +}; + +#endif // GUI_MODELS_SKILLMODEL_H diff --git a/src/gui/widgets/skillinfo.cpp b/src/gui/widgets/skillinfo.cpp index 46a3f425f..a009d623a 100644 --- a/src/gui/widgets/skillinfo.cpp +++ b/src/gui/widgets/skillinfo.cpp @@ -27,7 +27,8 @@ #include "gui/theme.h" #include "gui/widgets/skilldata.h" -#include "gui/widgets/skillmodel.h" + +#include "gui/models/skillmodel.h" #include "utils/gettext.h" #include "utils/stringutils.h" diff --git a/src/gui/widgets/skillmodel.cpp b/src/gui/widgets/skillmodel.cpp deleted file mode 100644 index 3244feec4..000000000 --- a/src/gui/widgets/skillmodel.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/skillmodel.h" - -#include "gui/widgets/skilldata.h" - -#include - -#include "debug.h" - -SkillModel::SkillModel() : - mSkills(), - mVisibleSkills() -{ -} - -SkillInfo *SkillModel::getSkillAt(const int i) const -{ - if (i < 0 || i >= static_cast(mVisibleSkills.size())) - return nullptr; - return mVisibleSkills.at(i); -} - -std::string SkillModel::getElementAt(int i) -{ - const SkillInfo *const info = getSkillAt(i); - if (info) - return info->data->name; - else - return std::string(); -} - -void SkillModel::updateVisibilities() -{ - mVisibleSkills.clear(); - - FOR_EACH (SkillList::const_iterator, it, mSkills) - { - if ((*it) && (*it)->visible) - mVisibleSkills.push_back((*it)); - } -} diff --git a/src/gui/widgets/skillmodel.h b/src/gui/widgets/skillmodel.h deleted file mode 100644 index 38e36c2f1..000000000 --- a/src/gui/widgets/skillmodel.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_SKILLMODEL_H -#define GUI_WIDGETS_SKILLMODEL_H - -#include "gui/widgets/skillinfo.h" -#include "gui/models/listmodel.h" - -#include - -#include "localconsts.h" - -class SkillModel final : public ListModel -{ - public: - SkillModel(); - - SkillInfo *getSkillAt(const int i) const; - - std::string getElementAt(int i) override final; - - int getNumberOfElements() override final - { return static_cast(mVisibleSkills.size()); } - - void addSkill(SkillInfo *const info) - { mSkills.push_back(info); } - - void updateVisibilities(); - - private: - SkillList mSkills; - SkillList mVisibleSkills; -}; - -#endif // GUI_WIDGETS_SKILLMODEL_H diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index f5f233402..d39d7061b 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -34,6 +34,8 @@ #include "gui/popups/textpopup.h" +#include "gui/models/skillmodel.h" + #include "gui/windows/setupwindow.h" #include "gui/windows/shortcutwindow.h" @@ -41,7 +43,6 @@ #include "gui/widgets/label.h" #include "gui/widgets/listbox.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/skillmodel.h" #include "gui/widgets/tabs/tab.h" #include "gui/widgets/tabbedarea.h" -- cgit v1.2.3-70-g09d2 From 32bc15a1d1aee30f5a259b1648f8d82a5e837ff7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 17:25:28 +0300 Subject: Move tablemodel into gui/models directory. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/gui/models/tablemodel.cpp | 180 +++++++++++++++++++++++++++++++++++++++++ src/gui/models/tablemodel.h | 164 +++++++++++++++++++++++++++++++++++++ src/gui/widgets/guitable.h | 2 +- src/gui/widgets/tablemodel.cpp | 180 ----------------------------------------- src/gui/widgets/tablemodel.h | 164 ------------------------------------- 7 files changed, 349 insertions(+), 349 deletions(-) create mode 100644 src/gui/models/tablemodel.cpp create mode 100644 src/gui/models/tablemodel.h delete mode 100644 src/gui/widgets/tablemodel.cpp delete mode 100644 src/gui/widgets/tablemodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0a9fafdec..b80e13a93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -226,8 +226,8 @@ SET(SRCS gui/widgets/tabbedarea.h gui/widgets/guitable.cpp gui/widgets/guitable.h - gui/widgets/tablemodel.cpp - gui/widgets/tablemodel.h + gui/models/tablemodel.cpp + gui/models/tablemodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h gui/widgets/textbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 7caa67529..c57e4eb74 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -322,8 +322,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabs/tab.h \ gui/widgets/tabbedarea.cpp \ gui/widgets/tabbedarea.h \ - gui/widgets/tablemodel.cpp \ - gui/widgets/tablemodel.h \ + gui/models/tablemodel.cpp \ + gui/models/tablemodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ gui/widgets/textbox.cpp \ diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp new file mode 100644 index 000000000..aad66a6ad --- /dev/null +++ b/src/gui/models/tablemodel.cpp @@ -0,0 +1,180 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/models/tablemodel.h" + +#include "utils/dtor.h" + +#include "gui/widgets/widget.h" + +#include "debug.h" + +void TableModel::installListener(TableModelListener *const listener) +{ + if (listener) + listeners.insert(listener); +} + +void TableModel::removeListener(TableModelListener *const listener) +{ + if (listener) + listeners.erase(listener); +} + +void TableModel::signalBeforeUpdate() +{ + for (std::set::const_iterator it = listeners.begin(); + it != listeners.end(); ++it) + { + (*it)->modelUpdated(false); + } +} + +void TableModel::signalAfterUpdate() +{ + for (std::set::const_iterator it = listeners.begin(); + it != listeners.end(); ++it) + { + if (*it) + (*it)->modelUpdated(true); + } +} + + +#define WIDGET_AT(row, column) (((row) * mColumns) + (column)) +#define DYN_SIZE(h) ((h) >= 0) + +StaticTableModel::StaticTableModel(const int row, const int column) : + TableModel(), + mRows(row), + mColumns(column), + mHeight(1), + mTableModel(), + mWidths() +{ + mTableModel.resize(row * column, nullptr); + mWidths.resize(column, 1); +} + +StaticTableModel::~StaticTableModel() +{ + delete_all(mTableModel); + mTableModel.clear(); +} + +void StaticTableModel::resize() +{ + mRows = getRows(); + mColumns = getColumns(); + mTableModel.resize(mRows * mColumns, nullptr); +} + +void StaticTableModel::set(const int row, const int column, + Widget *const widget) +{ + if (!widget || row >= mRows || row < 0 + || column >= mColumns || column < 0) + { + // raise exn? + return; + } + + if (DYN_SIZE(mHeight) + && widget->getHeight() > mHeight) + { + mHeight = widget->getHeight(); + } + + if (DYN_SIZE(mWidths[column]) + && widget->getWidth() > mWidths[column]) + { + mWidths[column] = widget->getWidth(); + } + + signalBeforeUpdate(); + + delete mTableModel[WIDGET_AT(row, column)]; + + mTableModel[WIDGET_AT(row, column)] = widget; + + signalAfterUpdate(); +} + +Widget *StaticTableModel::getElementAt(const int row, + const int column) const +{ + return mTableModel[WIDGET_AT(row, column)]; +} + +void StaticTableModel::fixColumnWidth(const int column, const int width) +{ + if (width < 0 || column < 0 || column >= mColumns) + return; + + mWidths[column] = -width; // Negate to tag as fixed +} + +void StaticTableModel::fixRowHeight(const int height) +{ + if (height < 0) + return; + + mHeight = -height; +} + +int StaticTableModel::getRowHeight() const +{ + return abs(mHeight); +} + +int StaticTableModel::getColumnWidth(const int column) const +{ + if (column < 0 || column >= mColumns) + return 0; + + return abs(mWidths[column]); +} + +int StaticTableModel::getRows() const +{ + return mRows; +} + +int StaticTableModel::getColumns() const +{ + return mColumns; +} + +int StaticTableModel::getWidth() const +{ + int width = 0; + + for (size_t i = 0, sz = mWidths.size(); i < sz; i++) + width += mWidths[i]; + + return width; +} + +int StaticTableModel::getHeight() const +{ + return mColumns * mHeight; +} diff --git a/src/gui/models/tablemodel.h b/src/gui/models/tablemodel.h new file mode 100644 index 000000000..ff752e6f1 --- /dev/null +++ b/src/gui/models/tablemodel.h @@ -0,0 +1,164 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_TABLEMODEL_H +#define GUI_MODELS_TABLEMODEL_H + +#include +#include + +#include "localconsts.h" + +class Widget; + +class TableModelListener +{ +public: + /** + * Must be invoked by the TableModel whenever a global change is about to + * occur or has occurred (e.g., when a row or column is being removed or + * added). + * + * This method is triggered twice, once before and once after the update. + * + * \param completed whether we are signalling the end of the update + */ + virtual void modelUpdated(const bool completed) = 0; + + virtual ~TableModelListener() + { } +}; + +/** + * A model for a regular table of widgets. + */ +class TableModel +{ +public: + virtual ~TableModel() + { } + + /** + * Determines the number of rows (lines) in the table + */ + virtual int getRows() const A_WARN_UNUSED = 0; + + /** + * Determines the number of columns in each row + */ + virtual int getColumns() const A_WARN_UNUSED = 0; + + /** + * Determines the height for each row + */ + virtual int getRowHeight() const A_WARN_UNUSED = 0; + + /** + * Determines the width of each individual column + */ + virtual int getColumnWidth(const int index) const A_WARN_UNUSED = 0; + + /** + * Retrieves the widget stored at the specified location within the table. + */ + virtual Widget *getElementAt(const int row, const int column) + const A_WARN_UNUSED = 0; + + virtual void installListener(TableModelListener *const listener); + + virtual void removeListener(TableModelListener *const listener); + +protected: + TableModel() : + listeners() + { + } + + /** + * Tells all listeners that the table is about to see an update + */ + virtual void signalBeforeUpdate(); + + /** + * Tells all listeners that the table has seen an update + */ + virtual void signalAfterUpdate(); + +private: + std::set listeners; +}; + + +class StaticTableModel final : public TableModel +{ +public: + StaticTableModel(const int width, const int height); + + A_DELETE_COPY(StaticTableModel) + + ~StaticTableModel(); + + /** + * Inserts a widget into the table model. + * The model is resized to accomodate the widget's width and height, + * unless column width / row height have been fixed. + */ + void set(const int row, const int column, Widget *const widget); + + /** + * Fixes the column width for a given column; this overrides dynamic width + * inference. + * + * Semantics are undefined for width 0. + */ + void fixColumnWidth(const int column, const int width); + + /** + * Fixes the row height; this overrides dynamic height inference. + * + * Semantics are undefined for width 0. + */ + void fixRowHeight(const int height); + + /** + * Resizes the table model + */ + void resize(); + + int getRows() const override final A_WARN_UNUSED; + int getColumns() const override final A_WARN_UNUSED; + int getRowHeight() const override final A_WARN_UNUSED; + int getWidth() const A_WARN_UNUSED; + int getHeight() const A_WARN_UNUSED; + int getColumnWidth(const int index) const override final A_WARN_UNUSED; + Widget *getElementAt(const int row, + const int column) const + override final A_WARN_UNUSED; + +protected: + int mRows, mColumns; + int mHeight; + std::vector mTableModel; + std::vector mWidths; +}; + +#endif // GUI_MODELS_TABLEMODEL_H diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 23185a903..8f5d0d300 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -25,7 +25,7 @@ #include "localconsts.h" -#include "gui/widgets/tablemodel.h" +#include "gui/models/tablemodel.h" #include "listeners/keylistener.h" #include "listeners/mouselistener.h" diff --git a/src/gui/widgets/tablemodel.cpp b/src/gui/widgets/tablemodel.cpp deleted file mode 100644 index 82b249d0f..000000000 --- a/src/gui/widgets/tablemodel.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/tablemodel.h" - -#include "utils/dtor.h" - -#include "gui/widgets/widget.h" - -#include "debug.h" - -void TableModel::installListener(TableModelListener *const listener) -{ - if (listener) - listeners.insert(listener); -} - -void TableModel::removeListener(TableModelListener *const listener) -{ - if (listener) - listeners.erase(listener); -} - -void TableModel::signalBeforeUpdate() -{ - for (std::set::const_iterator it = listeners.begin(); - it != listeners.end(); ++it) - { - (*it)->modelUpdated(false); - } -} - -void TableModel::signalAfterUpdate() -{ - for (std::set::const_iterator it = listeners.begin(); - it != listeners.end(); ++it) - { - if (*it) - (*it)->modelUpdated(true); - } -} - - -#define WIDGET_AT(row, column) (((row) * mColumns) + (column)) -#define DYN_SIZE(h) ((h) >= 0) - -StaticTableModel::StaticTableModel(const int row, const int column) : - TableModel(), - mRows(row), - mColumns(column), - mHeight(1), - mTableModel(), - mWidths() -{ - mTableModel.resize(row * column, nullptr); - mWidths.resize(column, 1); -} - -StaticTableModel::~StaticTableModel() -{ - delete_all(mTableModel); - mTableModel.clear(); -} - -void StaticTableModel::resize() -{ - mRows = getRows(); - mColumns = getColumns(); - mTableModel.resize(mRows * mColumns, nullptr); -} - -void StaticTableModel::set(const int row, const int column, - Widget *const widget) -{ - if (!widget || row >= mRows || row < 0 - || column >= mColumns || column < 0) - { - // raise exn? - return; - } - - if (DYN_SIZE(mHeight) - && widget->getHeight() > mHeight) - { - mHeight = widget->getHeight(); - } - - if (DYN_SIZE(mWidths[column]) - && widget->getWidth() > mWidths[column]) - { - mWidths[column] = widget->getWidth(); - } - - signalBeforeUpdate(); - - delete mTableModel[WIDGET_AT(row, column)]; - - mTableModel[WIDGET_AT(row, column)] = widget; - - signalAfterUpdate(); -} - -Widget *StaticTableModel::getElementAt(const int row, - const int column) const -{ - return mTableModel[WIDGET_AT(row, column)]; -} - -void StaticTableModel::fixColumnWidth(const int column, const int width) -{ - if (width < 0 || column < 0 || column >= mColumns) - return; - - mWidths[column] = -width; // Negate to tag as fixed -} - -void StaticTableModel::fixRowHeight(const int height) -{ - if (height < 0) - return; - - mHeight = -height; -} - -int StaticTableModel::getRowHeight() const -{ - return abs(mHeight); -} - -int StaticTableModel::getColumnWidth(const int column) const -{ - if (column < 0 || column >= mColumns) - return 0; - - return abs(mWidths[column]); -} - -int StaticTableModel::getRows() const -{ - return mRows; -} - -int StaticTableModel::getColumns() const -{ - return mColumns; -} - -int StaticTableModel::getWidth() const -{ - int width = 0; - - for (size_t i = 0, sz = mWidths.size(); i < sz; i++) - width += mWidths[i]; - - return width; -} - -int StaticTableModel::getHeight() const -{ - return mColumns * mHeight; -} diff --git a/src/gui/widgets/tablemodel.h b/src/gui/widgets/tablemodel.h deleted file mode 100644 index 48bd336af..000000000 --- a/src/gui/widgets/tablemodel.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_TABLEMODEL_H -#define GUI_WIDGETS_TABLEMODEL_H - -#include -#include - -#include "localconsts.h" - -class Widget; - -class TableModelListener -{ -public: - /** - * Must be invoked by the TableModel whenever a global change is about to - * occur or has occurred (e.g., when a row or column is being removed or - * added). - * - * This method is triggered twice, once before and once after the update. - * - * \param completed whether we are signalling the end of the update - */ - virtual void modelUpdated(const bool completed) = 0; - - virtual ~TableModelListener() - { } -}; - -/** - * A model for a regular table of widgets. - */ -class TableModel -{ -public: - virtual ~TableModel() - { } - - /** - * Determines the number of rows (lines) in the table - */ - virtual int getRows() const A_WARN_UNUSED = 0; - - /** - * Determines the number of columns in each row - */ - virtual int getColumns() const A_WARN_UNUSED = 0; - - /** - * Determines the height for each row - */ - virtual int getRowHeight() const A_WARN_UNUSED = 0; - - /** - * Determines the width of each individual column - */ - virtual int getColumnWidth(const int index) const A_WARN_UNUSED = 0; - - /** - * Retrieves the widget stored at the specified location within the table. - */ - virtual Widget *getElementAt(const int row, const int column) - const A_WARN_UNUSED = 0; - - virtual void installListener(TableModelListener *const listener); - - virtual void removeListener(TableModelListener *const listener); - -protected: - TableModel() : - listeners() - { - } - - /** - * Tells all listeners that the table is about to see an update - */ - virtual void signalBeforeUpdate(); - - /** - * Tells all listeners that the table has seen an update - */ - virtual void signalAfterUpdate(); - -private: - std::set listeners; -}; - - -class StaticTableModel final : public TableModel -{ -public: - StaticTableModel(const int width, const int height); - - A_DELETE_COPY(StaticTableModel) - - ~StaticTableModel(); - - /** - * Inserts a widget into the table model. - * The model is resized to accomodate the widget's width and height, - * unless column width / row height have been fixed. - */ - void set(const int row, const int column, Widget *const widget); - - /** - * Fixes the column width for a given column; this overrides dynamic width - * inference. - * - * Semantics are undefined for width 0. - */ - void fixColumnWidth(const int column, const int width); - - /** - * Fixes the row height; this overrides dynamic height inference. - * - * Semantics are undefined for width 0. - */ - void fixRowHeight(const int height); - - /** - * Resizes the table model - */ - void resize(); - - int getRows() const override final A_WARN_UNUSED; - int getColumns() const override final A_WARN_UNUSED; - int getRowHeight() const override final A_WARN_UNUSED; - int getWidth() const A_WARN_UNUSED; - int getHeight() const A_WARN_UNUSED; - int getColumnWidth(const int index) const override final A_WARN_UNUSED; - Widget *getElementAt(const int row, - const int column) const - override final A_WARN_UNUSED; - -protected: - int mRows, mColumns; - int mHeight; - std::vector mTableModel; - std::vector mWidths; -}; - -#endif // GUI_WIDGETS_TABLEMODEL_H -- cgit v1.2.3-70-g09d2 From 792ea379274005afc321cbb4ba26b9e79b51f0eb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 17:36:25 +0300 Subject: Move touchactionmodel into gui/models. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/touchactionmodel.h | 47 ++++++++++++++++++++++++++++++++++++ src/gui/widgets/setuptouchitem.cpp | 2 ++ src/gui/widgets/setuptouchitem.h | 19 +-------------- src/gui/widgets/tabs/setup_touch.cpp | 1 + 6 files changed, 53 insertions(+), 18 deletions(-) create mode 100644 src/gui/models/touchactionmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b80e13a93..297713e72 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -228,6 +228,7 @@ SET(SRCS gui/widgets/guitable.h gui/models/tablemodel.cpp gui/models/tablemodel.h + gui/models/touchactionmodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h gui/widgets/textbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index c57e4eb74..ebfb1c59f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -324,6 +324,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabbedarea.h \ gui/models/tablemodel.cpp \ gui/models/tablemodel.h \ + gui/models/touchactionmodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ gui/widgets/textbox.cpp \ diff --git a/src/gui/models/touchactionmodel.h b/src/gui/models/touchactionmodel.h new file mode 100644 index 000000000..00abe89e2 --- /dev/null +++ b/src/gui/models/touchactionmodel.h @@ -0,0 +1,47 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_TOUCHACTIONMODEL_H +#define GUI_MODELS_TOUCHACTIONMODEL_H + +#include "gui/models/namesmodel.h" + +#include "gui/widgets/setupitem.h" + +class TouchActionsModel final : public NamesModel +{ + public: + TouchActionsModel(); + + A_DELETE_COPY(TouchActionsModel) + + ~TouchActionsModel() + { } + + int getActionFromSelection(const int sel) const; + + int getSelectionFromAction(const int action) const; + + private: + std::vector mActionId; + std::map mActionToSelection; +}; + +#endif // GUI_MODELS_TOUCHACTIONMODEL_H diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index d50af8ff3..c620686fd 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -22,6 +22,8 @@ #include "gui/setupactiondata.h" +#include "gui/models/touchactionmodel.h" + #include "gui/widgets/dropdown.h" #include "gui/widgets/horizontcontainer.h" #include "gui/widgets/label.h" diff --git a/src/gui/widgets/setuptouchitem.h b/src/gui/widgets/setuptouchitem.h index b84b15f81..2c1aa05d0 100644 --- a/src/gui/widgets/setuptouchitem.h +++ b/src/gui/widgets/setuptouchitem.h @@ -25,24 +25,7 @@ #include "gui/widgets/setupitem.h" -class TouchActionsModel final : public NamesModel -{ - public: - TouchActionsModel(); - - A_DELETE_COPY(TouchActionsModel) - - ~TouchActionsModel() - { } - - int getActionFromSelection(const int sel) const; - - int getSelectionFromAction(const int action) const; - - private: - std::vector mActionId; - std::map mActionToSelection; -}; +class TouchActionsModel; class SetupActionDropDown final : public SetupItem { diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index e26716973..d141691d4 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -21,6 +21,7 @@ #include "gui/widgets/tabs/setup_touch.h" #include "gui/models/namesmodel.h" +#include "gui/models/touchactionmodel.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/setuptouchitem.h" -- cgit v1.2.3-70-g09d2 From 4574f63edea86ecf31f43818615722015f01ebb4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 18:01:50 +0300 Subject: Move avatarlistmodel into gui/models directory. --- src/gui/models/avatarlistmodel.h | 40 +++++++++++++++++++++++++++++++++++++++ src/gui/widgets/avatarlistbox.cpp | 2 ++ src/gui/widgets/avatarlistbox.h | 10 +--------- src/gui/windows/socialwindow.cpp | 1 + src/guild.h | 2 +- src/party.h | 2 +- 6 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/gui/models/avatarlistmodel.h (limited to 'src') diff --git a/src/gui/models/avatarlistmodel.h b/src/gui/models/avatarlistmodel.h new file mode 100644 index 000000000..2bbd64878 --- /dev/null +++ b/src/gui/models/avatarlistmodel.h @@ -0,0 +1,40 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_AVATARLISTMODEL_H +#define GUI_MODELS_AVATARLISTMODEL_H + +#include "avatar.h" + +#include "gui/models/listmodel.h" + +#include + +class AvatarListModel : public ListModel +{ + public: + virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0; + + std::string getElementAt(int i) override final A_WARN_UNUSED + { return getAvatarAt(i)->getName(); } +}; + +#endif // GUI_MODELS_AVATARLISTMODEL_H diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 46b6ea20f..cf01517c6 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -32,6 +32,8 @@ #include "gui/gui.h" #include "gui/viewport.h" +#include "gui/models/avatarlistmodel.h" + #include "gui/windows/chatwindow.h" #include "resources/image.h" diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index e98cee368..e4f65a992 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -32,17 +32,9 @@ #include +class AvatarListModel; class Image; -class AvatarListModel : public ListModel -{ -public: - virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0; - - std::string getElementAt(int i) override final A_WARN_UNUSED - { return getAvatarAt(i)->getName(); } -}; - class AvatarListBox final : public ListBox, public ConfigListener { diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 3dbfa566d..5fb479510 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -41,6 +41,7 @@ #include "gui/windows/outfitwindow.h" +#include "gui/widgets/avatarlistbox.h" #include "gui/widgets/button.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/label.h" diff --git a/src/guild.h b/src/guild.h index 48b3d17b2..6206271e0 100644 --- a/src/guild.h +++ b/src/guild.h @@ -25,7 +25,7 @@ #include "avatar.h" -#include "gui/widgets/avatarlistbox.h" +#include "gui/models/avatarlistmodel.h" #include "utils/dtor.h" #include "utils/stringvector.h" diff --git a/src/party.h b/src/party.h index 79fdfcf9e..c839168c7 100644 --- a/src/party.h +++ b/src/party.h @@ -22,7 +22,7 @@ #ifndef PARTY_H #define PARTY_H -#include "gui/widgets/avatarlistbox.h" +#include "gui/models/avatarlistmodel.h" #include "utils/dtor.h" #include "utils/stringvector.h" -- cgit v1.2.3-70-g09d2 From 7898171f05a06df0541031d7491127493947c939 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 18:08:37 +0300 Subject: Move shopitems into gui/models. --- src/CMakeLists.txt | 4 +- src/Makefile.am | 4 +- src/gui/models/shopitems.cpp | 132 +++++++++++++++++++++++++++++++++++++ src/gui/models/shopitems.h | 141 ++++++++++++++++++++++++++++++++++++++++ src/gui/widgets/shopitems.cpp | 132 ------------------------------------- src/gui/widgets/shopitems.h | 141 ---------------------------------------- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/windows/buydialog.cpp | 3 +- src/gui/windows/selldialog.cpp | 3 +- src/gui/windows/shopwindow.cpp | 3 +- 10 files changed, 284 insertions(+), 281 deletions(-) create mode 100644 src/gui/models/shopitems.cpp create mode 100644 src/gui/models/shopitems.h delete mode 100644 src/gui/widgets/shopitems.cpp delete mode 100644 src/gui/widgets/shopitems.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 297713e72..e5ddcd8f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -204,8 +204,8 @@ SET(SRCS gui/widgets/tabs/setuptabscroll.h gui/widgets/setuptouchitem.cpp gui/widgets/setuptouchitem.h - gui/widgets/shopitems.cpp - gui/widgets/shopitems.h + gui/models/shopitems.cpp + gui/models/shopitems.h gui/widgets/shoplistbox.cpp gui/widgets/shoplistbox.h gui/widgets/shortcutcontainer.cpp diff --git a/src/Makefile.am b/src/Makefile.am index ebfb1c59f..4a788fa77 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -302,8 +302,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabs/setuptabscroll.h \ gui/widgets/setuptouchitem.cpp \ gui/widgets/setuptouchitem.h \ - gui/widgets/shopitems.cpp \ - gui/widgets/shopitems.h \ + gui/models/shopitems.cpp \ + gui/models/shopitems.h \ gui/widgets/shoplistbox.cpp \ gui/widgets/shoplistbox.h \ gui/widgets/shortcutcontainer.cpp \ diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp new file mode 100644 index 000000000..492409e76 --- /dev/null +++ b/src/gui/models/shopitems.cpp @@ -0,0 +1,132 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/models/shopitems.h" + +#include "shopitem.h" + +#include "utils/dtor.h" + +#include "debug.h" + +ShopItems::ShopItems(const bool mergeDuplicates) : + mShopItems(), + mMergeDuplicates(mergeDuplicates) +{ +} + +ShopItems::~ShopItems() +{ + clear(); +} + +std::string ShopItems::getElementAt(int i) +{ + if (i < 0 || static_cast(i) >= mShopItems.size() + || !mShopItems.at(i)) + { + return ""; + } + + return mShopItems.at(i)->getDisplayName(); +} + +void ShopItems::addItem(const int id, const unsigned char color, + const int amount, const int price) +{ + mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); +} + +void ShopItems::addItemNoDup(const int id, const unsigned char color, + const int amount, const int price) +{ + const ShopItem *const item = findItem(id, color); + if (!item) + mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); +} + +void ShopItems::addItem2(const int inventoryIndex, const int id, + const unsigned char color, + const int quantity, const int price) +{ + ShopItem *item = nullptr; + if (mMergeDuplicates) + item = findItem(id, color); + + if (item) + { + item->addDuplicate(inventoryIndex, quantity); + } + else + { + item = new ShopItem(inventoryIndex, id, color, quantity, price); + mShopItems.push_back(item); + } +} + +ShopItem *ShopItems::at(unsigned int i) const +{ + if (i >= mShopItems.size()) + return nullptr; + + return mShopItems.at(i); +} + +void ShopItems::erase(const unsigned int i) +{ + if (i >= mShopItems.size()) + return; + + mShopItems.erase(mShopItems.begin() + i); +} + +void ShopItems::del(const unsigned int i) +{ + if (i >= mShopItems.size()) + return; + + ShopItem *item = *(mShopItems.begin() + i); + mShopItems.erase(mShopItems.begin() + i); + delete item; +} + +void ShopItems::clear() +{ + delete_all(mShopItems); + mShopItems.clear(); +} + +ShopItem *ShopItems::findItem(const int id, const unsigned char color) const +{ + std::vector::const_iterator it = mShopItems.begin(); + const std::vector::const_iterator e = mShopItems.end(); + while (it != e) + { + ShopItem *const item = *it; + if (item->getId() == id && item->getColor() == color) + return item; + + ++it; + } + + return nullptr; +} diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h new file mode 100644 index 000000000..925354960 --- /dev/null +++ b/src/gui/models/shopitems.h @@ -0,0 +1,141 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_SHOPITEMS_H +#define GUI_MODELS_SHOPITEMS_H + +#include "gui/models/listmodel.h" + +#include +#include + +#include "localconsts.h" + +class ShopItem; + +/** + * This class handles the list of items available in a shop. + * + * The addItem routine can automatically check, if an item already exists and + * only adds duplicates to the old item, if one is found. The original + * distribution of the duplicates can be retrieved from the item. + * + * This functionality can be enabled in the constructor. + */ +class ShopItems final : public ListModel +{ + public: + /** + * Constructor. + * + * @param mergeDuplicates lets the Shop look for duplicate entries and + * merges them to one item. + */ + explicit ShopItems(const bool mergeDuplicates = false); + + A_DELETE_COPY(ShopItems) + + ~ShopItems(); + + /** + * Adds an item to the list. + */ + void addItem(const int id, const unsigned char color, + const int amount, const int price); + + /** + * Adds an item to the list (used by sell dialog). Looks for + * duplicate entries, if mergeDuplicates was turned on. + * + * @param inventoryIndex the inventory index of the item + * @param id the id of the item + * @param quantity number of available copies of the item + * @param price price of the item + */ + void addItem2(const int inventoryIndex, const int id, + const unsigned char color, + const int amount, const int price); + + void addItemNoDup(const int id, const unsigned char color, + const int amount, const int price); + + /** + * Returns the number of items in the shop. + */ + int getNumberOfElements() override final A_WARN_UNUSED + { return static_cast(mShopItems.size()); } + + bool empty() const A_WARN_UNUSED + { return mShopItems.empty(); } + + /** + * Returns the name of item number i in the shop. + * + * @param i the index to retrieve + */ + std::string getElementAt(int i) override final A_WARN_UNUSED; + + /** + * Returns the item number i in the shop. + */ + ShopItem *at(unsigned int i) const A_WARN_UNUSED; + + /** + * Removes an element from the shop. + * + * @param i index to remove + */ + void erase(const unsigned int i); + + /** + * Removes an element from the shop and destroy it. + * + * @param i index to remove + */ + void del(const unsigned int i); + + /** + * Clears the list of items in the shop. + */ + void clear(); + + std::vector &items() A_WARN_UNUSED + { return mShopItems; } + + private: + /** + * Searches the current items in the shop for the specified + * id and returns the item if found, or 0 else. + * + * @return the item found or 0 + */ + ShopItem *findItem(const int id, + const unsigned char color) const A_WARN_UNUSED; + + /** The list of items in the shop. */ + std::vector mShopItems; + + /** Look for duplicate entries on addition. */ + bool mMergeDuplicates; +}; + +#endif // GUI_MODELS_SHOPITEMS_H diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp deleted file mode 100644 index 2ac65253d..000000000 --- a/src/gui/widgets/shopitems.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "gui/widgets/shopitems.h" - -#include "shopitem.h" - -#include "utils/dtor.h" - -#include "debug.h" - -ShopItems::ShopItems(const bool mergeDuplicates) : - mShopItems(), - mMergeDuplicates(mergeDuplicates) -{ -} - -ShopItems::~ShopItems() -{ - clear(); -} - -std::string ShopItems::getElementAt(int i) -{ - if (i < 0 || static_cast(i) >= mShopItems.size() - || !mShopItems.at(i)) - { - return ""; - } - - return mShopItems.at(i)->getDisplayName(); -} - -void ShopItems::addItem(const int id, const unsigned char color, - const int amount, const int price) -{ - mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); -} - -void ShopItems::addItemNoDup(const int id, const unsigned char color, - const int amount, const int price) -{ - const ShopItem *const item = findItem(id, color); - if (!item) - mShopItems.push_back(new ShopItem(-1, id, color, amount, price)); -} - -void ShopItems::addItem2(const int inventoryIndex, const int id, - const unsigned char color, - const int quantity, const int price) -{ - ShopItem *item = nullptr; - if (mMergeDuplicates) - item = findItem(id, color); - - if (item) - { - item->addDuplicate(inventoryIndex, quantity); - } - else - { - item = new ShopItem(inventoryIndex, id, color, quantity, price); - mShopItems.push_back(item); - } -} - -ShopItem *ShopItems::at(unsigned int i) const -{ - if (i >= mShopItems.size()) - return nullptr; - - return mShopItems.at(i); -} - -void ShopItems::erase(const unsigned int i) -{ - if (i >= mShopItems.size()) - return; - - mShopItems.erase(mShopItems.begin() + i); -} - -void ShopItems::del(const unsigned int i) -{ - if (i >= mShopItems.size()) - return; - - ShopItem *item = *(mShopItems.begin() + i); - mShopItems.erase(mShopItems.begin() + i); - delete item; -} - -void ShopItems::clear() -{ - delete_all(mShopItems); - mShopItems.clear(); -} - -ShopItem *ShopItems::findItem(const int id, const unsigned char color) const -{ - std::vector::const_iterator it = mShopItems.begin(); - const std::vector::const_iterator e = mShopItems.end(); - while (it != e) - { - ShopItem *const item = *it; - if (item->getId() == id && item->getColor() == color) - return item; - - ++it; - } - - return nullptr; -} diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h deleted file mode 100644 index d1fa1ca98..000000000 --- a/src/gui/widgets/shopitems.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef GUI_WIDGETS_SHOPITEMS_H -#define GUI_WIDGETS_SHOPITEMS_H - -#include "gui/models/listmodel.h" - -#include -#include - -#include "localconsts.h" - -class ShopItem; - -/** - * This class handles the list of items available in a shop. - * - * The addItem routine can automatically check, if an item already exists and - * only adds duplicates to the old item, if one is found. The original - * distribution of the duplicates can be retrieved from the item. - * - * This functionality can be enabled in the constructor. - */ -class ShopItems final : public ListModel -{ - public: - /** - * Constructor. - * - * @param mergeDuplicates lets the Shop look for duplicate entries and - * merges them to one item. - */ - explicit ShopItems(const bool mergeDuplicates = false); - - A_DELETE_COPY(ShopItems) - - ~ShopItems(); - - /** - * Adds an item to the list. - */ - void addItem(const int id, const unsigned char color, - const int amount, const int price); - - /** - * Adds an item to the list (used by sell dialog). Looks for - * duplicate entries, if mergeDuplicates was turned on. - * - * @param inventoryIndex the inventory index of the item - * @param id the id of the item - * @param quantity number of available copies of the item - * @param price price of the item - */ - void addItem2(const int inventoryIndex, const int id, - const unsigned char color, - const int amount, const int price); - - void addItemNoDup(const int id, const unsigned char color, - const int amount, const int price); - - /** - * Returns the number of items in the shop. - */ - int getNumberOfElements() override final A_WARN_UNUSED - { return static_cast(mShopItems.size()); } - - bool empty() const A_WARN_UNUSED - { return mShopItems.empty(); } - - /** - * Returns the name of item number i in the shop. - * - * @param i the index to retrieve - */ - std::string getElementAt(int i) override final A_WARN_UNUSED; - - /** - * Returns the item number i in the shop. - */ - ShopItem *at(unsigned int i) const A_WARN_UNUSED; - - /** - * Removes an element from the shop. - * - * @param i index to remove - */ - void erase(const unsigned int i); - - /** - * Removes an element from the shop and destroy it. - * - * @param i index to remove - */ - void del(const unsigned int i); - - /** - * Clears the list of items in the shop. - */ - void clear(); - - std::vector &items() A_WARN_UNUSED - { return mShopItems; } - - private: - /** - * Searches the current items in the shop for the specified - * id and returns the item if found, or 0 else. - * - * @return the item found or 0 - */ - ShopItem *findItem(const int id, - const unsigned char color) const A_WARN_UNUSED; - - /** The list of items in the shop. */ - std::vector mShopItems; - - /** Look for duplicate entries on addition. */ - bool mMergeDuplicates; -}; - -#endif // GUI_WIDGETS_SHOPITEMS_H diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index ff45e5297..36104241d 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -32,7 +32,7 @@ #include "gui/popups/itempopup.h" -#include "gui/widgets/shopitems.h" +#include "gui/models/shopitems.h" #include "resources/image.h" diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index ac8187fc3..e64a7489b 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -28,13 +28,14 @@ #include "gui/windows/tradewindow.h" +#include "gui/models/shopitems.h" + #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" #include "gui/widgets/inttextfield.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/shopitems.h" #include "gui/widgets/shoplistbox.h" #include "gui/widgets/slider.h" diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index a89f7655a..525e3f133 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -30,11 +30,12 @@ #include "gui/windows/confirmdialog.h" #include "gui/windows/tradewindow.h" +#include "gui/models/shopitems.h" + #include "gui/widgets/button.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/shopitems.h" #include "gui/widgets/shoplistbox.h" #include "gui/widgets/slider.h" diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 706438f61..32e249d35 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -27,12 +27,13 @@ #include "gui/windows/selldialog.h" #include "gui/windows/tradewindow.h" +#include "gui/models/shopitems.h" + #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/label.h" #include "gui/widgets/layout.h" #include "gui/widgets/scrollarea.h" -#include "gui/widgets/shopitems.h" #include "gui/widgets/shoplistbox.h" #include "gui/widgets/tabs/chattab.h" -- cgit v1.2.3-70-g09d2 From a21e7a1004f8c4b135451929bdd7fbb57ee55910 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 19:28:24 +0300 Subject: fix touchactionmodel. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/touchactionmodel.cpp | 93 +++++++++++++++++++++++++++++++++++++ src/gui/widgets/setuptouchitem.cpp | 58 ----------------------- 4 files changed, 95 insertions(+), 58 deletions(-) create mode 100644 src/gui/models/touchactionmodel.cpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5ddcd8f8..d48d8b50e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -228,6 +228,7 @@ SET(SRCS gui/widgets/guitable.h gui/models/tablemodel.cpp gui/models/tablemodel.h + gui/models/touchactionmodel.cpp gui/models/touchactionmodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h diff --git a/src/Makefile.am b/src/Makefile.am index 4a788fa77..45576ab99 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -324,6 +324,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabbedarea.h \ gui/models/tablemodel.cpp \ gui/models/tablemodel.h \ + gui/models/touchactionmodel.cpp \ gui/models/touchactionmodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp new file mode 100644 index 000000000..e6cc4d046 --- /dev/null +++ b/src/gui/models/touchactionmodel.cpp @@ -0,0 +1,93 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/widgets/setuptouchitem.h" + +#include "gui/setupactiondata.h" + +#include "gui/models/touchactionmodel.h" + +#include "gui/widgets/dropdown.h" +#include "gui/widgets/horizontcontainer.h" +#include "gui/widgets/label.h" +#include "gui/widgets/vertcontainer.h" + +#include "gui/widgets/tabs/setuptabscroll.h" + +#include + +#include "debug.h" + +static class SortTouchActionFunctor final +{ + public: + bool operator() (const SetupActionData *const data1, + const SetupActionData *const data2) const + { + if (!data1 || !data2) + return false; + return data1->name < data2->name; + } +} touchActionSorter; + +TouchActionsModel::TouchActionsModel() : + NamesModel(), + mActionId(), + mActionToSelection() +{ + std::vector data; + + for (int f = 0, sz = touchActionDataSize; f < sz; f ++) + { + int k = 0; + while (!touchActionData[f][k].name.empty()) + { + data.push_back(&touchActionData[f][k]); + k ++; + } + } + + std::sort(data.begin(), data.end(), touchActionSorter); + int cnt = 0; + FOR_EACH (std::vector::iterator, it, data) + { + const SetupActionData *const data1 = *it; + mNames.push_back(data1->name); + mActionId.push_back(data1->actionId); + mActionToSelection[data1->actionId] = cnt; + cnt ++; + } +} + +int TouchActionsModel::getActionFromSelection(const int sel) const +{ + if (sel < 0 || sel > static_cast(mActionId.size())) + return -1; + return mActionId[sel]; +} + +int TouchActionsModel::getSelectionFromAction(const int action) const +{ + const std::map::const_iterator it + = mActionToSelection.find(action); + if (it == mActionToSelection.end()) + return 0; + return (*it).second; +} diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index c620686fd..99a774ecd 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -35,64 +35,6 @@ #include "debug.h" -static class SortTouchActionFunctor final -{ - public: - bool operator() (const SetupActionData *const data1, - const SetupActionData *const data2) const - { - if (!data1 || !data2) - return false; - return data1->name < data2->name; - } -} touchActionSorter; - -TouchActionsModel::TouchActionsModel() : - NamesModel(), - mActionId(), - mActionToSelection() -{ - std::vector data; - - for (int f = 0, sz = touchActionDataSize; f < sz; f ++) - { - int k = 0; - while (!touchActionData[f][k].name.empty()) - { - data.push_back(&touchActionData[f][k]); - k ++; - } - } - - std::sort(data.begin(), data.end(), touchActionSorter); - int cnt = 0; - FOR_EACH (std::vector::iterator, it, data) - { - const SetupActionData *const data1 = *it; - mNames.push_back(data1->name); - mActionId.push_back(data1->actionId); - mActionToSelection[data1->actionId] = cnt; - cnt ++; - } -} - -int TouchActionsModel::getActionFromSelection(const int sel) const -{ - if (sel < 0 || sel > static_cast(mActionId.size())) - return -1; - return mActionId[sel]; -} - -int TouchActionsModel::getSelectionFromAction(const int action) const -{ - const std::map::const_iterator it - = mActionToSelection.find(action); - if (it == mActionToSelection.end()) - return 0; - return (*it).second; -} - - SetupActionDropDown::SetupActionDropDown(const std::string &restrict text, const std::string &restrict description, -- cgit v1.2.3-70-g09d2 From 4adbe6036ac29080bb8d02d92efe1175209a85a3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 21:35:13 +0300 Subject: Move themesmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/themesmodel.h | 45 ++++++++++++++++++++++++++++++++++++ src/gui/widgets/tabs/setup_theme.cpp | 15 +----------- 4 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 src/gui/models/themesmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d48d8b50e..af1191eee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -230,6 +230,7 @@ SET(SRCS gui/models/tablemodel.h gui/models/touchactionmodel.cpp gui/models/touchactionmodel.h + gui/models/themesmodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h gui/widgets/textbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 45576ab99..733c470d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -326,6 +326,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/tablemodel.h \ gui/models/touchactionmodel.cpp \ gui/models/touchactionmodel.h \ + gui/models/themesmodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ gui/widgets/textbox.cpp \ diff --git a/src/gui/models/themesmodel.h b/src/gui/models/themesmodel.h new file mode 100644 index 000000000..b8b9dbae6 --- /dev/null +++ b/src/gui/models/themesmodel.h @@ -0,0 +1,45 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_THEMESMODEL_H +#define GUI_MODELS_THEMESMODEL_H + +#include "gui/models/namesmodel.h" + +#include "utils/gettext.h" + +#include "debug.h" + +class ThemesModel final : public NamesModel +{ + public: + ThemesModel() : + NamesModel() + { + mNames.push_back(gettext("(default)")); + Theme::fillSkinsList(mNames); + } + + ~ThemesModel() + { } +}; + +#endif // GUI_MODELS_THEMESMODEL_H diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 99deda940..7f2804c2f 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -28,6 +28,7 @@ #include "gui/models/extendedlistmodel.h" #include "gui/models/namesmodel.h" +#include "gui/models/themesmodel.h" #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" @@ -54,20 +55,6 @@ const char* ACTION_JAPAN_FONT = "japanese font"; const char* ACTION_CHINA_FONT = "chinese font"; const char* ACTION_INFO = "info"; -class ThemesModel final : public NamesModel -{ -public: - ThemesModel() : - NamesModel() - { - mNames.push_back(gettext("(default)")); - Theme::fillSkinsList(mNames); - } - - ~ThemesModel() - { } -}; - class FontsModel final : public NamesModel { public: -- cgit v1.2.3-70-g09d2 From 56c7ed4647d168842bda18ee797e735ccc5fd557 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 22:28:59 +0300 Subject: Move themesmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/fontsmodel.h | 42 ++++++++++++++++++++++++++++++++++++ src/gui/models/themesmodel.h | 2 ++ src/gui/widgets/tabs/setup_theme.cpp | 12 +---------- 5 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 src/gui/models/fontsmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af1191eee..06dfac28e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,6 +141,7 @@ SET(SRCS gui/models/extendedlistmodel.h gui/models/extendednamesmodel.cpp gui/models/extendednamesmodel.h + gui/models/fontsmodel.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h gui/widgets/tabs/gmtab.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 733c470d0..b8e8abc3f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -237,6 +237,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/extendedlistmodel.h \ gui/models/extendednamesmodel.cpp \ gui/models/extendednamesmodel.h \ + gui/models/fontsmodel.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ gui/widgets/tabs/gmtab.cpp \ diff --git a/src/gui/models/fontsmodel.h b/src/gui/models/fontsmodel.h new file mode 100644 index 000000000..b20d3386b --- /dev/null +++ b/src/gui/models/fontsmodel.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_FONTSMODEL_H +#define GUI_MODELS_FONTSMODEL_H + +#include "gui/theme.h" + +#include "gui/models/namesmodel.h" + +#include "debug.h" + +class FontsModel final : public NamesModel +{ + public: + FontsModel() : + NamesModel() + { Theme::fillFontsList(mNames); } + + ~FontsModel() + { } +}; + +#endif // GUI_MODELS_FONTSMODEL_H diff --git a/src/gui/models/themesmodel.h b/src/gui/models/themesmodel.h index b8b9dbae6..b19c698fc 100644 --- a/src/gui/models/themesmodel.h +++ b/src/gui/models/themesmodel.h @@ -22,6 +22,8 @@ #ifndef GUI_MODELS_THEMESMODEL_H #define GUI_MODELS_THEMESMODEL_H +#include "gui/theme.h" + #include "gui/models/namesmodel.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 7f2804c2f..4bde4b35e 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -27,6 +27,7 @@ #include "gui/windows/okdialog.h" #include "gui/models/extendedlistmodel.h" +#include "gui/models/fontsmodel.h" #include "gui/models/namesmodel.h" #include "gui/models/themesmodel.h" @@ -55,17 +56,6 @@ const char* ACTION_JAPAN_FONT = "japanese font"; const char* ACTION_CHINA_FONT = "chinese font"; const char* ACTION_INFO = "info"; -class FontsModel final : public NamesModel -{ -public: - FontsModel() : - NamesModel() - { Theme::fillFontsList(mNames); } - - ~FontsModel() - { } -}; - const int maxFontSizes = 16; const char *SIZE_NAME[maxFontSizes] = -- cgit v1.2.3-70-g09d2 From 95982ba8c3767f93fc9b8627de3fa5adde26f126 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 22:44:16 +0300 Subject: Move playerrelationlistmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/playerrelationlistmodel.h | 67 ++++++++++++++++++++++++++++++++ src/gui/widgets/tabs/setup_relations.cpp | 39 +------------------ 4 files changed, 71 insertions(+), 37 deletions(-) create mode 100644 src/gui/models/playerrelationlistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 06dfac28e..b8b2b1925 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -179,6 +179,7 @@ SET(SRCS gui/widgets/listbox.h gui/models/namesmodel.cpp gui/models/namesmodel.h + gui/models/playerrelationlistmodel.h gui/widgets/passwordfield.cpp gui/widgets/passwordfield.h gui/widgets/playerbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b8e8abc3f..dec589c4b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -277,6 +277,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/listbox.h \ gui/models/namesmodel.cpp \ gui/models/namesmodel.h \ + gui/models/playerrelationlistmodel.h \ gui/widgets/passwordfield.cpp \ gui/widgets/passwordfield.h \ gui/widgets/playerbox.cpp \ diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h new file mode 100644 index 000000000..9251631f7 --- /dev/null +++ b/src/gui/models/playerrelationlistmodel.h @@ -0,0 +1,67 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_PLAYERRELATIONLISTMODEL_H +#define GUI_MODELS_PLAYERRELATIONLISTMODEL_H + +#include "being/playerrelations.h" + +#include "utils/gettext.h" + +static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] = +{ + // TRANSLATORS: relation type + N_("Neutral"), + // TRANSLATORS: relation type + N_("Friend"), + // TRANSLATORS: relation type + N_("Disregarded"), + // TRANSLATORS: relation type + N_("Ignored"), + // TRANSLATORS: relation type + N_("Erased"), + // TRANSLATORS: relation type + N_("Blacklisted"), + // TRANSLATORS: relation type + N_("Enemy") +}; + +class PlayerRelationListModel final : public ListModel +{ + public: + ~PlayerRelationListModel() + { } + + int getNumberOfElements() override final + { + return PlayerRelation::RELATIONS_NR; + } + + std::string getElementAt(int i) override final + { + if (i >= getNumberOfElements() || i < 0) + return ""; + return gettext(RELATION_NAMES[i]); + } +}; + +#endif diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 1af4e1769..8fa377e3d 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -26,6 +26,8 @@ #include "being/localplayer.h" +#include "gui/models/playerrelationlistmodel.h" + #include "gui/widgets/button.h" #include "gui/widgets/checkbox.h" #include "gui/widgets/dropdown.h" @@ -60,43 +62,6 @@ static const char *const table_titles[COLUMNS_NR] = N_("Relation") }; -static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] = -{ - // TRANSLATORS: relation type - N_("Neutral"), - // TRANSLATORS: relation type - N_("Friend"), - // TRANSLATORS: relation type - N_("Disregarded"), - // TRANSLATORS: relation type - N_("Ignored"), - // TRANSLATORS: relation type - N_("Erased"), - // TRANSLATORS: relation type - N_("Blacklisted"), - // TRANSLATORS: relation type - N_("Enemy") -}; - -class PlayerRelationListModel final : public ListModel -{ -public: - ~PlayerRelationListModel() - { } - - int getNumberOfElements() override final - { - return PlayerRelation::RELATIONS_NR; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return ""; - return gettext(RELATION_NAMES[i]); - } -}; - class PlayerTableModel final : public Widget2, public TableModel { public: -- cgit v1.2.3-70-g09d2 From 5c53d50e9da718690e3f8d055ecd3bf10a866267 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 23:06:48 +0300 Subject: Move ignorechoiceslistmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/ignorechoiceslistmodel.h | 55 ++++++++++++++++++++++++++++++++ src/gui/widgets/tabs/setup_relations.cpp | 26 +-------------- 4 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 src/gui/models/ignorechoiceslistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b8b2b1925..bff6a6ae1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -142,6 +142,7 @@ SET(SRCS gui/models/extendednamesmodel.cpp gui/models/extendednamesmodel.h gui/models/fontsmodel.h + gui/models/ignorechoiceslistmodel.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h gui/widgets/tabs/gmtab.cpp diff --git a/src/Makefile.am b/src/Makefile.am index dec589c4b..7de2a97d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -238,6 +238,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/extendednamesmodel.cpp \ gui/models/extendednamesmodel.h \ gui/models/fontsmodel.h \ + gui/models/ignorechoiceslistmodel.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ gui/widgets/tabs/gmtab.cpp \ diff --git a/src/gui/models/ignorechoiceslistmodel.h b/src/gui/models/ignorechoiceslistmodel.h new file mode 100644 index 000000000..7234b57f2 --- /dev/null +++ b/src/gui/models/ignorechoiceslistmodel.h @@ -0,0 +1,55 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_IGNORECHOICESLISTMODEL_H +#define GUI_MODELS_IGNORECHOICESLISTMODEL_H + +#include "being/playerrelations.h" + +#include "gui/models/playerrelationlistmodel.h" + +/** + * Class for choosing one of the various `what to do when ignoring a player' options + */ +class IgnoreChoicesListModel final : public ListModel +{ + public: + ~IgnoreChoicesListModel() + { } + + int getNumberOfElements() override final + { + return static_cast(player_relations.getPlayerIgnoreStrategies( + )->size()); + } + + std::string getElementAt(int i) override final + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + + return (*player_relations.getPlayerIgnoreStrategies()) + [i]->mDescription; + } +}; + +#endif // GUI_MODELS_IGNORECHOICESLISTMODEL_H diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 8fa377e3d..1f85a23b4 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -26,6 +26,7 @@ #include "being/localplayer.h" +#include "gui/models/ignorechoiceslistmodel.h" #include "gui/models/playerrelationlistmodel.h" #include "gui/widgets/button.h" @@ -178,31 +179,6 @@ protected: PlayerRelationListModel *mListModel; }; -/** - * Class for choosing one of the various `what to do when ignoring a player' options - */ -class IgnoreChoicesListModel final : public ListModel -{ -public: - ~IgnoreChoicesListModel() - { } - - int getNumberOfElements() override final - { - return static_cast(player_relations.getPlayerIgnoreStrategies() - ->size()); - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return (*player_relations.getPlayerIgnoreStrategies()) - [i]->mDescription; - } -}; - static const std::string ACTION_DELETE("delete"); static const std::string ACTION_TABLE("table"); static const std::string ACTION_STRATEGY("strategy"); -- cgit v1.2.3-70-g09d2 From 5bd149387fe8ce35915e9c58d35938eb03b99051 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 23:35:31 +0300 Subject: Move soundsmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/soundsmodel.h | 42 ++++++++++++++++++++++++++++++++++++ src/gui/widgets/tabs/setup_audio.cpp | 15 +------------ 4 files changed, 45 insertions(+), 14 deletions(-) create mode 100644 src/gui/models/soundsmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bff6a6ae1..857b09896 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -219,6 +219,7 @@ SET(SRCS gui/widgets/skillinfo.h gui/models/skillmodel.cpp gui/models/skillmodel.h + gui/models/soundsmodel.h gui/widgets/slider.cpp gui/widgets/slider.h gui/widgets/sliderlist.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 7de2a97d0..931a5da9f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -317,6 +317,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/skillinfo.h \ gui/models/skillmodel.cpp \ gui/models/skillmodel.h \ + gui/models/soundsmodel.h \ gui/widgets/slider.cpp \ gui/widgets/slider.h \ gui/widgets/sliderlist.cpp \ diff --git a/src/gui/models/soundsmodel.h b/src/gui/models/soundsmodel.h new file mode 100644 index 000000000..2851e2265 --- /dev/null +++ b/src/gui/models/soundsmodel.h @@ -0,0 +1,42 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "gui/theme.h" + +#include "gui/models/namesmodel.h" + +#include "utils/gettext.h" + +#include "debug.h" + +class SoundsModel final : public NamesModel +{ + public: + SoundsModel() : + NamesModel() + { + mNames.push_back(gettext("(no sound)")); + Theme::fillSoundsList(mNames); + } + + ~SoundsModel() + { } +}; diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index e7c49723a..c5cb8cef1 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -31,6 +31,7 @@ #include "gui/viewport.h" #include "gui/models/namesmodel.h" +#include "gui/models/soundsmodel.h" #include "gui/widgets/layouthelper.h" #include "gui/widgets/scrollarea.h" @@ -39,20 +40,6 @@ #include "debug.h" -class SoundsModel final : public NamesModel -{ -public: - SoundsModel() : - NamesModel() - { - mNames.push_back(gettext("(no sound)")); - Theme::fillSoundsList(mNames); - } - - ~SoundsModel() - { } -}; - Setup_Audio::Setup_Audio(const Widget2 *const widget) : SetupTabScroll(widget), mSoundModel(new SoundsModel), -- cgit v1.2.3-70-g09d2 From 462a5b4d9f0a65c33d7119d19e960065910f1766 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 22 Feb 2014 23:52:29 +0300 Subject: move sortlistmodelinv into gui/models directory. --- src/gui/models/sortlistmodelinv.h | 65 +++++++++++++++++++++++++++++++++++++ src/gui/windows/inventorywindow.cpp | 35 +------------------- 2 files changed, 66 insertions(+), 34 deletions(-) create mode 100644 src/gui/models/sortlistmodelinv.h (limited to 'src') diff --git a/src/gui/models/sortlistmodelinv.h b/src/gui/models/sortlistmodelinv.h new file mode 100644 index 000000000..ae0982af6 --- /dev/null +++ b/src/gui/models/sortlistmodelinv.h @@ -0,0 +1,65 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_SORTLISTMODELINV_H +#define GUI_MODELS_SORTLISTMODELINV_H + +#include "gui/models/listmodel.h" + +#include "utils/gettext.h" + +#include + +static const char *const SORT_NAME_INVENTORY[6] = +{ + // TRANSLATORS: inventory sort mode + N_("default"), + // TRANSLATORS: inventory sort mode + N_("by name"), + // TRANSLATORS: inventory sort mode + N_("by id"), + // TRANSLATORS: inventory sort mode + N_("by weight"), + // TRANSLATORS: inventory sort mode + N_("by amount"), + // TRANSLATORS: inventory sort mode + N_("by type") +}; + +class SortListModelInv final : public ListModel +{ + public: + ~SortListModelInv() + { } + + int getNumberOfElements() override final + { return 6; } + + std::string getElementAt(int i) override final + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + + return gettext(SORT_NAME_INVENTORY[i]); + } +}; + +#endif // GUI_MODELS_SORTLISTMODELINV_H diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index be1487566..af6a9a2c4 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -37,6 +37,7 @@ #include "gui/viewport.h" #include "gui/models/listmodel.h" +#include "gui/models/sortlistmodelinv.h" #include "gui/popups/textpopup.h" @@ -65,40 +66,6 @@ #include "debug.h" -static const char *const SORT_NAME_INVENTORY[6] = -{ - // TRANSLATORS: inventory sort mode - N_("default"), - // TRANSLATORS: inventory sort mode - N_("by name"), - // TRANSLATORS: inventory sort mode - N_("by id"), - // TRANSLATORS: inventory sort mode - N_("by weight"), - // TRANSLATORS: inventory sort mode - N_("by amount"), - // TRANSLATORS: inventory sort mode - N_("by type") -}; - -class SortListModelInv final : public ListModel -{ -public: - ~SortListModelInv() - { } - - int getNumberOfElements() override final - { return 6; } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return gettext(SORT_NAME_INVENTORY[i]); - } -}; - InventoryWindow::WindowList InventoryWindow::invInstances; InventoryWindow::InventoryWindow(Inventory *const inventory): -- cgit v1.2.3-70-g09d2 From 90bef86efe7fcd0a6f6c0cbefc3645ffcf689d9e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 00:08:07 +0300 Subject: Move itemsmodel into gui/models directory. --- src/gui/models/itemsmodel.h | 86 ++++++++++++++++++++++++++++++++++++ src/gui/windows/itemamountwindow.cpp | 50 +-------------------- 2 files changed, 87 insertions(+), 49 deletions(-) create mode 100644 src/gui/models/itemsmodel.h (limited to 'src') diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h new file mode 100644 index 000000000..383bb9c14 --- /dev/null +++ b/src/gui/models/itemsmodel.h @@ -0,0 +1,86 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_ITEMSMODEL_H +#define GUI_MODELS_ITEMSMODEL_H + +#include "gui/models/listmodel.h" + +#include "resources/iteminfo.h" + +#include "resources/db/itemdb.h" + +#include "utils/gettext.h" + +#include "debug.h" + +class ItemsModal final : public ListModel +{ + public: + ItemsModal() : + mStrings() + { + const std::map &items = ItemDB::getItemInfos(); + std::list tempStrings; + + for (std::map::const_iterator + i = items.begin(), i_end = items.end(); + i != i_end; ++i) + { + if (i->first < 0) + continue; + + const ItemInfo &info = *i->second; + const std::string name = info.getName(); + if (name != "unnamed" && !info.getName().empty() + && info.getName() != "unnamed") + { + tempStrings.push_back(name); + } + } + tempStrings.sort(); + FOR_EACH (std::list::const_iterator, i, tempStrings) + mStrings.push_back(*i); + } + + A_DELETE_COPY(ItemsModal) + + ~ItemsModal() + { } + + int getNumberOfElements() override final + { + return static_cast(mStrings.size()); + } + + std::string getElementAt(int i) override final + { + if (i < 0 || i >= getNumberOfElements()) + return "???"; + return mStrings.at(i); + } + + private: + StringVect mStrings; +}; + +#endif // GUI_MODELS_ITEMSMODEL_H diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index b65d5481f..dba69b424 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -33,6 +33,7 @@ #include "net/net.h" #include "gui/viewport.h" +#include "gui/models/itemsmodel.h" #include "gui/models/listmodel.h" #include "gui/popups/itempopup.h" @@ -52,55 +53,6 @@ #include "debug.h" -class ItemsModal final : public ListModel -{ -public: - ItemsModal() : - mStrings() - { - const std::map &items = ItemDB::getItemInfos(); - std::list tempStrings; - - for (std::map::const_iterator - i = items.begin(), i_end = items.end(); - i != i_end; ++i) - { - if (i->first < 0) - continue; - - const ItemInfo &info = *i->second; - const std::string name = info.getName(); - if (name != "unnamed" && !info.getName().empty() - && info.getName() != "unnamed") - { - tempStrings.push_back(name); - } - } - tempStrings.sort(); - FOR_EACH (std::list::const_iterator, i, tempStrings) - mStrings.push_back(*i); - } - - A_DELETE_COPY(ItemsModal) - - ~ItemsModal() - { } - - int getNumberOfElements() override final - { - return static_cast(mStrings.size()); - } - - std::string getElementAt(int i) override final - { - if (i < 0 || i >= getNumberOfElements()) - return "???"; - return mStrings.at(i); - } -private: - StringVect mStrings; -}; - void ItemAmountWindow::finish(Item *const item, const int amount, const int price, const Usage usage) { -- cgit v1.2.3-70-g09d2 From 76165a338ca9679ab029e95f6c4d691e85ddb7fb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 00:28:25 +0300 Subject: Move updatetypemodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/updatetypemodel.h | 63 ++++++++++++++++++++++++++++++++++++++++ src/gui/windows/logindialog.cpp | 36 ++--------------------- 4 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 src/gui/models/updatetypemodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 857b09896..608314038 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -234,6 +234,7 @@ SET(SRCS gui/models/tablemodel.h gui/models/touchactionmodel.cpp gui/models/touchactionmodel.h + gui/models/updatetypemodel.h gui/models/themesmodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h diff --git a/src/Makefile.am b/src/Makefile.am index 931a5da9f..62de23970 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -330,6 +330,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/tablemodel.h \ gui/models/touchactionmodel.cpp \ gui/models/touchactionmodel.h \ + gui/models/updatetypemodel.h \ gui/models/themesmodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ diff --git a/src/gui/models/updatetypemodel.h b/src/gui/models/updatetypemodel.h new file mode 100644 index 000000000..f96c11e87 --- /dev/null +++ b/src/gui/models/updatetypemodel.h @@ -0,0 +1,63 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_UPDATETYPEMODEL_H +#define GUI_MODELS_UPDATETYPEMODEL_H + +#include "utils/gettext.h" + +#include "gui/models/listmodel.h" + +const char *UPDATE_TYPE_TEXT[3] = +{ + // TRANSLATORS: update type + N_("Normal"), + // TRANSLATORS: update type + N_("Auto Close"), + // TRANSLATORS: update type + N_("Skip"), +}; + +class UpdateTypeModel final : public ListModel +{ + public: + UpdateTypeModel() + { } + + A_DELETE_COPY(UpdateTypeModel) + + ~UpdateTypeModel() + { } + + int getNumberOfElements() override final + { + return 3; + } + + std::string getElementAt(int i) override final + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + return gettext(UPDATE_TYPE_TEXT[i]); + } +}; + +#endif // GUI_MODELS_UPDATETYPEMODEL_H diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index ac060817d..edd010707 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -29,6 +29,8 @@ #include "input/keydata.h" +#include "gui/models/updatetypemodel.h" + #include "gui/windows/confirmdialog.h" #include "gui/widgets/button.h" @@ -74,40 +76,6 @@ namespace } urlListener; } // namespace -const char *UPDATE_TYPE_TEXT[3] = -{ - // TRANSLATORS: update type - N_("Normal"), - // TRANSLATORS: update type - N_("Auto Close"), - // TRANSLATORS: update type - N_("Skip"), -}; - -class UpdateTypeModel final : public ListModel -{ - public: - UpdateTypeModel() - { } - - A_DELETE_COPY(UpdateTypeModel) - - ~UpdateTypeModel() - { } - - int getNumberOfElements() override final - { - return 3; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(UPDATE_TYPE_TEXT[i]); - } -}; - class UpdateListModel final : public ListModel { public: -- cgit v1.2.3-70-g09d2 From f5186d4bc4c97b357fda2df45255d81c1045ee33 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 00:39:39 +0300 Subject: Move updatelistmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/updatelistmodel.h | 66 ++++++++++++++++++++++++++++++++++++++++ src/gui/windows/logindialog.cpp | 33 +------------------- 4 files changed, 69 insertions(+), 32 deletions(-) create mode 100644 src/gui/models/updatelistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 608314038..84c0c5057 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -235,6 +235,7 @@ SET(SRCS gui/models/touchactionmodel.cpp gui/models/touchactionmodel.h gui/models/updatetypemodel.h + gui/models/updatelistmodel.h gui/models/themesmodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h diff --git a/src/Makefile.am b/src/Makefile.am index 62de23970..dc765b567 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -331,6 +331,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/touchactionmodel.cpp \ gui/models/touchactionmodel.h \ gui/models/updatetypemodel.h \ + gui/models/updatelistmodel.h \ gui/models/themesmodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h new file mode 100644 index 000000000..31f96c959 --- /dev/null +++ b/src/gui/models/updatelistmodel.h @@ -0,0 +1,66 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_UPDATELISTMODEL_H +#define GUI_MODELS_UPDATELISTMODEL_H + +#include "gui/models/listmodel.h" + +#include "net/logindata.h" + +#include "utils/gettext.h" + +#include "debug.h" + +class UpdateListModel final : public ListModel +{ + public: + explicit UpdateListModel(LoginData *const data) : + ListModel(), + mLoginData(data) + { + } + + A_DELETE_COPY(UpdateListModel) + + ~UpdateListModel() + { } + + int getNumberOfElements() override final + { + if (!mLoginData) + return 0; + return static_cast(mLoginData->updateHosts.size()); + } + + std::string getElementAt(int i) override final + { + if (!mLoginData || i >= getNumberOfElements() || i < 0) + return "???"; + return mLoginData->updateHosts[i]; + } + + protected: + LoginData *mLoginData; +}; + +#endif // GUI_MODELS_UPDATELISTMODEL_H diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index edd010707..71abf153a 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -29,6 +29,7 @@ #include "input/keydata.h" +#include "gui/models/updatelistmodel.h" #include "gui/models/updatetypemodel.h" #include "gui/windows/confirmdialog.h" @@ -76,38 +77,6 @@ namespace } urlListener; } // namespace -class UpdateListModel final : public ListModel -{ - public: - explicit UpdateListModel(LoginData *const data) : - ListModel(), - mLoginData(data) - { - } - - A_DELETE_COPY(UpdateListModel) - - ~UpdateListModel() - { } - - int getNumberOfElements() override final - { - if (!mLoginData) - return 0; - return static_cast(mLoginData->updateHosts.size()); - } - - std::string getElementAt(int i) override final - { - if (!mLoginData || i >= getNumberOfElements() || i < 0) - return "???"; - return mLoginData->updateHosts[i]; - } - - protected: - LoginData *mLoginData; -}; - LoginDialog::LoginDialog(LoginData *const data, std::string serverName, std::string *const updateHost): // TRANSLATORS: login dialog name -- cgit v1.2.3-70-g09d2 From d94fca4c217f7adef156a80b450be8073364a707 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 01:19:43 +0300 Subject: Move worldlistmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/worldlistmodel.h | 68 +++++++++++++++++++++++++++++++++++ src/gui/windows/worldselectdialog.cpp | 39 +------------------- 4 files changed, 71 insertions(+), 38 deletions(-) create mode 100644 src/gui/models/worldlistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84c0c5057..8e668ce2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -236,6 +236,7 @@ SET(SRCS gui/models/touchactionmodel.h gui/models/updatetypemodel.h gui/models/updatelistmodel.h + gui/models/worldlistmodel.h gui/models/themesmodel.h gui/widgets/tabstrip.cpp gui/widgets/tabstrip.h diff --git a/src/Makefile.am b/src/Makefile.am index dc765b567..0d33eedcb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -332,6 +332,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/touchactionmodel.h \ gui/models/updatetypemodel.h \ gui/models/updatelistmodel.h \ + gui/models/worldlistmodel.h \ gui/models/themesmodel.h \ gui/widgets/tabstrip.cpp \ gui/widgets/tabstrip.h \ diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h new file mode 100644 index 000000000..7d9dc322c --- /dev/null +++ b/src/gui/models/worldlistmodel.h @@ -0,0 +1,68 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_WORLDLISTMODEL_H +#define GUI_MODELS_WORLDLISTMODEL_H + +#include "gui/models/listmodel.h" + +#include "net/worldinfo.h" + +/** + * The list model for the server list. + */ +class WorldListModel final : public ListModel +{ + public: + explicit WorldListModel(Worlds worlds) : + mWorlds(worlds) + { + } + + A_DELETE_COPY(WorldListModel) + + ~WorldListModel() + { } + + int getNumberOfElements() override final + { + return static_cast(mWorlds.size()); + } + + std::string getElementAt(int i) override final + { + const WorldInfo *const si = mWorlds[i]; + if (si) + { + return std::string(si->name).append(" (").append( + toString(si->online_users)).append(")"); + } + else + { + return "???"; + } + } + private: + Worlds mWorlds; +}; + +#endif // GUI_MODELS_WORLDLISTMODEL_H diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index e588e5eb0..db17820db 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -34,6 +34,7 @@ #include "gui/widgets/scrollarea.h" #include "gui/models/listmodel.h" +#include "gui/models/worldlistmodel.h" #include "net/loginhandler.h" #include "net/net.h" @@ -44,44 +45,6 @@ extern WorldInfo **server_info; -/** - * The list model for the server list. - */ -class WorldListModel final : public ListModel -{ - public: - explicit WorldListModel(Worlds worlds) : - mWorlds(worlds) - { - } - - A_DELETE_COPY(WorldListModel) - - ~WorldListModel() - { } - - int getNumberOfElements() override final - { - return static_cast(mWorlds.size()); - } - - std::string getElementAt(int i) override final - { - const WorldInfo *const si = mWorlds[i]; - if (si) - { - return std::string(si->name).append(" (").append( - toString(si->online_users)).append(")"); - } - else - { - return "???"; - } - } - private: - Worlds mWorlds; -}; - WorldSelectDialog::WorldSelectDialog(Worlds worlds): // TRANSLATORS: world select dialog name Window(_("Select World"), false, nullptr, "world.xml"), -- cgit v1.2.3-70-g09d2 From df2ba2dd07a6358f9015af6a6549ef766f86a8fb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 12:09:01 +0300 Subject: Move iconsmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/iconsmodel.h | 84 +++++++++++++++++++++++++++++++++++ src/gui/windows/textcommandeditor.cpp | 60 +++---------------------- src/gui/windows/textcommandeditor.h | 4 +- 5 files changed, 93 insertions(+), 57 deletions(-) create mode 100644 src/gui/models/iconsmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e668ce2c..e90c06b0f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -142,6 +142,7 @@ SET(SRCS gui/models/extendednamesmodel.cpp gui/models/extendednamesmodel.h gui/models/fontsmodel.h + gui/models/iconsmodel.h gui/models/ignorechoiceslistmodel.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h diff --git a/src/Makefile.am b/src/Makefile.am index 0d33eedcb..56840ea85 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -238,6 +238,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/extendednamesmodel.cpp \ gui/models/extendednamesmodel.h \ gui/models/fontsmodel.h \ + gui/models/iconsmodel.h \ gui/models/ignorechoiceslistmodel.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h new file mode 100644 index 000000000..4c549953b --- /dev/null +++ b/src/gui/models/iconsmodel.h @@ -0,0 +1,84 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_ICONSMODEL_H +#define GUI_MODELS_ICONSMODEL_H + +#include "gui/models/listmodel.h" + +#include "resources/iteminfo.h" + +#include "resources/db/itemdb.h" + +#include "debug.h" + +class IconsModel final : public ListModel +{ + public: + IconsModel() : + mStrings() + { + const std::map &items = ItemDB::getItemInfos(); + std::list tempStrings; + + for (std::map::const_iterator + i = items.begin(), i_end = items.end(); + i != i_end; ++i) + { + if (i->first < 0) + continue; + + const ItemInfo &info = (*i->second); + const std::string name = info.getName(); + if (name != "unnamed" && !info.getName().empty() + && info.getName() != "unnamed") + { + tempStrings.push_back(name); + } + } + tempStrings.sort(); + mStrings.push_back(""); + FOR_EACH (std::list::const_iterator, i, tempStrings) + mStrings.push_back(*i); + } + + A_DELETE_COPY(IconsModel) + + ~IconsModel() + { } + + int getNumberOfElements() override final + { + return static_cast(mStrings.size()); + } + + std::string getElementAt(int i) override final + { + if (i < 0 || i >= getNumberOfElements()) + return "???"; + return mStrings.at(i); + } + private: + StringVect mStrings; +}; + +#endif // GUI_MODELS_ICONSMODEL_H diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 358077021..c1cd204ac 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -27,6 +27,7 @@ #include "input/keyboardconfig.h" +#include "gui/models/iconsmodel.h" #include "gui/models/listmodel.h" #include "gui/widgets/button.h" @@ -44,57 +45,6 @@ #include "debug.h" -class IconsModal final : public ListModel -{ -public: - IconsModal() : - mStrings() - { - const std::map &items = ItemDB::getItemInfos(); - std::list tempStrings; - - for (std::map::const_iterator - i = items.begin(), i_end = items.end(); - i != i_end; ++i) - { - if (i->first < 0) - continue; - - const ItemInfo &info = (*i->second); - const std::string name = info.getName(); - if (name != "unnamed" && !info.getName().empty() - && info.getName() != "unnamed") - { - tempStrings.push_back(name); - } - } - tempStrings.sort(); - mStrings.push_back(""); - FOR_EACH (std::list::const_iterator, i, tempStrings) - mStrings.push_back(*i); - } - - A_DELETE_COPY(IconsModal) - - ~IconsModal() - { } - - int getNumberOfElements() override final - { - return static_cast(mStrings.size()); - } - - std::string getElementAt(int i) override final - { - if (i < 0 || i >= getNumberOfElements()) - return "???"; - return mStrings.at(i); - } -private: - StringVect mStrings; -}; - - const char *TARGET_TYPE_TEXT[3] = { // TRANSLATORS: target type @@ -182,10 +132,10 @@ TextCommandEditor::TextCommandEditor(TextCommand *const command) : // TRANSLATORS: command editor label mTypeLabel(new Label(this, _("Target Type:"))), mTypeDropDown(new DropDown(this, mTargetTypeModel)), - mIconsModal(new IconsModal), + mIconsModel(new IconsModel), // TRANSLATORS: command editor label mIconLabel(new Label(this, _("Icon:"))), - mIconDropDown(new DropDown(this, mIconsModal)), + mIconDropDown(new DropDown(this, mIconsModel)), // TRANSLATORS: command editor label mManaLabel(new Label(this, _("Mana:"))), mManaField(new IntTextField(this, 0)), @@ -308,8 +258,8 @@ void TextCommandEditor::postInit() TextCommandEditor::~TextCommandEditor() { - delete mIconsModal; - mIconsModal = nullptr; + delete mIconsModel; + mIconsModel = nullptr; delete mTargetTypeModel; mTargetTypeModel = nullptr; delete mMagicSchoolModel; diff --git a/src/gui/windows/textcommandeditor.h b/src/gui/windows/textcommandeditor.h index 3b5e239cd..de7f3b1a4 100644 --- a/src/gui/windows/textcommandeditor.h +++ b/src/gui/windows/textcommandeditor.h @@ -29,7 +29,7 @@ class Button; class DropDown; -class IconsModal; +class IconsModel; class IntTextField; class Label; class MagicSchoolModel; @@ -83,7 +83,7 @@ class TextCommandEditor final : public Window, TargetTypeModel *mTargetTypeModel; Label *mTypeLabel; DropDown *mTypeDropDown; - IconsModal *mIconsModal; + IconsModel *mIconsModel; Label *mIconLabel; DropDown *mIconDropDown; Label *mManaLabel; -- cgit v1.2.3-70-g09d2 From 0d6d3d8c02aa4979577bbcd932c875d6463046b4 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 12:19:52 +0300 Subject: Move targettypemodel into gui/model directory. --- src/gui/models/targettypemodel.h | 58 +++++++++++++++++++++++++++++++++++ src/gui/windows/textcommandeditor.cpp | 30 +----------------- 2 files changed, 59 insertions(+), 29 deletions(-) create mode 100644 src/gui/models/targettypemodel.h (limited to 'src') diff --git a/src/gui/models/targettypemodel.h b/src/gui/models/targettypemodel.h new file mode 100644 index 000000000..d049585a5 --- /dev/null +++ b/src/gui/models/targettypemodel.h @@ -0,0 +1,58 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_TARGETTYPEMODEL_H +#define GUI_MODELS_TARGETTYPEMODEL_H + +#include "gui/models/listmodel.h" + +#include "utils/gettext.h" + +const char *TARGET_TYPE_TEXT[3] = +{ + // TRANSLATORS: target type + N_("No Target"), + // TRANSLATORS: target type + N_("Allow Target"), + // TRANSLATORS: target type + N_("Need Target") +}; + +class TargetTypeModel final : public ListModel +{ + public: + ~TargetTypeModel() + { } + + int getNumberOfElements() override final + { + return 3; + } + + std::string getElementAt(int i) override final + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + return TARGET_TYPE_TEXT[i]; + } +}; + +#endif // GUI_MODELS_TARGETTYPEMODEL_H diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index c1cd204ac..1a3094701 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -29,6 +29,7 @@ #include "gui/models/iconsmodel.h" #include "gui/models/listmodel.h" +#include "gui/models/targettypemodel.h" #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" @@ -45,16 +46,6 @@ #include "debug.h" -const char *TARGET_TYPE_TEXT[3] = -{ - // TRANSLATORS: target type - N_("No Target"), - // TRANSLATORS: target type - N_("Allow Target"), - // TRANSLATORS: target type - N_("Need Target"), -}; - const char *MAGIC_SCHOOL_TEXT[6] = { // TRANSLATORS: magic school @@ -71,25 +62,6 @@ const char *MAGIC_SCHOOL_TEXT[6] = N_("Astral Magic") }; -class TargetTypeModel final : public ListModel -{ -public: - ~TargetTypeModel() - { } - - int getNumberOfElements() override final - { - return 3; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return TARGET_TYPE_TEXT[i]; - } -}; - class MagicSchoolModel final : public ListModel { public: -- cgit v1.2.3-70-g09d2 From 2da15d7db0aa51bf2d64802fdeee08b0b8a5a161 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 12:25:16 +0300 Subject: Move magicschoolmodel into gui/model directory. --- src/gui/models/magicschoolmodel.h | 67 +++++++++++++++++++++++++++++++++++ src/gui/windows/textcommandeditor.cpp | 36 +------------------ 2 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 src/gui/models/magicschoolmodel.h (limited to 'src') diff --git a/src/gui/models/magicschoolmodel.h b/src/gui/models/magicschoolmodel.h new file mode 100644 index 000000000..b30147f3d --- /dev/null +++ b/src/gui/models/magicschoolmodel.h @@ -0,0 +1,67 @@ +/* + * The ManaPlus Client + * Copyright (C) 2009 The Mana World Development Team + * Copyright (C) 2009-2010 Andrei Karas + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_MAGICSCHOOLMODEL_H +#define GUI_MODELS_MAGICSCHOOLMODEL_H + +#include "gui/models/listmodel.h" + +#include "utils/gettext.h" + +#include "debug.h" + +const char *MAGIC_SCHOOL_TEXT[6] = +{ + // TRANSLATORS: magic school + N_("General Magic"), + // TRANSLATORS: magic school + N_("Life Magic"), + // TRANSLATORS: magic school + N_("War Magic"), + // TRANSLATORS: magic school + N_("Transmute Magic"), + // TRANSLATORS: magic school + N_("Nature Magic"), + // TRANSLATORS: magic school + N_("Astral Magic") +}; + +class MagicSchoolModel final : public ListModel +{ + public: + ~MagicSchoolModel() + { } + + int getNumberOfElements() override final + { + return 6; + } + + std::string getElementAt(int i) override final + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + return MAGIC_SCHOOL_TEXT[i]; + } +}; + +#endif // GUI_MODELS_MAGICSCHOOLMODEL_H diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 1a3094701..17703388f 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -29,6 +29,7 @@ #include "gui/models/iconsmodel.h" #include "gui/models/listmodel.h" +#include "gui/models/magicschoolmodel.h" #include "gui/models/targettypemodel.h" #include "gui/widgets/button.h" @@ -46,41 +47,6 @@ #include "debug.h" -const char *MAGIC_SCHOOL_TEXT[6] = -{ - // TRANSLATORS: magic school - N_("General Magic"), - // TRANSLATORS: magic school - N_("Life Magic"), - // TRANSLATORS: magic school - N_("War Magic"), - // TRANSLATORS: magic school - N_("Transmute Magic"), - // TRANSLATORS: magic school - N_("Nature Magic"), - // TRANSLATORS: magic school - N_("Astral Magic") -}; - -class MagicSchoolModel final : public ListModel -{ -public: - ~MagicSchoolModel() - { } - - int getNumberOfElements() override final - { - return 6; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return MAGIC_SCHOOL_TEXT[i]; - } -}; - TextCommandEditor::TextCommandEditor(TextCommand *const command) : // TRANSLATORS: command editor name Window(_("Command Editor"), false, nullptr, "commandeditor.xml"), -- cgit v1.2.3-70-g09d2 From a82f24070bc8d11f0fd487a18df0c73c63a0742c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 12:51:27 +0300 Subject: Move typelistmodel into gui/model directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/typelistmodel.h | 82 ++++++++++++++++++++++++++++++++++++ src/gui/windows/editserverdialog.cpp | 25 +---------- src/gui/windows/editserverdialog.h | 35 +-------------- 5 files changed, 87 insertions(+), 57 deletions(-) create mode 100644 src/gui/models/typelistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e90c06b0f..db705332c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -235,6 +235,7 @@ SET(SRCS gui/models/tablemodel.h gui/models/touchactionmodel.cpp gui/models/touchactionmodel.h + gui/models/typelistmodel.h gui/models/updatetypemodel.h gui/models/updatelistmodel.h gui/models/worldlistmodel.h diff --git a/src/Makefile.am b/src/Makefile.am index 56840ea85..4db3f1fa5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -331,6 +331,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/tablemodel.h \ gui/models/touchactionmodel.cpp \ gui/models/touchactionmodel.h \ + gui/models/typelistmodel.h \ gui/models/updatetypemodel.h \ gui/models/updatelistmodel.h \ gui/models/worldlistmodel.h \ diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h new file mode 100644 index 000000000..d7b6226b0 --- /dev/null +++ b/src/gui/models/typelistmodel.h @@ -0,0 +1,82 @@ +/* + * The Mana Client + * Copyright (C) 2011-2012 The Mana Developers + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The Mana Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_TYPELISTMODEL_H +#define GUI_MODELS_TYPELISTMODEL_H + +#include "gui/models/listmodel.h" + +/** + * Server Type List Model + */ +class TypeListModel : public ListModel +{ + public: + TypeListModel() + { } + + /** + * Used to get number of line in the list + */ + int getNumberOfElements() override final A_WARN_UNUSED +#ifdef EATHENA_SUPPORT +#ifdef MANASERV_SUPPORT + { return 4; } +#else + { return 3; } +#endif +#else +#ifdef MANASERV_SUPPORT + { return 3; } +#else + { return 2; } +#endif +#endif + + /** + * Used to get an element from the list + */ + std::string getElementAt(int elementIndex) + override final A_WARN_UNUSED + { + if (elementIndex == 0) + return "TmwAthena"; + else if (elementIndex == 1) + return "Evol"; +#ifdef EATHENA_SUPPORT + else if (elementIndex == 2) + return "eAthena"; +#ifdef MANASERV_SUPPORT + else if (elementIndex == 3) + return "ManaServ"; +#endif +#else +#ifdef MANASERV_SUPPORT + else if (elementIndex == 2) + return "ManaServ"; +#endif +#endif + else + return "Unknown"; + } +}; + +#endif // GUI_MODELS_TYPELISTMODEL_H diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index 2286a9b36..e236841a5 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -25,6 +25,8 @@ #include "input/keydata.h" +#include "gui/models/typelistmodel.h" + #include "gui/windows/okdialog.h" #include "gui/windows/serverdialog.h" @@ -36,29 +38,6 @@ #include "utils/gettext.h" -std::string TypeListModel::getElementAt(int elementIndex) -{ - if (elementIndex == 0) - return "TmwAthena"; - else if (elementIndex == 1) - return "Evol"; -#ifdef EATHENA_SUPPORT - else if (elementIndex == 2) - return "eAthena"; -#ifdef MANASERV_SUPPORT - else if (elementIndex == 3) - return "ManaServ"; -#endif -#else -#ifdef MANASERV_SUPPORT - else if (elementIndex == 2) - return "ManaServ"; -#endif -#endif - else - return "Unknown"; -} - EditServerDialog::EditServerDialog(ServerDialog *const parent, ServerInfo server, const int index) : diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index a3f649f0d..215666394 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -26,6 +26,7 @@ class Button; class TextField; class DropDown; class ServerDialog; +class TypeListModel; #include "gui/widgets/window.h" @@ -36,40 +37,6 @@ class ServerDialog; #include "gui/models/listmodel.h" -/** - * Server Type List Model - */ -class TypeListModel : public ListModel -{ - public: - TypeListModel() - { } - - /** - * Used to get number of line in the list - */ - int getNumberOfElements() override final A_WARN_UNUSED -#ifdef EATHENA_SUPPORT -#ifdef MANASERV_SUPPORT - { return 4; } -#else - { return 3; } -#endif -#else -#ifdef MANASERV_SUPPORT - { return 3; } -#else - { return 2; } -#endif -#endif - - /** - * Used to get an element from the list - */ - std::string getElementAt(int elementIndex) - override final A_WARN_UNUSED; -}; - /** * The custom server addition dialog. * -- cgit v1.2.3-70-g09d2 From 03e7dcdcf8624a6c2a5d25e25484cd5d8c7df74b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 12:59:26 +0300 Subject: Move questsmodel into gui/models directory. --- src/gui/models/questsmodel.h | 40 ++++++++++++++++++++++++++++++++++++++++ src/gui/windows/questswindow.cpp | 15 +-------------- 2 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 src/gui/models/questsmodel.h (limited to 'src') diff --git a/src/gui/models/questsmodel.h b/src/gui/models/questsmodel.h new file mode 100644 index 000000000..d9421f402 --- /dev/null +++ b/src/gui/models/questsmodel.h @@ -0,0 +1,40 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_QUESTSMODEL_H +#define GUI_MODELS_QUESTSMODEL_H + +#include "gui/models/extendednamesmodel.h" + +class QuestsModel final : public ExtendedNamesModel +{ + public: + QuestsModel() : + ExtendedNamesModel() + { + } + + A_DELETE_COPY(QuestsModel) + + ~QuestsModel() + { } +}; + +#endif // GUI_MODELS_QUESTSMODEL_H diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 1ee78e563..319bf5df0 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -30,6 +30,7 @@ #include "gui/gui.h" #include "gui/models/extendednamesmodel.h" +#include "gui/models/questsmodel.h" #include "gui/widgets/browserbox.h" #include "gui/widgets/button.h" @@ -89,20 +90,6 @@ struct QuestItem final bool broken; }; -class QuestsModel final : public ExtendedNamesModel -{ - public: - QuestsModel() : - ExtendedNamesModel() - { - } - - A_DELETE_COPY(QuestsModel) - - ~QuestsModel() - { } -}; - struct QuestEffect final { QuestEffect() : -- cgit v1.2.3-70-g09d2 From 61292d969be1ba94ed2847edc2168c438b1a76ab Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 13:16:28 +0300 Subject: Move serverslistmodel into gui/models directory. --- src/gui/models/serverslistmodel.h | 109 ++++++++++++++++++++++++++++++++++++++ src/gui/windows/serverdialog.cpp | 42 +-------------- src/gui/windows/serverdialog.h | 42 +-------------- 3 files changed, 112 insertions(+), 81 deletions(-) create mode 100644 src/gui/models/serverslistmodel.h (limited to 'src') diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h new file mode 100644 index 000000000..630d9664e --- /dev/null +++ b/src/gui/models/serverslistmodel.h @@ -0,0 +1,109 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_SERVERSLISTMODEL_H +#define GUI_MODELS_SERVERSLISTMODEL_H + +#include "net/serverinfo.h" + +#include "utils/mutex.h" + +#include "gui/models/listmodel.h" + +#include "net/serverinfo.h" + +#include +#include + +class ServerDialog; + +/** + * Server and Port List Model + */ +class ServersListModel final : public ListModel +{ + public: + typedef std::pair VersionString; + + ServersListModel(ServerInfos *const servers, + ServerDialog *const parent) : + mServers(servers), + mVersionStrings(servers->size(), VersionString(0, "")), + mParent(parent) + { + } + + A_DELETE_COPY(ServersListModel) + + /** + * Used to get number of line in the list + */ + int getNumberOfElements() override final A_WARN_UNUSED + { + MutexLocker lock = mParent->lock(); + return static_cast(mServers->size()); + } + + /** + * Used to get an element from the list + */ + std::string getElementAt(int elementIndex) + override final A_WARN_UNUSED + { + MutexLocker lock = mParent->lock(); + const ServerInfo &server = mServers->at(elementIndex); + std::string myServer; + myServer.append(server.hostname); + return myServer; + } + + /** + * Used to get the corresponding Server struct + */ + const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED + { return mServers->at(elementIndex); } + + void setVersionString(const int index, const std::string &version) + { + if (index < 0 || index >= static_cast(mVersionStrings.size())) + return; + + if (version.empty() || !gui) + { + mVersionStrings[index] = VersionString(0, ""); + } + else + { + mVersionStrings[index] = VersionString( + gui->getFont()->getWidth(version), version); + } + } + + private: + typedef std::vector VersionStrings; + + ServerInfos *mServers; + VersionStrings mVersionStrings; + ServerDialog *mParent; +}; + +#endif // GUI_MODELS_SERVERSLISTMODEL_H diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index a6e3637fb..18da8682e 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -34,6 +34,8 @@ #include "gui/font.h" #include "gui/gui.h" +#include "gui/models/serverslistmodel.h" + #include "gui/widgets/checkbox.h" #include "gui/windows/editserverdialog.h" #include "gui/windows/logindialog.h" @@ -105,46 +107,6 @@ static uint16_t defaultPortForServerType(const ServerInfo::Type type) } } -ServersListModel::ServersListModel(ServerInfos *const servers, - ServerDialog *const parent) : - mServers(servers), - mVersionStrings(servers->size(), VersionString(0, "")), - mParent(parent) -{ -} - -int ServersListModel::getNumberOfElements() -{ - MutexLocker lock = mParent->lock(); - return static_cast(mServers->size()); -} - -std::string ServersListModel::getElementAt(int elementIndex) -{ - MutexLocker lock = mParent->lock(); - const ServerInfo &server = mServers->at(elementIndex); - std::string myServer; - myServer.append(server.hostname); - return myServer; -} - -void ServersListModel::setVersionString(const int index, - const std::string &version) -{ - if (index < 0 || index >= static_cast(mVersionStrings.size())) - return; - - if (version.empty() || !gui) - { - mVersionStrings[index] = VersionString(0, ""); - } - else - { - mVersionStrings[index] = VersionString( - gui->getFont()->getWidth(version), version); - } -} - class ServersListBox final : public ListBox { public: diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 2d0ada344..07e2b5dcc 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -44,47 +44,7 @@ class CheckBox; class Label; class ListBox; class ServerDialog; - -/** - * Server and Port List Model - */ -class ServersListModel final : public ListModel -{ - public: - typedef std::pair VersionString; - - ServersListModel(ServerInfos *const servers, - ServerDialog *const parent); - - A_DELETE_COPY(ServersListModel) - - /** - * Used to get number of line in the list - */ - int getNumberOfElements() override final A_WARN_UNUSED; - - /** - * Used to get an element from the list - */ - std::string getElementAt(int elementIndex) - override final A_WARN_UNUSED; - - /** - * Used to get the corresponding Server struct - */ - const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED - { return mServers->at(elementIndex); } - - void setVersionString(const int index, const std::string &version); - - private: - typedef std::vector VersionStrings; - - ServerInfos *mServers; - VersionStrings mVersionStrings; - ServerDialog *mParent; -}; - +class ServersListModel; /** * The server choice dialog. -- cgit v1.2.3-70-g09d2 From 8b21a7d29c64f57b38fe8e54a36299ded552da8b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 13:43:09 +0300 Subject: Move colorlistmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/colorlistmodel.h | 81 +++++++++++++++++++++++++++++++++++++++++ src/gui/windows/chatwindow.cpp | 54 +-------------------------- 4 files changed, 85 insertions(+), 52 deletions(-) create mode 100644 src/gui/models/colorlistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index db705332c..930729f36 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -107,6 +107,7 @@ MARK_AS_ADVANCED(SDL_LIBRARY) SET(SRCS gui/widgets/avatarlistbox.cpp gui/widgets/avatarlistbox.h + gui/models/colorlistmodel.h gui/widgets/tabs/battletab.cpp gui/widgets/tabs/battletab.h gui/widgets/browserbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 4db3f1fa5..0391b1bde 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -203,6 +203,7 @@ manaplus_SOURCES += events/actionevent.h \ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/avatarlistbox.h \ + gui/models/colorlistmodel.h \ gui/widgets/tabs/battletab.cpp \ gui/widgets/tabs/battletab.h \ gui/widgets/browserbox.cpp \ diff --git a/src/gui/models/colorlistmodel.h b/src/gui/models/colorlistmodel.h new file mode 100644 index 000000000..d4b2e4237 --- /dev/null +++ b/src/gui/models/colorlistmodel.h @@ -0,0 +1,81 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_COLORLISTMODEL_H +#define GUI_MODELS_COLORLISTMODEL_H + +#include "gui/models/listmodel.h" + +#include "utils/gettext.h" + +const char *COLOR_NAME[14] = +{ + // TRANSLATORS: chat color + N_("default"), + // TRANSLATORS: chat color + N_("black"), + // TRANSLATORS: chat color + N_("red"), + // TRANSLATORS: chat color + N_("green"), + // TRANSLATORS: chat color + N_("blue"), + // TRANSLATORS: chat color + N_("gold"), + // TRANSLATORS: chat color + N_("yellow"), + // TRANSLATORS: chat color + N_("pink"), + // TRANSLATORS: chat color + N_("purple"), + // TRANSLATORS: chat color + N_("grey"), + // TRANSLATORS: chat color + N_("brown"), + // TRANSLATORS: chat color + N_("rainbow 1"), + // TRANSLATORS: chat color + N_("rainbow 2"), + // TRANSLATORS: chat color + N_("rainbow 3"), +}; + +class ColorListModel final : public ListModel +{ + public: + ~ColorListModel() + { } + + int getNumberOfElements() + { + return 14; + } + + std::string getElementAt(int i) + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + return gettext(COLOR_NAME[i]); + } +}; + +#endif // GUI_MODELS_COLORLISTMODEL_H diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index eb4a0fb44..3c0e09ad5 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -43,6 +43,8 @@ #include "gui/gui.h" #include "gui/viewport.h" +#include "gui/models/colorlistmodel.h" + #include "gui/windows/emotewindow.h" #include "gui/windows/setupwindow.h" #include "gui/widgets/tabbedarea.h" @@ -144,58 +146,6 @@ class ChatInput final : public TextField bool mFocusGaining; }; -const char *COLOR_NAME[14] = -{ - // TRANSLATORS: chat color - N_("default"), - // TRANSLATORS: chat color - N_("black"), - // TRANSLATORS: chat color - N_("red"), - // TRANSLATORS: chat color - N_("green"), - // TRANSLATORS: chat color - N_("blue"), - // TRANSLATORS: chat color - N_("gold"), - // TRANSLATORS: chat color - N_("yellow"), - // TRANSLATORS: chat color - N_("pink"), - // TRANSLATORS: chat color - N_("purple"), - // TRANSLATORS: chat color - N_("grey"), - // TRANSLATORS: chat color - N_("brown"), - // TRANSLATORS: chat color - N_("rainbow 1"), - // TRANSLATORS: chat color - N_("rainbow 2"), - // TRANSLATORS: chat color - N_("rainbow 3"), -}; - - -class ColorListModel final : public ListModel -{ -public: - ~ColorListModel() - { } - - int getNumberOfElements() - { - return 14; - } - - std::string getElementAt(int i) - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(COLOR_NAME[i]); - } -}; - static const char *const ACTION_COLOR_PICKER = "color picker"; ChatWindow::ChatWindow(): -- cgit v1.2.3-70-g09d2 From 2bdfb00921306fd3d0370e15fd1fe7f08b1f67f7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 13:55:55 +0300 Subject: Move beingslistmodel into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/beingslistmodel.h | 62 ++++++++++++++++++++++++++++++++++++++++ src/gui/windows/socialwindow.cpp | 57 ++++++++---------------------------- 4 files changed, 76 insertions(+), 45 deletions(-) create mode 100644 src/gui/models/beingslistmodel.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 930729f36..dec92abe1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -107,6 +107,7 @@ MARK_AS_ADVANCED(SDL_LIBRARY) SET(SRCS gui/widgets/avatarlistbox.cpp gui/widgets/avatarlistbox.h + gui/models/beingslistmodel.h gui/models/colorlistmodel.h gui/widgets/tabs/battletab.cpp gui/widgets/tabs/battletab.h diff --git a/src/Makefile.am b/src/Makefile.am index 0391b1bde..dc9475d48 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -203,6 +203,7 @@ manaplus_SOURCES += events/actionevent.h \ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/avatarlistbox.h \ + gui/models/beingslistmodel.h \ gui/models/colorlistmodel.h \ gui/widgets/tabs/battletab.cpp \ gui/widgets/tabs/battletab.h \ diff --git a/src/gui/models/beingslistmodel.h b/src/gui/models/beingslistmodel.h new file mode 100644 index 000000000..9f3c48bcc --- /dev/null +++ b/src/gui/models/beingslistmodel.h @@ -0,0 +1,62 @@ +/* + * The ManaPlus Client + * Copyright (C) 2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_BEINGSLISTMODEL_H +#define GUI_MODELS_BEINGSLISTMODEL_H + +#include "gui/models/avatarlistmodel.h" + +class BeingsListModel final : public AvatarListModel +{ + public: + BeingsListModel() : + AvatarListModel(), + mMembers() + { + } + + A_DELETE_COPY(BeingsListModel) + + ~BeingsListModel() + { + delete_all(mMembers); + mMembers.clear(); + } + + std::vector *getMembers() + { + return &mMembers; + } + + Avatar *getAvatarAt(int index) override final + { + return mMembers[index]; + } + + int getNumberOfElements() override final + { + return static_cast(mMembers.size()); + } + + std::vector mMembers; +}; + +#endif // GUI_MODELS_BEINGSLISTMODEL_H diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 5fb479510..f33534a85 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -33,6 +33,8 @@ #include "input/keyboardconfig.h" +#include "gui/models/beingslistmodel.h" + #include "gui/windows/confirmdialog.h" #include "gui/windows/okdialog.h" #include "gui/windows/setupwindow.h" @@ -503,41 +505,6 @@ private: Party *mParty; }; -class BeingsListModal final : public AvatarListModel -{ -public: - BeingsListModal() : - AvatarListModel(), - mMembers() - { - } - - A_DELETE_COPY(BeingsListModal) - - ~BeingsListModal() - { - delete_all(mMembers); - mMembers.clear(); - } - - std::vector *getMembers() - { - return &mMembers; - } - - Avatar *getAvatarAt(int index) override final - { - return mMembers[index]; - } - - int getNumberOfElements() override final - { - return static_cast(mMembers.size()); - } - - std::vector mMembers; -}; - class SocialPlayersTab final : public SocialTab { public: @@ -545,7 +512,7 @@ public: std::string name, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModal) + mBeings(new BeingsListModel) { mList = new AvatarListBox(this, mBeings); mList->postInit(); @@ -701,7 +668,7 @@ public: } private: - BeingsListModal *mBeings; + BeingsListModel *mBeings; }; @@ -711,7 +678,7 @@ public: SocialNavigationTab(const Widget2 *const widget, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModal) + mBeings(new BeingsListModel) { mList = new AvatarListBox(this, mBeings); mList->postInit(); @@ -978,7 +945,7 @@ public: } private: - BeingsListModal *mBeings; + BeingsListModel *mBeings; }; @@ -1040,7 +1007,7 @@ public: SocialAttackTab(const Widget2 *const widget, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModal) + mBeings(new BeingsListModel) { mList = new AvatarListBox(this, mBeings); mList->postInit(); @@ -1078,7 +1045,7 @@ public: } private: - BeingsListModal *mBeings; + BeingsListModel *mBeings; }; class SocialPickupTab final : public SocialTab @@ -1087,7 +1054,7 @@ public: SocialPickupTab(const Widget2 *const widget, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModal) + mBeings(new BeingsListModel) { mList = new AvatarListBox(this, mBeings); mList->postInit(); @@ -1123,7 +1090,7 @@ public: } private: - BeingsListModal *mBeings; + BeingsListModel *mBeings; }; @@ -1134,7 +1101,7 @@ public: std::string name, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModal) + mBeings(new BeingsListModel) { mList = new AvatarListBox(this, mBeings); mList->postInit(); @@ -1214,7 +1181,7 @@ public: } private: - BeingsListModal *mBeings; + BeingsListModel *mBeings; }; -- cgit v1.2.3-70-g09d2 From abbe2e84657fdb3afc6f07b6df82918938862fd8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 14:03:30 +0300 Subject: Move sortlistmodelbuy into gui/models directory. --- src/CMakeLists.txt | 1 + src/Makefile.am | 1 + src/gui/models/sortlistmodelbuy.h | 65 +++++++++++++++++++++++++++++++++++++++ src/gui/windows/buydialog.cpp | 36 +--------------------- 4 files changed, 68 insertions(+), 35 deletions(-) create mode 100644 src/gui/models/sortlistmodelbuy.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dec92abe1..01d842f87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -222,6 +222,7 @@ SET(SRCS gui/widgets/skillinfo.h gui/models/skillmodel.cpp gui/models/skillmodel.h + gui/models/sortlistmodelbuy.h gui/models/soundsmodel.h gui/widgets/slider.cpp gui/widgets/slider.h diff --git a/src/Makefile.am b/src/Makefile.am index dc9475d48..73a69231b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -320,6 +320,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/skillinfo.h \ gui/models/skillmodel.cpp \ gui/models/skillmodel.h \ + gui/models/sortlistmodelbuy.h \ gui/models/soundsmodel.h \ gui/widgets/slider.cpp \ gui/widgets/slider.h \ diff --git a/src/gui/models/sortlistmodelbuy.h b/src/gui/models/sortlistmodelbuy.h new file mode 100644 index 000000000..1647ae822 --- /dev/null +++ b/src/gui/models/sortlistmodelbuy.h @@ -0,0 +1,65 @@ +/* + * The ManaPlus Client + * Copyright (C) 2004-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MODELS_SORTLISTMODELBUY_H +#define GUI_MODELS_SORTLISTMODELBUY_H + +#include "gui/models/listmodel.h" + +#include "utils/gettext.h" + +static const char *const SORT_NAME_BUY[7] = +{ + // TRANSLATORS: buy dialog sort type. + N_("unsorted"), + // TRANSLATORS: buy dialog sort type. + N_("by price"), + // TRANSLATORS: buy dialog sort type. + N_("by name"), + // TRANSLATORS: buy dialog sort type. + N_("by id"), + // TRANSLATORS: buy dialog sort type. + N_("by weight"), + // TRANSLATORS: buy dialog sort type. + N_("by amount"), + // TRANSLATORS: buy dialog sort type. + N_("by type") +}; + +class SortListModelBuy final : public ListModel +{ + public: + ~SortListModelBuy() + { } + + int getNumberOfElements() + { return 7; } + + std::string getElementAt(int i) + { + if (i >= getNumberOfElements() || i < 0) + return "???"; + return gettext(SORT_NAME_BUY[i]); + } +}; + +#endif // GUI_MODELS_SORTLISTMODELBUY_H diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index e64a7489b..c2514a15d 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -29,6 +29,7 @@ #include "gui/windows/tradewindow.h" #include "gui/models/shopitems.h" +#include "gui/models/sortlistmodelbuy.h" #include "gui/widgets/button.h" #include "gui/widgets/dropdown.h" @@ -52,41 +53,6 @@ #include "debug.h" -static const char *const SORT_NAME_BUY[7] = -{ - // TRANSLATORS: buy dialog sort type. - N_("unsorted"), - // TRANSLATORS: buy dialog sort type. - N_("by price"), - // TRANSLATORS: buy dialog sort type. - N_("by name"), - // TRANSLATORS: buy dialog sort type. - N_("by id"), - // TRANSLATORS: buy dialog sort type. - N_("by weight"), - // TRANSLATORS: buy dialog sort type. - N_("by amount"), - // TRANSLATORS: buy dialog sort type. - N_("by type") -}; - -class SortListModelBuy final : public ListModel -{ -public: - ~SortListModelBuy() - { } - - int getNumberOfElements() - { return 7; } - - std::string getElementAt(int i) - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(SORT_NAME_BUY[i]); - } -}; - class SortItemPriceFunctor final { public: -- cgit v1.2.3-70-g09d2 From 813c0ece9e8063badf15f53ac5e0a759dcaa6d73 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 14:20:42 +0300 Subject: Add missing files into make files. --- src/CMakeLists.txt | 7 +++++++ src/Makefile.am | 7 +++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 01d842f87..5920448ea 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -107,6 +107,7 @@ MARK_AS_ADVANCED(SDL_LIBRARY) SET(SRCS gui/widgets/avatarlistbox.cpp gui/widgets/avatarlistbox.h + gui/models/avatarlistmodel.h gui/models/beingslistmodel.h gui/models/colorlistmodel.h gui/widgets/tabs/battletab.cpp @@ -146,6 +147,7 @@ SET(SRCS gui/models/fontsmodel.h gui/models/iconsmodel.h gui/models/ignorechoiceslistmodel.h + gui/models/itemsmodel.h gui/widgets/flowcontainer.cpp gui/widgets/flowcontainer.h gui/widgets/tabs/gmtab.cpp @@ -184,6 +186,8 @@ SET(SRCS gui/models/namesmodel.cpp gui/models/namesmodel.h gui/models/playerrelationlistmodel.h + gui/models/questsmodel.h + gui/models/serverslistmodel.h gui/widgets/passwordfield.cpp gui/widgets/passwordfield.h gui/widgets/playerbox.cpp @@ -223,6 +227,7 @@ SET(SRCS gui/models/skillmodel.cpp gui/models/skillmodel.h gui/models/sortlistmodelbuy.h + gui/models/sortlistmodelinv.h gui/models/soundsmodel.h gui/widgets/slider.cpp gui/widgets/slider.h @@ -236,6 +241,7 @@ SET(SRCS gui/widgets/guitable.h gui/models/tablemodel.cpp gui/models/tablemodel.h + gui/models/targettypemodel.h gui/models/touchactionmodel.cpp gui/models/touchactionmodel.h gui/models/typelistmodel.h @@ -792,6 +798,7 @@ SET(SRCS events/keyevent.h listeners/keylistener.h gui/models/listmodel.h + gui/models/magicschoolmodel.h events/mouseevent.h listeners/mouselistener.h gui/rectangle.h diff --git a/src/Makefile.am b/src/Makefile.am index 73a69231b..3efaea9c1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -163,6 +163,7 @@ manaplus_SOURCES += events/actionevent.h \ events/keyevent.h \ listeners/keylistener.h \ gui/models/listmodel.h \ + gui/models/magicschoolmodel.h \ events/mouseevent.h \ listeners/mouselistener.h \ gui/rectangle.h \ @@ -203,6 +204,7 @@ manaplus_SOURCES += events/actionevent.h \ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/avatarlistbox.h \ + gui/models/avatarlistmodel.h \ gui/models/beingslistmodel.h \ gui/models/colorlistmodel.h \ gui/widgets/tabs/battletab.cpp \ @@ -242,6 +244,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/fontsmodel.h \ gui/models/iconsmodel.h \ gui/models/ignorechoiceslistmodel.h \ + gui/models/itemsmodel.h \ gui/widgets/flowcontainer.cpp \ gui/widgets/flowcontainer.h \ gui/widgets/tabs/gmtab.cpp \ @@ -282,6 +285,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/namesmodel.cpp \ gui/models/namesmodel.h \ gui/models/playerrelationlistmodel.h \ + gui/models/questsmodel.h \ + gui/models/serverslistmodel.h \ gui/widgets/passwordfield.cpp \ gui/widgets/passwordfield.h \ gui/widgets/playerbox.cpp \ @@ -321,6 +326,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/models/skillmodel.cpp \ gui/models/skillmodel.h \ gui/models/sortlistmodelbuy.h \ + gui/models/sortlistmodelinv.h \ gui/models/soundsmodel.h \ gui/widgets/slider.cpp \ gui/widgets/slider.h \ @@ -332,6 +338,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabbedarea.h \ gui/models/tablemodel.cpp \ gui/models/tablemodel.h \ + gui/models/targettypemodel.h \ gui/models/touchactionmodel.cpp \ gui/models/touchactionmodel.h \ gui/models/typelistmodel.h \ -- cgit v1.2.3-70-g09d2 From bec451007ce9471004ec4a8357cea3cb7712de55 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 17:11:15 +0300 Subject: Join exguichan Window and normal Window classes. --- src/CMakeLists.txt | 2 - src/Makefile.am | 4 +- src/gui/base/widgets/window.cpp | 231 ---------------------------------- src/gui/base/widgets/window.hpp | 271 ---------------------------------------- src/gui/widgets/window.cpp | 121 ++++++++++++++++-- src/gui/widgets/window.h | 216 +++++++++++++++++++++++++++++++- 6 files changed, 324 insertions(+), 521 deletions(-) delete mode 100644 src/gui/base/widgets/window.cpp delete mode 100644 src/gui/base/widgets/window.hpp (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5920448ea..692a6c7e3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -817,7 +817,6 @@ SET(SRCS gui/base/widgets/slider.hpp gui/base/widgets/textbox.hpp gui/base/widgets/textfield.hpp - gui/base/widgets/window.hpp gui/base/basiccontainer.cpp gui/cliprectangle.cpp gui/color.cpp @@ -835,7 +834,6 @@ SET(SRCS gui/base/widgets/slider.cpp gui/base/widgets/textbox.cpp gui/base/widgets/textfield.cpp - gui/base/widgets/window.cpp ) SET(SRCS_EVOL diff --git a/src/Makefile.am b/src/Makefile.am index 3efaea9c1..27286cf25 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -182,7 +182,6 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/slider.hpp \ gui/base/widgets/textbox.hpp \ gui/base/widgets/textfield.hpp \ - gui/base/widgets/window.hpp \ gui/base/basiccontainer.cpp \ gui/cliprectangle.cpp \ gui/color.cpp \ @@ -199,8 +198,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/scrollarea.cpp \ gui/base/widgets/slider.cpp \ gui/base/widgets/textbox.cpp \ - gui/base/widgets/textfield.cpp \ - gui/base/widgets/window.cpp + gui/base/widgets/textfield.cpp manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/avatarlistbox.h \ diff --git a/src/gui/base/widgets/window.cpp b/src/gui/base/widgets/window.cpp deleted file mode 100644 index 401e3ab6d..000000000 --- a/src/gui/base/widgets/window.cpp +++ /dev/null @@ -1,231 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/base/widgets/window.hpp" - -#include "render/graphics.h" - -#include "debug.h" - -namespace gcn -{ - Window::Window(const Widget2 *const widget) : - Container(widget), - MouseListener(), - mCaption(), - mAlignment(Graphics::CENTER), - mPadding(2), - mTitleBarHeight(16), - mMovable(true), - mOpaque(true), - mDragOffsetX(0), - mDragOffsetY(0), - mMoved(false) - { - mFrameSize = 1; - addMouseListener(this); - } - - Window::Window(const Widget2 *const widget, - const std::string& caption) : - Container(widget), - MouseListener(), - mCaption(caption), - mAlignment(Graphics::CENTER), - mPadding(2), - mTitleBarHeight(16), - mMovable(true), - mOpaque(true), - mDragOffsetX(0), - mDragOffsetY(0), - mMoved(false) - { - mFrameSize = 1; - addMouseListener(this); - } - - Window::~Window() - { - } - - void Window::setPadding(unsigned int padding) - { - mPadding = padding; - } - - unsigned int Window::getPadding() const - { - return mPadding; - } - - void Window::setTitleBarHeight(unsigned int height) - { - mTitleBarHeight = height; - } - - unsigned int Window::getTitleBarHeight() - { - return mTitleBarHeight; - } - - void Window::setCaption(const std::string& caption) - { - mCaption = caption; - } - - const std::string& Window::getCaption() const - { - return mCaption; - } - - void Window::setAlignment(Graphics::Alignment alignment) - { - mAlignment = alignment; - } - - Graphics::Alignment Window::getAlignment() const - { - return mAlignment; - } - - void Window::mousePressed(MouseEvent& mouseEvent) - { - if (mouseEvent.getSource() != this) - return; - - if (getParent()) - getParent()->moveToTop(this); - - mDragOffsetX = mouseEvent.getX(); - mDragOffsetY = mouseEvent.getY(); - - mMoved = mouseEvent.getY() <= static_cast(mTitleBarHeight); - } - - void Window::mouseReleased(MouseEvent& mouseEvent A_UNUSED) - { - mMoved = false; - } - - void Window::mouseDragged(MouseEvent& mouseEvent) - { - if (mouseEvent.isConsumed() || mouseEvent.getSource() != this) - return; - - if (isMovable() && mMoved) - { - setPosition(mouseEvent.getX() - mDragOffsetX + getX(), - mouseEvent.getY() - mDragOffsetY + getY()); - } - - mouseEvent.consume(); - } - - Rectangle Window::getChildrenArea() - { - return Rectangle(getPadding(), - getTitleBarHeight(), - getWidth() - getPadding() * 2, - getHeight() - getPadding() - getTitleBarHeight()); - } - - void Window::setMovable(bool movable) - { - mMovable = movable; - } - - bool Window::isMovable() const - { - return mMovable; - } - - void Window::setOpaque(bool opaque) - { - mOpaque = opaque; - } - - bool Window::isOpaque() - { - return mOpaque; - } - - void Window::resizeToContent() - { - int w = 0, h = 0; - for (WidgetListConstIterator it = mWidgets.begin(); - it != mWidgets.end(); ++ it) - { - if ((*it)->getX() + (*it)->getWidth() > w) - w = (*it)->getX() + (*it)->getWidth(); - - if ((*it)->getY() + (*it)->getHeight() > h) - h = (*it)->getY() + (*it)->getHeight(); - } - - setSize(w + 2* getPadding(), h + getPadding() + getTitleBarHeight()); - } -} // namespace gcn diff --git a/src/gui/base/widgets/window.hpp b/src/gui/base/widgets/window.hpp deleted file mode 100644 index e2772d850..000000000 --- a/src/gui/base/widgets/window.hpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GCN_WINDOW_HPP -#define GCN_WINDOW_HPP - -#include - -#include "listeners/mouselistener.h" - -#include "gui/base/widgets/container.hpp" - -namespace gcn -{ - /** - * An implementation of a movable window that can contain other widgets. - */ - class Window : public Container, - public MouseListener - { - public: - /** - * Constructor. - */ - explicit Window(const Widget2 *const widget); - - /** - * Constructor. The window will be automatically resized in height - * to fit the caption. - * - * @param caption the caption of the window. - */ - Window(const Widget2 *const widget, - const std::string& caption); - - A_DELETE_COPY(Window) - - /** - * Destructor. - */ - virtual ~Window(); - - /** - * Sets the caption of the window. - * - * @param caption The caption of the window. - * @see getCaption - */ - void setCaption(const std::string& caption); - - /** - * Gets the caption of the window. - * - * @return the caption of the window. - * @see setCaption - */ - const std::string& getCaption() const; - - /** - * Sets the alignment of the caption. - * - * @param alignment The alignment of the caption. - * @see getAlignment, Graphics - */ - void setAlignment(Graphics::Alignment alignment); - - /** - * Gets the alignment of the caption. - * - * @return The alignment of caption. - * @see setAlignment, Graphics - */ - Graphics::Alignment getAlignment() const; - - /** - * Sets the padding of the window. The padding is the distance between the - * window border and the content. - * - * @param padding The padding of the window. - * @see getPadding - */ - void setPadding(unsigned int padding); - - /** - * Gets the padding of the window. The padding is the distance between the - * window border and the content. - * - * @return The padding of the window. - * @see setPadding - */ - unsigned int getPadding() const; - - /** - * Sets the title bar height. - * - * @param height The title height value. - * @see getTitleBarHeight - */ - void setTitleBarHeight(unsigned int height); - - /** - * Gets the title bar height. - * - * @return The title bar height. - * @see setTitleBarHeight - */ - unsigned int getTitleBarHeight(); - - /** - * Sets the window to be moveble or not. - * - * @param movable True if the window should be movable, false otherwise. - * @see isMovable - */ - void setMovable(bool movable); - - /** - * Checks if the window is movable. - * - * @return True if the window is movable, false otherwise. - * @see setMovable - */ - bool isMovable() const; - - /** - * Sets the window to be opaque or not. An opaque window will draw it's background - * and it's content. A non opaque window will only draw it's content. - * - * @param opaque True if the window should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque); - - /** - * Checks if the window is opaque. - * - * @return True if the window is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque(); - - /** - * Resizes the window to fit the content. - */ - virtual void resizeToContent(); - - // Inherited from BasicContainer - - virtual Rectangle getChildrenArea(); - - // Inherited from MouseListener - - virtual void mousePressed(MouseEvent& mouseEvent) override; - - virtual void mouseDragged(MouseEvent& mouseEvent) override; - - virtual void mouseReleased(MouseEvent& mouseEvent) override; - - protected: - /** - * Holds the caption of the window. - */ - std::string mCaption; - - /** - * Holds the alignment of the caption. - */ - Graphics::Alignment mAlignment; - - /** - * Holds the padding of the window. - */ - unsigned int mPadding; - - /** - * Holds the title bar height of the window. - */ - unsigned int mTitleBarHeight; - - /** - * True if the window is movable, false otherwise. - */ - bool mMovable; - - /** - * True if the window is opaque, false otherwise. - */ - bool mOpaque; - - /** - * Holds a drag offset as an x coordinate where the drag of the window - * started if the window is being dragged. It's used to move the window - * correctly when dragged. - */ - int mDragOffsetX; - - /** - * Holds a drag offset as an y coordinate where the drag of the window - * started if the window is being dragged. It's used to move the window - * correctly when dragged. - */ - int mDragOffsetY; - - /** - * True if the window is being moved, false otherwise. - */ - bool mMoved; - }; -} // namespace gcn - -#endif // end GCN_WINDOW_HPP diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 8388ae64e..3404bb573 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -20,6 +20,49 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + #include "gui/widgets/window.h" #include "client.h" @@ -48,8 +91,18 @@ int Window::mouseResize = 0; Window::Window(const std::string &caption, const bool modal, Window *const parent, std::string skin) : - gcn::Window(nullptr, caption), + gcn::Container(nullptr), + MouseListener(), WidgetListener(), + mCaption(caption), + mAlignment(Graphics::CENTER), + mPadding(2), + mTitleBarHeight(16), + mMovable(true), + mOpaque(true), + mDragOffsetX(0), + mDragOffsetY(0), + mMoved(false), mSkin(nullptr), mDefaultX(0), mDefaultY(0), @@ -91,6 +144,9 @@ Window::Window(const std::string &caption, const bool modal, windowInstances++; +// mFrameSize = 1; + addMouseListener(this); + setFrameSize(0); setPadding(3); setTitleBarHeight(20); @@ -608,18 +664,14 @@ void Window::setVisible(const bool visible, const bool forceSticky) // Check if the window is off screen... if (visible) - { ensureOnScreen(); - } else - { mResizeHandles = 0; - } if (mStickyButtonLock) - gcn::Window::setVisible(visible); + gcn::Container::setVisible(visible); else - gcn::Window::setVisible((!forceSticky && mSticky) || visible); + gcn::Container::setVisible((!forceSticky && mSticky) || visible); if (visible) { if (mPlayVisibleSound) @@ -655,8 +707,15 @@ void Window::scheduleDelete() void Window::mousePressed(MouseEvent &event) { - // Let Guichan move window to top and figure out title bar drag - gcn::Window::mousePressed(event); + if (event.getSource() == this) + { + if (getParent()) + getParent()->moveToTop(this); + + mDragOffsetX = event.getX(); + mDragOffsetY = event.getY(); + mMoved = event.getY() <= static_cast(mTitleBarHeight); + } if (event.getButton() == MouseEvent::LEFT) { @@ -705,7 +764,6 @@ void Window::mouseReleased(MouseEvent &event A_UNUSED) gui->setCursorType(Cursor::CURSOR_POINTER); } - // This should be the responsibility of Guichan (and is from 0.8.0 on) mMoved = false; } @@ -771,8 +829,16 @@ void Window::mouseDragged(MouseEvent &event) { if (canMove()) { - // Let Guichan handle title bar drag - gcn::Window::mouseDragged(event); + if (!event.isConsumed() && event.getSource() == this) + { + if (isMovable() && mMoved) + { + setPosition(event.getX() - mDragOffsetX + getX(), + event.getY() - mDragOffsetY + getY()); + } + + event.consume(); + } } else { @@ -1255,6 +1321,37 @@ bool Window::getOptionBool(const std::string &name, const bool def) const return def; } +Rectangle Window::getChildrenArea() +{ + return Rectangle(mPadding, + mTitleBarHeight, + mDimension.width - mPadding * 2, + mDimension.height - mPadding - mTitleBarHeight); +} + +void Window::resizeToContent() +{ + int w = 0; + int h = 0; + for (WidgetListConstIterator it = mWidgets.begin(); + it != mWidgets.end(); ++ it) + { + const Widget *const widget = *it; + const int x = widget->getX(); + const int y = widget->getY(); + const int width = widget->getWidth(); + const int height = widget->getHeight(); + if (x + width > w) + w = x + width; + + if (y + height > h) + h = y + height; + } + + setSize(w + 2 * mPadding, + h + mPadding + mTitleBarHeight); +} + #ifdef USE_PROFILER void Window::logic() { diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 50babfce4..9bf1b4b7a 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -20,14 +20,58 @@ * along with this program. If not, see . */ +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_WIDGETS_WINDOW_H #define GUI_WIDGETS_WINDOW_H #include "render/graphics.h" +#include "listeners/mouselistener.h" #include "listeners/widgetlistener.h" -#include "gui/base/widgets/window.hpp" +#include "gui/base/widgets/container.hpp" #include "localconsts.h" @@ -44,7 +88,8 @@ class WindowContainer; * * \ingroup GUI */ -class Window : public gcn::Window, +class Window : public gcn::Container, + public MouseListener, private WidgetListener { public: @@ -418,6 +463,124 @@ class Window : public gcn::Window, bool isWindowVisible() const A_WARN_UNUSED { return mVisible; } + /** + * Sets the padding of the window. The padding is the distance between the + * window border and the content. + * + * @param padding The padding of the window. + * @see getPadding + */ + void setPadding(unsigned int padding) + { mPadding = padding; } + + /** + * Gets the padding of the window. The padding is the distance between the + * window border and the content. + * + * @return The padding of the window. + * @see setPadding + */ + unsigned int getPadding() const + { return mPadding; } + + /** + * Sets the title bar height. + * + * @param height The title height value. + * @see getTitleBarHeight + */ + void setTitleBarHeight(unsigned int height) + { mTitleBarHeight = height; } + + /** + * Gets the title bar height. + * + * @return The title bar height. + * @see setTitleBarHeight + */ + unsigned int getTitleBarHeight() + { return mTitleBarHeight; } + + /** + * Sets the caption of the window. + * + * @param caption The caption of the window. + * @see getCaption + */ + void setCaption(const std::string& caption) + { mCaption = caption; } + + /** + * Gets the caption of the window. + * + * @return the caption of the window. + * @see setCaption + */ + const std::string& getCaption() const + { return mCaption; } + + /** + * Sets the alignment of the caption. + * + * @param alignment The alignment of the caption. + * @see getAlignment, Graphics + */ + void setAlignment(Graphics::Alignment alignment) + { mAlignment = alignment; } + + /** + * Gets the alignment of the caption. + * + * @return The alignment of caption. + * @see setAlignment, Graphics + */ + Graphics::Alignment getAlignment() const + { return mAlignment; } + + /** + * Sets the window to be moveble or not. + * + * @param movable True if the window should be movable, false otherwise. + * @see isMovable + */ + void setMovable(bool movable) + { mMovable = movable; } + + /** + * Checks if the window is movable. + * + * @return True if the window is movable, false otherwise. + * @see setMovable + */ + bool isMovable() const + { return mMovable; } + + /** + * Sets the window to be opaque or not. An opaque window will draw it's background + * and it's content. A non opaque window will only draw it's content. + * + * @param opaque True if the window should be opaque, false otherwise. + * @see isOpaque + */ + void setOpaque(bool opaque) + { mOpaque = opaque; } + + /** + * Checks if the window is opaque. + * + * @return True if the window is opaque, false otherwise. + * @see setOpaque + */ + bool isOpaque() + { return mOpaque; } + + virtual Rectangle getChildrenArea(); + + /** + * Resizes the window to fit the content. + */ + virtual void resizeToContent(); + #ifdef USE_PROFILER virtual void logic(); #endif @@ -437,6 +600,55 @@ class Window : public gcn::Window, int getTitlePadding() const A_WARN_UNUSED { return mTitlePadding; } + /** + * Holds the caption of the window. + */ + std::string mCaption; + + /** + * Holds the alignment of the caption. + */ + Graphics::Alignment mAlignment; + + /** + * Holds the padding of the window. + */ + unsigned int mPadding; + + /** + * Holds the title bar height of the window. + */ + unsigned int mTitleBarHeight; + + /** + * True if the window is movable, false otherwise. + */ + bool mMovable; + + /** + * True if the window is opaque, false otherwise. + */ + bool mOpaque; + + /** + * Holds a drag offset as an x coordinate where the drag of the window + * started if the window is being dragged. It's used to move the window + * correctly when dragged. + */ + int mDragOffsetX; + + /** + * Holds a drag offset as an y coordinate where the drag of the window + * started if the window is being dragged. It's used to move the window + * correctly when dragged. + */ + int mDragOffsetY; + + /** + * True if the window is being moved, false otherwise. + */ + bool mMoved; + Skin *mSkin; /**< Skin in use by this window */ int mDefaultX; /**< Default window X position */ int mDefaultY; /**< Default window Y position */ -- cgit v1.2.3-70-g09d2 From eed93efa8aa8539b47f225b4abafe6d59bebe67d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 23 Feb 2014 20:17:46 +0300 Subject: Rename drawImage2 methods into drawImage. --- src/animatedsprite.cpp | 2 +- src/being/compoundsprite.cpp | 4 ++-- src/gui/font.cpp | 4 ++-- src/gui/gui.cpp | 4 ++-- src/gui/widgets/avatarlistbox.cpp | 2 +- src/gui/widgets/browserbox.cpp | 2 +- src/gui/widgets/button.cpp | 4 ++-- src/gui/widgets/checkbox.cpp | 2 +- src/gui/widgets/desktop.cpp | 2 +- src/gui/widgets/dropdown.cpp | 4 ++-- src/gui/widgets/dropshortcutcontainer.cpp | 2 +- src/gui/widgets/emotepage.cpp | 2 +- src/gui/widgets/extendedlistbox.cpp | 4 ++-- src/gui/widgets/icon.cpp | 2 +- src/gui/widgets/itemcontainer.cpp | 6 +++--- src/gui/widgets/itemshortcutcontainer.cpp | 6 +++--- src/gui/widgets/radiobutton.cpp | 2 +- src/gui/widgets/scrollarea.cpp | 2 +- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/slider.cpp | 12 ++++++------ src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/tabs/tab.cpp | 2 +- src/gui/widgets/window.cpp | 6 +++--- src/gui/windows/equipmentwindow.cpp | 8 ++++---- src/gui/windows/minimap.cpp | 2 +- src/gui/windows/outfitwindow.cpp | 4 ++-- src/gui/windows/skilldialog.cpp | 2 +- src/imagesprite.cpp | 2 +- src/maplayer.cpp | 6 +++--- src/particle/imageparticle.cpp | 2 +- src/render/graphics.h | 4 ++-- src/render/mobileopenglgraphics.cpp | 4 ++-- src/render/normalopenglgraphics.cpp | 4 ++-- src/render/nullopenglgraphics.cpp | 4 ++-- src/render/openglgraphicsdef.hpp | 4 ++-- src/render/safeopenglgraphics.cpp | 4 ++-- src/render/sdl2graphics.cpp | 4 ++-- src/render/sdl2graphics.h | 4 ++-- src/render/sdl2softwaregraphics.cpp | 4 ++-- src/render/sdl2softwaregraphics.h | 4 ++-- src/render/sdlgraphics.cpp | 4 ++-- src/render/sdlgraphics.h | 4 ++-- src/render/surfacegraphics.cpp | 4 ++-- src/render/surfacegraphics.h | 4 ++-- src/resources/atlasmanager.cpp | 2 +- src/simpleanimation.cpp | 5 +++-- src/test/testlauncher.cpp | 12 ++++++------ src/touchmanager.cpp | 2 +- 49 files changed, 93 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 93f8c6009..97424fbfb 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -294,7 +294,7 @@ void AnimatedSprite::draw(Graphics *const graphics, if (image->getAlpha() != mAlpha) image->setAlpha(mAlpha); - graphics->drawImage2(image, + graphics->drawImage(image, posX + mFrame->offsetX, posY + mFrame->offsetY); } diff --git a/src/being/compoundsprite.cpp b/src/being/compoundsprite.cpp index 27e48caa7..ea4a2067f 100644 --- a/src/being/compoundsprite.cpp +++ b/src/being/compoundsprite.cpp @@ -123,12 +123,12 @@ void CompoundSprite::draw(Graphics *const graphics, if (mAlpha == 1.0F && mImage) { - graphics->drawImage2(mImage, posX + mOffsetX, posY + mOffsetY); + graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY); } else if (mAlpha && mAlphaImage) { mAlphaImage->setAlpha(mAlpha); - graphics->drawImage2(mAlphaImage, + graphics->drawImage(mAlphaImage, posX + mOffsetX, posY + mOffsetY); } else diff --git a/src/gui/font.cpp b/src/gui/font.cpp index e1d793ce1..8c022f99d 100644 --- a/src/gui/font.cpp +++ b/src/gui/font.cpp @@ -522,7 +522,7 @@ void Font::drawString(Graphics *const graphics, if (image) { image->setAlpha(alpha); - g->drawImage2(image, x, y); + g->drawImage(image, x, y); } } else @@ -544,7 +544,7 @@ void Font::drawString(Graphics *const graphics, const Image *const image = chunk2->img; if (image) - g->drawImage2(image, x, y); + g->drawImage(image, x, y); } BLOCK_END("Font::drawString") } diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 07aca0c81..5914e43d9 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -451,7 +451,7 @@ void Gui::draw() { const int posX = mouseX - (image->mBounds.w / 2); const int posY = mouseY - (image->mBounds.h / 2); - mGraphics->drawImage2(image, posX, posY); + mGraphics->drawImage(image, posX, posY); } if (mGuiFont) { @@ -469,7 +469,7 @@ void Gui::draw() if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); - mGraphics->drawImage2(mouseCursor, mouseX - 15, mouseY - 17); + mGraphics->drawImage(mouseCursor, mouseX - 15, mouseY - 17); } } diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index cf01517c6..46a78d99e 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -135,7 +135,7 @@ void AvatarListBox::draw(Graphics *graphics) } else { - graphics->drawImage2(icon, mImagePadding, y + mPadding); + graphics->drawImage(icon, mImagePadding, y + mPadding); } } } diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index cfc26da0e..c36a607f4 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -508,7 +508,7 @@ void BrowserBox::draw(Graphics *graphics) } else if (part.mImage) { - graphics->drawImage2(part.mImage, part.mX, part.mY); + graphics->drawImage(part.mImage, part.mX, part.mY); } } diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 90c1706b5..2642a67a3 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -507,9 +507,9 @@ void Button::draw(Graphics *graphics) if (mImages) { if (isPressed()) - graphics->drawImage2(mImages[mode], imageX + 1, imageY + 1); + graphics->drawImage(mImages[mode], imageX + 1, imageY + 1); else - graphics->drawImage2(mImages[mode], imageX, imageY); + graphics->drawImage(mImages[mode], imageX, imageY); } } diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 63e32a0f9..9fb63b2e8 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -167,7 +167,7 @@ void CheckBox::drawBox(Graphics *const graphics) if (box) { - graphics->drawImage2(box, + graphics->drawImage(box, mImagePadding, (getHeight() - mImageSize) / 2); } diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index a296fb49d..5dca7578c 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -123,7 +123,7 @@ void Desktop::draw(Graphics *graphics) if (imageHelper->useOpenGL() == RENDER_SOFTWARE) { - graphics->drawImage2(mWallpaper, + graphics->drawImage(mWallpaper, (width - wallpWidth) / 2, (height - wallpHeight) / 2); } diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 763cf47a5..982b2cf0d 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -251,7 +251,7 @@ void DropDown::draw(Graphics* graphics) } else { - graphics->drawImage2(image, + graphics->drawImage(image, mImagePadding, (mDimension.height - image->getHeight()) / 2 + mPadding); font->drawString(graphics, model->getElementAt(sel), @@ -305,7 +305,7 @@ void DropDown::drawButton(Graphics *graphics) Image *image = buttons[mDroppedDown][mPushed]; if (image) { - graphics->drawImage2(image, + graphics->drawImage(image, mDimension.width - image->getWidth() - mImagePadding, (height - image->getHeight()) / 2); } diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index fcb0f8ea1..c8e4bc2d9 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -143,7 +143,7 @@ void DropShortcutContainer::draw(Graphics *graphics) caption = "Eq."; image->setAlpha(1.0F); - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); if (item->isEquipped()) graphics->setColorAll(mEquipedColor, mEquipedColor2); else diff --git a/src/gui/widgets/emotepage.cpp b/src/gui/widgets/emotepage.cpp index 2aff81955..139082815 100644 --- a/src/gui/widgets/emotepage.cpp +++ b/src/gui/widgets/emotepage.cpp @@ -101,7 +101,7 @@ void EmotePage::draw(Graphics *graphics) const Image *const image = *it; if (image) { - graphics->drawImage2(image, x, y); + graphics->drawImage(image, x, y); x += emoteWidth; if (x + emoteWidth > width) { diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 13fb70f28..15a52ee82 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -147,7 +147,7 @@ void ExtendedListBox::draw(Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - graphics->drawImage2(image, + graphics->drawImage(image, mImagePadding, item.y + (height - image->getHeight()) / 2 + mPadding); } @@ -182,7 +182,7 @@ void ExtendedListBox::draw(Graphics *graphics) const Image *const image = model->getImageAt(row1); if (image) { - graphics->drawImage2(image, + graphics->drawImage(image, mImagePadding, item.y + (height - image->getHeight()) / 2 + mPadding); } diff --git a/src/gui/widgets/icon.cpp b/src/gui/widgets/icon.cpp index 53be9ef91..9a86fc9bf 100644 --- a/src/gui/widgets/icon.cpp +++ b/src/gui/widgets/icon.cpp @@ -74,7 +74,7 @@ void Icon::draw(Graphics *graphics) BLOCK_START("Icon::draw") if (mImage) { - graphics->drawImage2(mImage, + graphics->drawImage(mImage, (mDimension.width - mImage->mBounds.w) / 2, (mDimension.height - mImage->mBounds.h) / 2); } diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 0ea3adef1..fe666e6f7 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -276,16 +276,16 @@ void ItemContainer::draw(Graphics *graphics) if (mShowMatrix[itemIndex] == mSelectedIndex) { if (mSelImg) - graphics->drawImage2(mSelImg, itemX, itemY); + graphics->drawImage(mSelImg, itemX, itemY); } image->setAlpha(1.0F); // ensure the image if fully drawn... - graphics->drawImage2(image, + graphics->drawImage(image, itemX + mPaddingItemX, itemY + mPaddingItemY); if (mProtectedImg && PlayerInfo::isItemProtected( item->getId())) { - graphics->drawImage2(mProtectedImg, + graphics->drawImage(mProtectedImg, itemX + mPaddingItemX, itemY + mPaddingItemY); } diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index 83c8820ae..b9dc3bec8 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -174,7 +174,7 @@ void ItemShortcutContainer::draw(Graphics *graphics) caption = "Eq."; image->setAlpha(1.0F); - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); if (item->isEquipped()) { graphics->setColorAll(mEquipedColor, mEquipedColor2); @@ -203,7 +203,7 @@ void ItemShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); } } @@ -222,7 +222,7 @@ void ItemShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); } font->drawString(graphics, skill->data->shortName, itemX + 2, diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index 7b5c5fa11..bb9ae46f9 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -150,7 +150,7 @@ void RadioButton::drawBox(Graphics* graphics) if (box) { - graphics->drawImage2(box, + graphics->drawImage(box, mImagePadding, (getHeight() - mImageSize) / 2); } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2ca851254..f28f45d78 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -409,7 +409,7 @@ void ScrollArea::drawButton(Graphics *const graphics, } if (buttons[dir][state]) - graphics->drawImage2(buttons[dir][state], dim.x, dim.y); + graphics->drawImage(buttons[dir][state], dim.x, dim.y); } void ScrollArea::calcButton(Graphics *const graphics, diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 36104241d..45d3022c8 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -154,7 +154,7 @@ void ShopListBox::draw(Graphics *graphics) if (icon) { icon->setAlpha(1.0F); - graphics->drawImage2(icon, mPadding, y + mPadding); + graphics->drawImage(icon, mPadding, y + mPadding); } } if (mSelected == i) diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index a7e166da3..b059098b5 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -110,7 +110,7 @@ void ShortcutContainer::drawBackground(Graphics *g) { for (unsigned i = 0; i < mMaxItems; i ++) { - g->drawImage2(mBackgroundImg, (i % mGridWidth) * mBoxWidth, + g->drawImage(mBackgroundImg, (i % mGridWidth) * mBoxWidth, (i / mGridWidth) * mBoxHeight); } } diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index c785f4016..7a9b38050 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -222,7 +222,7 @@ void Slider::draw(Graphics *graphics) { if (!mHasMouse) { - graphics->drawImage2(buttons[0].grid[HSTART], x, y); + graphics->drawImage(buttons[0].grid[HSTART], x, y); const int width = buttons[0].grid[HSTART]->getWidth(); w -= width + buttons[0].grid[HEND]->getWidth(); x += width; @@ -234,18 +234,18 @@ void Slider::draw(Graphics *graphics) } x += w; - graphics->drawImage2(buttons[0].grid[HEND], x, y); + graphics->drawImage(buttons[0].grid[HEND], x, y); const Image *const img = buttons[0].grid[HGRIP]; if (img) { - graphics->drawImage2(img, getMarkerPosition(), + graphics->drawImage(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } else { - graphics->drawImage2(buttons[1].grid[HSTART], x, y); + graphics->drawImage(buttons[1].grid[HSTART], x, y); const int width = buttons[1].grid[HSTART]->getWidth(); w -= width; @@ -261,12 +261,12 @@ void Slider::draw(Graphics *graphics) x += w; if (buttons[1].grid[HEND]) - graphics->drawImage2(buttons[1].grid[HEND], x, y); + graphics->drawImage(buttons[1].grid[HEND], x, y); const Image *const img = buttons[1].grid[HGRIP]; if (img) { - graphics->drawImage2(img, getMarkerPosition(), + graphics->drawImage(img, getMarkerPosition(), (mDimension.height - img->getHeight()) / 2); } } diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index 239fc6797..f1d4d0cd1 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -133,7 +133,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) if (image) { image->setAlpha(1.0F); - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); } } diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 2d91129f2..96ae76787 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -291,7 +291,7 @@ void Tab::draw(Graphics *graphics) if (skin1) { const int padding = skin1->getPadding(); - graphics->drawImage2(mImage, padding, padding); + graphics->drawImage(mImage, padding, padding); } } } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 3404bb573..9a43a305b 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -334,18 +334,18 @@ void Window::draw(Graphics *graphics) const Image *const button = mSkin->getCloseImage( mResizeHandles == CLOSE); if (button) - graphics->drawImage2(button, mCloseRect.x, mCloseRect.y); + graphics->drawImage(button, mCloseRect.x, mCloseRect.y); } // Draw Sticky Button if (mStickyButton) { const Image *const button = mSkin->getStickyImage(mSticky); if (button) - graphics->drawImage2(button, mStickyRect.x, mStickyRect.y); + graphics->drawImage(button, mStickyRect.x, mStickyRect.y); } if (mGrip) - graphics->drawImage2(mGrip, mGripRect.x, mGripRect.y); + graphics->drawImage(mGrip, mGripRect.x, mGripRect.y); } // Draw title diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index a50d0e9fa..ea7944f94 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -202,12 +202,12 @@ void EquipmentWindow::draw(Graphics *graphics) continue; if (i == mSelected) { - graphics->drawImage2(mSlotHighlightedBackground, + graphics->drawImage(mSlotHighlightedBackground, box->x, box->y); } else { - graphics->drawImage2(mSlotBackground, box->x, box->y); + graphics->drawImage(mSlotBackground, box->x, box->y); } } } @@ -234,7 +234,7 @@ void EquipmentWindow::draw(Graphics *graphics) { image->setAlpha(1.0F); // Ensure the image is drawn // with maximum opacity - graphics->drawImage2(image, box->x + mItemPadding, + graphics->drawImage(image, box->x + mItemPadding, box->y + mItemPadding); if (i == EQUIP_PROJECTILE_SLOT) { @@ -249,7 +249,7 @@ void EquipmentWindow::draw(Graphics *graphics) } else if (box->image) { - graphics->drawImage2(box->image, + graphics->drawImage(box->image, box->x + mItemPadding, box->y + mItemPadding); } diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index dd8a1d2b7..4c246aed4 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -284,7 +284,7 @@ void Minimap::draw(Graphics *graphics) mMapOriginY = 0; } - graphics->drawImage2(mMapImage, mMapOriginX, mMapOriginY); + graphics->drawImage(mMapImage, mMapOriginX, mMapOriginY); } const ActorSprites &actors = actorManager->getAll(); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index acf681cf4..0f25b84a6 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -347,7 +347,7 @@ void OutfitWindow::draw(Graphics *graphics) const Image *const image = item->getImage(); if (image) { - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); foundItem = true; } } @@ -358,7 +358,7 @@ void OutfitWindow::draw(Graphics *graphics) mItemColors[mCurrentOutfit][i]); if (image) { - graphics->drawImage2(image, itemX, itemY); + graphics->drawImage(image, itemX, itemY); image->decRef(); } } diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index d39d7061b..1346c8e95 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -135,7 +135,7 @@ class SkillListBox final : public ListBox const SkillData *const data = e->data; const int yPad = y + mPadding; const std::string &description = data->description; - graphics->drawImage2(data->icon, mPadding, yPad); + graphics->drawImage(data->icon, mPadding, yPad); font->drawString(graphics, data->name, mTextPadding, yPad); if (!description.empty()) { diff --git a/src/imagesprite.cpp b/src/imagesprite.cpp index c40e49856..965c333bf 100644 --- a/src/imagesprite.cpp +++ b/src/imagesprite.cpp @@ -56,5 +56,5 @@ void ImageSprite::draw(Graphics *const graphics, return; mImage->setAlpha(mAlpha); - graphics->drawImage2(mImage, posX, posY); + graphics->drawImage(mImage, posX, posY); } diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 93434aca9..5779190a9 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -140,7 +140,7 @@ void MapLayer::draw(Graphics *const graphics, if (!c) { - graphics->drawImage2(img, px, py); + graphics->drawImage(img, px, py); } else { @@ -456,7 +456,7 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, if (!c) { - graphics->drawImage2(img, px, py); + graphics->drawImage(img, px, py); } else { @@ -798,7 +798,7 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y, { BLOCK_START("MapItem::draw") if (mImage) - graphics->drawImage2(mImage, x, y); + graphics->drawImage(mImage, x, y); switch (mType) { diff --git a/src/particle/imageparticle.cpp b/src/particle/imageparticle.cpp index e41c072b4..92f458e41 100644 --- a/src/particle/imageparticle.cpp +++ b/src/particle/imageparticle.cpp @@ -103,6 +103,6 @@ void ImageParticle::draw(Graphics *const graphics, } mImage->setAlpha(alphafactor); - graphics->drawImage2(mImage, screenX, screenY); + graphics->drawImage(mImage, screenX, screenY); return; } diff --git a/src/render/graphics.h b/src/render/graphics.h index 35e2a3ba3..14784a408 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -377,8 +377,8 @@ class Graphics * @return true if the image was blitted properly * false otherwise. */ - virtual bool drawImage2(const Image *const image, - int dstX, int dstY) = 0; + virtual bool drawImage(const Image *const image, + int dstX, int dstY) = 0; virtual void drawImageCached(const Image *const image, int srcX, int srcY) = 0; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index a2f7909ff..b306cf021 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -219,7 +219,7 @@ static inline void drawRescaledQuad(const Image *const image, } } -bool MobileOpenGLGraphics::drawImage2(const Image *const image, +bool MobileOpenGLGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -228,7 +228,7 @@ bool MobileOpenGLGraphics::drawImage2(const Image *const image, bool MobileOpenGLGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) if (!image) return false; diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 67a18bde5..0a57c8341 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -286,7 +286,7 @@ static inline void drawRescaledQuad(const Image *const image, } } -bool NormalOpenGLGraphics::drawImage2(const Image *const image, +bool NormalOpenGLGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -295,7 +295,7 @@ bool NormalOpenGLGraphics::drawImage2(const Image *const image, bool NormalOpenGLGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) if (!image) return false; diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 6018247f9..8dd4ca91f 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -139,7 +139,7 @@ static inline void drawRescaledQuad(const Image *const image A_UNUSED, } } -bool NullOpenGLGraphics::drawImage2(const Image *const image, +bool NullOpenGLGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -148,7 +148,7 @@ bool NullOpenGLGraphics::drawImage2(const Image *const image, bool NullOpenGLGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) if (!image) return false; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index a582d9043..d3fcebf81 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -130,8 +130,8 @@ void updateTextureFormat(); - bool drawImage2(const Image *const image, - int dstX, int dstY) override final; + bool drawImage(const Image *const image, + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index c1c266464..342495a47 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -142,7 +142,7 @@ static inline void drawRescaledQuad(const Image *const image, } } -bool SafeOpenGLGraphics::drawImage2(const Image *const image, +bool SafeOpenGLGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -151,7 +151,7 @@ bool SafeOpenGLGraphics::drawImage2(const Image *const image, bool SafeOpenGLGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) if (!image) return false; diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index 053049cef..ac7d8debc 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -157,7 +157,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, &srcRect, &dstRect) < 0); } -bool SDLGraphics::drawImage2(const Image *const image, +bool SDLGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -166,7 +166,7 @@ bool SDLGraphics::drawImage2(const Image *const image, bool SDLGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. if (!mWindow || !image || !image->mTexture) return false; diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index cce15e270..6631e53f4 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -182,8 +182,8 @@ class SDLGraphics final : public Graphics void setRendererFlags(const uint32_t flags) { mRendererFlags = flags; } - bool drawImage2(const Image *const image, - int dstX, int dstY) override final; + bool drawImage(const Image *const image, + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 05b1fa2ef..016a9557e 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -109,7 +109,7 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image, return returnValue; } -bool SDL2SoftwareGraphics::drawImage2(const Image *const image, +bool SDL2SoftwareGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -118,7 +118,7 @@ bool SDL2SoftwareGraphics::drawImage2(const Image *const image, bool SDL2SoftwareGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. if (!mSurface || !image || !image->mSDLSurface) return false; diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 270536e11..1211de5eb 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -141,8 +141,8 @@ class SDL2SoftwareGraphics final : public Graphics bool resizeScreen(const int width, const int height) override final; - bool drawImage2(const Image *const image, - int dstX, int dstY) override final; + bool drawImage(const Image *const image, + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 9694eb0fb..05c57a952 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -103,7 +103,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, return returnValue; } -bool SDLGraphics::drawImage2(const Image *const image, +bool SDLGraphics::drawImage(const Image *const image, int dstX, int dstY) { return drawImageInline(image, dstX, dstY); @@ -112,7 +112,7 @@ bool SDLGraphics::drawImage2(const Image *const image, bool SDLGraphics::drawImageInline(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. if (!mWindow || !image || !image->mSDLSurface) return false; diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index f5ca099de..c8565f4be 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -136,8 +136,8 @@ class SDLGraphics final : public Graphics const bool resize, const bool noFrame) override final; - bool drawImage2(const Image *const image, - int dstX, int dstY) override final; + bool drawImage(const Image *const image, + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp index 8834bb171..d9cb03136 100644 --- a/src/render/surfacegraphics.cpp +++ b/src/render/surfacegraphics.cpp @@ -42,10 +42,10 @@ SurfaceGraphics::~SurfaceGraphics() { } -bool SurfaceGraphics::drawImage2(const Image *const image, +bool SurfaceGraphics::drawImage(const Image *const image, int dstX, int dstY) { - FUNC_BLOCK("Graphics::drawImage2", 1) + FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. if (!mTarget || !image || !image->mSDLSurface) return false; diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index cadd19876..89de995ee 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -179,8 +179,8 @@ class SurfaceGraphics final : public Graphics const bool noFrame A_UNUSED) override final { return false; } - bool drawImage2(const Image *const image, - int dstX, int dstY) override final; + bool drawImage(const Image *const image, + int dstX, int dstY) override final; void drawImageCached(const Image *const image, int x, int y) override final; diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 71a6382dc..870de40a9 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -250,7 +250,7 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas) #else SDL_SetAlpha(image->mSDLSurface, 0, SDL_ALPHA_OPAQUE); #endif - graphics->drawImage2(image, item->x, item->y); + graphics->drawImage(image, item->x, item->y); } } } diff --git a/src/simpleanimation.cpp b/src/simpleanimation.cpp index 1409146df..075c98c06 100644 --- a/src/simpleanimation.cpp +++ b/src/simpleanimation.cpp @@ -78,8 +78,9 @@ void SimpleAnimation::draw(Graphics *const graphics, if (!mCurrentFrame || !mCurrentFrame->image) return; - graphics->drawImage2(mCurrentFrame->image, - posX + mCurrentFrame->offsetX, posY + mCurrentFrame->offsetY); + graphics->drawImage(mCurrentFrame->image, + posX + mCurrentFrame->offsetX, + posY + mCurrentFrame->offsetY); } void SimpleAnimation::reset() diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index a0e4f98dc..584bdb5cb 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -94,7 +94,7 @@ int TestLauncher::testBackend() const for (int f = 0; f < cnt; f ++) { - mainGraphics->drawImage2(img, cnt * 7, cnt * 5); + mainGraphics->drawImage(img, cnt * 7, cnt * 5); mainGraphics->updateScreen(); } @@ -152,11 +152,11 @@ int TestLauncher::testFps() { for (int y = 0; y < 600; y += 50) { - mainGraphics->drawImage2(img[idx], x, y); + mainGraphics->drawImage(img[idx], x, y); idx ++; if (idx > sz) idx = 0; - mainGraphics->drawImage2(img[idx], x, y); + mainGraphics->drawImage(img[idx], x, y); idx ++; if (idx > sz) idx = 0; @@ -211,9 +211,9 @@ int TestLauncher::testInternal() { for (int y = 0; y < 600; y += 25) { - mainGraphics->drawImage2(img[idx], x, y); - mainGraphics->drawImage2(img[idx], x + 1, y); - mainGraphics->drawImage2(img[idx], x, y + 5); + mainGraphics->drawImage(img[idx], x, y); + mainGraphics->drawImage(img[idx], x + 1, y); + mainGraphics->drawImage(img[idx], x, y + 5); idx ++; if (idx > 3) diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index f560b8817..bb222c3e8 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -232,7 +232,7 @@ void TouchManager::draw() const Image *const icon = item->icon; if (icon) { - mainGraphics->drawImage2(icon, + mainGraphics->drawImage(icon, item->x + (item->width - icon->mBounds.w) / 2, item->y + (item->height - icon->mBounds.h) / 2); } -- cgit v1.2.3-70-g09d2 From 779b65f15d3350b2d95a095e24a90526c64dcecb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 24 Feb 2014 13:51:40 +0300 Subject: load branding info from portable.xml if branding file missing. --- src/client.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/client.cpp b/src/client.cpp index 0babef941..86a0ec094 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1914,6 +1914,12 @@ void Client::initRootDir() Configuration portable; portable.init(portableName); + if (mOptions.brandingPath.empty()) + { + branding.init(portableName); + branding.setDefaultValues(getBrandingDefaults()); + } + logger->log("Portable file: %s", portableName.c_str()); if (mOptions.localDataDir.empty()) -- cgit v1.2.3-70-g09d2 From 0a8b5d325f2d2c326b6da27399711b198417a499 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 24 Feb 2014 14:01:32 +0300 Subject: Rename Rectangle into Rect. Rename ClipRectangle into ClipRect. --- src/CMakeLists.txt | 8 +- src/Makefile.am | 16 +-- src/being/being.cpp | 16 +-- src/client.cpp | 2 +- src/flooritem.cpp | 6 +- src/gui/base/basiccontainer.cpp | 12 +-- src/gui/base/basiccontainer.hpp | 4 +- src/gui/base/widgets/container.cpp | 2 +- src/gui/base/widgets/listbox.cpp | 2 +- src/gui/base/widgets/scrollarea.cpp | 10 +- src/gui/base/widgets/scrollarea.hpp | 6 +- src/gui/base/widgets/textbox.cpp | 2 +- src/gui/cliprect.cpp | 104 ++++++++++++++++++ src/gui/cliprect.h | 126 ++++++++++++++++++++++ src/gui/cliprectangle.cpp | 104 ------------------ src/gui/cliprectangle.h | 126 ---------------------- src/gui/popups/spellpopup.cpp | 2 +- src/gui/popups/textpopup.cpp | 2 +- src/gui/rect.cpp | 156 +++++++++++++++++++++++++++ src/gui/rect.h | 162 +++++++++++++++++++++++++++++ src/gui/rectangle.cpp | 156 --------------------------- src/gui/rectangle.h | 162 ----------------------------- src/gui/viewport.cpp | 6 +- src/gui/widgets/avatarlistbox.cpp | 4 +- src/gui/widgets/browserbox.cpp | 8 +- src/gui/widgets/button.cpp | 6 +- src/gui/widgets/colorpage.cpp | 2 +- src/gui/widgets/desktop.cpp | 10 +- src/gui/widgets/dropdown.cpp | 10 +- src/gui/widgets/dropdown.h | 2 +- src/gui/widgets/extendedlistbox.cpp | 2 +- src/gui/widgets/guitable.cpp | 16 +-- src/gui/widgets/guitable.h | 2 +- src/gui/widgets/label.cpp | 2 +- src/gui/widgets/layout.cpp | 2 +- src/gui/widgets/layouthelper.cpp | 2 +- src/gui/widgets/listbox.cpp | 4 +- src/gui/widgets/popup.cpp | 4 +- src/gui/widgets/popup.h | 2 +- src/gui/widgets/progressbar.cpp | 2 +- src/gui/widgets/scrollarea.cpp | 82 +++++++-------- src/gui/widgets/scrollarea.h | 16 +-- src/gui/widgets/shoplistbox.cpp | 2 +- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/spellshortcutcontainer.cpp | 2 +- src/gui/widgets/tabbedarea.cpp | 4 +- src/gui/widgets/tabbedarea.h | 2 +- src/gui/widgets/tabs/chattab.cpp | 2 +- src/gui/widgets/tabs/setup_audio.cpp | 2 +- src/gui/widgets/tabs/setup_chat.cpp | 2 +- src/gui/widgets/tabs/setup_colors.cpp | 2 +- src/gui/widgets/tabs/setup_input.cpp | 2 +- src/gui/widgets/tabs/setup_joystick.cpp | 2 +- src/gui/widgets/tabs/setup_mods.cpp | 2 +- src/gui/widgets/tabs/setup_other.cpp | 2 +- src/gui/widgets/tabs/setup_perfomance.cpp | 2 +- src/gui/widgets/tabs/setup_players.cpp | 2 +- src/gui/widgets/tabs/setup_relations.cpp | 2 +- src/gui/widgets/tabs/setup_theme.cpp | 2 +- src/gui/widgets/tabs/setup_touch.cpp | 2 +- src/gui/widgets/tabs/setup_video.cpp | 2 +- src/gui/widgets/tabs/setup_visual.cpp | 2 +- src/gui/widgets/textbox.cpp | 2 +- src/gui/widgets/textfield.cpp | 2 +- src/gui/widgets/textpreview.cpp | 4 +- src/gui/widgets/widget.cpp | 26 ++--- src/gui/widgets/widget.h | 14 +-- src/gui/widgets/window.cpp | 14 +-- src/gui/widgets/window.h | 10 +- src/gui/windowmenu.cpp | 6 +- src/gui/windows/charcreatedialog.cpp | 6 +- src/gui/windows/chatwindow.cpp | 2 +- src/gui/windows/debugwindow.cpp | 10 +- src/gui/windows/debugwindow.h | 2 +- src/gui/windows/equipmentwindow.cpp | 12 +-- src/gui/windows/inventorywindow.cpp | 2 +- src/gui/windows/minimap.cpp | 14 +-- src/gui/windows/ministatuswindow.cpp | 8 +- src/gui/windows/ministatuswindow.h | 2 +- src/gui/windows/npcpostdialog.cpp | 2 +- src/gui/windows/outfitwindow.cpp | 6 +- src/gui/windows/selldialog.cpp | 2 +- src/gui/windows/serverdialog.cpp | 2 +- src/gui/windows/setupwindow.cpp | 6 +- src/gui/windows/skilldialog.cpp | 2 +- src/gui/windows/whoisonline.cpp | 6 +- src/map.cpp | 4 +- src/maplayer.cpp | 10 +- src/render/graphics.cpp | 12 +-- src/render/graphics.h | 14 +-- src/render/mobileopenglgraphics.cpp | 18 ++-- src/render/normalopenglgraphics.cpp | 18 ++-- src/render/nullopenglgraphics.cpp | 14 +-- src/render/openglgraphicsdef.hpp | 8 +- src/render/safeopenglgraphics.cpp | 16 +-- src/render/sdl2graphics.cpp | 36 +++---- src/render/sdl2graphics.h | 6 +- src/render/sdl2softwaregraphics.cpp | 38 +++---- src/render/sdl2softwaregraphics.h | 6 +- src/render/sdlgraphics.cpp | 38 +++---- src/render/sdlgraphics.h | 6 +- src/render/surfacegraphics.h | 6 +- src/touchmanager.cpp | 4 +- src/touchmanager.h | 6 +- 104 files changed, 918 insertions(+), 916 deletions(-) create mode 100644 src/gui/cliprect.cpp create mode 100644 src/gui/cliprect.h delete mode 100644 src/gui/cliprectangle.cpp delete mode 100644 src/gui/cliprectangle.h create mode 100644 src/gui/rect.cpp create mode 100644 src/gui/rect.h delete mode 100644 src/gui/rectangle.cpp delete mode 100644 src/gui/rectangle.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 692a6c7e3..baa1cf783 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -787,7 +787,7 @@ SET(SRCS events/actionevent.h listeners/actionlistener.h gui/base/basiccontainer.hpp - gui/cliprectangle.h + gui/cliprect.h gui/color.h listeners/deathlistener.h events/event.h @@ -801,7 +801,7 @@ SET(SRCS gui/models/magicschoolmodel.h events/mouseevent.h listeners/mouselistener.h - gui/rectangle.h + gui/rect.h events/selectionevent.h listeners/selectionlistener.h utils/sdlpixel.h @@ -818,11 +818,11 @@ SET(SRCS gui/base/widgets/textbox.hpp gui/base/widgets/textfield.hpp gui/base/basiccontainer.cpp - gui/cliprectangle.cpp + gui/cliprect.cpp gui/color.cpp gui/base/gui.cpp input/key.cpp - gui/rectangle.cpp + gui/rect.cpp gui/widgets/widget.cpp gui/base/widgets/button.cpp gui/base/widgets/checkbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 27286cf25..bf29e7d03 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -26,14 +26,14 @@ manaplus_SOURCES = endif dyecmd_CXXFLAGS = -dyecmd_SOURCES = gui/cliprectangle.cpp \ +dyecmd_SOURCES = gui/cliprect.cpp \ gui/color.cpp \ - gui/rectangle.cpp \ + gui/rect.cpp \ events/actionevent.h \ - gui/cliprectangle.h \ + gui/cliprect.h \ gui/color.h \ events/event.h \ - gui/rectangle.h + gui/rect.h dyecmd_SOURCES += dyetool/dyemain.cpp \ animatedsprite.cpp \ @@ -151,7 +151,7 @@ endif manaplus_SOURCES += events/actionevent.h \ listeners/actionlistener.h \ gui/base/basiccontainer.hpp \ - gui/cliprectangle.h \ + gui/cliprect.h \ gui/color.h \ listeners/deathlistener.h \ events/event.h \ @@ -166,7 +166,7 @@ manaplus_SOURCES += events/actionevent.h \ gui/models/magicschoolmodel.h \ events/mouseevent.h \ listeners/mouselistener.h \ - gui/rectangle.h \ + gui/rect.h \ events/selectionevent.h \ listeners/selectionlistener.h \ utils/sdlpixel.h \ @@ -183,11 +183,11 @@ manaplus_SOURCES += events/actionevent.h \ gui/base/widgets/textbox.hpp \ gui/base/widgets/textfield.hpp \ gui/base/basiccontainer.cpp \ - gui/cliprectangle.cpp \ + gui/cliprect.cpp \ gui/color.cpp \ gui/base/gui.cpp \ input/key.cpp \ - gui/rectangle.cpp \ + gui/rect.cpp \ gui/widgets/widget.cpp \ gui/base/widgets/button.cpp \ gui/base/widgets/checkbox.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index f1d8a7aa6..428e6e7f8 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -2515,7 +2515,7 @@ void Being::drawSpriteAt(Graphics *const graphics, graphics->setColor(userPalette-> getColorWithAlpha(UserPalette::PORTAL_HIGHLIGHT)); - graphics->fillRectangle(Rectangle(x, y, + graphics->fillRectangle(Rect(x, y, mapTileSize, mapTileSize)); if (mDrawHotKeys && !mName.empty()) @@ -2541,7 +2541,7 @@ void Being::drawSpriteAt(Graphics *const graphics, graphics->setColor(userPalette->getColorWithAlpha( UserPalette::MONSTER_ATTACK_RANGE)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x - attackRange, y - attackRange, 2 * attackRange + mapTileSize, 2 * attackRange + mapTileSize)); } @@ -2606,14 +2606,14 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp, || (!hp && maxHP == damage)) { graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, dx, height)); return; } else if (width - dx <= 0) { graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, width, height)); return; } @@ -2623,25 +2623,25 @@ void Being::drawHpBar(Graphics *const graphics, const int maxHP, const int hp, if (hp == maxHP) { graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, dx, height)); return; } else if (width - dx <= 0) { graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, width, height)); return; } } graphics->setColor(userPalette->getColorWithAlpha(color1)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, dx, height)); graphics->setColor(userPalette->getColorWithAlpha(color2)); - graphics->fillRectangle(Rectangle(x + dx, y, width - dx, height)); + graphics->fillRectangle(Rect(x + dx, y, width - dx, height)); } void Being::setHP(const int hp) diff --git a/src/client.cpp b/src/client.cpp index 86a0ec094..1238e9b8d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -617,7 +617,7 @@ static void updateProgress(int cnt) mainGraphics->setColor(Color(255, 255, 255)); const int maxSize = mainGraphics->mWidth - 100; const int width = maxSize * progress / 450; - mainGraphics->fillRectangle(Rectangle(50, h - 100, width, 50)); + mainGraphics->fillRectangle(Rect(50, h - 100, width, 50)); mainGraphics->updateScreen(); } diff --git a/src/flooritem.cpp b/src/flooritem.cpp index fd6a6afd3..9ffa8f64a 100644 --- a/src/flooritem.cpp +++ b/src/flooritem.cpp @@ -123,7 +123,7 @@ void FloorItem::draw(Graphics *const graphics, if (curTime > mDropTime + 28 && curTime < mDropTime + 50) { graphics->setColor(Color(80, 200, 20, 200)); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, dx, dy)); } else if (curTime > mDropTime + 19 @@ -131,14 +131,14 @@ void FloorItem::draw(Graphics *const graphics, { graphics->setColor(Color(200, 80, 20, 80 + 10 * (curTime - mDropTime - 18))); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x, y, dx, dy)); } else if (curTime > mDropTime && curTime < mDropTime + 20) { graphics->setColor(Color(20, 20, 255, 7 * (curTime - mDropTime))); - graphics->fillRectangle(Rectangle(x, y, dx, dy)); + graphics->fillRectangle(Rect(x, y, dx, dy)); } } } diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index 9f2806016..e854e15ff 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -117,9 +117,9 @@ namespace gcn mWidgets.erase(iter); } - Rectangle BasicContainer::getChildrenArea() + Rect BasicContainer::getChildrenArea() { - return Rectangle(0, 0, getWidth(), getHeight()); + return Rect(0, 0, getWidth(), getHeight()); } void BasicContainer::focusNext() @@ -184,7 +184,7 @@ namespace gcn Widget *BasicContainer::getWidgetAt(int x, int y) { - const Rectangle r = getChildrenArea(); + const Rect r = getChildrenArea(); if (!r.isPointInRect(x, y)) return nullptr; @@ -284,7 +284,7 @@ namespace gcn // draw it before drawing the widget if (widget->getFrameSize() > 0) { - Rectangle rec = widget->getDimension(); + Rect rec = widget->getDimension(); const int frame = widget->getFrameSize(); const int frame2 = frame * 2; rec.x -= frame; @@ -321,9 +321,9 @@ namespace gcn BLOCK_END("BasicContainer::logicChildren") } - void BasicContainer::showWidgetPart(Widget* widget, Rectangle area) + void BasicContainer::showWidgetPart(Widget* widget, Rect area) { - const Rectangle widgetArea = getChildrenArea(); + const Rect widgetArea = getChildrenArea(); area.x += widget->getX(); area.y += widget->getY(); diff --git a/src/gui/base/basiccontainer.hpp b/src/gui/base/basiccontainer.hpp index 6d30db100..e1947c652 100644 --- a/src/gui/base/basiccontainer.hpp +++ b/src/gui/base/basiccontainer.hpp @@ -108,7 +108,7 @@ namespace gcn * itself to be visible. * @param rectangle The rectangle to be visible. */ - virtual void showWidgetPart(Widget* widget, Rectangle area); + virtual void showWidgetPart(Widget* widget, Rect area); // Inherited from Widget @@ -116,7 +116,7 @@ namespace gcn virtual void moveToBottom(Widget* widget); - virtual Rectangle getChildrenArea() A_WARN_UNUSED; + virtual Rect getChildrenArea() A_WARN_UNUSED; virtual void focusNext(); diff --git a/src/gui/base/widgets/container.cpp b/src/gui/base/widgets/container.cpp index c79f8fcbc..53a900ec4 100644 --- a/src/gui/base/widgets/container.cpp +++ b/src/gui/base/widgets/container.cpp @@ -91,7 +91,7 @@ namespace gcn if (isOpaque()) { graphics->setColor(getBaseColor()); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); + graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight())); } drawChildren(graphics); diff --git a/src/gui/base/widgets/listbox.cpp b/src/gui/base/widgets/listbox.cpp index 62a3062a5..2e9606f0a 100644 --- a/src/gui/base/widgets/listbox.cpp +++ b/src/gui/base/widgets/listbox.cpp @@ -139,7 +139,7 @@ namespace gcn mSelected = selected; } - Rectangle scroll; + Rect scroll; if (mSelected < 0) scroll.y = 0; diff --git a/src/gui/base/widgets/scrollarea.cpp b/src/gui/base/widgets/scrollarea.cpp index 0fc605fa3..665830ce4 100644 --- a/src/gui/base/widgets/scrollarea.cpp +++ b/src/gui/base/widgets/scrollarea.cpp @@ -471,19 +471,19 @@ namespace gcn } } - Rectangle ScrollArea::getChildrenArea() + Rect ScrollArea::getChildrenArea() { - const Rectangle area = Rectangle(0, 0, + const Rect area = Rect(0, 0, mVBarVisible ? (getWidth() - mScrollbarWidth) : getWidth(), mHBarVisible ? (getHeight() - mScrollbarWidth) : getHeight()); if (area.width < 0 || area.height < 0) - return Rectangle(); + return Rect(); return area; } - void ScrollArea::showWidgetPart(Widget* widget, Rectangle area) + void ScrollArea::showWidgetPart(Widget* widget, Rect area) { const Widget *const content = getContent(); if (widget != content) @@ -539,7 +539,7 @@ namespace gcn checkPolicies(); } - void ScrollArea::setDimension(const Rectangle& dimension) + void ScrollArea::setDimension(const Rect& dimension) { Widget::setDimension(dimension); checkPolicies(); diff --git a/src/gui/base/widgets/scrollarea.hpp b/src/gui/base/widgets/scrollarea.hpp index 669ccfbdd..879792019 100644 --- a/src/gui/base/widgets/scrollarea.hpp +++ b/src/gui/base/widgets/scrollarea.hpp @@ -345,9 +345,9 @@ namespace gcn // Inherited from BasicContainer - virtual void showWidgetPart(Widget* widget, Rectangle area); + virtual void showWidgetPart(Widget* widget, Rect area); - virtual Rectangle getChildrenArea(); + virtual Rect getChildrenArea(); virtual Widget *getWidgetAt(int x, int y); @@ -362,7 +362,7 @@ namespace gcn void setHeight(int height); - void setDimension(const Rectangle& dimension); + void setDimension(const Rect& dimension); // Inherited from MouseListener diff --git a/src/gui/base/widgets/textbox.cpp b/src/gui/base/widgets/textbox.cpp index 04b506c59..f74db9a29 100644 --- a/src/gui/base/widgets/textbox.cpp +++ b/src/gui/base/widgets/textbox.cpp @@ -304,7 +304,7 @@ namespace gcn void TextBox::scrollToCaret() { - Rectangle scroll; + Rect scroll; scroll.x = getFont()->getWidth( mTextRows[mCaretRow].substr(0, mCaretColumn)); scroll.y = getFont()->getHeight() * mCaretRow; diff --git a/src/gui/cliprect.cpp b/src/gui/cliprect.cpp new file mode 100644 index 000000000..5255a4c98 --- /dev/null +++ b/src/gui/cliprect.cpp @@ -0,0 +1,104 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/cliprect.h" + +#include "debug.h" + +ClipRect::ClipRect() : + Rect(), + xOffset(0), + yOffset(0) +{ + x = 0; + y = 0; + width = 0; + height = 0; +} + +ClipRect::ClipRect(const int x0, const int y0, + const int width0, const int height0, + const int xOffset0, const int yOffset0) : + Rect(), + xOffset(xOffset0), + yOffset(yOffset0) +{ + x = x0; + y = y0; + width = width0; + height = height0; +} + +const ClipRect& ClipRect::operator=(const Rect& other) +{ + x = other.x; + y = other.y; + width = other.width; + height = other.height; + + return *this; +} diff --git a/src/gui/cliprect.h b/src/gui/cliprect.h new file mode 100644 index 000000000..3bbf5e47e --- /dev/null +++ b/src/gui/cliprect.h @@ -0,0 +1,126 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_CLIPRECTANGLE_H +#define GUI_CLIPRECTANGLE_H + +#include "gui/rect.h" + +#include "localconsts.h" + +/** + * A rectangle used when dealing with clipping. A clip rectangle is + * a regular rectangle extended with variables for x offsets and y + * offsets. The offsets are used for calculations from relative + * screen coordinates to actual screen coordinates. + */ +class ClipRect final : public Rect +{ + public: + /** + * Constructor. + */ + ClipRect(); + + /** + * Constructor. + * + * @param x0 The rectangle x coordinate. + * @param y0 The rectangle y coordinate. + * @param width0 The rectangle width. + * @param height0 The rectangle height. + * @param xOffset0 The offset of the x coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + * @param yOffset0 The offset of the y coordinate. Used to for + * calculating the actual screen coordinate from + * the relative screen coordinate. + */ + ClipRect(const int x0, + const int y0, + const int width0, + const int height0, + const int xOffset0, + const int yOffset0); + + /** + * Copy constructor. Copies x, y, width and height + * field from a rectangle to a clip rectangle. + * + * @param other The rectangle to copy data from. + * @returns A clip rectangle with data copyied from a rectangle. + */ + const ClipRect& operator=(const Rect& other); + + /** + * Holds the x offset of the x coordinate. + */ + int xOffset; + + /** + * Holds the y offset of the y coordinate. + */ + int yOffset; +}; + +#endif // GUI_CLIPRECTANGLE_H diff --git a/src/gui/cliprectangle.cpp b/src/gui/cliprectangle.cpp deleted file mode 100644 index ff393281c..000000000 --- a/src/gui/cliprectangle.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/cliprectangle.h" - -#include "debug.h" - -ClipRectangle::ClipRectangle() : - Rectangle(), - xOffset(0), - yOffset(0) -{ - x = 0; - y = 0; - width = 0; - height = 0; -} - -ClipRectangle::ClipRectangle(const int x0, const int y0, - const int width0, const int height0, - const int xOffset0, const int yOffset0) : - Rectangle(), - xOffset(xOffset0), - yOffset(yOffset0) -{ - x = x0; - y = y0; - width = width0; - height = height0; -} - -const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) -{ - x = other.x; - y = other.y; - width = other.width; - height = other.height; - - return *this; -} diff --git a/src/gui/cliprectangle.h b/src/gui/cliprectangle.h deleted file mode 100644 index 776bc702f..000000000 --- a/src/gui/cliprectangle.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GUI_CLIPRECTANGLE_H -#define GUI_CLIPRECTANGLE_H - -#include "gui/rectangle.h" - -#include "localconsts.h" - -/** - * A rectangle used when dealing with clipping. A clip rectangle is - * a regular rectangle extended with variables for x offsets and y - * offsets. The offsets are used for calculations from relative - * screen coordinates to actual screen coordinates. - */ -class ClipRectangle final : public Rectangle -{ - public: - /** - * Constructor. - */ - ClipRectangle(); - - /** - * Constructor. - * - * @param x0 The rectangle x coordinate. - * @param y0 The rectangle y coordinate. - * @param width0 The rectangle width. - * @param height0 The rectangle height. - * @param xOffset0 The offset of the x coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - * @param yOffset0 The offset of the y coordinate. Used to for - * calculating the actual screen coordinate from - * the relative screen coordinate. - */ - ClipRectangle(const int x0, - const int y0, - const int width0, - const int height0, - const int xOffset0, - const int yOffset0); - - /** - * Copy constructor. Copies x, y, width and height - * field from a rectangle to a clip rectangle. - * - * @param other The rectangle to copy data from. - * @returns A clip rectangle with data copyied from a rectangle. - */ - const ClipRectangle& operator=(const Rectangle& other); - - /** - * Holds the x offset of the x coordinate. - */ - int xOffset; - - /** - * Holds the y offset of the y coordinate. - */ - int yOffset; -}; - -#endif // GUI_CLIPRECTANGLE_H diff --git a/src/gui/popups/spellpopup.cpp b/src/gui/popups/spellpopup.cpp index 2dc1751d3..bf6ea1799 100644 --- a/src/gui/popups/spellpopup.cpp +++ b/src/gui/popups/spellpopup.cpp @@ -90,7 +90,7 @@ void SpellPopup::view(const int x, const int y) int posX = std::max(0, x - getWidth() / 2); int posY = y + distance; - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; const int w = rect.width; const int h = rect.height; if (posX + w > mainGraphics->mWidth) diff --git a/src/gui/popups/textpopup.cpp b/src/gui/popups/textpopup.cpp index 72ac26f0f..d5cc918d3 100644 --- a/src/gui/popups/textpopup.cpp +++ b/src/gui/popups/textpopup.cpp @@ -86,7 +86,7 @@ void TextPopup::show(const int x, const int y, const std::string &str1, setHeight(pad2 + mText[0]->getFont()->getHeight() * cnt); const int distance = 20; - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; int posX = std::max(0, x - rect.width / 2); int posY = y + distance; diff --git a/src/gui/rect.cpp b/src/gui/rect.cpp new file mode 100644 index 000000000..5f9d2bf0f --- /dev/null +++ b/src/gui/rect.cpp @@ -0,0 +1,156 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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. + */ + +/* + * For comments regarding functions please see the header file. + */ + +#include "gui/rect.h" + +#include "debug.h" + +Rect::Rect() : + x(0), + y(0), + width(0), + height(0) +{ +} + +Rect::Rect(const int x_, const int y_, + const int width_, const int height_) : + x(x_), + y(y_), + width(width_), + height(height_) +{ +} + +void Rect::setAll(const int x0, + const int y0, + const int width0, + const int height0) +{ + x = x0; + y = y0; + width = width0; + height = height0; +} + +bool Rect::isIntersecting(const Rect& rectangle) const +{ + int x_ = x; + int y_ = y; + int width_ = width; + int height_ = height; + + x_ -= rectangle.x; + y_ -= rectangle.y; + + if (x_ < 0) + { + width_ += x_; +// x_ = 0; + } + else if (x_ + width_ > rectangle.width) + { + width_ = rectangle.width - x_; + } + + if (y_ < 0) + { + height_ += y_; +// y_ = 0; + } + else if (y_ + height_ > rectangle.height) + { + height_ = rectangle.height - y_; + } + + if (width_ <= 0 || height_ <= 0) + { + return false; + } + + return true; +} + +bool Rect::isPointInRect(int x_, int y_) const +{ + return x_ >= x + && y_ >= y + && x_ < x + width + && y_ < y + height; +} + +std::ostream& operator<<(std::ostream& out, + const Rect& rectangle) +{ + out << "Rect [x = " << rectangle.x + << ", y = " << rectangle.y + << ", width = " << rectangle.width + << ", height = " << rectangle.height + << "]"; + + return out; +} diff --git a/src/gui/rect.h b/src/gui/rect.h new file mode 100644 index 000000000..f7cb7ae92 --- /dev/null +++ b/src/gui/rect.h @@ -0,0 +1,162 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* _______ __ __ __ ______ __ __ _______ __ __ + * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ + * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / + * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / + * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / + * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / + * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ + * + * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson + * + * + * Per Larsson a.k.a finalman + * Olof Naessén a.k.a jansem/yakslem + * + * Visit: http://guichan.sourceforge.net + * + * License: (BSD) + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Guichan 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 GUI_RECT_H +#define GUI_RECT_H + +#include + +#include "localconsts.h" + +/** + * Represents a rectangle. + * + * @since 0.1.0 + */ +class Rect +{ + public: + /** + * Constructor. The default rectangle is an empty rectangle + * at the coordinates (0,0). + */ + Rect(); + + /** + * Constructor. + * + * @param x The x coordinate of the rectangle. + * @param y The y coordinate of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @since 0.1.0 + */ + Rect(const int x, const int y, const int width, const int height); + + virtual ~Rect() + { } + + /** + * Sets the dimension of a rectangle. + * + * @param x The x coordinate of the rectangle. + * @param y The y coordinate of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @since 0.1.0 + */ + void setAll(const int x, + const int y, + const int width0, + const int height0); + + /** + * Checks if another rectangle intersects with the rectangle. + * + * @param rectangle Another rectangle to check for intersection. + * @return True if the rectangles intersect, false otherwise. + * @since 0.1.0 + */ + bool isIntersecting(const Rect& rectangle) const A_WARN_UNUSED; + + /** + * Checks if a point is inside the rectangle + * + * @param x The x coordinate of the point. + * @param y The y coordinate of the point. + * @return True if the point is inside the rectangle. + * @since 0.1.0 + */ + bool isPointInRect(int x, int y) const A_WARN_UNUSED; + + /** + * Output operator for output. + * + * @param out The stream to output to. + * @param rectangle The rectangle to output. + */ + friend std::ostream& operator<<(std::ostream& out, + const Rect& rectangle); + + /** + * Holds the x coordinate of the rectangle. + */ + int x; + + /** + * Holds the x coordinate of the rectangle. + */ + int y; + + /** + * Holds the width of the rectangle. + */ + int width; + + /** + * Holds the height of the rectangle. + */ + int height; +}; + +#endif // GUI_RECTANGEL_H diff --git a/src/gui/rectangle.cpp b/src/gui/rectangle.cpp deleted file mode 100644 index d7de61c39..000000000 --- a/src/gui/rectangle.cpp +++ /dev/null @@ -1,156 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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. - */ - -/* - * For comments regarding functions please see the header file. - */ - -#include "gui/rectangle.h" - -#include "debug.h" - -Rectangle::Rectangle() - : x(0), - y(0), - width(0), - height(0) -{ -} - -Rectangle::Rectangle(const int x_, const int y_, - const int width_, const int height_) : - x(x_), - y(y_), - width(width_), - height(height_) -{ -} - -void Rectangle::setAll(const int x0, - const int y0, - const int width0, - const int height0) -{ - x = x0; - y = y0; - width = width0; - height = height0; -} - -bool Rectangle::isIntersecting(const Rectangle& rectangle) const -{ - int x_ = x; - int y_ = y; - int width_ = width; - int height_ = height; - - x_ -= rectangle.x; - y_ -= rectangle.y; - - if (x_ < 0) - { - width_ += x_; -// x_ = 0; - } - else if (x_ + width_ > rectangle.width) - { - width_ = rectangle.width - x_; - } - - if (y_ < 0) - { - height_ += y_; -// y_ = 0; - } - else if (y_ + height_ > rectangle.height) - { - height_ = rectangle.height - y_; - } - - if (width_ <= 0 || height_ <= 0) - { - return false; - } - - return true; -} - -bool Rectangle::isPointInRect(int x_, int y_) const -{ - return x_ >= x - && y_ >= y - && x_ < x + width - && y_ < y + height; -} - -std::ostream& operator<<(std::ostream& out, - const Rectangle& rectangle) -{ - out << "Rectangle [x = " << rectangle.x - << ", y = " << rectangle.y - << ", width = " << rectangle.width - << ", height = " << rectangle.height - << "]"; - - return out; -} diff --git a/src/gui/rectangle.h b/src/gui/rectangle.h deleted file mode 100644 index ae8364417..000000000 --- a/src/gui/rectangle.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2014 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * 3. Neither the name of Guichan 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 GUI_RECTANGLE_H -#define GUI_RECTANGLE_H - -#include - -#include "localconsts.h" - -/** - * Represents a rectangle. - * - * @since 0.1.0 - */ -class Rectangle -{ - public: - /** - * Constructor. The default rectangle is an empty rectangle - * at the coordinates (0,0). - */ - Rectangle(); - - /** - * Constructor. - * - * @param x The x coordinate of the rectangle. - * @param y The y coordinate of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @since 0.1.0 - */ - Rectangle(const int x, const int y, const int width, const int height); - - virtual ~Rectangle() - { } - - /** - * Sets the dimension of a rectangle. - * - * @param x The x coordinate of the rectangle. - * @param y The y coordinate of the rectangle. - * @param width The width of the rectangle. - * @param height The height of the rectangle. - * @since 0.1.0 - */ - void setAll(const int x, - const int y, - const int width0, - const int height0); - - /** - * Checks if another rectangle intersects with the rectangle. - * - * @param rectangle Another rectangle to check for intersection. - * @return True if the rectangles intersect, false otherwise. - * @since 0.1.0 - */ - bool isIntersecting(const Rectangle& rectangle) const A_WARN_UNUSED; - - /** - * Checks if a point is inside the rectangle - * - * @param x The x coordinate of the point. - * @param y The y coordinate of the point. - * @return True if the point is inside the rectangle. - * @since 0.1.0 - */ - bool isPointInRect(int x, int y) const A_WARN_UNUSED; - - /** - * Output operator for output. - * - * @param out The stream to output to. - * @param rectangle The rectangle to output. - */ - friend std::ostream& operator<<(std::ostream& out, - const Rectangle& rectangle); - - /** - * Holds the x coordinate of the rectangle. - */ - int x; - - /** - * Holds the x coordinate of the rectangle. - */ - int y; - - /** - * Holds the width of the rectangle. - */ - int width; - - /** - * Holds the height of the rectangle. - */ - int height; -}; - -#endif // GUI_RECTANGEL_H diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index d9175a07f..500378628 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -123,7 +123,7 @@ void Viewport::draw(Graphics *graphics) { graphics->setColor(Color(64, 64, 64)); graphics->fillRectangle( - Rectangle(0, 0, getWidth(), getHeight())); + Rect(0, 0, getWidth(), getHeight())); BLOCK_END("Viewport::draw 1") return; } @@ -353,7 +353,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const int squareX = i->x * mapTileSize - mPixelViewX + 12; const int squareY = i->y * mapTileSize - mPixelViewY + 12; - graphics->fillRectangle(Rectangle(squareX, squareY, 8, 8)); + graphics->fillRectangle(Rect(squareX, squareY, 8, 8)); if (mMap) { const std::string str = toString(cnt); @@ -371,7 +371,7 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, const int squareX = i->x - mPixelViewX; const int squareY = i->y - mPixelViewY; - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( squareX - 4, squareY - 4, 8, 8)); if (mMap) { diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 46a78d99e..01126f8ac 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -162,7 +162,7 @@ void AvatarListBox::draw(Graphics *graphics) color.a = 80; graphics->setColor(color); - graphics->fillRectangle(Rectangle(mPadding, y + mPadding, + graphics->fillRectangle(Rect(mPadding, y + mPadding, parent->getWidth() * a->getHp() / a->getMaxHp() - 2 * mPadding, fontHeight)); } @@ -186,7 +186,7 @@ void AvatarListBox::draw(Graphics *graphics) color.a = 80; graphics->setColor(color); - graphics->fillRectangle(Rectangle(mPadding, y + mPadding, + graphics->fillRectangle(Rect(mPadding, y + mPadding, parent->getWidth() * a->getDamageHp() / 1024 - 2 * mPadding, fontHeight)); diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index c36a607f4..100281d94 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -37,7 +37,7 @@ #include "utils/stringutils.h" #include "utils/timer.h" -#include "gui/cliprectangle.h" +#include "gui/cliprect.h" #include "render/graphics.h" @@ -448,7 +448,7 @@ void BrowserBox::mouseMoved(MouseEvent &event) void BrowserBox::draw(Graphics *graphics) { BLOCK_START("BrowserBox::draw") - const ClipRectangle *const cr = graphics->getCurrentClipArea(); + const ClipRect *const cr = graphics->getCurrentClipArea(); if (!cr) return; mYStart = cr->y - cr->yOffset; @@ -462,7 +462,7 @@ void BrowserBox::draw(Graphics *graphics) if (mOpaque) { graphics->setColor(mBackgroundColor); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); + graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight())); } if (mSelectedLink >= 0 && mSelectedLink @@ -471,7 +471,7 @@ void BrowserBox::draw(Graphics *graphics) if ((mHighMode & BACKGROUND)) { graphics->setColor(mHighlightColor); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( mLinks[mSelectedLink].x1, mLinks[mSelectedLink].y1, mLinks[mSelectedLink].x2 - mLinks[mSelectedLink].x1, diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 2642a67a3..3cb6d823d 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -35,6 +35,8 @@ #include "gui/font.h" #include "gui/gui.h" +#include "gui/rect.h" + #include "debug.h" int Button::mInstances = 0; @@ -380,7 +382,7 @@ void Button::draw(Graphics *graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - ClipRectangle &rect = graphics->getTopClip(); + ClipRect &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { recalc = true; @@ -420,7 +422,7 @@ void Button::draw(Graphics *graphics) int imageX = 0; int imageY = 0; int textX = 0; - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; const int width = rect.width; const int height = rect.height; Font *const font = getFont(); diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 5e10b885c..501b3dea7 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -64,7 +64,7 @@ void ColorPage::draw(Graphics *graphics) if (mSelected >= 0) { - graphics->fillRectangle(Rectangle(mPadding, + graphics->fillRectangle(Rect(mPadding, rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 5dca7578c..a77516c62 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -107,7 +107,7 @@ void Desktop::draw(Graphics *graphics) { BLOCK_START("Desktop::draw") - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; const int width = rect.width; const int height = rect.height; if (mWallpaper) @@ -118,7 +118,7 @@ void Desktop::draw(Graphics *graphics) if (width > wallpWidth || height > wallpHeight) { graphics->setColor(mBackgroundGrayColor); - graphics->fillRectangle(Rectangle(0, 0, width, height)); + graphics->fillRectangle(Rect(0, 0, width, height)); } if (imageHelper->useOpenGL() == RENDER_SOFTWARE) @@ -135,12 +135,12 @@ void Desktop::draw(Graphics *graphics) else { graphics->setColor(mBackgroundGrayColor); - graphics->fillRectangle(Rectangle(0, 0, width, height)); + graphics->fillRectangle(Rect(0, 0, width, height)); } // Draw a thin border under the application version... graphics->setColor(mBackgroundColor); - graphics->fillRectangle(Rectangle(mVersionLabel->getDimension())); + graphics->fillRectangle(Rect(mVersionLabel->getDimension())); Container::draw(graphics); BLOCK_END("Desktop::draw") @@ -165,7 +165,7 @@ void Desktop::setBestFittingWallpaper() mWallpaper = nullptr; } - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; const int width = rect.width; const int height = rect.height; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 982b2cf0d..dfc17e17b 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -268,7 +268,7 @@ void DropDown::draw(Graphics* graphics) if (isFocused()) { graphics->setColor(mHighlightColor); - graphics->drawRectangle(Rectangle(mPadding, mPadding, + graphics->drawRectangle(Rect(mPadding, mPadding, mDimension.width - h - pad, h - pad)); } @@ -291,7 +291,7 @@ void DropDown::drawFrame(Graphics *graphics) { BLOCK_START("DropDown::drawFrame") const int bs2 = getFrameSize(); - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; graphics->drawImageRect(0, 0, rect.width + bs2, rect.height + bs2, skinRect); @@ -513,16 +513,16 @@ void DropDown::action(const ActionEvent &actionEvent A_UNUSED) distributeActionEvent(); } -Rectangle DropDown::getChildrenArea() +Rect DropDown::getChildrenArea() { if (mDroppedDown) { // Calculate the children area (with the one pixel border in mind) - return Rectangle(1, mFoldedUpHeight + 1, + return Rect(1, mFoldedUpHeight + 1, mDimension.width - 2, mDimension.height - mFoldedUpHeight - 2); } - return Rectangle(); + return Rect(); } void DropDown::valueChanged(const SelectionEvent& event A_UNUSED) diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h index b8c3e7150..8e463a2c1 100644 --- a/src/gui/widgets/dropdown.h +++ b/src/gui/widgets/dropdown.h @@ -125,7 +125,7 @@ class DropDown final : public ActionListener, void removeSelectionListener(SelectionListener* selectionListener); - Rectangle getChildrenArea() override; + Rect getChildrenArea() override; void action(const ActionEvent &actionEvent) override; diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 15a52ee82..7245ddd19 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -134,7 +134,7 @@ void ExtendedListBox::draw(Graphics *graphics) { mHighlightColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mHighlightColor); - graphics->fillRectangle(Rectangle(mPadding, minY + mPadding, + graphics->fillRectangle(Rect(mPadding, minY + mPadding, width - pad2, maxY - minY + height)); } diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 98e7e5f23..70ebb77d6 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -304,7 +304,7 @@ void GuiTable::draw(Graphics* graphics) if (client->getGuiAlpha() != mAlpha) mAlpha = client->getGuiAlpha(); - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; const int width = rect.width; const int height = rect.height; const int y = rect.y; @@ -312,7 +312,7 @@ void GuiTable::draw(Graphics* graphics) { mBackgroundColor.a = static_cast(mAlpha * 255.0F); graphics->setColor(mBackgroundColor); - graphics->fillRectangle(Rectangle(0, 0, width, height)); + graphics->fillRectangle(Rect(0, 0, width, height)); } // First, determine how many rows we need to draw, @@ -351,7 +351,7 @@ void GuiTable::draw(Graphics* graphics) const int cWidth = getColumnWidth(c); if (widget) { - Rectangle bounds(x_offset, y_offset, cWidth, rHeight); + Rect bounds(x_offset, y_offset, cWidth, rHeight); if (widget == mTopWidget) { @@ -369,14 +369,14 @@ void GuiTable::draw(Graphics* graphics) if (mLinewiseMode && r == static_cast( mSelectedRow) && c == 0) { - graphics->fillRectangle(Rectangle(0, y_offset, + graphics->fillRectangle(Rect(0, y_offset, width, rHeight)); } else if (!mLinewiseMode && mSelectedColumn > 0 && c == static_cast(mSelectedColumn) && r == static_cast(mSelectedRow)) { - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( x_offset, y_offset, cWidth, rHeight)); } } @@ -393,7 +393,7 @@ void GuiTable::draw(Graphics* graphics) if (mTopWidget) { - const Rectangle &bounds = mTopWidget->getDimension(); + const Rect &bounds = mTopWidget->getDimension(); graphics->pushClipArea(bounds); mTopWidget->draw(graphics); graphics->popClipArea(); @@ -414,9 +414,9 @@ void GuiTable::moveToBottom(Widget *widget) mTopWidget = nullptr; } -Rectangle GuiTable::getChildrenArea() +Rect GuiTable::getChildrenArea() { - return Rectangle(0, 0, mDimension.width, mDimension.height); + return Rect(0, 0, mDimension.width, mDimension.height); } // -- KeyListener notifications diff --git a/src/gui/widgets/guitable.h b/src/gui/widgets/guitable.h index 8f5d0d300..fb0c34784 100644 --- a/src/gui/widgets/guitable.h +++ b/src/gui/widgets/guitable.h @@ -93,7 +93,7 @@ public: void setWrappingEnabled(bool wrappingEnabled) { mWrappingEnabled = wrappingEnabled; } - Rectangle getChildrenArea() override final A_WARN_UNUSED; + Rect getChildrenArea() override final A_WARN_UNUSED; /** * Toggle whether to use linewise selection mode, in which the table selects diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 5b1804667..56c949964 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -80,7 +80,7 @@ void Label::draw(Graphics* graphics) { BLOCK_START("Label::draw") int textX; - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; const int textY = rect.height / 2 - getFont()->getHeight() / 2; Font *const font = getFont(); diff --git a/src/gui/widgets/layout.cpp b/src/gui/widgets/layout.cpp index 2af27a21c..24722510b 100644 --- a/src/gui/widgets/layout.cpp +++ b/src/gui/widgets/layout.cpp @@ -80,7 +80,7 @@ void LayoutCell::reflow(int nx, int ny, int nw, int nh) if (mType == ARRAY) mArray->reflow(nx, ny, nw, nh); else - mWidget->setDimension(Rectangle(nx, ny, nw, nh)); + mWidget->setDimension(Rect(nx, ny, nw, nh)); } void LayoutCell::computeSizes() diff --git a/src/gui/widgets/layouthelper.cpp b/src/gui/widgets/layouthelper.cpp index 83e6d050a..c225c7543 100644 --- a/src/gui/widgets/layouthelper.cpp +++ b/src/gui/widgets/layouthelper.cpp @@ -65,7 +65,7 @@ void LayoutHelper::reflowLayout(int w, int h) void LayoutHelper::widgetResized(const Event &event A_UNUSED) { - const Rectangle area = mContainer->getChildrenArea(); + const Rect area = mContainer->getChildrenArea(); int w = area.width; int h = area.height; mLayout.reflow(w, h); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 949c52455..c6e431634 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -118,7 +118,7 @@ void ListBox::draw(Graphics *graphics) // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(Rectangle(mPadding, + graphics->fillRectangle(Rect(mPadding, rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); @@ -148,7 +148,7 @@ void ListBox::draw(Graphics *graphics) // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(Rectangle(mPadding, + graphics->fillRectangle(Rect(mPadding, rowHeight * mSelected + mPadding, mDimension.width - 2 * mPadding, rowHeight)); diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 9a0a38013..1114b4a5e 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -122,10 +122,10 @@ void Popup::draw(Graphics *graphics) BLOCK_END("Popup::draw") } -Rectangle Popup::getChildrenArea() +Rect Popup::getChildrenArea() { const int pad2 = mPadding * 2; - return Rectangle(mPadding, mPadding, + return Rect(mPadding, mPadding, mDimension.width - pad2, mDimension.height - pad2); } diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h index 3c8947fce..01247cf61 100644 --- a/src/gui/widgets/popup.h +++ b/src/gui/widgets/popup.h @@ -152,7 +152,7 @@ class Popup : public Container, // Inherited from BasicContainer - virtual Rectangle getChildrenArea() override; + virtual Rect getChildrenArea() override; /** * Sets the location to display the popup. Tries to horizontally center diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 1a1b8dc0e..5bccd61ca 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -261,7 +261,7 @@ void ProgressBar::render(Graphics *graphics) { if (width > maxWidth) width = maxWidth; - graphics->fillRectangle(Rectangle(mFillPadding, mFillPadding, + graphics->fillRectangle(Rect(mFillPadding, mFillPadding, width, mDimension.height - pad)); } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index f28f45d78..dcc3a871b 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -318,7 +318,7 @@ void ScrollArea::updateCalcFlag(Graphics *const graphics) { // because we don't know where parent windows was moved, // need recalc vertexes - const ClipRectangle &rect = graphics->getTopClip(); + const ClipRect &rect = graphics->getTopClip(); if (rect.xOffset != mXOffset || rect.yOffset != mYOffset) { mRedraw = true; @@ -381,7 +381,7 @@ void ScrollArea::drawButton(Graphics *const graphics, const BUTTON_DIR dir) { int state = 0; - Rectangle dim; + Rect dim; switch (dir) { @@ -416,7 +416,7 @@ void ScrollArea::calcButton(Graphics *const graphics, const BUTTON_DIR dir) { int state = 0; - Rectangle dim; + Rect dim; switch (dir) { @@ -452,7 +452,7 @@ void ScrollArea::calcButton(Graphics *const graphics, void ScrollArea::drawVBar(Graphics *const graphics) { - const Rectangle &dim = getVerticalBarDimension(); + const Rect &dim = getVerticalBarDimension(); if (vBackground.grid[4]) { @@ -475,7 +475,7 @@ void ScrollArea::drawVBar(Graphics *const graphics) void ScrollArea::calcVBar(Graphics *const graphics) { - const Rectangle &dim = getVerticalBarDimension(); + const Rect &dim = getVerticalBarDimension(); if (vBackground.grid[4]) { @@ -502,7 +502,7 @@ void ScrollArea::calcVBar(Graphics *const graphics) void ScrollArea::drawHBar(Graphics *const graphics) { - const Rectangle &dim = getHorizontalBarDimension(); + const Rect &dim = getHorizontalBarDimension(); if (hBackground.grid[4]) { @@ -530,7 +530,7 @@ void ScrollArea::drawHBar(Graphics *const graphics) void ScrollArea::calcHBar(Graphics *const graphics) { - const Rectangle &dim = getHorizontalBarDimension(); + const Rect &dim = getHorizontalBarDimension(); if (hBackground.grid[4]) { @@ -561,7 +561,7 @@ void ScrollArea::calcHBar(Graphics *const graphics) void ScrollArea::drawVMarker(Graphics *const graphics) { - const Rectangle &dim = getVerticalMarkerDimension(); + const Rect &dim = getVerticalMarkerDimension(); if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { @@ -579,7 +579,7 @@ void ScrollArea::drawVMarker(Graphics *const graphics) void ScrollArea::calcVMarker(Graphics *const graphics) { - const Rectangle &dim = getVerticalMarkerDimension(); + const Rect &dim = getVerticalMarkerDimension(); if ((mHasMouse) && (mX > (mDimension.width - mScrollbarWidth))) { @@ -599,7 +599,7 @@ void ScrollArea::calcVMarker(Graphics *const graphics) void ScrollArea::drawHMarker(Graphics *const graphics) { - const Rectangle dim = getHorizontalMarkerDimension(); + const Rect dim = getHorizontalMarkerDimension(); if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { @@ -618,7 +618,7 @@ void ScrollArea::drawHMarker(Graphics *const graphics) void ScrollArea::calcHMarker(Graphics *const graphics) { - const Rectangle dim = getHorizontalMarkerDimension(); + const Rect dim = getHorizontalMarkerDimension(); if ((mHasMouse) && (mY > (mDimension.height - mScrollbarWidth))) { @@ -811,7 +811,7 @@ void ScrollArea::mouseDragged(MouseEvent &event) { if (mIsVerticalMarkerDragged) { - const Rectangle barDim = getVerticalBarDimension(); + const Rect barDim = getVerticalBarDimension(); const int pos = event.getY() - barDim.y - mVerticalMarkerDragOffset; @@ -830,7 +830,7 @@ void ScrollArea::mouseDragged(MouseEvent &event) if (mIsHorizontalMarkerDragged) { - const Rectangle barDim = getHorizontalBarDimension(); + const Rect barDim = getHorizontalBarDimension(); const int pos = event.getX() - barDim.x - mHorizontalMarkerDragOffset; @@ -851,50 +851,50 @@ void ScrollArea::mouseDragged(MouseEvent &event) mRedraw = true; } -Rectangle ScrollArea::getVerticalBarDimension() const +Rect ScrollArea::getVerticalBarDimension() const { if (!mVBarVisible) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); const int height = (mVBarVisible && mShowButtons) ? mScrollbarWidth : 0; if (mHBarVisible) { - return Rectangle(mDimension.width - mScrollbarWidth, + return Rect(mDimension.width - mScrollbarWidth, height, mScrollbarWidth, mDimension.height - 2 * height - mScrollbarWidth); } - return Rectangle(mDimension.width - mScrollbarWidth, + return Rect(mDimension.width - mScrollbarWidth, height, mScrollbarWidth, mDimension.height - 2 * height); } -Rectangle ScrollArea::getHorizontalBarDimension() const +Rect ScrollArea::getHorizontalBarDimension() const { if (!mHBarVisible) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); const int width = mShowButtons ? mScrollbarWidth : 0; if (mVBarVisible) { - return Rectangle(width, + return Rect(width, mDimension.height - mScrollbarWidth, mDimension.width - 2 * width - mScrollbarWidth, mScrollbarWidth); } - return Rectangle(width, + return Rect(width, mDimension.height - mScrollbarWidth, mDimension.width - 2 * width, mScrollbarWidth); } -Rectangle ScrollArea::getVerticalMarkerDimension() +Rect ScrollArea::getVerticalMarkerDimension() { if (!mVBarVisible) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); int length, pos; int height; @@ -945,14 +945,14 @@ Rectangle ScrollArea::getVerticalMarkerDimension() pos = 0; } - return Rectangle(mDimension.width - mScrollbarWidth, h2 + pos, + return Rect(mDimension.width - mScrollbarWidth, h2 + pos, mScrollbarWidth, length); } -Rectangle ScrollArea::getHorizontalMarkerDimension() +Rect ScrollArea::getHorizontalMarkerDimension() { if (!mHBarVisible) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); int length, pos; int width; @@ -1007,61 +1007,61 @@ Rectangle ScrollArea::getHorizontalMarkerDimension() } } - return Rectangle(w2 + pos, mDimension.height - mScrollbarWidth, + return Rect(w2 + pos, mDimension.height - mScrollbarWidth, length, mScrollbarWidth); } -Rectangle ScrollArea::getUpButtonDimension() const +Rect ScrollArea::getUpButtonDimension() const { if (!mVBarVisible || !mShowButtons) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); - return Rectangle(mDimension.width - mScrollbarWidth, 0, + return Rect(mDimension.width - mScrollbarWidth, 0, mScrollbarWidth, mScrollbarWidth); } -Rectangle ScrollArea::getDownButtonDimension() const +Rect ScrollArea::getDownButtonDimension() const { if (!mVBarVisible || !mShowButtons) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); if (mVBarVisible && mHBarVisible) { - return Rectangle(mDimension.width - mScrollbarWidth, + return Rect(mDimension.width - mScrollbarWidth, mDimension.height - mScrollbarWidth*2, mScrollbarWidth, mScrollbarWidth); } - return Rectangle(mDimension.width - mScrollbarWidth, + return Rect(mDimension.width - mScrollbarWidth, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); } -Rectangle ScrollArea::getLeftButtonDimension() const +Rect ScrollArea::getLeftButtonDimension() const { if (!mHBarVisible || !mShowButtons) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); - return Rectangle(0, mDimension.height - mScrollbarWidth, + return Rect(0, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); } -Rectangle ScrollArea::getRightButtonDimension() const +Rect ScrollArea::getRightButtonDimension() const { if (!mHBarVisible || !mShowButtons) - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); if (mVBarVisible && mHBarVisible) { - return Rectangle(mDimension.width - mScrollbarWidth*2, + return Rect(mDimension.width - mScrollbarWidth*2, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); } - return Rectangle(mDimension.width - mScrollbarWidth, + return Rect(mDimension.width - mScrollbarWidth, mDimension.height - mScrollbarWidth, mScrollbarWidth, mScrollbarWidth); diff --git a/src/gui/widgets/scrollarea.h b/src/gui/widgets/scrollarea.h index a6081e506..7d2b39a96 100644 --- a/src/gui/widgets/scrollarea.h +++ b/src/gui/widgets/scrollarea.h @@ -119,21 +119,21 @@ class ScrollArea final : public gcn::ScrollArea, void widgetMoved(const Event &event) override final; - Rectangle getVerticalBarDimension() const; + Rect getVerticalBarDimension() const; - Rectangle getHorizontalBarDimension() const; + Rect getHorizontalBarDimension() const; - Rectangle getVerticalMarkerDimension(); + Rect getVerticalMarkerDimension(); - Rectangle getHorizontalMarkerDimension(); + Rect getHorizontalMarkerDimension(); - Rectangle getUpButtonDimension() const; + Rect getUpButtonDimension() const; - Rectangle getDownButtonDimension() const; + Rect getDownButtonDimension() const; - Rectangle getLeftButtonDimension() const; + Rect getLeftButtonDimension() const; - Rectangle getRightButtonDimension() const; + Rect getRightButtonDimension() const; protected: enum BUTTON_DIR diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 45d3022c8..007dc6442 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -144,7 +144,7 @@ void ShopListBox::draw(Graphics *graphics) if (needDraw) { graphics->setColor(*backgroundColor); - graphics->fillRectangle(Rectangle(mPadding, y + mPadding, + graphics->fillRectangle(Rect(mPadding, y + mPadding, width, mRowHeight)); } diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index b059098b5..d3781b421 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -73,7 +73,7 @@ void ShortcutContainer::widgetResized(const Event &event A_UNUSED) int ShortcutContainer::getIndexFromGrid(const int pointX, const int pointY) const { - const Rectangle tRect = Rectangle(0, 0, + const Rect tRect = Rect(0, 0, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); int index = ((pointY / mBoxHeight) * mGridWidth) + pointX / mBoxWidth; diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index f1d4d0cd1..ed92b62e1 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -116,7 +116,7 @@ void SpellShortcutContainer::draw(Graphics *graphics) const int itemId = getItemByIndex(i); if (selectedId >= 0 && itemId == selectedId) { - graphics->drawRectangle(Rectangle(itemX + 1, itemY + 1, + graphics->drawRectangle(Rect(itemX + 1, itemY + 1, mBoxWidth - 1, mBoxHeight - 1)); } diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 7f58a061e..d2bb24720 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -457,7 +457,7 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) { if (mFollowDownScroll && height != 0) { - const Rectangle &rect = w->getDimension(); + const Rect &rect = w->getDimension(); if (rect.height != 0 && rect.height > height + 2) { if (scr->getVerticalScrollAmount() @@ -722,7 +722,7 @@ void TabbedArea::setSize(int width, int height) adjustSize(); } -void TabbedArea::setDimension(const Rectangle &dimension) +void TabbedArea::setDimension(const Rect &dimension) { Widget::setDimension(dimension); adjustSize(); diff --git a/src/gui/widgets/tabbedarea.h b/src/gui/widgets/tabbedarea.h index 0ad4fbbe6..dbaa4334b 100644 --- a/src/gui/widgets/tabbedarea.h +++ b/src/gui/widgets/tabbedarea.h @@ -222,7 +222,7 @@ class TabbedArea final : public ActionListener, void setSize(int width, int height); - void setDimension(const Rectangle &dimension); + void setDimension(const Rect &dimension); void death(const Event &event); diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 70018f999..fe979ae5a 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -407,7 +407,7 @@ void ChatTab::chatInput(const std::string &message) void ChatTab::scroll(const int amount) { const int range = mScrollArea->getHeight() / 8 * amount; - Rectangle scr; + Rect scr; scr.y = mScrollArea->getVerticalScrollAmount() + range; scr.height = abs(range); mTextOutput->showPart(scr); diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index c5cb8cef1..c8e625ca4 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -156,7 +156,7 @@ Setup_Audio::Setup_Audio(const Widget2 *const widget) : new SetupItemCheckBox(_("Download music"), "", "download-music", this, "download-musicEvent"); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } Setup_Audio::~Setup_Audio() diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp index 94a65163b..7ac88ab0a 100644 --- a/src/gui/widgets/tabs/setup_chat.cpp +++ b/src/gui/widgets/tabs/setup_chat.cpp @@ -195,7 +195,7 @@ Setup_Chat::Setup_Chat(const Widget2 *const widget) : new SetupItemCheckBox(_("Show motd server message on start"), "", "showmotd", this, "showmotdEvent"); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } void Setup_Chat::apply() diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 41be92454..ac6bf2837 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -192,7 +192,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) : mGradTypeText->setCaption(""); - setDimension(Rectangle(0, 0, 365, 350)); + setDimension(Rect(0, 0, 365, 350)); } Setup_Colors::~Setup_Colors() diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp index ed371b364..b04937881 100644 --- a/src/gui/widgets/tabs/setup_input.cpp +++ b/src/gui/widgets/tabs/setup_input.cpp @@ -164,7 +164,7 @@ Setup_Input::Setup_Input(const Widget2 *const widget) : if (config.getIntValue("screenwidth") >= 730) width += 100; - setDimension(Rectangle(0, 0, width, 350)); + setDimension(Rect(0, 0, width, 350)); } Setup_Input::~Setup_Input() diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp index ba5c37b5a..b3d7b78b9 100644 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ b/src/gui/widgets/tabs/setup_joystick.cpp @@ -94,7 +94,7 @@ Setup_Joystick::Setup_Joystick(const Widget2 *const widget) : place(0, 4, mCalibrateLabel); place(0, 5, mCalibrateButton); - setDimension(Rectangle(0, 0, 365, 75)); + setDimension(Rect(0, 0, 365, 75)); } Setup_Joystick::~Setup_Joystick() diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp index 657d09658..b30b84c16 100644 --- a/src/gui/widgets/tabs/setup_mods.cpp +++ b/src/gui/widgets/tabs/setup_mods.cpp @@ -44,7 +44,7 @@ Setup_Mods::Setup_Mods(const Widget2 *const widget) : ContainerPlacer place = h.getPlacer(0, 0); place(0, 0, mScroll, 10, 10); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } Setup_Mods::~Setup_Mods() diff --git a/src/gui/widgets/tabs/setup_other.cpp b/src/gui/widgets/tabs/setup_other.cpp index 678dc2672..e4801506c 100644 --- a/src/gui/widgets/tabs/setup_other.cpp +++ b/src/gui/widgets/tabs/setup_other.cpp @@ -391,7 +391,7 @@ Setup_Other::Setup_Other(const Widget2 *const widget) : new SetupItemDropDown(_("Screen density override"), "", "screenDensity", this, "screenDensityEvent", mDensityList, 100); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } Setup_Other::~Setup_Other() diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp index cd92c8542..5a0566ec2 100644 --- a/src/gui/widgets/tabs/setup_perfomance.cpp +++ b/src/gui/widgets/tabs/setup_perfomance.cpp @@ -154,7 +154,7 @@ Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) : "", "uselonglivesounds", this, "uselonglivesoundsEvent"); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } Setup_Perfomance::~Setup_Perfomance() diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp index a612a51c4..01bb60f53 100644 --- a/src/gui/widgets/tabs/setup_players.cpp +++ b/src/gui/widgets/tabs/setup_players.cpp @@ -100,5 +100,5 @@ Setup_Players::Setup_Players(const Widget2 *const widget) : new SetupItemCheckBox(_("Use special diagonal speed in players moving"), "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent"); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 1f85a23b4..1458ecd25 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -260,7 +260,7 @@ Setup_Relations::Setup_Relations(const Widget2 *const widget) : player_relations.addListener(this); - setDimension(Rectangle(0, 0, 500, 350)); + setDimension(Rect(0, 0, 500, 350)); } Setup_Relations::~Setup_Relations() diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 4bde4b35e..419400853 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -367,7 +367,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) : else if (size > maxWidth) size = maxWidth; - setDimension(Rectangle(0, 0, size, 500)); + setDimension(Rect(0, 0, size, 500)); } Setup_Theme::~Setup_Theme() diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index d141691d4..fb50ab4d5 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -121,7 +121,7 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) : key, this, event, mActionsList, 250); } - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } Setup_Touch::~Setup_Touch() diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp index b587e8d5d..f55dceaa4 100644 --- a/src/gui/widgets/tabs/setup_video.cpp +++ b/src/gui/widgets/tabs/setup_video.cpp @@ -304,7 +304,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : if (config.getIntValue("screenwidth") >= 730) width += 100; - setDimension(Rectangle(0, 0, width, 300)); + setDimension(Rect(0, 0, width, 300)); } Setup_Video::~Setup_Video() diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp index 525d73d07..9666b224a 100644 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ b/src/gui/widgets/tabs/setup_visual.cpp @@ -203,7 +203,7 @@ Setup_Visual::Setup_Visual(const Widget2 *const widget) : new SetupItemCheckBox(_("Allow screensaver to run"), "", "allowscreensaver", this, "allowscreensaverEvent"); - setDimension(Rectangle(0, 0, 550, 350)); + setDimension(Rect(0, 0, 550, 350)); } Setup_Visual::~Setup_Visual() diff --git a/src/gui/widgets/textbox.cpp b/src/gui/widgets/textbox.cpp index 6fce77641..a1ce0e61d 100644 --- a/src/gui/widgets/textbox.cpp +++ b/src/gui/widgets/textbox.cpp @@ -357,7 +357,7 @@ void TextBox::draw(Graphics* graphics) if (mOpaque) { graphics->setColor(mBackgroundColor); - graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight())); + graphics->fillRectangle(Rect(0, 0, getWidth(), getHeight())); } Font *const font = getFont(); diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 3b4c5302c..78a2826d5 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -662,7 +662,7 @@ void TextField::handleCopy() const void TextField::drawCaret(Graphics* graphics, int x) { - const Rectangle *const clipArea = graphics->getCurrentClipArea(); + const Rect *const clipArea = graphics->getCurrentClipArea(); if (!clipArea) return; diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 3772f3bbc..8ac49bfd6 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -93,7 +93,7 @@ void TextPreview::draw(Graphics* graphics) static_cast(mBGColor->g), static_cast(mBGColor->b), static_cast(mAlpha * 255.0F))); - graphics->fillRectangle(Rectangle(0, 0, + graphics->fillRectangle(Rect(0, 0, mDimension.width, mDimension.height)); } @@ -109,7 +109,7 @@ void TextPreview::draw(Graphics* graphics) static_cast(mTextBGColor->g), static_cast(mTextBGColor->b), intAlpha)); - graphics->fillRectangle(Rectangle(mPadding, mPadding, x, y)); + graphics->fillRectangle(Rect(mPadding, mPadding, x, y)); } } diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index f93107bc5..23edadac0 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -162,7 +162,7 @@ void Widget::_setParent(Widget* parent) void Widget::setWidth(int width) { - Rectangle newDimension = mDimension; + Rect newDimension = mDimension; newDimension.width = width; setDimension(newDimension); @@ -170,7 +170,7 @@ void Widget::setWidth(int width) void Widget::setHeight(int height) { - Rectangle newDimension = mDimension; + Rect newDimension = mDimension; newDimension.height = height; setDimension(newDimension); @@ -178,7 +178,7 @@ void Widget::setHeight(int height) void Widget::setX(int x) { - Rectangle newDimension = mDimension; + Rect newDimension = mDimension; newDimension.x = x; setDimension(newDimension); @@ -186,7 +186,7 @@ void Widget::setX(int x) void Widget::setY(int y) { - Rectangle newDimension = mDimension; + Rect newDimension = mDimension; newDimension.y = y; setDimension(newDimension); @@ -194,16 +194,16 @@ void Widget::setY(int y) void Widget::setPosition(int x, int y) { - Rectangle newDimension = mDimension; + Rect newDimension = mDimension; newDimension.x = x; newDimension.y = y; setDimension(newDimension); } -void Widget::setDimension(const Rectangle& dimension) +void Widget::setDimension(const Rect& dimension) { - const Rectangle oldDimension = mDimension; + const Rect oldDimension = mDimension; mDimension = dimension; if (mDimension.width != oldDimension.width @@ -229,7 +229,7 @@ unsigned int Widget::getFrameSize() const return mFrameSize; } -const Rectangle& Widget::getDimension() const +const Rect& Widget::getDimension() const { return mDimension; } @@ -434,7 +434,7 @@ void Widget::getAbsolutePosition(int& x, int& y) const mParent->getAbsolutePosition(parentX, parentY); - const Rectangle &rect = mParent->getChildrenArea(); + const Rect &rect = mParent->getChildrenArea(); x = parentX + mDimension.x + rect.x; y = parentY + mDimension.y + rect.y; } @@ -492,7 +492,7 @@ void Widget::setTabOutEnabled(bool enabled) void Widget::setSize(int width, int height) { - Rectangle newDimension = mDimension; + Rect newDimension = mDimension; newDimension.width = width; newDimension.height = height; @@ -589,9 +589,9 @@ const std::list& Widget::_getFocusListeners() return mFocusListeners; } -Rectangle Widget::getChildrenArea() +Rect Widget::getChildrenArea() { - return Rectangle(0, 0, 0, 0); + return Rect(0, 0, 0, 0); } FocusHandler* Widget::_getInternalFocusHandler() @@ -669,7 +669,7 @@ void Widget::distributeShownEvent() } } -void Widget::showPart(Rectangle rectangle) +void Widget::showPart(Rect rectangle) { if (mParent) mParent->showWidgetPart(this, rectangle); diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 08f1456b0..e05844e4c 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -69,7 +69,7 @@ #include #include "gui/color.h" -#include "gui/rectangle.h" +#include "gui/rect.h" #include "gui/widgets/widget2.h" @@ -313,7 +313,7 @@ class Widget : public Widget2 * @see getDimension, setX, getX, setY, getY, setPosition * @since 0.1.0 */ - void setDimension(const Rectangle& dimension); + void setDimension(const Rect& dimension); /** * Gets the dimension of the widget. The dimension is @@ -323,7 +323,7 @@ class Widget : public Widget2 * @see getDimension, setX, getX, setY, getY, setPosition * @since 0.1.0 */ - const Rectangle& getDimension() const A_WARN_UNUSED; + const Rect& getDimension() const A_WARN_UNUSED; /** * Sets the widget to be fosusable, or not. @@ -888,7 +888,7 @@ class Widget : public Widget2 * @see BasicContainer::drawChildren * @since 0.1.0 */ - virtual Rectangle getChildrenArea() A_WARN_UNUSED; + virtual Rect getChildrenArea() A_WARN_UNUSED; /** * Gets the internal focus handler used. @@ -960,7 +960,7 @@ class Widget : public Widget2 * @since 0.1.0 */ virtual void showWidgetPart(Widget* widget A_UNUSED, - Rectangle area A_UNUSED) + Rect area A_UNUSED) { } /** @@ -997,7 +997,7 @@ class Widget : public Widget2 * @param rectangle The rectangle to be shown. * @since 0.8.0 */ - virtual void showPart(Rectangle rectangle); + virtual void showPart(Rect rectangle); protected: /** @@ -1165,7 +1165,7 @@ class Widget : public Widget2 /** * Holds the dimension of the widget. */ - Rectangle mDimension; + Rect mDimension; /** * Holds the frame size of the widget. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 9a43a305b..8b106b489 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -543,7 +543,7 @@ void Window::setResizable(const bool r) void Window::widgetResized(const Event &event A_UNUSED) { - const Rectangle area = getChildrenArea(); + const Rect area = getChildrenArea(); if (mGrip) { @@ -860,7 +860,7 @@ void Window::mouseDragged(MouseEvent &event) { const int dx = event.getX() - mDragOffsetX; const int dy = event.getY() - mDragOffsetY; - Rectangle newDim = getDimension(); + Rect newDim = getDimension(); if (mouseResize & (TOP | BOTTOM)) { @@ -1258,7 +1258,7 @@ void Window::redraw() { if (mLayout) { - const Rectangle area = getChildrenArea(); + const Rect area = getChildrenArea(); int w = area.width; int h = area.height; mLayout->reflow(w, h); @@ -1294,9 +1294,9 @@ void Window::ensureOnScreen() mDimension.y = 0; } -Rectangle Window::getWindowArea() const +Rect Window::getWindowArea() const { - return Rectangle(mPadding, + return Rect(mPadding, mPadding, mDimension.width - mPadding * 2, mDimension.height - mPadding * 2); @@ -1321,9 +1321,9 @@ bool Window::getOptionBool(const std::string &name, const bool def) const return def; } -Rectangle Window::getChildrenArea() +Rect Window::getChildrenArea() { - return Rectangle(mPadding, + return Rect(mPadding, mTitleBarHeight, mDimension.width - mPadding * 2, mDimension.height - mPadding - mTitleBarHeight); diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 9bf1b4b7a..7cf34c67c 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -450,7 +450,7 @@ class Window : public gcn::Container, */ int getGuiAlpha() const A_WARN_UNUSED; - Rectangle getWindowArea() const A_WARN_UNUSED; + Rect getWindowArea() const A_WARN_UNUSED; bool isResizeAllowed(const MouseEvent &event) const A_WARN_UNUSED; @@ -574,7 +574,7 @@ class Window : public gcn::Container, bool isOpaque() { return mOpaque; } - virtual Rectangle getChildrenArea(); + virtual Rect getChildrenArea(); /** * Resizes the window to fit the content. @@ -688,9 +688,9 @@ class Window : public gcn::Container, Image *mGrip; /**< Resize grip */ Window *mParent; /**< The parent window */ Layout *mLayout; /**< Layout handler */ - Rectangle mCloseRect; /**< Close button rectangle */ - Rectangle mStickyRect; /**< Sticky button rectangle */ - Rectangle mGripRect; /**< Resize grip rectangle */ + Rect mCloseRect; /**< Close button rectangle */ + Rect mStickyRect; /**< Sticky button rectangle */ + Rect mGripRect; /**< Resize grip rectangle */ std::string mWindowName; /**< Name of the window */ int mMinWinWidth; /**< Minimum window width */ int mMinWinHeight; /**< Minimum window height */ diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 79ed7255d..40a5445ca 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -168,7 +168,7 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : x += mPadding - mSpacing; if (mainGraphics) - setDimension(Rectangle(mainGraphics->mWidth - x, 0, x, h)); + setDimension(Rect(mainGraphics->mWidth - x, 0, x, h)); loadButtons(); @@ -293,7 +293,7 @@ void WindowMenu::mouseMoved(MouseEvent &event) const int x = event.getX(); const int y = event.getY(); const int key = btn->getTag(); - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; if (key != Input::KEY_NO_VALUE) { mTextPopup->show(x + rect.x, y + rect.y, btn->getDescription(), @@ -350,7 +350,7 @@ void WindowMenu::updateButtons() } x += mPadding - mSpacing; if (mainGraphics) - setDimension(Rectangle(mainGraphics->mWidth - x, 0, x, h)); + setDimension(Rect(mainGraphics->mWidth - x, 0, x, h)); } void WindowMenu::loadButtons() diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 1ddaaa7b2..4f98cb931 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -208,13 +208,13 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, const int h = 350; setContentSize(w, h); - mPlayerBox->setDimension(Rectangle(360, 0, 110, 90)); + mPlayerBox->setDimension(Rect(360, 0, 110, 90)); mActionButton->setPosition(385, 100); mRotateButton->setPosition(415, 100); mNameLabel->setPosition(5, 2); mNameField->setDimension( - Rectangle(60, 2, 300, mNameField->getHeight())); + Rect(60, 2, 300, mNameField->getHeight())); const int leftX = 120; const int rightX = 300; @@ -530,7 +530,7 @@ void CharCreateDialog::setAttributes(const StringVect &labels, add(mAttributeLabel[i]); mAttributeSlider[i] = new Slider(this, min, max); - mAttributeSlider[i]->setDimension(Rectangle(140, y + i * 24, + mAttributeSlider[i]->setDimension(Rect(140, y + i * 24, 150, 12)); mAttributeSlider[i]->setActionEventId("statslider"); mAttributeSlider[i]->addActionListener(this); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 3c0e09ad5..d769c4397 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -327,7 +327,7 @@ void ChatWindow::updateTabsMargin() void ChatWindow::adjustTabSize() { - const Rectangle area = getChildrenArea(); + const Rect area = getChildrenArea(); const int aw = area.width; const int ah = area.height; diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 2a227c4e2..50dc5dbe5 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -75,7 +75,7 @@ DebugWindow::DebugWindow() : // TRANSLATORS: debug window tab mTabs->addTab(std::string(_("Net")), mNetWidget); - mTabs->setDimension(Rectangle(0, 0, 600, 300)); + mTabs->setDimension(Rect(0, 0, 600, 300)); const int w = mDimension.width; const int h = mDimension.height; @@ -151,7 +151,7 @@ void DebugWindow::widgetResized(const Event &event) { Window::widgetResized(event); - mTabs->setDimension(Rectangle(0, 0, + mTabs->setDimension(Rect(0, 0, mDimension.width, mDimension.height)); } @@ -267,7 +267,7 @@ MapDebugTab::MapDebugTab(const Widget2 *const widget) : #endif place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); - setDimension(Rectangle(0, 0, 600, 300)); + setDimension(Rect(0, 0, 600, 300)); } void MapDebugTab::logic() @@ -412,7 +412,7 @@ TargetDebugTab::TargetDebugTab(const Widget2 *const widget) : place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); - setDimension(Rectangle(0, 0, 600, 300)); + setDimension(Rect(0, 0, 600, 300)); } void TargetDebugTab::logic() @@ -531,7 +531,7 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) : place.getCell().matchColWidth(0, 0); place = h.getPlacer(0, 1); - setDimension(Rectangle(0, 0, 600, 300)); + setDimension(Rect(0, 0, 600, 300)); } void NetDebugTab::logic() diff --git a/src/gui/windows/debugwindow.h b/src/gui/windows/debugwindow.h index 194385b06..1a56f3164 100644 --- a/src/gui/windows/debugwindow.h +++ b/src/gui/windows/debugwindow.h @@ -41,7 +41,7 @@ class DebugTab : public Container } void resize(const int x, const int y) - { setDimension(Rectangle(0, 0, x, y)); } + { setDimension(Rect(0, 0, x, y)); } protected: explicit DebugTab(const Widget2 *const widget) : diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp index ea7944f94..c793ba6ce 100644 --- a/src/gui/windows/equipmentwindow.cpp +++ b/src/gui/windows/equipmentwindow.cpp @@ -92,7 +92,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, mBoxSize = 36; // Control that shows the Player - mPlayerBox->setDimension(Rectangle(50, 80, 74, 168)); + mPlayerBox->setDimension(Rect(50, 80, 74, 168)); mPlayerBox->setPlayer(being); if (foring) @@ -116,7 +116,7 @@ EquipmentWindow::EquipmentWindow(Equipment *const equipment, void EquipmentWindow::postInit() { - const Rectangle &area = getChildrenArea(); + const Rect &area = getChildrenArea(); mUnequip->setPosition(area.width - mUnequip->getWidth() - mButtonPadding, area.height - mUnequip->getHeight() - mButtonPadding); mUnequip->setEnabled(false); @@ -283,7 +283,7 @@ Item *EquipmentWindow::getItem(const int x, const int y) const const EquipmentBox *const box = *it; if (!box) continue; - const Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); + const Rect tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) return mEquipment->getEquipment(i); @@ -321,7 +321,7 @@ void EquipmentWindow::mousePressed(MouseEvent& mouseEvent) if (!box) continue; const Item *const item = mEquipment->getEquipment(i); - const Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); + const Rect tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) { @@ -402,7 +402,7 @@ void EquipmentWindow::mouseReleased(MouseEvent &mouseEvent) const EquipmentBox *const box = *it; if (!box) continue; - const Rectangle tRect(box->x, box->y, mBoxSize, mBoxSize); + const Rect tRect(box->x, box->y, mBoxSize, mBoxSize); if (tRect.isPointInRect(x, y)) return; @@ -514,7 +514,7 @@ void EquipmentWindow::fillBoxes() void EquipmentWindow::loadPlayerBox(const XmlNodePtr playerBoxNode) { - mPlayerBox->setDimension(Rectangle( + mPlayerBox->setDimension(Rect( XML::getProperty(playerBoxNode, "x", 50), XML::getProperty(playerBoxNode, "y", 80), XML::getProperty(playerBoxNode, "width", 74), diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index af6a9a2c4..5323854fb 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -565,7 +565,7 @@ void InventoryWindow::mouseMoved(MouseEvent &event) { const int x = event.getX(); const int y = event.getY(); - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; mTextPopup->show(rect.x + x, rect.y + y, strprintf(_("Money: %s"), Units::formatCurrency(PlayerInfo::getAttribute( PlayerInfo::MONEY)).c_str())); diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp index 4c246aed4..ef1830763 100644 --- a/src/gui/windows/minimap.cpp +++ b/src/gui/windows/minimap.cpp @@ -213,7 +213,7 @@ void Minimap::setMap(const Map *const map) setHeight(height); } - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; setDefaultSize(rect.x, rect.y, rect.width, rect.height); resetToDefaultSize(); @@ -244,7 +244,7 @@ void Minimap::draw(Graphics *graphics) return; } - const Rectangle a = getChildrenArea(); + const Rect a = getChildrenArea(); graphics->pushClipArea(a); @@ -346,7 +346,7 @@ void Minimap::draw(Graphics *graphics) dotSize - 1) * mWidthProportion); const Vector &pos = being->getPosition(); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( static_cast(pos.x * mWidthProportion) / 32 + mMapOriginX - offsetWidth, static_cast(pos.y * mHeightProportion) / 32 @@ -384,7 +384,7 @@ void Minimap::draw(Graphics *graphics) const int offsetWidth = static_cast( mWidthProportion); - graphics->fillRectangle(Rectangle( + graphics->fillRectangle(Rect( static_cast(member->getX() * mWidthProportion) + mMapOriginX - offsetWidth, static_cast(member->getY() @@ -429,7 +429,7 @@ void Minimap::draw(Graphics *graphics) } graphics->setColor(userPalette->getColor(UserPalette::PC)); - graphics->drawRectangle(Rectangle(x, y, w, h)); + graphics->drawRectangle(Rect(x, y, w, h)); graphics->popClipArea(); BLOCK_END("Minimap::draw") } @@ -463,7 +463,7 @@ void Minimap::mouseMoved(MouseEvent &event) Window::mouseMoved(event); const int x = event.getX(); const int y = event.getY(); - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; mTextPopup->show(x + rect.x, y + rect.y, mCaption); } @@ -475,7 +475,7 @@ void Minimap::mouseExited(MouseEvent &event) void Minimap::screenToMap(int &x, int &y) { - const Rectangle a = getChildrenArea(); + const Rect a = getChildrenArea(); x = (x - a.x - mMapOriginX + mWidthProportion) / mWidthProportion; y = (y - a.y - mMapOriginY + mHeightProportion) / mHeightProportion; } diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp index 655ccb277..db4555b26 100644 --- a/src/gui/windows/ministatuswindow.cpp +++ b/src/gui/windows/ministatuswindow.cpp @@ -322,7 +322,7 @@ void MiniStatusWindow::mouseMoved(MouseEvent &event) const int x = event.getX(); const int y = event.getY(); - const Rectangle &rect = mDimension; + const Rect &rect = mDimension; if (event.getSource() == mStatusBar) { mStatusPopup->view(x + rect.x, y + rect.y); @@ -535,12 +535,12 @@ void MiniStatusWindow::updateArrows() StatusWindow::updateArrowsBar(mArrowsBar); } -Rectangle MiniStatusWindow::getChildrenArea() +Rect MiniStatusWindow::getChildrenArea() { const int padding = mPadding; const int padding2 = padding * 2; - const Rectangle &rect = mDimension; - return Rectangle(padding, padding, + const Rect &rect = mDimension; + return Rect(padding, padding, rect.width - padding2, rect.height - padding2); } diff --git a/src/gui/windows/ministatuswindow.h b/src/gui/windows/ministatuswindow.h index e061cbfae..0344d6c3a 100644 --- a/src/gui/windows/ministatuswindow.h +++ b/src/gui/windows/ministatuswindow.h @@ -88,7 +88,7 @@ class MiniStatusWindow final : public Popup, std::vector &getBars() A_WARN_UNUSED { return mBars; } - Rectangle getChildrenArea() override final A_WARN_UNUSED; + Rect getChildrenArea() override final A_WARN_UNUSED; #ifdef USE_PROFILER void logicChildren(); diff --git a/src/gui/windows/npcpostdialog.cpp b/src/gui/windows/npcpostdialog.cpp index aa510b88e..3c63775fe 100644 --- a/src/gui/windows/npcpostdialog.cpp +++ b/src/gui/windows/npcpostdialog.cpp @@ -76,7 +76,7 @@ void NpcPostDialog::postInit() // create scroll box for letter text ScrollArea *const scrollArea = new ScrollArea(this, mText); scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); - scrollArea->setDimension(Rectangle( + scrollArea->setDimension(Rect( 5, mSender->getHeight() + 5, 380, 140 - (mSender->getHeight() + sendButton->getHeight()))); diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index 0f25b84a6..be0c840f6 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -328,9 +328,9 @@ void OutfitWindow::draw(Graphics *graphics) + ((i / mGridWidth) * mBoxHeight); graphics->setColor(mBorderColor); - graphics->drawRectangle(Rectangle(itemX, itemY, 32, 32)); + graphics->drawRectangle(Rect(itemX, itemY, 32, 32)); graphics->setColor(mBackgroundColor); - graphics->fillRectangle(Rectangle(itemX, itemY, 32, 32)); + graphics->fillRectangle(Rect(itemX, itemY, 32, 32)); if (mItems[mCurrentOutfit][i] < 0) continue; @@ -483,7 +483,7 @@ void OutfitWindow::mouseReleased(MouseEvent &event) int OutfitWindow::getIndexFromGrid(const int pointX, const int pointY) const { - const Rectangle tRect = Rectangle(mPadding, mTitleBarHeight, + const Rect tRect = Rect(mPadding, mTitleBarHeight, mGridWidth * mBoxWidth, mGridHeight * mBoxHeight); if (!tRect.isPointInRect(pointX, pointY)) return -1; diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 525e3f133..524c77366 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -292,7 +292,7 @@ void SellDialog::action(const ActionEvent &event) delete mShopItems->at(selectedItem); mShopItems->erase(selectedItem); - Rectangle scroll; + Rect scroll; scroll.y = mShopItemList->getRowHeight() * (selectedItem + 1); scroll.height = mShopItemList->getRowHeight(); mShopItemList->showPart(scroll); diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 18da8682e..579e9ad18 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -139,7 +139,7 @@ public: // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(Rectangle(mPadding, + graphics->fillRectangle(Rect(mPadding, height * mSelected + mPadding, getWidth() - 2 * mPadding, height)); } diff --git a/src/gui/windows/setupwindow.cpp b/src/gui/windows/setupwindow.cpp index 0f4468882..2bcac85a5 100644 --- a/src/gui/windows/setupwindow.cpp +++ b/src/gui/windows/setupwindow.cpp @@ -113,7 +113,7 @@ void SetupWindow::postInit() mResetWindows = btn; } - mPanel->setDimension(Rectangle(5, 5, width - 10, height - 40)); + mPanel->setDimension(Rect(5, 5, width - 10, height - 40)); mPanel->enableScrollButtons(true); mTabs.push_back(new Setup_Video(this)); @@ -265,12 +265,12 @@ void SetupWindow::widgetResized(const Event &event) { Window::widgetResized(event); - const Rectangle area = getChildrenArea(); + const Rect area = getChildrenArea(); int x = area.width; const int height = area.height; const int width = area.width; const int buttonPadding = getOption("buttonPadding", 5); - mPanel->setDimension(Rectangle(5, 5, width - 10, height - 40)); + mPanel->setDimension(Rect(5, 5, width - 10, height - 40)); FOR_EACH (std::vector::iterator, it, mButtons) { Button *const btn = *it; diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp index 1346c8e95..21cc009bc 100644 --- a/src/gui/windows/skilldialog.cpp +++ b/src/gui/windows/skilldialog.cpp @@ -115,7 +115,7 @@ class SkillListBox final : public ListBox // Draw filled rectangle around the selected list element if (mSelected >= 0) { - graphics->fillRectangle(Rectangle(mPadding, getRowHeight() + graphics->fillRectangle(Rect(mPadding, getRowHeight() * mSelected + mPadding, getWidth() - 2 * mPadding, getRowHeight())); } diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 70edccad1..dabc8c7c1 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -116,10 +116,10 @@ void WhoIsOnline::postInit() setSaveVisible(true); mUpdateButton->setEnabled(false); - mUpdateButton->setDimension(Rectangle(5, 5, w - 10, 20 + 5)); + mUpdateButton->setDimension(Rect(5, 5, w - 10, 20 + 5)); mBrowserBox->setOpaque(false); - mScrollArea->setDimension(Rectangle(5, 20 + 10, w - 10, h - 10 - 30)); + mScrollArea->setDimension(Rect(5, 20 + 10, w - 10, h - 10 - 30)); mScrollArea->setSize(w - 10, h - 10 - 30); mBrowserBox->setLinkHandler(this); @@ -723,7 +723,7 @@ void WhoIsOnline::widgetResized(const Event &event) void WhoIsOnline::updateSize() { - const Rectangle area = getChildrenArea(); + const Rect area = getChildrenArea(); if (mUpdateButton) mUpdateButton->setWidth(area.width - 10); diff --git a/src/map.cpp b/src/map.cpp index 257516381..4e654198c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -401,7 +401,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) graphics->setColor(userPalette->getColorWithAlpha( UserPalette::WALKABLE_HIGHLIGHT)); - graphics->fillRectangle(Rectangle(0, 0, + graphics->fillRectangle(Rect(0, 0, graphics->mWidth, graphics->mHeight)); } @@ -549,7 +549,7 @@ void Map::draw(Graphics *const graphics, int scrollX, int scrollY) {\ graphics->setColor(userPalette->getColorWithAlpha(\ UserPalette::color));\ - graphics->fillRectangle(Rectangle(\ + graphics->fillRectangle(Rect(\ x0 * mTileWidth - scrollX, \ y * mTileHeight - scrollY, \ width, mapTileSize));\ diff --git a/src/maplayer.cpp b/src/maplayer.cpp index 5779190a9..701fa9958 100644 --- a/src/maplayer.cpp +++ b/src/maplayer.cpp @@ -538,10 +538,10 @@ void MapLayer::drawFringe(Graphics *const graphics, int startX, int startY, { graphics->setColor(userPalette->getColorWithAlpha( UserPalette::ATTACK_RANGE)); - graphics->fillRectangle(Rectangle(x, y, w, h)); + graphics->fillRectangle(Rect(x, y, w, h)); graphics->setColor(userPalette->getColorWithAlpha( UserPalette::ATTACK_RANGE_BORDER)); - graphics->drawRectangle(Rectangle(x, y, w, h)); + graphics->drawRectangle(Rect(x, y, w, h)); } } } @@ -806,17 +806,17 @@ void MapItem::draw(Graphics *const graphics, const int x, const int y, case CROSS: graphics->setColor(userPalette->getColorWithAlpha( UserPalette::ROAD_POINT)); - graphics->fillRectangle(Rectangle(x + dx / 3, y + dy / 3, + graphics->fillRectangle(Rect(x + dx / 3, y + dy / 3, dx / 3, dy / 3)); break; case HOME: { graphics->setColor(userPalette->getColorWithAlpha( UserPalette::HOME_PLACE)); - graphics->fillRectangle(Rectangle(x, y, dx, dy)); + graphics->fillRectangle(Rect(x, y, dx, dy)); graphics->setColor(userPalette->getColorWithAlpha( UserPalette::HOME_PLACE_BORDER)); - graphics->drawRectangle(Rectangle(x, y, dx, dy)); + graphics->drawRectangle(Rect(x, y, dx, dy)); break; } default: diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index bac987695..17f444eb8 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -547,21 +547,21 @@ void Graphics::setWindowSize(const int width A_UNUSED, #endif } -bool Graphics::pushClipArea(Rectangle area) +bool Graphics::pushClipArea(Rect area) { // Ignore area with a negate width or height // by simple pushing an empty clip area // to the stack. if (area.width < 0 || area.height < 0) { - ClipRectangle carea; + ClipRect carea; mClipStack.push(carea); return true; } if (mClipStack.empty()) { - ClipRectangle carea; + ClipRect carea; carea.x = area.x; carea.y = area.y; carea.width = area.width; @@ -572,8 +572,8 @@ bool Graphics::pushClipArea(Rectangle area) return true; } - const ClipRectangle &top = mClipStack.top(); - ClipRectangle carea; + const ClipRect &top = mClipStack.top(); + ClipRect carea; carea = area; carea.xOffset = top.xOffset + carea.x; carea.yOffset = top.yOffset + carea.y; @@ -618,7 +618,7 @@ void Graphics::popClipArea() mClipStack.pop(); } -const ClipRectangle *Graphics::getCurrentClipArea() const +const ClipRect *Graphics::getCurrentClipArea() const { if (mClipStack.empty()) return nullptr; diff --git a/src/render/graphics.h b/src/render/graphics.h index 14784a408..75b26a241 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -74,7 +74,7 @@ #include "render/renderers.h" -#include "gui/cliprectangle.h" +#include "gui/cliprect.h" #ifdef USE_SDL2 #include @@ -259,7 +259,7 @@ class Graphics const int w, const int h, const ImageRect &imgRect) = 0; - virtual void fillRectangle(const Rectangle& rectangle) = 0; + virtual void fillRectangle(const Rect& rectangle) = 0; /** * Updates the screen. This is done by either copying the buffer to the @@ -293,7 +293,7 @@ class Graphics const int x2, const int y2, const int width, const int height); - ClipRectangle &getTopClip() A_WARN_UNUSED + ClipRect &getTopClip() A_WARN_UNUSED { return mClipStack.top(); } void setRedraw(const bool n) @@ -410,7 +410,7 @@ class Graphics * @return False if the the new area lays outside the current clip * area. */ - virtual bool pushClipArea(Rectangle area); + virtual bool pushClipArea(Rect area); /** * Removes the top most clip area from the stack. @@ -434,7 +434,7 @@ class Graphics * * @param rectangle The rectangle to draw. */ - virtual void drawRectangle(const Rectangle &rectangle) = 0; + virtual void drawRectangle(const Rect &rectangle) = 0; /** * Gets the current clip area. Usefull if you want to do drawing @@ -442,7 +442,7 @@ class Graphics * * @return The current clip area. */ - virtual const ClipRectangle *getCurrentClipArea() const; + virtual const ClipRect *getCurrentClipArea() const; /** * Draws a single point/pixel. @@ -510,7 +510,7 @@ class Graphics /** * Holds the clip area stack. */ - std::stack mClipStack; + std::stack mClipStack; SDL_Window *mWindow; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index b306cf021..6925f47d0 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -884,7 +884,7 @@ void MobileOpenGLGraphics::_beginDraw() // glScalef(0.5F, 0.5F, 0.5F); - pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } void MobileOpenGLGraphics::_endDraw() @@ -951,21 +951,21 @@ SDL_Surface* MobileOpenGLGraphics::getScreenshot() return screenshot; } -bool MobileOpenGLGraphics::pushClipArea(Rectangle area) +bool MobileOpenGLGraphics::pushClipArea(Rect area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; @@ -986,7 +986,7 @@ void MobileOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &clipArea1 = mClipStack.top(); + const ClipRect &clipArea1 = mClipStack.top(); int transX = -clipArea1.xOffset; int transY = -clipArea1.yOffset; @@ -995,7 +995,7 @@ void MobileOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; if (transX || transY) @@ -1040,12 +1040,12 @@ void MobileOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) drawLineArrays(4); } -void MobileOpenGLGraphics::drawRectangle(const Rectangle& rect) +void MobileOpenGLGraphics::drawRectangle(const Rect& rect) { drawRectangle(rect, false); } -void MobileOpenGLGraphics::fillRectangle(const Rectangle& rect) +void MobileOpenGLGraphics::fillRectangle(const Rect& rect) { drawRectangle(rect, true); } @@ -1090,7 +1090,7 @@ void MobileOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void MobileOpenGLGraphics::drawRectangle(const Rectangle& rect, +void MobileOpenGLGraphics::drawRectangle(const Rect& rect, const bool filled) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 0a57c8341..916002f26 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -1145,7 +1145,7 @@ void NormalOpenGLGraphics::_beginDraw() #endif #endif - pushClipArea(Rectangle(0, 0, w, h)); + pushClipArea(Rect(0, 0, w, h)); } void NormalOpenGLGraphics::_endDraw() @@ -1211,21 +1211,21 @@ SDL_Surface* NormalOpenGLGraphics::getScreenshot() return screenshot; } -bool NormalOpenGLGraphics::pushClipArea(Rectangle area) +bool NormalOpenGLGraphics::pushClipArea(Rect area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; @@ -1247,7 +1247,7 @@ void NormalOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &clipArea1 = mClipStack.top(); + const ClipRect &clipArea1 = mClipStack.top(); int transX = -clipArea1.xOffset; int transY = -clipArea1.yOffset; @@ -1256,7 +1256,7 @@ void NormalOpenGLGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; if (transX || transY) @@ -1297,12 +1297,12 @@ void NormalOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) drawLineArrayf(4); } -void NormalOpenGLGraphics::drawRectangle(const Rectangle& rect) +void NormalOpenGLGraphics::drawRectangle(const Rect& rect) { drawRectangle(rect, false); } -void NormalOpenGLGraphics::fillRectangle(const Rectangle& rect) +void NormalOpenGLGraphics::fillRectangle(const Rect& rect) { drawRectangle(rect, true); } @@ -1347,7 +1347,7 @@ void NormalOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void NormalOpenGLGraphics::drawRectangle(const Rectangle& rect, +void NormalOpenGLGraphics::drawRectangle(const Rect& rect, const bool filled) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 8dd4ca91f..159ccea94 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -918,7 +918,7 @@ void NullOpenGLGraphics::updateScreen() void NullOpenGLGraphics::_beginDraw() { - pushClipArea(Rectangle(0, 0, 640, 480)); + pushClipArea(Rect(0, 0, 640, 480)); } void NullOpenGLGraphics::_endDraw() @@ -935,21 +935,21 @@ SDL_Surface* NullOpenGLGraphics::getScreenshot() return nullptr; } -bool NullOpenGLGraphics::pushClipArea(Rectangle area) +bool NullOpenGLGraphics::pushClipArea(Rect area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX += clipArea.xOffset; transY += clipArea.yOffset; @@ -984,12 +984,12 @@ void NullOpenGLGraphics::drawLine(int x1, int y1, drawLineArrayf(4); } -void NullOpenGLGraphics::drawRectangle(const Rectangle& rect) +void NullOpenGLGraphics::drawRectangle(const Rect& rect) { drawRectangle(rect, false); } -void NullOpenGLGraphics::fillRectangle(const Rectangle& rect) +void NullOpenGLGraphics::fillRectangle(const Rect& rect) { drawRectangle(rect, true); } @@ -1017,7 +1017,7 @@ void NullOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void NullOpenGLGraphics::drawRectangle(const Rectangle& rect A_UNUSED, +void NullOpenGLGraphics::drawRectangle(const Rect& rect A_UNUSED, const bool filled A_UNUSED) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index d3fcebf81..5e8e3390c 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -88,7 +88,7 @@ void _endDraw() override final; - bool pushClipArea(Rectangle area) override final; + bool pushClipArea(Rect area) override final; void popClipArea() override final; @@ -110,12 +110,12 @@ void drawLine(int x1, int y1, int x2, int y2) override final; - void drawRectangle(const Rectangle &rect, + void drawRectangle(const Rect &rect, const bool filled); - void drawRectangle(const Rectangle &rect) override final; + void drawRectangle(const Rect &rect) override final; - void fillRectangle(const Rectangle &rect) override final; + void fillRectangle(const Rect &rect) override final; static void dumpSettings(); diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index 342495a47..a739a4904 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -459,7 +459,7 @@ void SafeOpenGLGraphics::_beginDraw() glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } void SafeOpenGLGraphics::_endDraw() @@ -523,21 +523,21 @@ SDL_Surface* SafeOpenGLGraphics::getScreenshot() return screenshot; } -bool SafeOpenGLGraphics::pushClipArea(Rectangle area) +bool SafeOpenGLGraphics::pushClipArea(Rect area) { int transX = 0; int transY = 0; if (!mClipStack.empty()) { - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); transX = -clipArea.xOffset; transY = -clipArea.yOffset; } const bool result = Graphics::pushClipArea(area); - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); glPushMatrix(); glTranslatef(static_cast(transX + clipArea.xOffset), @@ -557,7 +557,7 @@ void SafeOpenGLGraphics::popClipArea() return; glPopMatrix(); - const ClipRectangle &clipArea = mClipStack.top(); + const ClipRect &clipArea = mClipStack.top(); glScissor(clipArea.x * mScale, (mRect.h - clipArea.y - clipArea.height) * mScale, clipArea.width * mScale, @@ -613,12 +613,12 @@ void SafeOpenGLGraphics::drawLine(int x1, int y1, int x2, int y2) glEnd(); } -void SafeOpenGLGraphics::drawRectangle(const Rectangle& rect) +void SafeOpenGLGraphics::drawRectangle(const Rect& rect) { drawRectangle(rect, false); } -void SafeOpenGLGraphics::fillRectangle(const Rectangle& rect) +void SafeOpenGLGraphics::fillRectangle(const Rect& rect) { drawRectangle(rect, true); } @@ -661,7 +661,7 @@ void SafeOpenGLGraphics::setTexturingAndBlending(const bool enable) } } -void SafeOpenGLGraphics::drawRectangle(const Rectangle& rect, +void SafeOpenGLGraphics::drawRectangle(const Rect& rect, const bool filled) { BLOCK_START("Graphics::drawRectangle") diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index ac7d8debc..ebfcdb226 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -136,7 +136,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, if (!image->mTexture) return false; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; const SDL_Rect srcRect = { @@ -171,7 +171,7 @@ bool SDLGraphics::drawImageInline(const Image *const image, if (!mWindow || !image || !image->mTexture) return false; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return false; @@ -203,7 +203,7 @@ void SDLGraphics::drawImageCached(const Image *const image, if (!mWindow || !image || !image->mTexture) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -238,7 +238,7 @@ void SDLGraphics::drawPatternCached(const Image *const image, if (!image->mTexture) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -296,7 +296,7 @@ void SDLGraphics::drawPatternInline(const Image *const image, if (!image->mTexture) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -347,7 +347,7 @@ void SDLGraphics::drawRescaledPattern(const Image *const image, if (scaledHeight == 0 || scaledWidth == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -407,7 +407,7 @@ void SDLGraphics::calcPatternInline(ImageVertexes* const vert, if (!vert || !mWindow || !image || !image->mTexture) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -492,7 +492,7 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const if (!vert || !vert->image || !vert->image->mTexture) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); if (!top.width || !top.height) return; @@ -638,9 +638,9 @@ void SDLGraphics::calcWindow(ImageCollection *const vertCol, calcImageRect(vert, x, y, w, h, imgRect); } -void SDLGraphics::fillRectangle(const Rectangle &rectangle) +void SDLGraphics::fillRectangle(const Rect &rectangle) { - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect rect = { static_cast(rectangle.x + top.xOffset), @@ -655,7 +655,7 @@ void SDLGraphics::fillRectangle(const Rectangle &rectangle) void SDLGraphics::_beginDraw() { - pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } void SDLGraphics::_endDraw() @@ -663,11 +663,11 @@ void SDLGraphics::_endDraw() popClipArea(); } -bool SDLGraphics::pushClipArea(Rectangle area) +bool SDLGraphics::pushClipArea(Rect area) { const bool result = Graphics::pushClipArea(area); - const ClipRectangle &carea = mClipStack.top(); + const ClipRect &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -686,7 +686,7 @@ void SDLGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &carea = mClipStack.top(); + const ClipRect &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -703,7 +703,7 @@ void SDLGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -722,9 +722,9 @@ void SDLGraphics::drawPoint(int x, int y) } -void SDLGraphics::drawRectangle(const Rectangle &rectangle) +void SDLGraphics::drawRectangle(const Rect &rectangle) { - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); @@ -746,7 +746,7 @@ void SDLGraphics::drawRectangle(const Rectangle &rectangle) void SDLGraphics::drawLine(int x1, int y1, int x2, int y2) { - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); SDL_SetRenderDrawColor(mRenderer, mColor.r, mColor.g, mColor.b, mColor.a); diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index 6631e53f4..15692bca9 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -101,7 +101,7 @@ class SDLGraphics final : public Graphics void _endDraw() override final; - bool pushClipArea(Rectangle rect) override final; + bool pushClipArea(Rect rect) override final; void popClipArea() override final; @@ -163,9 +163,9 @@ class SDLGraphics final : public Graphics const int w, const int h, const ImageRect &imgRect) override final; - void fillRectangle(const Rectangle &rect) override final; + void fillRectangle(const Rect &rect) override final; - void drawRectangle(const Rectangle &rect) override final; + void drawRectangle(const Rect &rect) override final; void drawPoint(int x, int y) override final; diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 016a9557e..8fe83188f 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -82,7 +82,7 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image, if (!tmpImage->mSDLSurface) return false; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Rect srcRect = @@ -123,7 +123,7 @@ bool SDL2SoftwareGraphics::drawImageInline(const Image *const image, if (!mSurface || !image || !image->mSDLSurface) return false; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -211,7 +211,7 @@ void SDL2SoftwareGraphics::drawImageCached(const Image *const image, if (!mSurface || !image || !image->mSDLSurface) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -307,7 +307,7 @@ void SDL2SoftwareGraphics::drawPatternCached(const Image *const image, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -428,7 +428,7 @@ void SDL2SoftwareGraphics::drawPatternInline(const Image *const image, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -547,7 +547,7 @@ void SDL2SoftwareGraphics::drawRescaledPattern(const Image *const image, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -610,7 +610,7 @@ void SDL2SoftwareGraphics::calcPatternInline(ImageVertexes* const vert, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -695,7 +695,7 @@ void SDL2SoftwareGraphics::calcTileSDL(ImageVertexes *const vert, return; const Image *const image = vert->image; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; DoubleRect *rect = new DoubleRect(); @@ -917,15 +917,15 @@ int SDL2SoftwareGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, return 0; } -void SDL2SoftwareGraphics::fillRectangle(const Rectangle &rectangle) +void SDL2SoftwareGraphics::fillRectangle(const Rect &rectangle) { FUNC_BLOCK("Graphics::fillRectangle", 1) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); - Rectangle area = rectangle; + Rect area = rectangle; area.x += top.xOffset; area.y += top.yOffset; @@ -1117,7 +1117,7 @@ void SDL2SoftwareGraphics::fillRectangle(const Rectangle &rectangle) void SDL2SoftwareGraphics::_beginDraw() { - pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } void SDL2SoftwareGraphics::_endDraw() @@ -1125,11 +1125,11 @@ void SDL2SoftwareGraphics::_endDraw() popClipArea(); } -bool SDL2SoftwareGraphics::pushClipArea(Rectangle area) +bool SDL2SoftwareGraphics::pushClipArea(Rect area) { const bool result = Graphics::pushClipArea(area); - const ClipRectangle &carea = mClipStack.top(); + const ClipRect &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1148,7 +1148,7 @@ void SDL2SoftwareGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &carea = mClipStack.top(); + const ClipRect &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1165,7 +1165,7 @@ void SDL2SoftwareGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -1184,7 +1184,7 @@ void SDL2SoftwareGraphics::drawHLine(int x1, int y, int x2) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); const int xOffset = top.xOffset; x1 += xOffset; @@ -1310,7 +1310,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); const int yOffset = top.yOffset; x += top.xOffset; @@ -1440,7 +1440,7 @@ void SDL2SoftwareGraphics::drawVLine(int x, int y1, int y2) SDL_UnlockSurface(mSurface); } -void SDL2SoftwareGraphics::drawRectangle(const Rectangle &rectangle) +void SDL2SoftwareGraphics::drawRectangle(const Rect &rectangle) { const int x1 = rectangle.x; const int x2 = x1 + rectangle.width - 1; diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 1211de5eb..265c9349d 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -58,7 +58,7 @@ class SDL2SoftwareGraphics final : public Graphics void _endDraw(); - bool pushClipArea(Rectangle rect); + bool pushClipArea(Rect rect); void popClipArea(); @@ -120,9 +120,9 @@ class SDL2SoftwareGraphics final : public Graphics const int w, const int h, const ImageRect &imgRect) override final; - void fillRectangle(const Rectangle &rect) override final; + void fillRectangle(const Rect &rect) override final; - void drawRectangle(const Rectangle &rect) override final; + void drawRectangle(const Rect &rect) override final; void drawPoint(int x, int y) override final; diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 05c57a952..5d1589424 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -76,7 +76,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, if (!tmpImage->mSDLSurface) return false; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Rect srcRect = @@ -117,7 +117,7 @@ bool SDLGraphics::drawImageInline(const Image *const image, if (!mWindow || !image || !image->mSDLSurface) return false; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -205,7 +205,7 @@ void SDLGraphics::drawImageCached(const Image *const image, if (!mWindow || !image || !image->mSDLSurface) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; SDL_Surface *const src = image->mSDLSurface; @@ -301,7 +301,7 @@ void SDLGraphics::drawPatternCached(const Image *const image, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -422,7 +422,7 @@ void SDLGraphics::drawPatternInline(const Image *const image, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -541,7 +541,7 @@ void SDLGraphics::drawRescaledPattern(const Image *const image, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -604,7 +604,7 @@ void SDLGraphics::calcPatternInline(ImageVertexes* const vert, if (iw == 0 || ih == 0) return; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const int xOffset = top.xOffset + x; const int yOffset = top.yOffset + y; const int srcX = bounds.x; @@ -688,7 +688,7 @@ void SDLGraphics::calcTileSDL(ImageVertexes *const vert, int x, int y) const return; const Image *const image = vert->image; - const ClipRectangle &top = mClipStack.top(); + const ClipRect &top = mClipStack.top(); const SDL_Rect &bounds = image->mBounds; DoubleRect *rect = new DoubleRect(); @@ -914,15 +914,15 @@ int SDLGraphics::SDL_FakeUpperBlit(const SDL_Surface *const src, return 0; } -void SDLGraphics::fillRectangle(const Rectangle& rectangle) +void SDLGraphics::fillRectangle(const Rect& rectangle) { FUNC_BLOCK("Graphics::fillRectangle", 1) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); - Rectangle area = rectangle; + Rect area = rectangle; area.x += top.xOffset; area.y += top.yOffset; @@ -1114,7 +1114,7 @@ void SDLGraphics::fillRectangle(const Rectangle& rectangle) void SDLGraphics::_beginDraw() { - pushClipArea(Rectangle(0, 0, mRect.w, mRect.h)); + pushClipArea(Rect(0, 0, mRect.w, mRect.h)); } void SDLGraphics::_endDraw() @@ -1122,10 +1122,10 @@ void SDLGraphics::_endDraw() popClipArea(); } -bool SDLGraphics::pushClipArea(Rectangle area) +bool SDLGraphics::pushClipArea(Rect area) { const bool result = Graphics::pushClipArea(area); - const ClipRectangle &carea = mClipStack.top(); + const ClipRect &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1145,7 +1145,7 @@ void SDLGraphics::popClipArea() if (mClipStack.empty()) return; - const ClipRectangle &carea = mClipStack.top(); + const ClipRect &carea = mClipStack.top(); const SDL_Rect rect = { static_cast(carea.x), @@ -1162,7 +1162,7 @@ void SDLGraphics::drawPoint(int x, int y) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); x += top.xOffset; y += top.yOffset; @@ -1181,7 +1181,7 @@ void SDLGraphics::drawHLine(int x1, int y, int x2) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); const int xOffset = top.xOffset; x1 += xOffset; @@ -1307,7 +1307,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) if (mClipStack.empty()) return; - const ClipRectangle& top = mClipStack.top(); + const ClipRect& top = mClipStack.top(); const int yOffset = top.yOffset; x += top.xOffset; @@ -1437,7 +1437,7 @@ void SDLGraphics::drawVLine(int x, int y1, int y2) SDL_UnlockSurface(mWindow); } -void SDLGraphics::drawRectangle(const Rectangle &rectangle) +void SDLGraphics::drawRectangle(const Rect &rectangle) { const int x1 = rectangle.x; const int x2 = x1 + rectangle.width - 1; diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h index c8565f4be..170c0010b 100644 --- a/src/render/sdlgraphics.h +++ b/src/render/sdlgraphics.h @@ -58,7 +58,7 @@ class SDLGraphics final : public Graphics void _endDraw() override final; - bool pushClipArea(Rectangle rect) override final; + bool pushClipArea(Rect rect) override final; void popClipArea() override final; @@ -120,9 +120,9 @@ class SDLGraphics final : public Graphics const int w, const int h, const ImageRect &imgRect) override final; - void fillRectangle(const Rectangle &rect) override final; + void fillRectangle(const Rect &rect) override final; - void drawRectangle(const Rectangle &rect) override final; + void drawRectangle(const Rect &rect) override final; void drawPoint(int x, int y) override final; diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h index 89de995ee..8e85356da 100644 --- a/src/render/surfacegraphics.h +++ b/src/render/surfacegraphics.h @@ -63,7 +63,7 @@ class SurfaceGraphics final : public Graphics void _endDraw() override final { } - bool pushClipArea(Rectangle rect A_UNUSED) override final + bool pushClipArea(Rect rect A_UNUSED) override final { return true; } void popClipArea() override final @@ -158,10 +158,10 @@ class SurfaceGraphics final : public Graphics BlitMode getBlitMode() const A_WARN_UNUSED { return mBlitMode; } - void fillRectangle(const Rectangle &rect A_UNUSED) override final + void fillRectangle(const Rect &rect A_UNUSED) override final { } - void drawRectangle(const Rectangle &rect A_UNUSED) override final + void drawRectangle(const Rect &rect A_UNUSED) override final { } void drawPoint(int x A_UNUSED, int y A_UNUSED) override final diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index bb222c3e8..b1ed41fdc 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -163,7 +163,7 @@ void TouchManager::loadTouchItem(TouchItem **item, const std::string &name, default: break; } - *item = new TouchItem(text, Rectangle(x + diff, y + diff, + *item = new TouchItem(text, Rect(x + diff, y + diff, width + border2, height + border2), type, eventPressed, eventReleased, images, icon, x + pad, y + pad, width, height, @@ -270,7 +270,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) const TouchItem *const item = *it; if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard))) continue; - const Rectangle &rect = item->rect; + const Rect &rect = item->rect; if (rect.isPointInRect(x, y)) { MouseInput event = mouseInput; diff --git a/src/touchmanager.h b/src/touchmanager.h index 7e670b1a6..d874ec452 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -25,7 +25,7 @@ #include "input/keydata.h" -#include "gui/rectangle.h" +#include "gui/rect.h" #include #include @@ -45,7 +45,7 @@ const int buttonsCount = 12; struct TouchItem final { TouchItem(const std::string &text0, - const Rectangle &rect0, const int type0, + const Rect &rect0, const int type0, const std::string &eventPressed0, const std::string &eventReleased0, ImageRect *const images0, Image *const icon0, @@ -73,7 +73,7 @@ struct TouchItem final A_DELETE_COPY(TouchItem) std::string text; - Rectangle rect; + Rect rect; int type; std::string eventPressed; std::string eventReleased; -- cgit v1.2.3-70-g09d2 From f91a3ef02da845393dc7df7cf6337d064a1feaa7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 26 Feb 2014 01:10:30 +0300 Subject: Add xmlutils for quick load simple xml files. Also add test for xmlutils. --- src/CMakeLists.txt | 2 ++ src/Makefile.am | 5 +++ src/utils/xmlutils.cpp | 63 +++++++++++++++++++++++++++++++++++++ src/utils/xmlutils.h | 34 ++++++++++++++++++++ src/utils/xmlutils_unittest.cc | 70 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 src/utils/xmlutils.cpp create mode 100644 src/utils/xmlutils.h create mode 100644 src/utils/xmlutils_unittest.cc (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index baa1cf783..6c9d82731 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -587,6 +587,8 @@ SET(SRCS utils/mkdir.h utils/xml.cpp utils/xml.h + utils/xmlutils.cpp + utils/xmlutils.h test/testlauncher.cpp test/testlauncher.h test/testmain.cpp diff --git a/src/Makefile.am b/src/Makefile.am index bf29e7d03..e45a5397a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -118,6 +118,8 @@ dyecmd_SOURCES += dyetool/dyemain.cpp \ utils/timer.h \ utils/xml.cpp \ utils/xml.h \ + utils/xmlutils.cpp \ + utils/xmlutils.h \ utils/translation/podict.cpp \ utils/translation/podict.h @@ -686,6 +688,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ utils/mutex.h \ utils/xml.cpp \ utils/xml.h \ + utils/xmlutils.cpp \ + utils/xmlutils.h \ test/testlauncher.cpp \ test/testlauncher.h \ test/testmain.cpp \ @@ -1033,6 +1037,7 @@ manaplus_SOURCES += \ gui/widgets/browserbox_unittest.cc \ utils/files_unittest.cc \ utils/stringutils_unittest.cc \ + utils/xmlutils_unittest.cc \ resources/dye_unittest.cc endif diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp new file mode 100644 index 000000000..7d19b1064 --- /dev/null +++ b/src/utils/xmlutils.cpp @@ -0,0 +1,63 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "utils/xmlutils.h" + +#include "logger.h" + +#include "utils/xml.h" + +#include "debug.h" + +void readXmlIntVector(const std::string &fileName, + const std::string &rootName, + const std::string §ionName, + const std::string &itemName, + const std::string &attributeName, + std::vector &arr) +{ + arr.clear(); + XML::Document doc(fileName); + const XmlNodePtrConst rootNode = doc.rootNode(); + + if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str())) + { + logger->log("Error while loading %s!", fileName.c_str()); + return; + } + + for_each_xml_child_node(sectionNode, rootNode) + { + if (!xmlNameEqual(sectionNode, sectionName.c_str())) + continue; + for_each_xml_child_node(childNode, sectionNode) + { + if (!xmlNameEqual(childNode, itemName.c_str())) + continue; + + const int val = XML::getProperty(childNode, + attributeName.c_str(), -1); + if (val == -1) + continue; + + arr.push_back(val); + } + } +} diff --git a/src/utils/xmlutils.h b/src/utils/xmlutils.h new file mode 100644 index 000000000..3dbee5f95 --- /dev/null +++ b/src/utils/xmlutils.h @@ -0,0 +1,34 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UTILS_XMLUTILS_H +#define UTILS_XMLUTILS_H + +#include +#include + +void readXmlIntVector(const std::string &fileName, + const std::string &rootName, + const std::string §ionName, + const std::string &itemName, + const std::string &attributeName, + std::vector &arr); + +#endif // UTILS_XMLUTILS_H diff --git a/src/utils/xmlutils_unittest.cc b/src/utils/xmlutils_unittest.cc new file mode 100644 index 000000000..5b3469805 --- /dev/null +++ b/src/utils/xmlutils_unittest.cc @@ -0,0 +1,70 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "utils/xmlutils.h" + +#include "client.h" +#include "logger.h" + +#include "gtest/gtest.h" + +#include "utils/physfstools.h" +#include "utils/xml.h" + +#include "resources/resourcemanager.h" + +#include +#include + +#include "debug.h" + +static void init() +{ + PHYSFS_init("manaplus"); + dirSeparator = "/"; + XML::initXML(); + logger = new Logger(); + ResourceManager *resman = ResourceManager::getInstance(); + resman->addToSearchPath("data", false); + resman->addToSearchPath("../data", false); +} + +TEST(xmlutils, readXmlIntVector1) +{ + Client::Options options; + client = new Client(options); + init(); + + std::vector arr; + + readXmlIntVector("graphics/gui/browserbox.xml", + "skinset", + "widget", + "option", + "value", + arr); + + EXPECT_EQ(5, arr.size()); + EXPECT_EQ(1, arr[0]); + EXPECT_EQ(15, arr[1]); + EXPECT_EQ(0, arr[2]); + EXPECT_EQ(1, arr[3]); + EXPECT_EQ(1, arr[4]); +} -- cgit v1.2.3-70-g09d2 From b481cd74dfd1629ca7b045cde57562e752c49638 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Feb 2014 12:48:21 +0300 Subject: Dehardcode swords, shields and bows for auto switching weapons. --- data/perserver/default/CMakeLists.txt | 1 + data/perserver/default/Makefile.am | 3 +- data/perserver/default/weapons.xml | 19 ++++++++ src/CMakeLists.txt | 2 + src/Makefile.am | 2 + src/being/localplayer.cpp | 51 +++++++++++----------- src/client.cpp | 3 ++ src/resources/db/weaponsdb.cpp | 81 +++++++++++++++++++++++++++++++++++ src/resources/db/weaponsdb.h | 45 +++++++++++++++++++ 9 files changed, 180 insertions(+), 27 deletions(-) create mode 100644 data/perserver/default/weapons.xml create mode 100644 src/resources/db/weaponsdb.cpp create mode 100644 src/resources/db/weaponsdb.h (limited to 'src') diff --git a/data/perserver/default/CMakeLists.txt b/data/perserver/default/CMakeLists.txt index ed7e61e1e..19cf3686d 100644 --- a/data/perserver/default/CMakeLists.txt +++ b/data/perserver/default/CMakeLists.txt @@ -4,6 +4,7 @@ SET (FILES deadmessages.xml features.xml gmcommands.txt + weapons.xml ) INSTALL(FILES ${FILES} DESTINATION ${DATA_DIR}/perserver/default) diff --git a/data/perserver/default/Makefile.am b/data/perserver/default/Makefile.am index 8a66984b8..5b478d82d 100644 --- a/data/perserver/default/Makefile.am +++ b/data/perserver/default/Makefile.am @@ -5,7 +5,8 @@ default_DATA = \ chatcommands.txt \ deadmessages.xml \ features.xml \ - gmcommands.txt + gmcommands.txt \ + weapons.xml EXTRA_DIST = \ $(default_DATA) \ diff --git a/data/perserver/default/weapons.xml b/data/perserver/default/weapons.xml new file mode 100644 index 000000000..051e1f59e --- /dev/null +++ b/data/perserver/default/weapons.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6c9d82731..054ab4823 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -525,6 +525,8 @@ SET(SRCS resources/sdlmusic.h resources/db/sounddb.cpp resources/db/sounddb.h + resources/db/weaponsdb.cpp + resources/db/weaponsdb.h resources/soundeffect.cpp resources/soundeffect.h resources/soundinfo.h diff --git a/src/Makefile.am b/src/Makefile.am index e45a5397a..2b1eb4c68 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -624,6 +624,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ resources/sdlmusic.h \ resources/db/sounddb.cpp \ resources/db/sounddb.h \ + resources/db/weaponsdb.cpp \ + resources/db/weaponsdb.h \ resources/soundeffect.cpp \ resources/soundeffect.h \ resources/soundinfo.h \ diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 2a3c5fa2f..0e7f8a9b0 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -67,6 +67,7 @@ #include "resources/iteminfo.h" #include "resources/db/emotedb.h" +#include "resources/db/weaponsdb.h" #include "utils/gettext.h" #include "utils/timer.h" @@ -2337,23 +2338,14 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const // if attack distance for sword if (allowSword) { - // finding sword - item = inv->findItem(571, 0); - - if (!item) - item = inv->findItem(570, 0); - - if (!item) - item = inv->findItem(579, 0); - - if (!item) - item = inv->findItem(867, 0); - - if (!item) - item = inv->findItem(536, 0); - - if (!item) - item = inv->findItem(758, 0); + // searching swords + const WeaponsInfos &swords = WeaponsDB::getSwords(); + FOR_EACH (WeaponsInfosIter, it, swords) + { + item = inv->findItem(*it, 0); + if (item) + break; + } // no swords if (!item) @@ -2366,10 +2358,14 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const // if need equip shield too if (mAttackWeaponType == 3) { - // finding shield - item = inv->findItem(601, 0); - if (!item) - item = inv->findItem(602, 0); + // searching shield + const WeaponsInfos &shields = WeaponsDB::getShields(); + FOR_EACH (WeaponsInfosIter, it, shields) + { + item = inv->findItem(*it, 0); + if (item) + break; + } if (item && !item->isEquipped()) PlayerInfo::equipItem(item, true); } @@ -2377,11 +2373,14 @@ void LocalPlayer::changeEquipmentBeforeAttack(const Being *const target) const // big distance. allowed only bow else { - // finding bow - item = inv->findItem(545, 0); - - if (!item) - item = inv->findItem(530, 0); + // searching bow + const WeaponsInfos &bows = WeaponsDB::getBows(); + FOR_EACH (WeaponsInfosIter, it, bows) + { + item = inv->findItem(*it, 0); + if (item) + break; + } // no bow if (!item) diff --git a/src/client.cpp b/src/client.cpp index 1238e9b8d..990306fc1 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -108,6 +108,7 @@ #endif #include "resources/db/palettedb.h" #include "resources/db/petdb.h" +#include "resources/db/weaponsdb.h" #include "utils/base64.h" #include "utils/cpu.h" @@ -838,6 +839,7 @@ void Client::gameClear() MonsterDB::unload(); NPCDB::unload(); AvatarDB::unload(); + WeaponsDB::unload(); PaletteDB::unload(); PETDB::unload(); StatusEffect::unload(); @@ -1468,6 +1470,7 @@ int Client::gameExec() SpecialDB::load(); #endif AvatarDB::load(); + WeaponsDB::load(); NPCDB::load(); PETDB::load(); EmoteDB::load(); diff --git a/src/resources/db/weaponsdb.cpp b/src/resources/db/weaponsdb.cpp new file mode 100644 index 000000000..82892cc5f --- /dev/null +++ b/src/resources/db/weaponsdb.cpp @@ -0,0 +1,81 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "resources/db/weaponsdb.h" + +#include "logger.h" + +#include "utils/gettext.h" +#include "utils/xmlutils.h" + +#include "configuration.h" + +#include "debug.h" + +namespace +{ + WeaponsInfos mBows; + WeaponsInfos mSwords; + WeaponsInfos mShields; + bool mLoaded = false; +} + +static void loadDB(const std::string name, WeaponsInfos &arr) +{ + readXmlIntVector("weapons.xml", + "weapons", + name, + "item", + "id", + arr); +} + +void WeaponsDB::load() +{ + if (mLoaded) + unload(); + + loadDB("swords", mSwords); + loadDB("bows", mBows); + loadDB("shields", mShields); +} + +void WeaponsDB::unload() +{ + mBows.clear(); + mSwords.clear(); + mShields.clear(); + mLoaded = false; +} + +const WeaponsInfos &WeaponsDB::getBows() +{ + return mBows; +} + +const WeaponsInfos &WeaponsDB::getSwords() +{ + return mSwords; +} + +const WeaponsInfos &WeaponsDB::getShields() +{ + return mShields; +} diff --git a/src/resources/db/weaponsdb.h b/src/resources/db/weaponsdb.h new file mode 100644 index 000000000..287237c48 --- /dev/null +++ b/src/resources/db/weaponsdb.h @@ -0,0 +1,45 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef RESOURCES_DB_WEAPONSDB_H +#define RESOURCES_DB_WEAPONSDB_H + +#include +#include + +#include "localconsts.h" + +typedef std::vector WeaponsInfos; +typedef WeaponsInfos::const_iterator WeaponsInfosIter; + +namespace WeaponsDB +{ + void load(); + + void unload(); + + const WeaponsInfos &getBows(); + + const WeaponsInfos &getSwords(); + + const WeaponsInfos &getShields(); +} // namespace WeaponsDB + +#endif // RESOURCES_DB_WEAPONSDB_H -- cgit v1.2.3-70-g09d2 From c61f1b6abe8e68995f00ae3a939afe5049e5cdb3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Feb 2014 13:25:41 +0300 Subject: Remove manaserv ifdefs code. ManaServ was already depricated long ago. --- src/actormanager.cpp | 21 +- src/being/actorsprite.h | 9 +- src/being/being.cpp | 249 +++--------- src/being/being.h | 11 +- src/being/localplayer.cpp | 765 ++++------------------------------- src/being/playerinfo.cpp | 19 - src/client.cpp | 6 - src/game.cpp | 12 - src/gui/models/typelistmodel.h | 17 - src/gui/viewport.cpp | 242 +++++------ src/gui/windowmenu.cpp | 12 - src/gui/windows/charcreatedialog.cpp | 13 +- src/gui/windows/charselectdialog.cpp | 7 - src/gui/windows/editserverdialog.cpp | 23 +- src/gui/windows/selldialog.cpp | 10 - src/gui/windows/serverdialog.cpp | 20 +- src/main.h | 2 +- src/map.cpp | 125 ------ src/map.h | 23 -- src/net/ea/loginhandler.cpp | 5 - src/net/loginhandler.h | 5 - src/net/messagein.cpp | 5 +- src/net/net.cpp | 10 - src/net/serverinfo.h | 4 - src/resources/db/monsterdb.cpp | 6 - 25 files changed, 248 insertions(+), 1373 deletions(-) (limited to 'src') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 9661dc2fe..72ab8c21c 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -137,23 +137,10 @@ class SortBeingFunctor final return being1->getDistance() < being2->getDistance(); } - int d1, d2; -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - const Vector &pos1 = being1->getPosition(); - d1 = abs((static_cast(pos1.x)) - x) - + abs((static_cast(pos1.y)) - y); - const Vector &pos2 = being2->getPosition(); - d2 = abs((static_cast(pos2.x)) - x) - + abs((static_cast(pos2.y)) - y); - } - else -#endif - { - d1 = abs(being1->getTileX() - x) + abs(being1->getTileY() - y); - d2 = abs(being2->getTileX() - x) + abs(being2->getTileY() - y); - } + const int d1 = abs(being1->getTileX() - x) + + abs(being1->getTileY() - y); + const int d2 = abs(being2->getTileX() - x) + + abs(being2->getTileY() - y); if (d1 != d2) return d1 < d2; diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index f9876fa79..444232ddd 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -183,14 +183,7 @@ public: { return getPixelX() - mapTileSize / 2; } int getActorY() const - { -#ifdef MANASERV_SUPPORT - return getPixelY() + ((Net::getNetworkType() == ServerInfo::MANASERV) - ? 15 : mapTileSize); -#else - return getPixelY() - mapTileSize; -#endif - } + { return getPixelY() - mapTileSize; } protected: /** diff --git a/src/being/being.cpp b/src/being/being.cpp index 428e6e7f8..705d97439 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -371,50 +371,7 @@ void Being::setDestination(const int dstX, const int dstY) if (!mMap) return; -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif - { - setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask())); - return; - } - -#ifdef MANASERV_SUPPORT - // Don't handle flawed destinations from server... - if (dstX == 0 || dstY == 0) - return; - - // If the destination is unwalkable, don't bother trying to get there - if (!mMap->getWalk(dstX / mapTileSize, dstY / mapTileSize)) - return; - - Position dest = mMap->checkNodeOffsets(getCollisionRadius(), getWalkMask(), - dstX, dstY); - Path thisPath = mMap->findPixelPath(static_cast(mPos.x), - static_cast(mPos.y), dest.x, dest.y, - static_cast(getCollisionRadius()), - static_cast(getWalkMask())); - - if (thisPath.empty()) - { - // If there is no path but the destination is on the same walkable tile, - // we accept it. - if (static_cast(mPos.x) / mapTileSize == dest.x / mapTileSize - && static_cast(mPos.y) / mapTileSize == dest.y / mapTileSize) - { - mDest.x = static_cast(dest.x); - mDest.y = static_cast(dest.y); - } - setPath(Path()); - return; - } - - // The destination is valid, so we set it. - mDest.x = static_cast(dest.x); - mDest.y = static_cast(dest.y); - - setPath(thisPath); -#endif + setPath(mMap->findPath(mX, mY, dstX, dstY, getWalkMask())); } void Being::clearPath() @@ -428,12 +385,7 @@ void Being::setPath(const Path &path) if (mPath.empty()) return; -#ifdef MANASERV_SUPPORT - if ((Net::getNetworkType() != ServerInfo::MANASERV) && - mAction != MOVE && mAction != DEAD) -#else if (mAction != MOVE && mAction != DEAD) -#endif { nextTile(); mActionTime = tick_time; @@ -771,13 +723,8 @@ void Being::handleAttack(Being *const victim, const int damage, else if (mInfo->getAttack(attackId)) fireMissile(victim, mInfo->getAttack(attackId)->mMissileParticle); -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif - { - reset(); - mActionTime = tick_time; - } + reset(); + mActionTime = tick_time; if (this != player_node) { @@ -824,13 +771,8 @@ void Being::handleSkill(Being *const victim, const int damage, if (data) fireMissile(victim, data->particle); -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif - { - reset(); - mActionTime = tick_time; - } + reset(); + mActionTime = tick_time; if (this != player_node) { @@ -1443,157 +1385,68 @@ void Being::logic() } int frameCount = static_cast(getFrameCount()); -#ifdef MANASERV_SUPPORT - if ((Net::getNetworkType() == ServerInfo::MANASERV) && (mAction != DEAD)) - { - const Vector dest = (mPath.empty()) ? - mDest : Vector(static_cast(mPath.front().x), - static_cast(mPath.front().y)); - // This is a hack that stops NPCs from running off the map... - if (mDest.x <= 0 && mDest.y <= 0) - { - BLOCK_END("Being::logic") - return; - } - - // The Vector representing the difference between current position - // and the next destination path node. - Vector dir = dest - mPos; - - const float nominalLength = dir.length(); + switch (mAction) + { + case STAND: + case SIT: + case DEAD: + case HURT: + case SPAWN: + default: + break; - // When we've not reached our destination, move to it. - if (nominalLength > 0.0F && !mWalkSpeed.isNull()) + case MOVE: { - // The deplacement of a point along a vector is calculated - // using the Unit Vector (â) multiplied by the point speed. - // â = a / ||a|| (||a|| is the a length.) - // Then, diff = (dir/||dir||) * speed. - const Vector normalizedDir = dir.normalized(); - Vector diff(normalizedDir.x * mWalkSpeed.x, - normalizedDir.y * mWalkSpeed.y); - - // Test if we don't miss the destination by a move too far: - if (diff.length() > nominalLength) - { - setPosition(mPos + dir); - - // Also, if the destination is reached, try to get the next - // path point, if existing. - if (!mPath.empty()) - mPath.pop_front(); - } - // Otherwise, go to it using the nominal speed. - else + if (static_cast(get_elapsed_time( + mActionTime)) >= mSpeed) { - setPosition(mPos + diff); + nextTile(); } - - if (mAction != MOVE) - setAction(MOVE, 0); - - // Update the player sprite direction. - // N.B.: We only change this if the distance is more than one pixel. - if (nominalLength > 1.0F) - { - int direction = 0; - const float dx = std::abs(dir.x); - float dy = std::abs(dir.y); - - // When not using mouse for the player, we slightly prefer - // UP and DOWN position, especially when walking diagonally. - if (player_node && this == player_node && - !player_node->isPathSetByMouse()) - { - dy = dy + 2; - } - - if (dx > dy) - direction |= (dir.x > 0) ? RIGHT : LEFT; - else - direction |= (dir.y > 0) ? DOWN : UP; - - setDirection(static_cast(direction)); - } - } - else if (!mPath.empty()) - { - // If the current path node has been reached, - // remove it and go to the next one. - mPath.pop_front(); - } - else if (mAction == MOVE) - { - setAction(STAND, 0); + break; } - } - else - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif - { - switch (mAction) - { - case STAND: - case SIT: - case DEAD: - case HURT: - case SPAWN: - default: - break; - case MOVE: - { - if (static_cast(get_elapsed_time( - mActionTime)) >= mSpeed) - { - nextTile(); - } + case ATTACK: + { + if (!mActionTime) break; - } - case ATTACK: + int curFrame = 0; + if (mAttackSpeed) { - if (!mActionTime) - break; - - int curFrame = 0; - if (mAttackSpeed) - { - curFrame = (get_elapsed_time(mActionTime) * frameCount) - / mAttackSpeed; - } + curFrame = (get_elapsed_time(mActionTime) * frameCount) + / mAttackSpeed; + } - if (this == player_node && curFrame >= frameCount) - nextTile(); + if (this == player_node && curFrame >= frameCount) + nextTile(); - break; - } + break; } + } - if (mAction == MOVE) - { - const int xOffset = getXOffset(); - const int yOffset = getYOffset(); - int offset = xOffset; - if (!offset) - offset = yOffset; + if (mAction == MOVE) + { + const int xOffset = getXOffset(); + const int yOffset = getYOffset(); + int offset = xOffset; + if (!offset) + offset = yOffset; - mSortOffsetY = (mOldHeight * mapTileSize / 2) - + (mOffsetY * mapTileSize / 2) - * (mapTileSize - abs(offset)) / mapTileSize; - const int yOffset2 = yOffset - mSortOffsetY; + mSortOffsetY = (mOldHeight * mapTileSize / 2) + + (mOffsetY * mapTileSize / 2) + * (mapTileSize - abs(offset)) / mapTileSize; + const int yOffset2 = yOffset - mSortOffsetY; - // Update pixel coordinates - setPosition(static_cast(mX * mapTileSize - + mapTileSize / 2 + xOffset), static_cast( - mY * mapTileSize + mapTileSize + yOffset2)); - } - else - { - setPosition(static_cast(mX * mapTileSize + mapTileSize / 2), - static_cast(mY * mapTileSize + mapTileSize)); - } + // Update pixel coordinates + setPosition(static_cast(mX * mapTileSize + + mapTileSize / 2 + xOffset), static_cast( + mY * mapTileSize + mapTileSize + yOffset2)); + } + else + { + setPosition(static_cast(mX * mapTileSize + mapTileSize / 2), + static_cast(mY * mapTileSize + mapTileSize)); } if (mEmotionSprite) diff --git a/src/being/being.h b/src/being/being.h index e427612f0..2521eb0c3 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -472,17 +472,13 @@ class Being : public ActorSprite, public ConfigListener } /** - * Sets the walk speed. - * in pixels per second for eAthena, - * in tiles per second for Manaserv. + * Sets the walk speed in pixels per second. */ void setWalkSpeed(Vector speed) { mWalkSpeed = speed; mSpeed = speed.x; } /** - * Gets the walk speed. - * in pixels per second for eAthena, - * in tiles per second for Manaserv (0.1 precision). + * Gets the walk speed in pixels per second. */ Vector getWalkSpeed() const A_WARN_UNUSED { return mWalkSpeed; } @@ -1037,8 +1033,7 @@ class Being : public ActorSprite, public ConfigListener /** * Walk speed for x and y movement values. - * In pixels per second for eAthena, - * In pixels per ticks for Manaserv. + * In pixels per second. * @see MILLISECONDS_IN_A_TICK */ Vector mWalkSpeed; diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 0e7f8a9b0..5d4ce123e 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -286,10 +286,6 @@ void LocalPlayer::logic() mMessageTime--; } -#ifdef MANASERV_SUPPORT - PlayerInfo::logic(); -#endif - if (mTarget) { if (mTarget->getType() == ActorSprite::NPC) @@ -300,23 +296,10 @@ void LocalPlayer::logic() else { // Find whether target is in range -#ifdef MANASERV_SUPPORT - const int rangeX = - (Net::getNetworkType() == ServerInfo::MANASERV) ? - static_cast(abs(static_cast(mTarget->getPosition().x - - getPosition().x))) : - static_cast(abs(mTarget->getTileX() - getTileX())); - const int rangeY = - (Net::getNetworkType() == ServerInfo::MANASERV) ? - static_cast(abs(static_cast(mTarget->getPosition().y - - getPosition().y))) : - static_cast(abs(mTarget->getTileY() - getTileY())); -#else const int rangeX = static_cast( abs(mTarget->getTileX() - getTileX())); const int rangeY = static_cast( abs(mTarget->getTileY() - getTileY())); -#endif const int attackRange = getAttackRange(); const TargetCursorType targetType = rangeX > attackRange || rangeY > attackRange ? @@ -420,475 +403,58 @@ void LocalPlayer::setGMLevel(const int level) } } -#ifdef MANASERV_SUPPORT -Position LocalPlayer::getNextWalkPosition(const unsigned char dir) const +void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0) { - // Compute where the next tile will be set. - int dx = 0, dy = 0; - if (dir & Being::UP) - dy--; - if (dir & Being::DOWN) - dy++; - if (dir & Being::LEFT) - dx--; - if (dir & Being::RIGHT) - dx++; - - const Vector &pos = getPosition(); - - // If no map or no direction is given, give back the current player position - if (!mMap || (!dx && !dy)) - return Position(static_cast(pos.x), static_cast(pos.y)); - - const int posX = static_cast(pos.x); - const int posY = static_cast(pos.y); - // Get the current tile pos and its offset - const int tileX = posX / mMap->getTileWidth(); - const int tileY = posY / mMap->getTileHeight(); - const int offsetX = posX % mMap->getTileWidth(); - const int offsetY = posY % mMap->getTileHeight(); - const unsigned char walkMask = getWalkMask(); - const int radius = getCollisionRadius(); - - // Get the walkability of every surrounding tiles. - bool wTopLeft = mMap->getWalk(tileX - 1, tileY - 1, walkMask); - const bool wTop = mMap->getWalk(tileX, tileY - 1, walkMask); - bool wTopRight = mMap->getWalk(tileX + 1, tileY - 1, walkMask); - const bool wLeft = mMap->getWalk(tileX - 1, tileY, walkMask); - const bool wRight = mMap->getWalk(tileX + 1, tileY, walkMask); - bool wBottomLeft = mMap->getWalk(tileX - 1, tileY + 1, walkMask); - const bool wBottom = mMap->getWalk(tileX, tileY + 1, walkMask); - bool wBottomRight = mMap->getWalk(tileX + 1, tileY + 1, walkMask); - - // Make diagonals unwalkable when both straight directions are blocking - if (!wTop) - { - if (!wRight) - wTopRight = false; - if (!wLeft) - wTopLeft = false; - } - if (!wBottom) - { - if (!wRight) - wBottomRight = false; - if (!wLeft) - wBottomLeft = false; - } - - // We'll make tests for each desired direction - - // Handle diagonal cases by setting the way back to a straight direction - // when necessary. - if (dx && dy) + const Party *const party = Party::getParty(1); + if (party) { - // Going top-right - if (dx > 0 && dy < 0) - { - if (!wTopRight) - { - // Choose a straight direction when diagonal target is blocked - if (!wTop && wRight) - { - dy = 0; - } - else if (wTop && !wRight) - { - dx = 0; - } - else if (!wTop && !wRight) - { - return Position(tileX * mapTileSize + mapTileSize - radius, - tileY * mapTileSize + getCollisionRadius()); - } - else // Both straight direction are walkable - { - // Go right when below the corner - if (offsetY >= (offsetX / mMap->getTileHeight() - - (offsetX / mMap->getTileWidth() - * mMap->getTileHeight()) )) - { - dy = 0; - } - else // Go up otherwise - { - dx = 0; - } - } - } - else // The diagonal is walkable - { - return mMap->checkNodeOffsets(radius, walkMask, - Position(posX + mapTileSize, posY - mapTileSize)); - } - } - - // Going top-left - if (dx < 0 && dy < 0) - { - if (!wTopLeft) - { - // Choose a straight direction when diagonal target is blocked - if (!wTop && wLeft) - { - dy = 0; - } - else if (wTop && !wLeft) - { - dx = 0; - } - else if (!wTop && !wLeft) - { - return Position(tileX * mapTileSize + radius, - tileY * mapTileSize + radius); - } - else // Both straight direction are walkable - { - // Go left when below the corner - if (offsetY >= (offsetX / mMap->getTileWidth() - * mMap->getTileHeight())) - { - dy = 0; - } - else // Go up otherwise - { - dx = 0; - } - } - } - else // The diagonal is walkable - { - return mMap->checkNodeOffsets(radius, walkMask, - Position(posX - mapTileSize, posY - mapTileSize)); - } - } - - // Going bottom-left - if (dx < 0 && dy > 0) - { - if (!wBottomLeft) - { - // Choose a straight direction when diagonal target is blocked - if (!wBottom && wLeft) - { - dy = 0; - } - else if (wBottom && !wLeft) - { - dx = 0; - } - else if (!wBottom && !wLeft) - { - return Position(tileX * mapTileSize + radius, - tileY * mapTileSize + mapTileSize - radius); - } - else // Both straight direction are walkable - { - // Go down when below the corner - if (offsetY >= (offsetX / mMap->getTileHeight() - - (offsetX / mMap->getTileWidth() - * mMap->getTileHeight()))) - { - dx = 0; - } - else // Go left otherwise - { - dy = 0; - } - } - } - else // The diagonal is walkable - { - return mMap->checkNodeOffsets(radius, walkMask, - Position(posX - mapTileSize, posY + mapTileSize)); - } - } - - // Going bottom-right - if (dx > 0 && dy > 0) + PartyMember *const pm = party->getMember(getName()); + if (pm) { - if (!wBottomRight) - { - // Choose a straight direction when diagonal target is blocked - if (!wBottom && wRight) - { - dy = 0; - } - else if (wBottom && !wRight) - { - dx = 0; - } - else if (!wBottom && !wRight) - { - return Position(tileX * mapTileSize + mapTileSize - radius, - tileY * mapTileSize + mapTileSize - radius); - } - else // Both straight direction are walkable - { - // Go down when below the corner - if (offsetY >= (offsetX / mMap->getTileWidth() - * mMap->getTileHeight())) - { - dx = 0; - } - else // Go right otherwise - { - dy = 0; - } - } - } - else // The diagonal is walkable - { - return mMap->checkNodeOffsets(radius, walkMask, - Position(posX + mapTileSize, posY + mapTileSize)); - } + pm->setX(mX); + pm->setY(mY); } - } // End of diagonal cases + } - // Straight directions - // Right direction - if (dx > 0 && !dy) + if (mPath.empty()) { - // If the straight destination is blocked, - // Make the player go the closest possible. - if (!wRight) - { - return Position(tileX * mapTileSize + mapTileSize - radius, posY); - } - else - { - if (!wTopRight) - { - // If we're going to collide with the top-right corner - if (offsetY - radius < 0) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + mapTileSize - radius, - tileY * mapTileSize + radius); - } - } + if (mPickUpTarget) + pickUp(mPickUpTarget); - if (!wBottomRight) - { - // If we're going to collide with the bottom-right corner - if (offsetY + radius > mapTileSize) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + mapTileSize - radius, - tileY * mapTileSize + mapTileSize - radius); - } - } - // If the way is clear, step up one checked tile ahead. - return mMap->checkNodeOffsets(radius, walkMask, - Position(posX + mapTileSize, posY)); - } + if (mWalkingDir) + startWalking(mWalkingDir); } - - // Left direction - if (dx < 0 && !dy) + else if (mPath.size() == 1) { - // If the straight destination is blocked, - // Make the player go the closest possible. - if (!wLeft) - { - return Position(tileX * mapTileSize + radius, posY); - } - else - { - if (!wTopLeft) - { - // If we're going to collide with the top-left corner - if (offsetY - radius < 0) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + radius, - tileY * mapTileSize + radius); - } - } - - if (!wBottomLeft) - { - // If we're going to collide with the bottom-left corner - if (offsetY + radius > mapTileSize) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + radius, - tileY * mapTileSize + mapTileSize - radius); - } - } - // If the way is clear, step up one checked tile ahead. - return mMap->checkNodeOffsets(radius, walkMask, - Position(posX - mapTileSize, posY)); - } + if (mPickUpTarget) + pickUp(mPickUpTarget); } - // Up direction - if (!dx && dy < 0) + if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) { - // If the straight destination is blocked, - // Make the player go the closest possible. - if (!wTop) - { - return Position(posX, tileY * mapTileSize + radius); - } - else - { - if (!wTopLeft) - { - // If we're going to collide with the top-left corner - if (offsetX - radius < 0) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + radius, - tileY * mapTileSize + radius); - } - } - - if (!wTopRight) - { - // If we're going to collide with the top-right corner - if (offsetX + radius > mapTileSize) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + mapTileSize - radius, - tileY * mapTileSize + radius); - } - } - // If the way is clear, step up one checked tile ahead. - return mMap->checkNodeOffsets(radius, - walkMask, Position(posX, posY - mapTileSize)); - } + mAction = Being::STAND; + attack(mTarget, true); + mGoingToTarget = false; + mPath.clear(); + return; } - - // Down direction - if (!dx && dy > 0) + else if (mGoingToTarget && !mTarget) { - // If the straight destination is blocked, - // Make the player go the closest possible. - if (!wBottom) - { - return Position(posX, tileY * mapTileSize + mapTileSize - radius); - } - else - { - if (!wBottomLeft) - { - // If we're going to collide with the bottom-left corner - if (offsetX - radius < 0) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + radius, - tileY * mapTileSize + mapTileSize - radius); - } - } - - if (!wBottomRight) - { - // If we're going to collide with the bottom-right corner - if (offsetX + radius > mapTileSize) - { - // We make the player corrects its offset - // before going further - return Position(tileX * mapTileSize + mapTileSize - radius, - tileY * mapTileSize + mapTileSize - radius); - } - } - // If the way is clear, step up one checked tile ahead. - return mMap->checkNodeOffsets(radius, - walkMask, Position(posX, posY + mapTileSize)); - } + mGoingToTarget = false; + mPath.clear(); } - // Return the current position if everything else has failed. - return Position(posX, posY); -} -#endif - -void LocalPlayer::nextTile(unsigned char dir A_UNUSED = 0) -{ -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif + if (mPath.empty()) { - const Party *const party = Party::getParty(1); - if (party) - { - PartyMember *const pm = party->getMember(getName()); - if (pm) - { - pm->setX(mX); - pm->setY(mY); - } - } - - if (mPath.empty()) - { - if (mPickUpTarget) - pickUp(mPickUpTarget); - - if (mWalkingDir) - startWalking(mWalkingDir); - } - else if (mPath.size() == 1) - { - if (mPickUpTarget) - pickUp(mPickUpTarget); - } - - if (mGoingToTarget && mTarget && withinAttackRange(mTarget)) - { - mAction = Being::STAND; - attack(mTarget, true); - mGoingToTarget = false; - mPath.clear(); - return; - } - else if (mGoingToTarget && !mTarget) - { - mGoingToTarget = false; - mPath.clear(); - } - - if (mPath.empty()) - { - if (mNavigatePath.empty() || mAction != MOVE) - setAction(STAND); - else - mNextStep = true; - } + if (mNavigatePath.empty() || mAction != MOVE) + setAction(STAND); else - { - Being::nextTile(); - } + mNextStep = true; } -#ifdef MANASERV_SUPPORT else { - if (!mMap || !dir) - return; - - const Vector &pos = getPosition(); - const Position destination = getNextWalkPosition(dir); - - if (static_cast(pos.x) != destination.x - || static_cast(pos.y) != destination.y) - { - setDestination(destination.x, destination.y); - } - else if (dir != mDirection) - { - Net::getPlayerHandler()->setDirection(dir); - setDirection(dir); - } + Being::nextTile(); } -#endif } bool LocalPlayer::pickUp(FloorItem *const item) @@ -916,29 +482,18 @@ bool LocalPlayer::pickUp(FloorItem *const item) } else if (mPickUpType >= 4 && mPickUpType <= 6) { -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - setDestination(item->getPixelX() + 16, item->getPixelY() + 16); - mPickUpTarget = item; - mPickUpTarget->addActorSpriteListener(this); - } + const Vector &playerPos = getPosition(); + const Path debugPath = mMap->findPath( + static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, + static_cast(playerPos.y - mapTileSize) / mapTileSize, + item->getTileX(), item->getTileY(), getWalkMask(), 0); + if (!debugPath.empty()) + navigateTo(item->getTileX(), item->getTileY()); else -#endif - { - const Vector &playerPos = getPosition(); - const Path debugPath = mMap->findPath( - static_cast(playerPos.x - mapTileSize / 2) / mapTileSize, - static_cast(playerPos.y - mapTileSize) / mapTileSize, - item->getTileX(), item->getTileY(), getWalkMask(), 0); - if (!debugPath.empty()) - navigateTo(item->getTileX(), item->getTileY()); - else - setDestination(item->getTileX(), item->getTileY()); + setDestination(item->getTileX(), item->getTileY()); - mPickUpTarget = item; - mPickUpTarget->addActorSpriteListener(this); - } + mPickUpTarget = item; + mPickUpTarget->addActorSpriteListener(this); } return true; } @@ -1024,17 +579,7 @@ void LocalPlayer::setDestination(const int x, const int y) } Being::setDestination(x, y); - -#ifdef MANASERV_SUPPORT - // Manaserv: - // If the destination given to being class is accepted, - // we inform the Server. - if ((x == mDest.x && y == mDest.y) - || Net::getNetworkType() != ServerInfo::MANASERV) -#endif - { - Net::getPlayerHandler()->setDestination(x, y, mDirection); - } + Net::getPlayerHandler()->setDestination(x, y, mDirection); } } } @@ -1042,51 +587,11 @@ void LocalPlayer::setDestination(const int x, const int y) void LocalPlayer::setWalkingDir(const unsigned char dir) { // This function is called by Game::handleInput() - -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - // First if player is pressing key for the direction he is already - // going, do nothing more... - - // Else if he is pressing a key, and its different from what he has - // been pressing, stop (do not send this stop to the server) and - // start in the new direction - if (dir && (dir != getWalkingDir())) - stopWalking(false); - - // Else, he is not pressing a key, - // and the current path hasn't been sent by mouse, - // then, stop (sending to server). - else if (!dir) - { - if (!mPathSetByMouse) - stopWalking(true); - return; - } - - // If the delay to send another walk message to the server hasn't - // expired, don't do anything or we could get disconnected for - // spamming the server - if (get_elapsed_time(mLocalWalkTime) < walkingKeyboardDelay) - return; - } -#endif - mWalkingDir = dir; // If we're not already walking, start walking. if (mAction != MOVE && dir) - { startWalking(dir); - } -#ifdef MANASERV_SUPPORT - else if (mAction == MOVE && (Net::getNetworkType() - == ServerInfo::MANASERV)) - { - nextTile(dir); - } -#endif } void LocalPlayer::startWalking(const unsigned char dir) @@ -1100,18 +605,7 @@ void LocalPlayer::startWalking(const unsigned char dir) if (mAction == MOVE && !mPath.empty()) { // Just finish the current action, otherwise we get out of sync -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - const Vector &pos = getPosition(); - Being::setDestination(static_cast(pos.x), - static_cast(pos.y)); - } - else -#endif - { - Being::setDestination(mX, mY); - } + Being::setDestination(mX, mY); return; } @@ -1125,43 +619,32 @@ void LocalPlayer::startWalking(const unsigned char dir) if (dir & RIGHT) dx++; -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif - { - const unsigned char walkMask = getWalkMask(); - // Prevent skipping corners over colliding tiles - if (dx && !mMap->getWalk(mX + dx, mY, walkMask)) - dx = 0; - if (dy && !mMap->getWalk(mX, mY + dy, walkMask)) - dy = 0; + const unsigned char walkMask = getWalkMask(); + // Prevent skipping corners over colliding tiles + if (dx && !mMap->getWalk(mX + dx, mY, walkMask)) + dx = 0; + if (dy && !mMap->getWalk(mX, mY + dy, walkMask)) + dy = 0; - // Choose a straight direction when diagonal target is blocked - if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask)) - dx = 0; + // Choose a straight direction when diagonal target is blocked + if (dx && dy && !mMap->getWalk(mX + dx, mY + dy, walkMask)) + dx = 0; - // Walk to where the player can actually go - if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask)) - { - setDestination(mX + dx, mY + dy); - } - else if (dir != mDirection) - { - // If the being can't move, just change direction + // Walk to where the player can actually go + if ((dx || dy) && mMap->getWalk(mX + dx, mY + dy, walkMask)) + { + setDestination(mX + dx, mY + dy); + } + else if (dir != mDirection) + { + // If the being can't move, just change direction // if (client->limitPackets(PACKET_DIRECTION)) - { - Net::getPlayerHandler()->setDirection(dir); - setDirection(dir); - } + { + Net::getPlayerHandler()->setDirection(dir); + setDirection(dir); } } -#ifdef MANASERV_SUPPORT - else - { - nextTile(dir); - } -#endif } void LocalPlayer::stopWalking(const bool sendToServer) @@ -1238,18 +721,6 @@ bool LocalPlayer::emote(const uint8_t emotion) void LocalPlayer::attack(Being *const target, const bool keep, const bool dontChangeEquipment) { -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - if (mLastAction != -1) - return; - - // Can only attack when standing still - if (mAction != STAND && mAction != ATTACK) - return; - } -#endif - mKeepAttacking = keep; if (!target || target->getType() == ActorSprite::NPC) @@ -1258,59 +729,30 @@ void LocalPlayer::attack(Being *const target, const bool keep, if (mTarget != target) setTarget(target); -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - const Vector &plaPos = this->getPosition(); - const Vector &tarPos = mTarget->getPosition(); - const int dist_x = static_cast(plaPos.x - tarPos.x); - const int dist_y = static_cast(plaPos.y - tarPos.y); + const int dist_x = target->getTileX() - mX; + const int dist_y = target->getTileY() - mY; - if (abs(dist_y) >= abs(dist_x)) - { - if (dist_y < 0) - setDirection(DOWN); - else - setDirection(UP); - } - else - { - if (dist_x < 0) - setDirection(RIGHT); - else - setDirection(LEFT); - } + // Must be standing or sitting to attack + if (mAction != STAND && mAction != SIT) + return; - mLastAction = tick_time; + if (abs(dist_y) >= abs(dist_x)) + { + if (dist_y > 0) + setDirection(DOWN); + else + setDirection(UP); } else -#endif { - const int dist_x = target->getTileX() - mX; - const int dist_y = target->getTileY() - mY; - - // Must be standing or sitting to attack - if (mAction != STAND && mAction != SIT) - return; - - if (abs(dist_y) >= abs(dist_x)) - { - if (dist_y > 0) - setDirection(DOWN); - else - setDirection(UP); - } + if (dist_x > 0) + setDirection(RIGHT); else - { - if (dist_x > 0) - setDirection(RIGHT); - else - setDirection(LEFT); - } - - mActionTime = tick_time; + setDirection(LEFT); } + mActionTime = tick_time; + if (target->getType() != Being::PLAYER || checAttackPermissions(target)) { setAction(ATTACK); @@ -1324,11 +766,7 @@ void LocalPlayer::attack(Being *const target, const bool keep, Net::getPlayerHandler()->attack(target->getId(), mServerAttack); } -#ifdef MANASERV_SUPPORT - if ((Net::getNetworkType() != ServerInfo::MANASERV) && !keep) -#else if (!keep) -#endif stopAttack(); } @@ -1476,20 +914,8 @@ bool LocalPlayer::withinAttackRange(const Being *const target, if (fixDistance && range == 1) range = 2; -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - const Vector &targetPos = target->getPosition(); - const Vector &pos = getPosition(); - dx = static_cast(abs(static_cast(targetPos.x - pos.x))); - dy = static_cast(abs(static_cast(targetPos.y - pos.y))); - } - else -#endif - { - dx = static_cast(abs(target->getTileX() - mX)); - dy = static_cast(abs(target->getTileY() - mY)); - } + dx = static_cast(abs(target->getTileX() - mX)); + dy = static_cast(abs(target->getTileY() - mY)); return !(dx > range || dy > range); } @@ -1499,22 +925,9 @@ void LocalPlayer::setGotoTarget(Being *const target) return; mPickUpTarget = nullptr; -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - mTarget = target; - mGoingToTarget = true; - const Vector &targetPos = target->getPosition(); - setDestination(static_cast(targetPos.x), - static_cast(targetPos.y)); - } - else -#endif - { - setTarget(target); - mGoingToTarget = true; - setDestination(target->getTileX(), target->getTileY()); - } + setTarget(target); + mGoingToTarget = true; + setDestination(target->getTileX(), target->getTileY()); } void LocalPlayer::handleStatusEffect(StatusEffect *const effect, @@ -3192,16 +2605,6 @@ bool LocalPlayer::pickUpItems(int pickUpType) void LocalPlayer::moveByDirection(const unsigned char dir) { int dx = 0, dy = 0; -#ifdef MANASERV_SUPPORT - if (dir & UP) - dy -= mapTileSize; - if (dir & DOWN) - dy += mapTileSize; - if (dir & LEFT) - dx -= mapTileSize; - if (dir & RIGHT) - dx += mapTileSize; -#else if (dir & UP) dy--; if (dir & DOWN) @@ -3210,8 +2613,6 @@ void LocalPlayer::moveByDirection(const unsigned char dir) dx--; if (dir & RIGHT) dx++; -#endif - move(dx, dy); } diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index c9b10b4a6..728fe786f 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -48,11 +48,6 @@ int mCharId = 0; Inventory *mInventory = nullptr; Equipment *mEquipment = nullptr; -#ifdef MANASERV_SUPPORT -std::map mSpecials; -signed char mSpecialRechargeUpdateNeeded = 0; -#endif - bool mTrading = false; int mLevelProgress = 0; std::set mProtectedItems; @@ -365,20 +360,6 @@ int getCharId() void logic() { -#ifdef MANASERV_SUPPORT - if ((mSpecialRechargeUpdateNeeded % 11) == 0) - { - mSpecialRechargeUpdateNeeded = 0; - FOR_EACH (SpecialsMap::iterator, it, mSpecials) - { - Special &special = it->second; - special.currentMana += special.recharge; - if (special.currentMana > special.neededMana) - special.currentMana = special.neededMana; - } - } - mSpecialRechargeUpdateNeeded++; -#endif } bool isTrading() diff --git a/src/client.cpp b/src/client.cpp index 990306fc1..daae02221 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -103,9 +103,6 @@ #include "resources/db/moddb.h" #include "resources/db/monsterdb.h" #include "resources/db/npcdb.h" -#ifdef MANASERV_SUPPORT -#include "resources/db/specialdb.h" -#endif #include "resources/db/palettedb.h" #include "resources/db/petdb.h" #include "resources/db/weaponsdb.h" @@ -1466,9 +1463,6 @@ int Client::gameExec() ItemDB::load(); Being::load(); MonsterDB::load(); -#ifdef MANASERV_SUPPORT - SpecialDB::load(); -#endif AvatarDB::load(); WeaponsDB::load(); NPCDB::load(); diff --git a/src/game.cpp b/src/game.cpp index e0957b57d..253c4bff2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -49,9 +49,6 @@ #include "input/keyboardconfig.h" #include "gui/gui.h" -#ifdef MANASERV_SUPPORT -#include "gui/specialswindow.h" -#endif #include "gui/viewport.h" #include "gui/windowmenu.h" @@ -139,9 +136,6 @@ DebugWindow *debugWindow = nullptr; ShortcutWindow *itemShortcutWindow = nullptr; ShortcutWindow *emoteShortcutWindow = nullptr; OutfitWindow *outfitWindow = nullptr; -#ifdef MANASERV_SUPPORT -SpecialsWindow *specialsWindow = nullptr; -#endif ShortcutWindow *dropShortcutWindow = nullptr; ShortcutWindow *spellShortcutWindow = nullptr; WhoIsOnline *whoIsOnline = nullptr; @@ -249,9 +243,6 @@ static void createGuiWindows() "emotes.xml", 130, 480); outfitWindow = new OutfitWindow(); -#ifdef MANASERV_SUPPORT - specialsWindow = new SpecialsWindow(); -#endif dropShortcutWindow = new ShortcutWindow("DropShortcut", new DropShortcutContainer(nullptr), "drops.xml"); @@ -373,9 +364,6 @@ static void destroyGuiWindows() del_0(itemShortcutWindow) del_0(emoteShortcutWindow) del_0(outfitWindow) -#ifdef MANASERV_SUPPORT - del_0(specialsWindow) -#endif del_0(socialWindow) del_0(dropShortcutWindow); del_0(spellShortcutWindow); diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h index d7b6226b0..f9c005f8f 100644 --- a/src/gui/models/typelistmodel.h +++ b/src/gui/models/typelistmodel.h @@ -38,17 +38,9 @@ class TypeListModel : public ListModel */ int getNumberOfElements() override final A_WARN_UNUSED #ifdef EATHENA_SUPPORT -#ifdef MANASERV_SUPPORT - { return 4; } -#else - { return 3; } -#endif -#else -#ifdef MANASERV_SUPPORT { return 3; } #else { return 2; } -#endif #endif /** @@ -64,15 +56,6 @@ class TypeListModel : public ListModel #ifdef EATHENA_SUPPORT else if (elementIndex == 2) return "eAthena"; -#ifdef MANASERV_SUPPORT - else if (elementIndex == 3) - return "ManaServ"; -#endif -#else -#ifdef MANASERV_SUPPORT - else if (elementIndex == 2) - return "ManaServ"; -#endif #endif else return "Unknown"; diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 500378628..96760f8c7 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -343,46 +343,21 @@ void Viewport::_drawPath(Graphics *const graphics, const Path &path, graphics->setColor(color); Font *const font = getFont(); -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif + int cnt = 1; + FOR_EACH (Path::const_iterator, i, path) { - int cnt = 1; - FOR_EACH (Path::const_iterator, i, path) - { - const int squareX = i->x * mapTileSize - mPixelViewX + 12; - const int squareY = i->y * mapTileSize - mPixelViewY + 12; + const int squareX = i->x * mapTileSize - mPixelViewX + 12; + const int squareY = i->y * mapTileSize - mPixelViewY + 12; - graphics->fillRectangle(Rect(squareX, squareY, 8, 8)); - if (mMap) - { - const std::string str = toString(cnt); - font->drawString(graphics, str, squareX + 4 - - font->getWidth(str) / 2, squareY + 12); - } - cnt ++; - } - } -#ifdef MANASERV_SUPPORT - else if (Net::getNetworkType() == ServerInfo::MANASERV) - { - FOR_EACH (Path::const_iterator, i, path) + graphics->fillRectangle(Rect(squareX, squareY, 8, 8)); + if (mMap) { - const int squareX = i->x - mPixelViewX; - const int squareY = i->y - mPixelViewY; - - graphics->fillRectangle(Rect( - squareX - 4, squareY - 4, 8, 8)); - if (mMap) - { - const std::string str = toString(mMap->getMetaTile( - i->x / mapTileSize, i->y / mapTileSize)->Gcost); - font->drawString(graphics, str, - squareX + 4 - font->getWidth(text) / 2, squareY + 12); - } + const std::string str = toString(cnt); + font->drawString(graphics, str, squareX + 4 + - font->getWidth(str) / 2, squareY + 12); } + cnt ++; } -#endif } void Viewport::mousePressed(MouseEvent &event) @@ -557,127 +532,111 @@ void Viewport::mouseDragged(MouseEvent &event) Input::KEY_STOP_ATTACK) && !inputManager.isActionActive( Input::KEY_UNTARGET)) { -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - if (get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay) - { - mLocalWalkTime = tick_time; - player_node->unSetPickUpTarget(); - player_node->setDestination(event.getX() + mPixelViewX, - event.getY() + mPixelViewY); - player_node->pathSetByMouse(); - } - } - else -#endif + if (mLocalWalkTime != player_node->getActionTime()) { - if (mLocalWalkTime != player_node->getActionTime()) + mLocalWalkTime = cur_time; + player_node->unSetPickUpTarget(); + int playerX = player_node->getTileX(); + int playerY = player_node->getTileY(); + if (mMouseDirectionMove) { - mLocalWalkTime = cur_time; - player_node->unSetPickUpTarget(); - int playerX = player_node->getTileX(); - int playerY = player_node->getTileY(); - if (mMouseDirectionMove) + const int width = mainGraphics->mWidth / 2; + const int height = mainGraphics->mHeight / 2; + const float wh = static_cast(width) + / static_cast(height); + int x = event.getX() - width; + int y = event.getY() - height; + if (!x && !y) + return; + const int x2 = abs(x); + const int y2 = abs(y); + const float diff = 2; + int dx = 0; + int dy = 0; + if (x2 > y2) { - const int width = mainGraphics->mWidth / 2; - const int height = mainGraphics->mHeight / 2; - const float wh = static_cast(width) - / static_cast(height); - int x = event.getX() - width; - int y = event.getY() - height; - if (!x && !y) - return; - const int x2 = abs(x); - const int y2 = abs(y); - const float diff = 2; - int dx = 0; - int dy = 0; - if (x2 > y2) - { - if (y2 && x2 / y2 / wh > diff) - y = 0; - } - else - { - if (x2 && y2 * wh / x2 > diff) - x = 0; - } - if (x > 0) - dx = 1; - else if (x < 0) - dx = -1; - if (y > 0) - dy = 1; - else if (y < 0) - dy = -1; - - if (mMap->getWalk(playerX + dx, playerY + dy)) + if (y2 && x2 / y2 / wh > diff) + y = 0; + } + else + { + if (x2 && y2 * wh / x2 > diff) + x = 0; + } + if (x > 0) + dx = 1; + else if (x < 0) + dx = -1; + if (y > 0) + dy = 1; + else if (y < 0) + dy = -1; + + if (mMap->getWalk(playerX + dx, playerY + dy)) + { + player_node->navigateTo(playerX + dx, playerY + dy); + } + else + { + if (dx && dy) { - player_node->navigateTo(playerX + dx, playerY + dy); + // try avoid diagonal collision + if (x2 > y2) + { + if (mMap->getWalk(playerX + dx, playerY)) + dy = 0; + else + dx = 0; + } + else + { + if (mMap->getWalk(playerX, playerY + dy)) + dx = 0; + else + dy = 0; + } } else { - if (dx && dy) + // try avoid vertical or horisontal collision + if (!dx) { - // try avoid diagonal collision - if (x2 > y2) - { - if (mMap->getWalk(playerX + dx, playerY)) - dy = 0; - else - dx = 0; - } - else - { - if (mMap->getWalk(playerX, playerY + dy)) - dx = 0; - else - dy = 0; - } + if (mMap->getWalk(playerX + 1, playerY + dy)) + dx = 1; + if (mMap->getWalk(playerX - 1, playerY + dy)) + dx = -1; } - else + if (!dy) { - // try avoid vertical or horisontal collision - if (!dx) - { - if (mMap->getWalk(playerX + 1, playerY + dy)) - dx = 1; - if (mMap->getWalk(playerX - 1, playerY + dy)) - dx = -1; - } - if (!dy) - { - if (mMap->getWalk(playerX + dx, playerY + 1)) - dy = 1; - if (mMap->getWalk(playerX + dx, playerY - 1)) - dy = -1; - } + if (mMap->getWalk(playerX + dx, playerY + 1)) + dy = 1; + if (mMap->getWalk(playerX + dx, playerY - 1)) + dy = -1; } - player_node->navigateTo(playerX + dx, playerY + dy); } + player_node->navigateTo(playerX + dx, playerY + dy); } - else + } + else + { + const int destX = (event.getX() + mPixelViewX) + / static_cast(mMap->getTileWidth()); + const int destY = (event.getY() + mPixelViewY) + / static_cast(mMap->getTileHeight()); + if (playerX != destX || playerY != destY) { - const int destX = (event.getX() + mPixelViewX) - / static_cast(mMap->getTileWidth()); - const int destY = (event.getY() + mPixelViewY) - / static_cast(mMap->getTileHeight()); - if (playerX != destX || playerY != destY) + if (!player_node->navigateTo(destX, destY)) { - if (!player_node->navigateTo(destX, destY)) - { - if (playerX > destX) - playerX --; - else if (playerX < destX) - playerX ++; - if (playerY > destY) - playerY --; - else if (playerY < destY) - playerY ++; - if (mMap->getWalk(playerX, playerY, 0)) - player_node->navigateTo(playerX, playerY); - } + if (playerX > destX) + playerX --; + else if (playerX < destX) + playerX ++; + if (playerY > destY) + playerY --; + else if (playerY < destY) + playerY ++; + if (mMap->getWalk(playerX, playerY, 0)) + player_node->navigateTo(playerX, playerY); } } } @@ -688,7 +647,6 @@ void Viewport::mouseDragged(MouseEvent &event) void Viewport::mouseReleased(MouseEvent &event A_UNUSED) { mPlayerFollowMouse = false; - // Only useful for eAthena but doesn't hurt under ManaServ mLocalWalkTime = -1; } diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 40a5445ca..795f2ad5a 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -31,9 +31,6 @@ #include "gui/popups/textpopup.h" #include "gui/windows/skilldialog.h" -#ifdef MANASERV_SUPPORT -#include "gui/specialswindow.h" -#endif #include "gui/widgets/button.h" @@ -111,15 +108,6 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : _("Skills"), x, h, Input::KEY_WINDOW_SKILL); } -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() == ServerInfo::MANASERV) - { - // TRANSLATORS: short button name for specials window. - addButton(N_("SPE"), - _("Specials"), x, h, Input::KEY_NO_VALUE); - } -#endif - // TRANSLATORS: short button name for social window. addButton(N_("SOC"), // TRANSLATORS: full button name diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 4f98cb931..a877f45e0 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -325,11 +325,7 @@ void CharCreateDialog::action(const ActionEvent &event) const std::string id = event.getId(); if (id == "create") { - if ( -#ifdef MANASERV_SUPPORT - Net::getNetworkType() == ServerInfo::MANASERV || -#endif - getName().length() >= 4) + if (getName().length() >= 4) { // Attempt to create the character mCreateButton->setEnabled(false); @@ -341,14 +337,7 @@ void CharCreateDialog::action(const ActionEvent &event) mAttributeSlider[i]->getValue())); } -#ifdef MANASERV_SUPPORT - int characterSlot = mSlot; - // On Manaserv, the slots start at 1, so we offset them. - if (Net::getNetworkType() == ServerInfo::MANASERV) - ++characterSlot; -#else const int characterSlot = mSlot; -#endif Net::getCharServerHandler()->newCharacter(getName(), characterSlot, mFemale->isSelected(), mHairStyle, mHairColor, diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index d67c15bf0..3ef378aa0 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -474,14 +474,7 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) Net::Character *const character = *i; // Slots Number start at 1 for Manaserv, so we offset them by one. -#ifdef MANASERV_SUPPORT - int characterSlot = character->slot; - if (Net::getNetworkType() == ServerInfo::MANASERV && characterSlot > 0) - --characterSlot; -#else const int characterSlot = character->slot; -#endif - if (characterSlot >= static_cast(mCharacterEntries.size())) { logger->log("Warning: slot out of range: %d", character->slot); diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index e236841a5..c4e490091 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -139,21 +139,11 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, case ServerInfo::EATHENA: mTypeField->setSelected(2); break; - case ServerInfo::MANASERV: -#ifdef MANASERV_SUPPORT - mTypeField->setSelected(3); - break; -#endif -#else - case ServerInfo::MANASERV: -#ifdef MANASERV_SUPPORT - mTypeField->setSelected(2); - break; -#endif #endif default: case ServerInfo::UNKNOWN: case ServerInfo::TMWATHENA: + case ServerInfo::MANASERV: #ifndef EATHENA_SUPPORT case ServerInfo::EATHENA: #endif @@ -226,17 +216,6 @@ void EditServerDialog::action(const ActionEvent &event) case 2: mServer.type = ServerInfo::EATHENA; break; -#ifdef MANASERV_SUPPORT - case 3: - mServer.type = ServerInfo::MANASERV; - break; -#endif -#else -#ifdef MANASERV_SUPPORT - case 2: - mServer.type = ServerInfo::MANASERV; - break; -#endif #endif default: mServer.type = ServerInfo::UNKNOWN; diff --git a/src/gui/windows/selldialog.cpp b/src/gui/windows/selldialog.cpp index 524c77366..8bfcc6728 100644 --- a/src/gui/windows/selldialog.cpp +++ b/src/gui/windows/selldialog.cpp @@ -258,20 +258,10 @@ void SellDialog::action(const ActionEvent &event) mMaxItems -= mAmountItems; while (mAmountItems > 0) { -#ifdef MANASERV_SUPPORT - // This order is important, item->getCurrentInvIndex() would - // return the inventory index of the next Duplicate otherwise. - int itemIndex = item->getCurrentInvIndex(); - const int sellCount = item->sellCurrentDuplicate(mAmountItems); - // For Manaserv, the Item id is to be given as index. - if ((Net::getNetworkType() == ServerInfo::MANASERV)) - itemIndex = item->getId(); -#else // This order is important, item->getCurrentInvIndex() would // return the inventory index of the next Duplicate otherwise. const int itemIndex = item->getCurrentInvIndex(); const int sellCount = item->sellCurrentDuplicate(mAmountItems); -#endif Net::getNpcHandler()->sellItem(mNpcId, itemIndex, sellCount); mAmountItems -= sellCount; } diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 579e9ad18..faae75ab3 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -63,20 +63,12 @@ static std::string serverTypeToString(const ServerInfo::Type type) return "TmwAthena"; case ServerInfo::EVOL: return "Evol"; -#ifdef EATHENA_SUPPORT case ServerInfo::EATHENA: +#ifdef EATHENA_SUPPORT return "eAthena"; -#endif -#ifdef MANASERV_SUPPORT - case ServerInfo::MANASERV: - return "ManaServ"; -#else - case ServerInfo::MANASERV: -#endif -#ifndef EATHENA_SUPPORT - case ServerInfo::EATHENA: #endif default: + case ServerInfo::MANASERV: case ServerInfo::UNKNOWN: return ""; } @@ -90,20 +82,12 @@ static uint16_t defaultPortForServerType(const ServerInfo::Type type) case ServerInfo::EATHENA: #ifdef EATHENA_SUPPORT return 6900; -#else - return 6901; #endif case ServerInfo::UNKNOWN: case ServerInfo::TMWATHENA: case ServerInfo::EVOL: -#ifdef MANASERV_SUPPORT - return 6901; - case ServerInfo::MANASERV: - return 9601; -#else case ServerInfo::MANASERV: return 6901; -#endif } } diff --git a/src/main.h b/src/main.h index 2035338a6..1884be6a5 100644 --- a/src/main.h +++ b/src/main.h @@ -40,7 +40,7 @@ * by the map, interleaved with the tiles in the fringe layer. * * The client supports two servers, \link EAthena eAthena\endlink (the TMW - * version) and the \link ManaServ Mana server\endlink. To achieve this, the + * version) and the \link EvolServ server\endlink. To achieve this, the * \link Net network communication layer\endlink is abstracted in many * different interfaces, which have different implementations for each server. */ diff --git a/src/map.cpp b/src/map.cpp index 4e654198c..70a48b811 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -800,131 +800,6 @@ const std::string Map::getFilename() const return fileName.substr(lastSlash, fileName.rfind(".") - lastSlash); } -#ifdef MANASERV_SUPPORT -Position Map::checkNodeOffsets(int radius, const unsigned char walkMask, - const Position &position) const -{ - // Pre-computing character's position in tiles - const int tx = position.x / mapTileSize; - const int ty = position.y / mapTileSize; - - // Pre-computing character's position offsets. - int fx = position.x % mapTileSize; - int fy = position.y % mapTileSize; - - // Compute the being radius: - // FIXME: Hande beings with more than 1/2 tile radius by not letting them - // go or spawn in too narrow places. The server will have to be aware - // of being's radius value (in tiles) to handle this gracefully. - if (radius > mapTileSize / 2) - radius = mapTileSize / 2; - // set a default value if no value returned. - if (radius < 1) - radius = mapTileSize / 3; - - // We check diagonal first as they are more restrictive. - // Top-left border check - if (!getWalk(tx - 1, ty - 1, walkMask) - && fy < radius && fx < radius) - { - fx = radius; - fy = radius; - } - // Top-right border check - if (!getWalk(tx + 1, ty - 1, walkMask) - && (fy < radius) && fx > (mapTileSize - radius)) - { - fx = mapTileSize - radius; - fy = radius; - } - // Bottom-left border check - if (!getWalk(tx - 1, ty + 1, walkMask) - && fy > (mapTileSize - radius) && fx < radius) - { - fx = radius; - fy = mapTileSize - radius; - } - // Bottom-right border check - if (!getWalk(tx + 1, ty + 1, walkMask) - && fy > (mapTileSize - radius) && fx > (mapTileSize - radius)) - { - fx = mapTileSize - radius; - fy = fx; - } - - // Fix coordinates so that the player does not seem to dig into walls. - if (fx > (mapTileSize - radius) && !getWalk(tx + 1, ty, walkMask)) - fx = mapTileSize - radius; - else if (fx < radius && !getWalk(tx - 1, ty, walkMask)) - fx = radius; - else if (fy > (mapTileSize - radius) && !getWalk(tx, ty + 1, walkMask)) - fy = mapTileSize - radius; - else if (fy < radius && !getWalk(tx, ty - 1, walkMask)) - fy = radius; - - return Position(tx * mapTileSize + fx, ty * mapTileSize + fy); -} - -Path Map::findPixelPath(const int startPixelX, const int startPixelY, - const int endPixelX, const int endPixelY, - const int radius, const unsigned char walkMask, - const int maxCost) -{ - Path myPath = findPath(startPixelX / mapTileSize, - startPixelY / mapTileSize, - endPixelX / mapTileSize, - endPixelY / mapTileSize, - walkMask, maxCost); - - // Don't compute empty coordinates. - if (myPath.empty()) - return myPath; - - // Find the starting offset - const float startOffsetX = static_cast(startPixelX % mapTileSize); - const float startOffsetY = static_cast(startPixelY % mapTileSize); - - // Find the ending offset - const float endOffsetX = static_cast(endPixelX % mapTileSize); - const float endOffsetY = static_cast(endPixelY % mapTileSize); - - const int sz = static_cast(myPath.size()); - // Find the distance, and divide it by the number of steps - const int changeX = static_cast((endOffsetX - startOffsetX) - / static_cast(sz)); - const int changeY = static_cast((endOffsetY - startOffsetY) - / static_cast(sz)); - - // Convert the map path to pixels over tiles - // And add interpolation between the starting and ending offsets - Path::iterator it = myPath.begin(); - const Path::iterator it_end = myPath.end(); - int i = 0; - while (it != it_end) - { - // A position that is valid on the start and end tile is not - // necessarily valid on all the tiles in between, so check the offsets. - *it = checkNodeOffsets(radius, walkMask, - it->x * mapTileSize + startOffsetX - + static_cast(changeX * i), - it->y * mapTileSize + startOffsetY - + static_cast(changeY * i)); - i++; - ++it; - } - - // Remove the last path node, as it's more clever to go to the destination. - // It also permit to avoid zigzag at the end of the path, - // especially with mouse. - const Position destination = checkNodeOffsets(radius, walkMask, - endPixelX, endPixelY); - myPath.pop_back(); - myPath.push_back(destination); - - return myPath; -} -#endif - Path Map::findPath(const int startX, const int startY, const int destX, const int destY, const unsigned char walkmask, const int maxCost) diff --git a/src/map.h b/src/map.h index d33857415..0ad048e7e 100644 --- a/src/map.h +++ b/src/map.h @@ -278,29 +278,6 @@ class Map final : public Properties, public ConfigListener */ const std::string getFilename() const A_WARN_UNUSED; -#ifdef MANASERV_SUPPORT - /** - * Check the current position against surrounding blocking tiles, and - * correct the position offset within tile when needed. - */ - Position checkNodeOffsets(int radius, const unsigned char walkMask, - const Position &position) - const A_WARN_UNUSED; - - Position checkNodeOffsets(const int radius, - const unsigned char walkMask, - const int x, const int y) const A_WARN_UNUSED - { return checkNodeOffsets(radius, walkMask, Position(x, y)); } - - /** - * Find a pixel path from one location to the next. - */ - Path findPixelPath(const int startPixelX, const int startPixelY, - const int destPixelX, const int destPixelY, - const int radius, const unsigned char walkmask, - const int maxCost = 20) A_WARN_UNUSED; -#endif - /** * Find a path from one location to the next. */ diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 62514b10b..44d834b94 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -70,12 +70,7 @@ void LoginHandler::loginAccount(LoginData *const loginData1) const { if (loginData1) { - // Since we're attempting to use the tAthena protocol, - // let's reset the character slots to the good value, - // in case we just logged out a Manaserv server - // with a different config. loginData1->resetCharacterSlots(); - sendLoginRegister(loginData1->username, loginData1->password, ""); } } diff --git a/src/net/loginhandler.h b/src/net/loginhandler.h index 0c3fa27ff..91c2e4603 100644 --- a/src/net/loginhandler.h +++ b/src/net/loginhandler.h @@ -36,11 +36,6 @@ namespace Net class LoginHandler { public: - /** - * This enum describes options specific to either eAthena or Manaserv. - * By querying for these flags, the GUI can adapt to the current - * server type dynamically. - */ enum OptionalAction { Unregister = 0x1, diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index 81340ba33..a6008da42 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -97,10 +97,7 @@ uint8_t MessageIn::fromServerDirection(const uint8_t serverDir) case 7: return 9; case 8: -#ifdef MANASERV_SUPPORT - if (Net::getNetworkType() != ServerInfo::MANASERV) -#endif - return 8; + return 8; default: logger->log("incorrect direction: %d", static_cast(serverDir)); diff --git a/src/net/net.cpp b/src/net/net.cpp index c7a4f33f7..6b744c673 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -32,10 +32,6 @@ #include "net/eathena/generalhandler.h" #endif -#ifdef MANASERV_SUPPORT -#include "net/manaserv/generalhandler.h" -#endif - #include "debug.h" Net::AdminHandler *adminHandler = nullptr; @@ -163,12 +159,6 @@ void connectToServer(const ServerInfo &server) #endif break; case ServerInfo::MANASERV: -#ifdef MANASERV_SUPPORT - new ManaServ::GeneralHandler; -#else - new TmwAthena::GeneralHandler; -#endif - break; case ServerInfo::TMWATHENA: case ServerInfo::UNKNOWN: default: diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 0b17184fd..6035a1f51 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -138,10 +138,6 @@ public: #else else if (compareStrI(serverType, "eathena") == 0) return TMWATHENA; -#endif -#ifdef MANASERV_SUPPORT - else if (compareStrI(serverType, "manaserv") == 0) - return MANASERV; #endif return UNKNOWN; } diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp index 9b9112f0f..7bdbeb33d 100644 --- a/src/resources/db/monsterdb.cpp +++ b/src/resources/db/monsterdb.cpp @@ -68,14 +68,8 @@ void MonsterDB::loadXmlFile(const std::string &fileName) return; } -#ifdef MANASERV_SUPPORT - const int offset = XML::getProperty(rootNode, "offset", - Net::getNetworkType() != ServerInfo::MANASERV - ? OLD_TMWATHENA_OFFSET : 0); -#else const int offset = XML::getProperty(rootNode, "offset", OLD_TMWATHENA_OFFSET); -#endif // iterate s for_each_xml_child_node(monsterNode, rootNode) -- cgit v1.2.3-70-g09d2 From f4776cb6852122ea1d6babc3a3df3bdbd401fce7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Feb 2014 17:14:45 +0300 Subject: Remove some manaserv enums usage. --- src/client.cpp | 3 +-- src/gui/windows/charselectdialog.cpp | 1 - src/gui/windows/editserverdialog.cpp | 1 - src/gui/windows/serverdialog.cpp | 2 -- src/net/messagein.cpp | 16 ---------------- src/net/messagein.h | 7 ------- src/net/net.cpp | 1 - src/net/serverinfo.h | 1 - 8 files changed, 1 insertion(+), 31 deletions(-) (limited to 'src') diff --git a/src/client.cpp b/src/client.cpp index daae02221..5d635f522 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1527,8 +1527,7 @@ int Client::gameExec() mCurrentDialog = new ConnectionDialog( // TRANSLATORS: connection dialog header _("Connecting to the game server"), - Net::getNetworkType() != ServerInfo::MANASERV ? - STATE_CHOOSE_SERVER : STATE_SWITCH_CHARACTER); + STATE_CHOOSE_SERVER); mCurrentDialog->postInit(); Net::getGameHandler()->connect(); BLOCK_END("Client::gameExec STATE_CONNECT_GAME") diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 3ef378aa0..4480f06af 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -473,7 +473,6 @@ void CharSelectDialog::setCharacters(const Net::Characters &characters) Net::Character *const character = *i; - // Slots Number start at 1 for Manaserv, so we offset them by one. const int characterSlot = character->slot; if (characterSlot >= static_cast(mCharacterEntries.size())) { diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index c4e490091..316a7051b 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -143,7 +143,6 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, default: case ServerInfo::UNKNOWN: case ServerInfo::TMWATHENA: - case ServerInfo::MANASERV: #ifndef EATHENA_SUPPORT case ServerInfo::EATHENA: #endif diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index faae75ab3..af29da656 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -68,7 +68,6 @@ static std::string serverTypeToString(const ServerInfo::Type type) return "eAthena"; #endif default: - case ServerInfo::MANASERV: case ServerInfo::UNKNOWN: return ""; } @@ -86,7 +85,6 @@ static uint16_t defaultPortForServerType(const ServerInfo::Type type) case ServerInfo::UNKNOWN: case ServerInfo::TMWATHENA: case ServerInfo::EVOL: - case ServerInfo::MANASERV: return 6901; } } diff --git a/src/net/messagein.cpp b/src/net/messagein.cpp index a6008da42..121e1e58f 100644 --- a/src/net/messagein.cpp +++ b/src/net/messagein.cpp @@ -59,22 +59,6 @@ unsigned char MessageIn::readInt8() return value; } -void MessageIn::readCoordinates(uint16_t &restrict x, uint16_t &restrict y) -{ - if (mPos + 3 <= mLength) - { - const unsigned char *const p - = reinterpret_cast(mData + mPos); - x = static_cast(p[0] | ((p[1] & 0x07) << 8)); - y = static_cast((p[1] >> 3) | ((p[2] & 0x3F) << 5)); - } - mPos += 3; - PacketCounters::incInBytes(3); - DEBUGLOG(std::string("readCoordinates: ").append(toString( - static_cast(x))).append(",").append(toString( - static_cast(y)))); -} - uint8_t MessageIn::fromServerDirection(const uint8_t serverDir) { // Translate from eAthena format diff --git a/src/net/messagein.h b/src/net/messagein.h index c3ed294c3..7b2b2400b 100644 --- a/src/net/messagein.h +++ b/src/net/messagein.h @@ -64,13 +64,6 @@ class MessageIn virtual int readInt32() = 0; /**< Reads a long. */ - /** - * Reads a 3-byte block containing tile-based coordinates. Used by - * manaserv. - */ - virtual void readCoordinates(uint16_t &restrict x, - uint16_t &restrict y); - /** * Reads a special 3 byte block used by eAthena, containing x and y * coordinates and direction. diff --git a/src/net/net.cpp b/src/net/net.cpp index 6b744c673..90cf9e16a 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -158,7 +158,6 @@ void connectToServer(const ServerInfo &server) new TmwAthena::GeneralHandler; #endif break; - case ServerInfo::MANASERV: case ServerInfo::TMWATHENA: case ServerInfo::UNKNOWN: default: diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h index 6035a1f51..48f216855 100644 --- a/src/net/serverinfo.h +++ b/src/net/serverinfo.h @@ -38,7 +38,6 @@ public: enum Type { UNKNOWN = 0, - MANASERV, TMWATHENA, EVOL, EATHENA -- cgit v1.2.3-70-g09d2 From 8148c13e015b58960dc555d01eeb09d74e2e0e01 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Feb 2014 20:26:04 +0300 Subject: fix compilation warnings. --- src/render/sdl2graphics.h | 2 +- src/render/sdl2softwaregraphics.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h index 15692bca9..9f604d9b5 100644 --- a/src/render/sdl2graphics.h +++ b/src/render/sdl2graphics.h @@ -204,7 +204,7 @@ class SDLGraphics final : public Graphics protected: uint32_t mRendererFlags; uint32_t mOldPixel; - int mOldAlpha; + unsigned int mOldAlpha; private: void inline calcImageRect(ImageVertexes *const vert, diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h index 265c9349d..6ef750dbd 100644 --- a/src/render/sdl2softwaregraphics.h +++ b/src/render/sdl2softwaregraphics.h @@ -173,7 +173,7 @@ class SDL2SoftwareGraphics final : public Graphics uint32_t mRendererFlags; SDL_Surface *mSurface; uint32_t mOldPixel; - int mOldAlpha; + unsigned int mOldAlpha; private: void inline calcImageRect(ImageVertexes *const vert, -- cgit v1.2.3-70-g09d2 From 409cee51fe11e2495a2741226432666a8702dceb Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 27 Feb 2014 20:26:18 +0300 Subject: fix compilation errors with debug flags. --- src/gui/models/fontsmodel.h | 2 +- src/gui/models/iconsmodel.h | 2 +- src/gui/models/itemsmodel.h | 2 +- src/gui/models/magicschoolmodel.h | 2 +- src/gui/models/soundsmodel.h | 2 +- src/gui/models/themesmodel.h | 2 +- src/gui/models/updatelistmodel.h | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gui/models/fontsmodel.h b/src/gui/models/fontsmodel.h index b20d3386b..036e3f9c4 100644 --- a/src/gui/models/fontsmodel.h +++ b/src/gui/models/fontsmodel.h @@ -26,7 +26,7 @@ #include "gui/models/namesmodel.h" -#include "debug.h" +#include "localconsts.h" class FontsModel final : public NamesModel { diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h index 4c549953b..c3031169c 100644 --- a/src/gui/models/iconsmodel.h +++ b/src/gui/models/iconsmodel.h @@ -29,7 +29,7 @@ #include "resources/db/itemdb.h" -#include "debug.h" +#include "localconsts.h" class IconsModel final : public ListModel { diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h index 383bb9c14..808ae0f04 100644 --- a/src/gui/models/itemsmodel.h +++ b/src/gui/models/itemsmodel.h @@ -31,7 +31,7 @@ #include "utils/gettext.h" -#include "debug.h" +#include "localconsts.h" class ItemsModal final : public ListModel { diff --git a/src/gui/models/magicschoolmodel.h b/src/gui/models/magicschoolmodel.h index b30147f3d..1f7c4f0f7 100644 --- a/src/gui/models/magicschoolmodel.h +++ b/src/gui/models/magicschoolmodel.h @@ -27,7 +27,7 @@ #include "utils/gettext.h" -#include "debug.h" +#include "localconsts.h" const char *MAGIC_SCHOOL_TEXT[6] = { diff --git a/src/gui/models/soundsmodel.h b/src/gui/models/soundsmodel.h index 2851e2265..2f645e666 100644 --- a/src/gui/models/soundsmodel.h +++ b/src/gui/models/soundsmodel.h @@ -25,7 +25,7 @@ #include "utils/gettext.h" -#include "debug.h" +#include "localconsts.h" class SoundsModel final : public NamesModel { diff --git a/src/gui/models/themesmodel.h b/src/gui/models/themesmodel.h index b19c698fc..7f76534f0 100644 --- a/src/gui/models/themesmodel.h +++ b/src/gui/models/themesmodel.h @@ -28,7 +28,7 @@ #include "utils/gettext.h" -#include "debug.h" +#include "localconsts.h" class ThemesModel final : public NamesModel { diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h index 31f96c959..2e1d2a7d5 100644 --- a/src/gui/models/updatelistmodel.h +++ b/src/gui/models/updatelistmodel.h @@ -29,7 +29,7 @@ #include "utils/gettext.h" -#include "debug.h" +#include "localconsts.h" class UpdateListModel final : public ListModel { -- cgit v1.2.3-70-g09d2 From f146cd42ce84a08879eb286ecd2ed2aa8ad82300 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 28 Feb 2014 15:46:02 +0300 Subject: fix code style. --- src/actormanager.cpp | 4 ++-- src/actormanager.h | 8 ++++---- src/commands.cpp | 6 +++--- src/gui/base/basiccontainer.cpp | 2 -- src/gui/cliprect.h | 16 ++++++++-------- src/gui/color.cpp | 8 ++++---- src/gui/color.h | 3 ++- src/gui/focushandler.h | 4 ++-- src/gui/font.h | 1 + src/gui/models/ignorechoiceslistmodel.h | 4 ++-- src/gui/models/playerrelationlistmodel.h | 2 +- src/gui/models/soundsmodel.h | 5 +++++ src/gui/models/tablemodel.h | 3 +-- src/gui/models/touchactionmodel.cpp | 9 --------- src/gui/rect.h | 2 +- src/gui/sdlinput.cpp | 4 ++-- src/gui/sdlinput.h | 12 ++---------- src/gui/widgets/avatarlistbox.h | 4 ---- src/gui/widgets/listbox.h | 2 -- src/gui/widgets/radiogroup.h | 2 -- src/gui/widgets/setupitem.h | 2 +- src/gui/widgets/setuptouchitem.cpp | 4 +--- src/gui/widgets/setuptouchitem.h | 2 -- src/gui/widgets/shortcutcontainer.cpp | 2 +- src/gui/widgets/tabs/setup_audio.cpp | 1 - src/gui/widgets/tabs/setup_theme.cpp | 1 - src/gui/widgets/tabstrip.h | 2 -- src/gui/widgets/widget.cpp | 10 ---------- src/gui/widgets/widget.h | 6 ++++-- src/gui/widgets/window.cpp | 1 - src/gui/widgets/window.h | 24 ------------------------ src/gui/windows/editserverdialog.h | 2 -- src/gui/windows/inventorywindow.cpp | 1 - src/gui/windows/itemamountwindow.cpp | 1 - src/gui/windows/outfitwindow.cpp | 2 +- src/gui/windows/questswindow.cpp | 1 - src/gui/windows/serverdialog.h | 4 ---- src/gui/windows/textcommandeditor.cpp | 5 ----- src/gui/windows/tradewindow.cpp | 3 +-- src/gui/windows/worldselectdialog.cpp | 1 - src/net/ea/inventoryhandler.cpp | 4 ++-- src/net/ea/inventoryhandler.h | 4 ++-- src/net/ea/partyhandler.cpp | 2 +- src/net/ea/partyhandler.h | 2 +- src/render/mobileopenglgraphics.cpp | 2 +- src/render/normalopenglgraphics.cpp | 2 +- src/render/nullopenglgraphics.cpp | 2 +- src/render/safeopenglgraphics.cpp | 2 +- src/render/sdl2graphics.cpp | 2 +- src/render/sdl2softwaregraphics.cpp | 2 +- src/render/sdlgraphics.cpp | 2 +- src/render/surfacegraphics.cpp | 2 +- src/resources/db/weaponsdb.cpp | 7 +------ src/resources/db/weaponsdb.h | 1 - 54 files changed, 64 insertions(+), 148 deletions(-) (limited to 'src') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 72ab8c21c..bc325abe8 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -1256,7 +1256,7 @@ void ActorManager::printAllToChat() const } void ActorManager::printBeingsToChat(const ActorSprites &beings, - const std::string &header) const + const std::string &header) { if (!debugChatTab) return; @@ -1281,7 +1281,7 @@ void ActorManager::printBeingsToChat(const ActorSprites &beings, } void ActorManager::printBeingsToChat(const std::vector &beings, - const std::string &header) const + const std::string &header) { if (!debugChatTab) return; diff --git a/src/actormanager.h b/src/actormanager.h index 17bd696d6..f7e306b2a 100644 --- a/src/actormanager.h +++ b/src/actormanager.h @@ -211,11 +211,11 @@ class ActorManager final: public ConfigListener void printAllToChat() const; - void printBeingsToChat(const ActorSprites &beings, - const std::string &header) const; + static void printBeingsToChat(const ActorSprites &beings, + const std::string &header); - void printBeingsToChat(const std::vector &beings, - const std::string &header) const; + static void printBeingsToChat(const std::vector &beings, + const std::string &header); void getPlayerNames(StringVect &names, const bool npcNames) const; diff --git a/src/commands.cpp b/src/commands.cpp index d4134c560..0cc5cee8a 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1339,7 +1339,7 @@ static void uploadFile(const std::string &str, upload->start(); } -impHandler0(uploadConfig) +impHandler2(uploadConfig) { uploadFile(_("Uploaded config into:"), config.getFileName(), @@ -1347,7 +1347,7 @@ impHandler0(uploadConfig) tab); } -impHandler0(uploadServerConfig) +impHandler2(uploadServerConfig) { uploadFile(_("Uploaded server config into:"), serverConfig.getFileName(), @@ -1355,7 +1355,7 @@ impHandler0(uploadServerConfig) tab); } -impHandler0(uploadLog) +impHandler2(uploadLog) { uploadFile(_("Uploaded log into:"), client->getLogFileName(), diff --git a/src/gui/base/basiccontainer.cpp b/src/gui/base/basiccontainer.cpp index e854e15ff..f323366ad 100644 --- a/src/gui/base/basiccontainer.cpp +++ b/src/gui/base/basiccontainer.cpp @@ -69,8 +69,6 @@ #include -#include "render/graphics.h" - #include "debug.h" namespace gcn diff --git a/src/gui/cliprect.h b/src/gui/cliprect.h index 3bbf5e47e..88a7ab5a4 100644 --- a/src/gui/cliprect.h +++ b/src/gui/cliprect.h @@ -61,8 +61,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef GUI_CLIPRECTANGLE_H -#define GUI_CLIPRECTANGLE_H +#ifndef GUI_CLIPRECT_H +#define GUI_CLIPRECT_H #include "gui/rect.h" @@ -97,11 +97,11 @@ class ClipRect final : public Rect * the relative screen coordinate. */ ClipRect(const int x0, - const int y0, - const int width0, - const int height0, - const int xOffset0, - const int yOffset0); + const int y0, + const int width0, + const int height0, + const int xOffset0, + const int yOffset0); /** * Copy constructor. Copies x, y, width and height @@ -123,4 +123,4 @@ class ClipRect final : public Rect int yOffset; }; -#endif // GUI_CLIPRECTANGLE_H +#endif // GUI_CLIPRECT_H diff --git a/src/gui/color.cpp b/src/gui/color.cpp index 9a0034257..aa9ffe840 100644 --- a/src/gui/color.cpp +++ b/src/gui/color.cpp @@ -86,9 +86,9 @@ Color::Color(const unsigned int color) : } Color::Color(const unsigned int ar, - const unsigned int ag, - const unsigned int ab, - const unsigned int aa) : + const unsigned int ag, + const unsigned int ab, + const unsigned int aa) : r(ar), g(ag), b(ab), @@ -149,7 +149,7 @@ bool Color::operator!=(const Color& color) const } std::ostream& operator<<(std::ostream& out, - const Color& color) + const Color& color) { out << "Color [r = " << color.r diff --git a/src/gui/color.h b/src/gui/color.h index 646680d96..db8fda970 100644 --- a/src/gui/color.h +++ b/src/gui/color.h @@ -81,7 +81,8 @@ class Color final /** * Constructor. Constructs a color from the bytes in an integer. - * Call it with a hexadecimal constant for HTML-style color representation. + * Call it with a hexadecimal constant for HTML-style color + * representation. * The alpha component is 255 by default. * * EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color. diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index ed3a08e98..f12819e75 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -335,7 +335,7 @@ class FocusHandler final * @param focusEvent the event to distribute. * @since 0.7.0 */ - void distributeFocusLostEvent(const Event& focusEvent); + static void distributeFocusLostEvent(const Event& focusEvent); /** * Distributes a focus gained event. @@ -343,7 +343,7 @@ class FocusHandler final * @param focusEvent the event to distribute. * @since 0.7.0 */ - void distributeFocusGainedEvent(const Event& focusEvent); + static void distributeFocusGainedEvent(const Event& focusEvent); /** * Typedef. diff --git a/src/gui/font.h b/src/gui/font.h index bdf81dadc..12ba473d8 100644 --- a/src/gui/font.h +++ b/src/gui/font.h @@ -76,6 +76,7 @@ #include "localconsts.h" +class Color; class Graphics; class Image; diff --git a/src/gui/models/ignorechoiceslistmodel.h b/src/gui/models/ignorechoiceslistmodel.h index 7234b57f2..8ba3eadb1 100644 --- a/src/gui/models/ignorechoiceslistmodel.h +++ b/src/gui/models/ignorechoiceslistmodel.h @@ -38,8 +38,8 @@ class IgnoreChoicesListModel final : public ListModel int getNumberOfElements() override final { - return static_cast(player_relations.getPlayerIgnoreStrategies( - )->size()); + return static_cast(player_relations. + getPlayerIgnoreStrategies()->size()); } std::string getElementAt(int i) override final diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h index 9251631f7..bc343de02 100644 --- a/src/gui/models/playerrelationlistmodel.h +++ b/src/gui/models/playerrelationlistmodel.h @@ -64,4 +64,4 @@ class PlayerRelationListModel final : public ListModel } }; -#endif +#endif // GUI_MODELS_PLAYERRELATIONLISTMODEL_H diff --git a/src/gui/models/soundsmodel.h b/src/gui/models/soundsmodel.h index 2f645e666..3ac679d37 100644 --- a/src/gui/models/soundsmodel.h +++ b/src/gui/models/soundsmodel.h @@ -19,6 +19,9 @@ * along with this program. If not, see . */ +#ifndef GUI_MODELS_SOUNDSMODEL_H +#define GUI_MODELS_SOUNDSMODEL_H + #include "gui/theme.h" #include "gui/models/namesmodel.h" @@ -40,3 +43,5 @@ class SoundsModel final : public NamesModel ~SoundsModel() { } }; + +#endif // GUI_MODELS_SOUNDSMODEL_H diff --git a/src/gui/models/tablemodel.h b/src/gui/models/tablemodel.h index ff752e6f1..032facadd 100644 --- a/src/gui/models/tablemodel.h +++ b/src/gui/models/tablemodel.h @@ -151,8 +151,7 @@ public: int getHeight() const A_WARN_UNUSED; int getColumnWidth(const int index) const override final A_WARN_UNUSED; Widget *getElementAt(const int row, - const int column) const - override final A_WARN_UNUSED; + const int column) const override final A_WARN_UNUSED; protected: int mRows, mColumns; diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp index e6cc4d046..b32d1479f 100644 --- a/src/gui/models/touchactionmodel.cpp +++ b/src/gui/models/touchactionmodel.cpp @@ -18,19 +18,10 @@ * along with this program. If not, see . */ -#include "gui/widgets/setuptouchitem.h" - #include "gui/setupactiondata.h" #include "gui/models/touchactionmodel.h" -#include "gui/widgets/dropdown.h" -#include "gui/widgets/horizontcontainer.h" -#include "gui/widgets/label.h" -#include "gui/widgets/vertcontainer.h" - -#include "gui/widgets/tabs/setuptabscroll.h" - #include #include "debug.h" diff --git a/src/gui/rect.h b/src/gui/rect.h index f7cb7ae92..69c0120ca 100644 --- a/src/gui/rect.h +++ b/src/gui/rect.h @@ -159,4 +159,4 @@ class Rect int height; }; -#endif // GUI_RECTANGEL_H +#endif // GUI_RECT_H diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp index d8a63b60c..ffb90a883 100644 --- a/src/gui/sdlinput.cpp +++ b/src/gui/sdlinput.cpp @@ -98,7 +98,7 @@ SDLInput::SDLInput() : { } -bool SDLInput::isKeyQueueEmpty() +bool SDLInput::isKeyQueueEmpty() const { return mKeyInputQueue.empty(); } @@ -114,7 +114,7 @@ KeyInput SDLInput::dequeueKeyInput2() return keyInput; } -bool SDLInput::isMouseQueueEmpty() +bool SDLInput::isMouseQueueEmpty() const { return mMouseInputQueue.empty(); } diff --git a/src/gui/sdlinput.h b/src/gui/sdlinput.h index 29cb5ce1f..8197aa110 100644 --- a/src/gui/sdlinput.h +++ b/src/gui/sdlinput.h @@ -107,14 +107,6 @@ public: */ void pushInput(const SDL_Event &event); - /** - * Polls all input. It exists for input driver compatibility. If you - * only use SDL and plan sticking with SDL you can safely ignore this - * function as it in the SDL case does nothing. - */ - void _pollInput() - { } - KeyInput dequeueKeyInput2() A_WARN_UNUSED; KeyInput dequeueKeyInput() A_WARN_UNUSED @@ -122,9 +114,9 @@ public: // Inherited from SDLInput - bool isKeyQueueEmpty() A_WARN_UNUSED; + bool isKeyQueueEmpty() const A_WARN_UNUSED; - bool isMouseQueueEmpty() A_WARN_UNUSED; + bool isMouseQueueEmpty() const A_WARN_UNUSED; MouseInput dequeueMouseInput() A_WARN_UNUSED; diff --git a/src/gui/widgets/avatarlistbox.h b/src/gui/widgets/avatarlistbox.h index e4f65a992..e0711a7b7 100644 --- a/src/gui/widgets/avatarlistbox.h +++ b/src/gui/widgets/avatarlistbox.h @@ -22,14 +22,10 @@ #ifndef GUI_WIDGETS_AVATARLISTBOX_H #define GUI_WIDGETS_AVATARLISTBOX_H -#include "avatar.h" - #include "listeners/configlistener.h" #include "gui/widgets/listbox.h" -#include "gui/models/listmodel.h" - #include class AvatarListModel; diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 0c3a62609..64faa6eb5 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -27,8 +27,6 @@ #include "gui/base/widgets/listbox.hpp" -#include "render/graphics.h" - #include "localconsts.h" class Skin; diff --git a/src/gui/widgets/radiogroup.h b/src/gui/widgets/radiogroup.h index b553c629a..41193b3d6 100644 --- a/src/gui/widgets/radiogroup.h +++ b/src/gui/widgets/radiogroup.h @@ -23,8 +23,6 @@ #include "gui/widgets/widgetgroup.h" -#include "gui/widgets/widget.h" - class RadioGroup final : public WidgetGroup { public: diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index 51f2eb94e..7dee860be 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -95,7 +95,7 @@ class SetupItem : public ActionListener, virtual void rereadValue(); - void setValue(const std::string str) + void setValue(const std::string &str) { mValue = str; } std::string getValue() const diff --git a/src/gui/widgets/setuptouchitem.cpp b/src/gui/widgets/setuptouchitem.cpp index 99a774ecd..3c8238fd0 100644 --- a/src/gui/widgets/setuptouchitem.cpp +++ b/src/gui/widgets/setuptouchitem.cpp @@ -20,8 +20,6 @@ #include "gui/widgets/setuptouchitem.h" -#include "gui/setupactiondata.h" - #include "gui/models/touchactionmodel.h" #include "gui/widgets/dropdown.h" @@ -31,7 +29,7 @@ #include "gui/widgets/tabs/setuptabscroll.h" -#include +#include "utils/stringutils.h" #include "debug.h" diff --git a/src/gui/widgets/setuptouchitem.h b/src/gui/widgets/setuptouchitem.h index 2c1aa05d0..f7bbf2691 100644 --- a/src/gui/widgets/setuptouchitem.h +++ b/src/gui/widgets/setuptouchitem.h @@ -21,8 +21,6 @@ #ifndef GUI_WIDGETS_SETUPTOUCHITEM_H #define GUI_WIDGETS_SETUPTOUCHITEM_H -#include "gui/models/namesmodel.h" - #include "gui/widgets/setupitem.h" class TouchActionsModel; diff --git a/src/gui/widgets/shortcutcontainer.cpp b/src/gui/widgets/shortcutcontainer.cpp index d3781b421..0d9aa64a6 100644 --- a/src/gui/widgets/shortcutcontainer.cpp +++ b/src/gui/widgets/shortcutcontainer.cpp @@ -61,7 +61,7 @@ void ShortcutContainer::widgetResized(const Event &event A_UNUSED) if (mGridWidth < 1) mGridWidth = 1; - mGridHeight = mMaxItems / mGridWidth; + mGridHeight = mMaxItems / static_cast(mGridWidth); if (mMaxItems % mGridWidth != 0 || mGridHeight < 1) ++mGridHeight; diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp index c8e625ca4..6cf675635 100644 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ b/src/gui/widgets/tabs/setup_audio.cpp @@ -30,7 +30,6 @@ #include "gui/viewport.h" -#include "gui/models/namesmodel.h" #include "gui/models/soundsmodel.h" #include "gui/widgets/layouthelper.h" diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp index 419400853..424828694 100644 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ b/src/gui/widgets/tabs/setup_theme.cpp @@ -28,7 +28,6 @@ #include "gui/models/extendedlistmodel.h" #include "gui/models/fontsmodel.h" -#include "gui/models/namesmodel.h" #include "gui/models/themesmodel.h" #include "gui/widgets/button.h" diff --git a/src/gui/widgets/tabstrip.h b/src/gui/widgets/tabstrip.h index b2dfc99e2..a89dd5144 100644 --- a/src/gui/widgets/tabstrip.h +++ b/src/gui/widgets/tabstrip.h @@ -23,8 +23,6 @@ #include "gui/widgets/widgetgroup.h" -#include "gui/widgets/widget.h" - class TabStrip final : public WidgetGroup { public: diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index 23edadac0..5b2024b1f 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -604,16 +604,6 @@ void Widget::setInternalFocusHandler(FocusHandler* focusHandler) mInternalFocusHandler = focusHandler; } -void Widget::setId(const std::string& id) -{ - mId = id; -} - -const std::string& Widget::getId() -{ - return mId; -} - void Widget::distributeResizedEvent() { for (WidgetListenerIterator iter = mWidgetListeners.begin(); diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index e05844e4c..17f016c76 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -973,7 +973,8 @@ class Widget : public Widget2 * @see getId, BasicContainer::findWidgetById * @since 0.8.0 */ - void setId(const std::string& id); + void setId(const std::string& id) + { mId = id; } /** * Gets the id of a widget. An id can be useful if a widget needs to be @@ -985,7 +986,8 @@ class Widget : public Widget2 * @see setId, BasicContainer::findWidgetById * @since 0.8.0 */ - const std::string& getId() A_WARN_UNUSED; + const std::string& getId() const A_WARN_UNUSED + { return mId; } /** * Shows a certain part of a widget in the widget's parent. diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 8b106b489..ec83af9a8 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -99,7 +99,6 @@ Window::Window(const std::string &caption, const bool modal, mPadding(2), mTitleBarHeight(16), mMovable(true), - mOpaque(true), mDragOffsetX(0), mDragOffsetY(0), mMoved(false), diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h index 7cf34c67c..6369990bb 100644 --- a/src/gui/widgets/window.h +++ b/src/gui/widgets/window.h @@ -555,25 +555,6 @@ class Window : public gcn::Container, bool isMovable() const { return mMovable; } - /** - * Sets the window to be opaque or not. An opaque window will draw it's background - * and it's content. A non opaque window will only draw it's content. - * - * @param opaque True if the window should be opaque, false otherwise. - * @see isOpaque - */ - void setOpaque(bool opaque) - { mOpaque = opaque; } - - /** - * Checks if the window is opaque. - * - * @return True if the window is opaque, false otherwise. - * @see setOpaque - */ - bool isOpaque() - { return mOpaque; } - virtual Rect getChildrenArea(); /** @@ -625,11 +606,6 @@ class Window : public gcn::Container, */ bool mMovable; - /** - * True if the window is opaque, false otherwise. - */ - bool mOpaque; - /** * Holds a drag offset as an x coordinate where the drag of the window * started if the window is being dragged. It's used to move the window diff --git a/src/gui/windows/editserverdialog.h b/src/gui/windows/editserverdialog.h index 215666394..b70d1031b 100644 --- a/src/gui/windows/editserverdialog.h +++ b/src/gui/windows/editserverdialog.h @@ -35,8 +35,6 @@ class TypeListModel; #include "listeners/actionlistener.h" #include "listeners/keylistener.h" -#include "gui/models/listmodel.h" - /** * The custom server addition dialog. * diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index 5323854fb..ee8c85f06 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -36,7 +36,6 @@ #include "gui/gui.h" #include "gui/viewport.h" -#include "gui/models/listmodel.h" #include "gui/models/sortlistmodelinv.h" #include "gui/popups/textpopup.h" diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index dba69b424..fc0c5880b 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -34,7 +34,6 @@ #include "gui/viewport.h" #include "gui/models/itemsmodel.h" -#include "gui/models/listmodel.h" #include "gui/popups/itempopup.h" diff --git a/src/gui/windows/outfitwindow.cpp b/src/gui/windows/outfitwindow.cpp index be0c840f6..6fcea7d3a 100644 --- a/src/gui/windows/outfitwindow.cpp +++ b/src/gui/windows/outfitwindow.cpp @@ -325,7 +325,7 @@ void OutfitWindow::draw(Graphics *graphics) { const int itemX = mPadding + ((i % mGridWidth) * mBoxWidth); const int itemY = mPadding + mTitleBarHeight - + ((i / mGridWidth) * mBoxHeight); + + ((i / static_cast(mGridWidth)) * mBoxHeight); graphics->setColor(mBorderColor); graphics->drawRectangle(Rect(itemX, itemY, 32, 32)); diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp index 319bf5df0..eee3e4259 100644 --- a/src/gui/windows/questswindow.cpp +++ b/src/gui/windows/questswindow.cpp @@ -29,7 +29,6 @@ #include "gui/font.h" #include "gui/gui.h" -#include "gui/models/extendednamesmodel.h" #include "gui/models/questsmodel.h" #include "gui/widgets/browserbox.h" diff --git a/src/gui/windows/serverdialog.h b/src/gui/windows/serverdialog.h index 07e2b5dcc..39c82279e 100644 --- a/src/gui/windows/serverdialog.h +++ b/src/gui/windows/serverdialog.h @@ -34,16 +34,12 @@ #include "listeners/keylistener.h" #include "listeners/selectionlistener.h" -#include "gui/models/listmodel.h" - #include -#include class Button; class CheckBox; class Label; class ListBox; -class ServerDialog; class ServersListModel; /** diff --git a/src/gui/windows/textcommandeditor.cpp b/src/gui/windows/textcommandeditor.cpp index 17703388f..dead469bc 100644 --- a/src/gui/windows/textcommandeditor.cpp +++ b/src/gui/windows/textcommandeditor.cpp @@ -28,7 +28,6 @@ #include "input/keyboardconfig.h" #include "gui/models/iconsmodel.h" -#include "gui/models/listmodel.h" #include "gui/models/magicschoolmodel.h" #include "gui/models/targettypemodel.h" @@ -41,10 +40,6 @@ #include "utils/gettext.h" -#include "resources/iteminfo.h" - -#include "resources/db/itemdb.h" - #include "debug.h" TextCommandEditor::TextCommandEditor(TextCommand *const command) : diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp index 7fe1a1e36..506f25c17 100644 --- a/src/gui/windows/tradewindow.cpp +++ b/src/gui/windows/tradewindow.cpp @@ -130,8 +130,7 @@ TradeWindow::TradeWindow(): place(1, 0, mMoneyLabel); place(0, 1, myScroll).setPadding(3); place(1, 1, partnerScroll).setPadding(3); - ContainerPlacer placer; - placer = getPlacer(0, 0); + ContainerPlacer placer = getPlacer(0, 0); placer(0, 0, moneyLabel2); placer(1, 0, mMoneyField, 2); placer(3, 0, mMoneyChangeButton).setHAlign(LayoutCell::LEFT); diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index db17820db..77d167c82 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -33,7 +33,6 @@ #include "gui/widgets/listbox.h" #include "gui/widgets/scrollarea.h" -#include "gui/models/listmodel.h" #include "gui/models/worldlistmodel.h" #include "net/loginhandler.h" diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index d64050e1a..2262a79f9 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -152,7 +152,7 @@ int InventoryHandler::convertFromServerSlot(const int serverSlot) const return EQUIP_CONVERT[serverSlot]; } -int InventoryHandler::getSlot(const int eAthenaSlot) const +int InventoryHandler::getSlot(const int eAthenaSlot) { if (eAthenaSlot == 0) return Equipment::EQUIP_VECTOREND; @@ -566,7 +566,7 @@ void InventoryHandler::processPlayerUnEquip(Net::MessageIn &msg) miniStatusWindow->updateArrows(); } -void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) const +void InventoryHandler::processPlayerAttackRange(Net::MessageIn &msg) { const int range = msg.readInt16(); if (player_node) diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 494b9145a..ac88c1d6c 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -175,7 +175,7 @@ class InventoryHandler : public Net::InventoryHandler void pushPickup(const int floorId) { mSentPickups.push(floorId); } - int getSlot(const int eAthenaSlot) const A_WARN_UNUSED; + static int getSlot(const int eAthenaSlot) A_WARN_UNUSED; void processPlayerInventory(Net::MessageIn &msg, const bool playerInvintory); @@ -204,7 +204,7 @@ class InventoryHandler : public Net::InventoryHandler void processPlayerUnEquip(Net::MessageIn &msg); - void processPlayerAttackRange(Net::MessageIn &msg) const; + static void processPlayerAttackRange(Net::MessageIn &msg); void processPlayerArrowEquip(Net::MessageIn &msg); diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index 7f29f277a..4e4cac3df 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -60,7 +60,7 @@ void PartyHandler::join(const int partyId A_UNUSED) const { } -void PartyHandler::reload() const +void PartyHandler::reload() { taParty = Party::getParty(1); } diff --git a/src/net/ea/partyhandler.h b/src/net/ea/partyhandler.h index 29f242285..24923bd4a 100644 --- a/src/net/ea/partyhandler.h +++ b/src/net/ea/partyhandler.h @@ -52,7 +52,7 @@ class PartyHandler : public Net::PartyHandler PartyShare getShareItems() const override final A_WARN_UNUSED { return mShareItems; } - void reload() const; + static void reload(); void clear() const override final; diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp index 6925f47d0..86707fac8 100644 --- a/src/render/mobileopenglgraphics.cpp +++ b/src/render/mobileopenglgraphics.cpp @@ -220,7 +220,7 @@ static inline void drawRescaledQuad(const Image *const image, } bool MobileOpenGLGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp index 916002f26..6bc25be32 100644 --- a/src/render/normalopenglgraphics.cpp +++ b/src/render/normalopenglgraphics.cpp @@ -287,7 +287,7 @@ static inline void drawRescaledQuad(const Image *const image, } bool NormalOpenGLGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp index 159ccea94..d09d7b13b 100644 --- a/src/render/nullopenglgraphics.cpp +++ b/src/render/nullopenglgraphics.cpp @@ -140,7 +140,7 @@ static inline void drawRescaledQuad(const Image *const image A_UNUSED, } bool NullOpenGLGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp index a739a4904..faf2de76e 100644 --- a/src/render/safeopenglgraphics.cpp +++ b/src/render/safeopenglgraphics.cpp @@ -143,7 +143,7 @@ static inline void drawRescaledQuad(const Image *const image, } bool SafeOpenGLGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp index ebfcdb226..8c78c8cdd 100644 --- a/src/render/sdl2graphics.cpp +++ b/src/render/sdl2graphics.cpp @@ -158,7 +158,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, } bool SDLGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp index 8fe83188f..0844cd52e 100644 --- a/src/render/sdl2softwaregraphics.cpp +++ b/src/render/sdl2softwaregraphics.cpp @@ -110,7 +110,7 @@ bool SDL2SoftwareGraphics::drawRescaledImage(const Image *const image, } bool SDL2SoftwareGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp index 5d1589424..44dcc426d 100644 --- a/src/render/sdlgraphics.cpp +++ b/src/render/sdlgraphics.cpp @@ -104,7 +104,7 @@ bool SDLGraphics::drawRescaledImage(const Image *const image, } bool SDLGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { return drawImageInline(image, dstX, dstY); } diff --git a/src/render/surfacegraphics.cpp b/src/render/surfacegraphics.cpp index d9cb03136..e6aee752f 100644 --- a/src/render/surfacegraphics.cpp +++ b/src/render/surfacegraphics.cpp @@ -43,7 +43,7 @@ SurfaceGraphics::~SurfaceGraphics() } bool SurfaceGraphics::drawImage(const Image *const image, - int dstX, int dstY) + int dstX, int dstY) { FUNC_BLOCK("Graphics::drawImage", 1) // Check that preconditions for blitting are met. diff --git a/src/resources/db/weaponsdb.cpp b/src/resources/db/weaponsdb.cpp index 82892cc5f..6e8e4ce1f 100644 --- a/src/resources/db/weaponsdb.cpp +++ b/src/resources/db/weaponsdb.cpp @@ -20,13 +20,8 @@ #include "resources/db/weaponsdb.h" -#include "logger.h" - -#include "utils/gettext.h" #include "utils/xmlutils.h" -#include "configuration.h" - #include "debug.h" namespace @@ -37,7 +32,7 @@ namespace bool mLoaded = false; } -static void loadDB(const std::string name, WeaponsInfos &arr) +static void loadDB(const std::string &name, WeaponsInfos &arr) { readXmlIntVector("weapons.xml", "weapons", diff --git a/src/resources/db/weaponsdb.h b/src/resources/db/weaponsdb.h index 287237c48..33688b338 100644 --- a/src/resources/db/weaponsdb.h +++ b/src/resources/db/weaponsdb.h @@ -21,7 +21,6 @@ #ifndef RESOURCES_DB_WEAPONSDB_H #define RESOURCES_DB_WEAPONSDB_H -#include #include #include "localconsts.h" -- cgit v1.2.3-70-g09d2 From 6d709b0c218791fdacdbd8b234a1301a135aeb33 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 28 Feb 2014 17:48:35 +0300 Subject: fix moving in crazy moves. --- src/being/localplayer.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 5d4ce123e..3d9d06bef 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -2240,24 +2240,24 @@ void LocalPlayer::crazyMoveA() move(1, -1); break; case 'f': - if (mDirection | UP) + if (mDirection & UP) dy = -1; - else if (mDirection | DOWN) + else if (mDirection & DOWN) dy = 1; - if (mDirection | LEFT) + if (mDirection & LEFT) dx = -1; - else if (mDirection | RIGHT) + else if (mDirection & RIGHT) dx = 1; move(dx, dy); break; case 'b': - if (mDirection | UP) + if (mDirection & UP) dy = 1; - else if (mDirection | DOWN) + else if (mDirection & DOWN) dy = -1; - if (mDirection | LEFT) + if (mDirection & LEFT) dx = 1; - else if (mDirection | RIGHT) + else if (mDirection & RIGHT) dx = -1; move(dx, dy); break; -- cgit v1.2.3-70-g09d2 From 79e8799a0782a018833ec0003bb0e5086508da07 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 28 Feb 2014 20:55:17 +0300 Subject: fix some leaks issues. --- src/being/being.cpp | 1 + src/gui/widgets/textpreview.cpp | 24 ++++++++++++------------ src/net/download.cpp | 1 + src/resources/mapreader.cpp | 1 + 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/being/being.cpp b/src/being/being.cpp index 705d97439..41c3bc40c 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -3148,6 +3148,7 @@ void Being::removePet(const int id) actorManager->erase(pet); mPets.erase(it); delete pet; + return; } } } diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 8ac49bfd6..10bd936c6 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -80,6 +80,9 @@ TextPreview::~TextPreview() void TextPreview::draw(Graphics* graphics) { + if (!mFont) + return; + BLOCK_START("TextPreview::draw") if (client->getGuiAlpha() != mAlpha) mAlpha = client->getGuiAlpha(); @@ -99,18 +102,15 @@ void TextPreview::draw(Graphics* graphics) if (mTextBGColor) { - if (mFont) - { - const int x = mFont->getWidth(mText) + 1 - + 2 * ((mOutline || mShadow) ? 1 :0); - const int y = mFont->getHeight() + 1 - + 2 * ((mOutline || mShadow) ? 1 : 0); - graphics->setColor(Color(static_cast(mTextBGColor->r), - static_cast(mTextBGColor->g), - static_cast(mTextBGColor->b), - intAlpha)); - graphics->fillRectangle(Rect(mPadding, mPadding, x, y)); - } + const int x = mFont->getWidth(mText) + 1 + + 2 * ((mOutline || mShadow) ? 1 :0); + const int y = mFont->getHeight() + 1 + + 2 * ((mOutline || mShadow) ? 1 : 0); + graphics->setColor(Color(static_cast(mTextBGColor->r), + static_cast(mTextBGColor->g), + static_cast(mTextBGColor->b), + intAlpha)); + graphics->fillRectangle(Rect(mPadding, mPadding, x, y)); } graphics->setColorAll(Color(mTextColor->r, diff --git a/src/net/download.cpp b/src/net/download.cpp index d0c6515fc..141a7772f 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -568,6 +568,7 @@ size_t Download::writeFunction(void *ptr, memcpy(buf, ptr, totalMem); buf[totalMem] = 0; mUploadResponse.append(buf); + delete [] buf; return totalMem; } diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp index e053e0035..4da901b09 100644 --- a/src/resources/mapreader.cpp +++ b/src/resources/mapreader.cpp @@ -214,6 +214,7 @@ void MapReader::addLayerToList(const std::string &fileName) mKnownLayers[name] = childNode; mKnownDocs.insert(doc); } + delete doc; } Map *MapReader::readMap(const std::string &restrict filename, -- cgit v1.2.3-70-g09d2 From 2c62286a7ecf246e8a445dd7d00f618efae2a96a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 1 Mar 2014 12:22:22 +0300 Subject: Change version to 1.4.3.1. --- ChangeLog | 8 ++++++++ README | 2 +- README.txt | 2 +- build/packevol | 2 +- build/packtmw | 2 +- build/packwin | 2 +- configure.ac | 2 +- src/main.h | 4 ++-- 8 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/ChangeLog b/ChangeLog index aebe8fd88..fa7871682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-03-01 New release 1.4.3.1 +fix: crazy moves. +add: missing help translations. +add: allow load branding info from portable.xml. +add: dehardcode weapons id for auto switching weapons. +add: remove all depericated manaserv code. +add: remove support for external guichan. + 2014-02-15 New release 1.4.2.15 fix: friends tab update in social window. fix: windows resizing for smaller screen size. diff --git a/README b/README index ced5a922a..29bb1168b 100644 --- a/README +++ b/README @@ -1,7 +1,7 @@ THE MANA PLUS CLIENT =============== - Version: 1.4.2.15 Date: 2014-02-15 + Version: 1.4.3.1 Date: 2014-03-01 Development team: - See AUTHORS file for a list diff --git a/README.txt b/README.txt index dda556840..ced317da4 100644 --- a/README.txt +++ b/README.txt @@ -1,7 +1,7 @@ THE MANA PLUS CLIENT =============== - Version: 1.4.2.15 Date: 2014-02-15 + Version: 1.4.3.1 Date: 2014-03-01 Development team: - See AUTHORS file for a list diff --git a/build/packevol b/build/packevol index 53ffa7624..c3f73541c 100755 --- a/build/packevol +++ b/build/packevol @@ -7,7 +7,7 @@ dir=`pwd` cd packaging/windows ./make-translations.sh makensis -DDLLDIR=$dir/../libs/dll/ \ - -DPRODUCT_VERSION="1.4.2.15" \ + -DPRODUCT_VERSION="1.4.3.1" \ -DEXESUFFIX=/src \ -DUPX=true \ evol.nsi diff --git a/build/packtmw b/build/packtmw index 897a97c8f..273b043a2 100755 --- a/build/packtmw +++ b/build/packtmw @@ -7,7 +7,7 @@ dir=`pwd` cd packaging/windows ./make-translations.sh makensis -DDLLDIR=$dir/../libs/dll/ \ - -DPRODUCT_VERSION="1.4.2.15" \ + -DPRODUCT_VERSION="1.4.3.1" \ -DEXESUFFIX=/src \ -DUPX=true \ tmw.nsi diff --git a/build/packwin b/build/packwin index 99754f169..54409f4b0 100755 --- a/build/packwin +++ b/build/packwin @@ -7,7 +7,7 @@ dir=`pwd` cd packaging/windows ./make-translations.sh makensis -DDLLDIR=$dir/../libs/dll/ \ - -DPRODUCT_VERSION="1.4.2.15" \ + -DPRODUCT_VERSION="1.4.3.1" \ -DEXESUFFIX=/src \ -DUPX=true \ setup.nsi diff --git a/configure.ac b/configure.ac index 51b92ffaa..f1aa8bb52 100755 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT([ManaPlus], [1.4.2.15], [akaras@inbox.ru], [manaplus]) +AC_INIT([ManaPlus], [1.4.3.1], [akaras@inbox.ru], [manaplus]) AM_INIT_AUTOMAKE([1.9]) AC_CONFIG_HEADERS([config.h:config.h.in]) AC_LANG_CPLUSPLUS diff --git a/src/main.h b/src/main.h index 1884be6a5..4d43f9447 100644 --- a/src/main.h +++ b/src/main.h @@ -45,8 +45,8 @@ * different interfaces, which have different implementations for each server. */ -#define SMALL_VERSION "1.4.2.15" -#define CHECK_VERSION "01.04.02.15" +#define SMALL_VERSION "1.4.3.1" +#define CHECK_VERSION "01.04.03.01" #ifdef HAVE_CONFIG_H #include "../config.h" -- cgit v1.2.3-70-g09d2