From c9f1d918bfeb3086cc9d109555c3512b2a10a0b2 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Fri, 20 Sep 2024 01:13:46 +0200 Subject: [PATCH] Use member initialization for constructors --- include/guisan/cliprectangle.hpp | 6 +- include/guisan/color.hpp | 10 ++-- include/guisan/containerevent.hpp | 2 +- include/guisan/event.hpp | 2 +- include/guisan/exception.hpp | 8 +-- include/guisan/focushandler.hpp | 18 +++--- include/guisan/graphics.hpp | 4 +- include/guisan/gui.hpp | 30 +++++----- include/guisan/imagefont.hpp | 8 +-- include/guisan/inputevent.hpp | 4 +- include/guisan/keyinput.hpp | 14 ++--- include/guisan/mouseinput.hpp | 18 +++--- include/guisan/opengl/openglimage.hpp | 14 ++--- include/guisan/rectangle.hpp | 13 ++-- include/guisan/sdl/sdl2graphics.hpp | 12 ++-- include/guisan/sdl/sdlgraphics.hpp | 6 +- include/guisan/sdl/sdlimage.hpp | 8 +-- include/guisan/sdl/sdlimageloader.hpp | 4 +- include/guisan/sdl/sdlinput.hpp | 6 +- include/guisan/sdl/sdltruetypefont.hpp | 11 ++-- include/guisan/widget.hpp | 28 ++++----- include/guisan/widgets/button.hpp | 10 ++-- include/guisan/widgets/checkbox.hpp | 8 +-- include/guisan/widgets/container.hpp | 8 +-- include/guisan/widgets/dropdown.hpp | 16 ++--- include/guisan/widgets/icon.hpp | 4 +- include/guisan/widgets/imagebutton.hpp | 4 +- include/guisan/widgets/imagetextbutton.hpp | 10 ++-- include/guisan/widgets/inputbox.hpp | 10 ++-- include/guisan/widgets/label.hpp | 4 +- include/guisan/widgets/listbox.hpp | 6 +- include/guisan/widgets/messagebox.hpp | 8 +-- include/guisan/widgets/progressbar.hpp | 10 ++-- include/guisan/widgets/radiobutton.hpp | 10 ++-- include/guisan/widgets/scrollarea.hpp | 40 ++++++------- include/guisan/widgets/slider.hpp | 26 ++++---- include/guisan/widgets/tab.hpp | 6 +- include/guisan/widgets/tabbedarea.hpp | 10 ++-- include/guisan/widgets/textbox.hpp | 6 +- include/guisan/widgets/textfield.hpp | 6 +- include/guisan/widgets/togglebutton.hpp | 8 +-- include/guisan/widgets/window.hpp | 14 ++--- src/cliprectangle.cpp | 18 ++---- src/color.cpp | 27 ++------- src/exception.cpp | 16 +---- src/focushandler.cpp | 11 ---- src/graphics.cpp | 4 -- src/gui.cpp | 20 +------ src/imagefont.cpp | 6 -- src/keyinput.cpp | 12 +--- src/opengl/openglimage.cpp | 29 +++++---- src/rectangle.cpp | 20 ++----- src/sdl/sdl2graphics.cpp | 6 +- src/sdl/sdlgraphics.cpp | 6 +- src/sdl/sdlimage.cpp | 10 ++-- src/sdl/sdlimageloader.cpp | 2 - src/sdl/sdlinput.cpp | 6 -- src/sdl/sdltruetypefont.cpp | 12 +--- src/widget.cpp | 16 +---- src/widgets/button.cpp | 25 +------- src/widgets/checkbox.cpp | 17 ++---- src/widgets/container.cpp | 4 -- src/widgets/dropdown.cpp | 31 ++-------- src/widgets/icon.cpp | 12 +--- src/widgets/imagebutton.cpp | 14 ++--- src/widgets/imagetextbutton.cpp | 6 +- src/widgets/inputbox.cpp | 13 ++-- src/widgets/label.cpp | 9 +-- src/widgets/listbox.cpp | 12 +--- src/widgets/messagebox.cpp | 56 +++++------------- src/widgets/progressbar.cpp | 21 ++----- src/widgets/radiobutton.cpp | 16 ++--- src/widgets/scrollarea.cpp | 69 +++------------------- src/widgets/slider.cpp | 33 +++-------- src/widgets/tab.cpp | 3 +- src/widgets/tabbedarea.cpp | 5 +- src/widgets/textbox.cpp | 17 +----- src/widgets/textfield.cpp | 14 ++--- src/widgets/togglebutton.cpp | 12 +--- src/widgets/window.cpp | 19 +----- 80 files changed, 356 insertions(+), 723 deletions(-) diff --git a/include/guisan/cliprectangle.hpp b/include/guisan/cliprectangle.hpp index c51172d..2430ee4 100644 --- a/include/guisan/cliprectangle.hpp +++ b/include/guisan/cliprectangle.hpp @@ -75,7 +75,7 @@ namespace gcn /** * Constructor. */ - ClipRectangle(); + ClipRectangle() = default; /** * Constructor. @@ -105,12 +105,12 @@ namespace gcn /** * Holds the x offset of the x coordinate. */ - int xOffset; + int xOffset = 0; /** * Holds the y offset of the y coordinate. */ - int yOffset; + int yOffset = 0; }; } diff --git a/include/guisan/color.hpp b/include/guisan/color.hpp index ed4ce00..7fc2283 100644 --- a/include/guisan/color.hpp +++ b/include/guisan/color.hpp @@ -73,7 +73,7 @@ namespace gcn /** * Constructor. Initializes the color to black. */ - Color(); + Color() = default; /** * Constructor. Constructs a color from the bytes in an integer. @@ -162,23 +162,23 @@ namespace gcn /** * Holds the red color component (range 0-255). */ - int r; + int r = 0; /** * Holds the green color component (range 0-255). */ - int g; + int g = 0; /** * Holds the blue color component (range 0-255). */ - int b; + int b = 0; /** * Holds the alpha color component. A value of 0 means totally * transparent while a value of 255 is considered opaque. */ - int a; + int a = 255; }; } diff --git a/include/guisan/containerevent.hpp b/include/guisan/containerevent.hpp index 2880907..42a0d45 100644 --- a/include/guisan/containerevent.hpp +++ b/include/guisan/containerevent.hpp @@ -92,7 +92,7 @@ namespace gcn /** * Holds the container the event concerns. */ - Container* mContainer; + Container* mContainer = nullptr; }; } // namespace gcn diff --git a/include/guisan/event.hpp b/include/guisan/event.hpp index 9dc4b50..1adfa42 100644 --- a/include/guisan/event.hpp +++ b/include/guisan/event.hpp @@ -99,7 +99,7 @@ namespace gcn /** * Holds the source widget of the event. */ - Widget* mSource; + Widget* mSource = nullptr; }; } diff --git a/include/guisan/exception.hpp b/include/guisan/exception.hpp index 7c3503e..ce26fbe 100644 --- a/include/guisan/exception.hpp +++ b/include/guisan/exception.hpp @@ -101,7 +101,7 @@ namespace gcn /** * Constructor. */ - Exception(); + Exception() = default; /** * Constructor. @@ -161,7 +161,7 @@ namespace gcn * Holds the name of the function name where the * exception occured. */ - std::string mFunction; + std::string mFunction = "?"; /** * Holds the error message of the exception. @@ -171,12 +171,12 @@ namespace gcn /** * Holds the filename where the exception occured. */ - std::string mFilename; + std::string mFilename = "?"; /** * Holds the line number where the exception occured. */ - unsigned int mLine; + unsigned int mLine = 0; }; } diff --git a/include/guisan/focushandler.hpp b/include/guisan/focushandler.hpp index 87cb80b..982834f 100644 --- a/include/guisan/focushandler.hpp +++ b/include/guisan/focushandler.hpp @@ -87,7 +87,7 @@ namespace gcn /** * Constructor. */ - FocusHandler(); + FocusHandler() = default; /** * Destructor. @@ -358,45 +358,45 @@ namespace gcn /** * Holds the focused widget. NULL if no widget has focus. */ - Widget* mFocusedWidget; + Widget* mFocusedWidget = nullptr; /** * Holds the modal focused widget. NULL if no widget has * modal focused. */ - Widget* mModalFocusedWidget; + Widget* mModalFocusedWidget = nullptr; /** * Holds the modal mouse input focused widget. NULL if no widget * is being dragged. */ - Widget* mModalMouseInputFocusedWidget; + Widget* mModalMouseInputFocusedWidget = nullptr; /** * Holds the dragged widget. NULL if no widget is * being dragged. */ - Widget* mDraggedWidget; + Widget* mDraggedWidget = nullptr; /** * Holds the last widget with the mouse. */ - Widget* mLastWidgetWithMouse; + Widget* mLastWidgetWithMouse = nullptr; /** * Holds the last widget with modal focus. */ - Widget* mLastWidgetWithModalFocus; + Widget* mLastWidgetWithModalFocus = nullptr; /** * Holds the last widget with modal mouse input focus. */ - Widget* mLastWidgetWithModalMouseInputFocus; + Widget* mLastWidgetWithModalMouseInputFocus = nullptr; /** * Holds the last widget pressed. */ - Widget* mLastWidgetPressed; + Widget* mLastWidgetPressed = nullptr; }; } diff --git a/include/guisan/graphics.hpp b/include/guisan/graphics.hpp index a3db45d..1aeec1a 100644 --- a/include/guisan/graphics.hpp +++ b/include/guisan/graphics.hpp @@ -119,7 +119,7 @@ namespace gcn /** * Constructor. */ - Graphics(); + Graphics() = default; /** * Destructor. @@ -290,7 +290,7 @@ namespace gcn /** * Holds the current font. */ - Font* mFont; + Font* mFont = nullptr; }; } diff --git a/include/guisan/gui.hpp b/include/guisan/gui.hpp index 98ae961..a536e52 100644 --- a/include/guisan/gui.hpp +++ b/include/guisan/gui.hpp @@ -420,27 +420,27 @@ namespace gcn /** * Holds the top widget. */ - Widget* mTop; + Widget* mTop = nullptr; /** * Holds the graphics implementation used. */ - Graphics* mGraphics; + Graphics* mGraphics = nullptr; /** * Holds the input implementation used. */ - Input* mInput; + Input* mInput = nullptr; /** * Holds the focus handler for the Gui. */ - FocusHandler* mFocusHandler; + FocusHandler* mFocusHandler = nullptr; /** * True if tabbing is enabled, false otherwise. */ - bool mTabbing; + bool mTabbing = true; typedef std::list KeyListenerList; typedef KeyListenerList::iterator KeyListenerListIterator; @@ -453,55 +453,55 @@ namespace gcn /** * True if shift is pressed, false otherwise. */ - bool mShiftPressed; + bool mShiftPressed = false; /** * True if meta is pressed, false otherwise. */ - bool mMetaPressed; + bool mMetaPressed = false; /** * True if control is pressed, false otherwise. */ - bool mControlPressed; + bool mControlPressed = false; /** * True if alt is pressed, false otherwise. */ - bool mAltPressed; + bool mAltPressed = false; /** * Holds the last mouse button pressed. */ - unsigned int mLastMousePressButton; + unsigned int mLastMousePressButton = 0; /** * Holds the last mouse press time stamp. */ - int mLastMousePressTimeStamp; + int mLastMousePressTimeStamp = 0; /** * Holds the last mouse x coordinate. */ - int mLastMouseX; + int mLastMouseX = 0; /** * Holds the last mouse y coordinate. */ - int mLastMouseY; + int mLastMouseY = 0; /** * Holds the current click count. Used to keep track * of clicks for a the last pressed button. */ - int mClickCount; + int mClickCount = 1; /** * 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; + int mLastMouseDragButton = 0; }; } diff --git a/include/guisan/imagefont.hpp b/include/guisan/imagefont.hpp index 76bdb2f..c25e253 100644 --- a/include/guisan/imagefont.hpp +++ b/include/guisan/imagefont.hpp @@ -236,22 +236,22 @@ pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); @endcode /** * Holds the height of the image font. */ - int mHeight; + int mHeight = 0; /** * Holds the glyph spacing of the image font. */ - int mGlyphSpacing; + int mGlyphSpacing = 0; /** * Holds the row spacing of the image font. */ - int mRowSpacing; + int mRowSpacing = 0; /** * Holds the image with the font data. */ - Image* mImage; + Image* mImage = nullptr; /** * Holds the filename of the image with the font data. diff --git a/include/guisan/inputevent.hpp b/include/guisan/inputevent.hpp index 735f86d..e774776 100644 --- a/include/guisan/inputevent.hpp +++ b/include/guisan/inputevent.hpp @@ -175,12 +175,12 @@ namespace gcn * True if the input event is consumed, * false otherwise. */ - bool mIsConsumed; + bool mIsConsumed = false; /** * Holds the distributor of the event. */ - Widget* mDistributor; + Widget* mDistributor = nullptr; /** * Gui is a friend of this class in order to be able to manipulate diff --git a/include/guisan/keyinput.hpp b/include/guisan/keyinput.hpp index aa6a375..6ee61b0 100644 --- a/include/guisan/keyinput.hpp +++ b/include/guisan/keyinput.hpp @@ -76,7 +76,7 @@ namespace gcn /** * Constructor. */ - KeyInput() { }; + KeyInput() = default; /** * Constructor. @@ -239,37 +239,37 @@ namespace gcn /** * Holds the type of the key input. */ - unsigned int mType; + unsigned int mType = 0; /** * True if shift was pressed at the same time as the key, * false otherwise. */ - bool mShiftPressed; + bool mShiftPressed = false; /** * True if control was pressed at the same time as the key, * false otherwise. */ - bool mControlPressed; + bool mControlPressed = false; /** * True if alt was pressed at the same time as the key, * false otherwise. */ - bool mAltPressed; + bool mAltPressed = false; /** * True if meta was pressed at the same time as the key, * false otherwise. */ - bool mMetaPressed; + bool mMetaPressed = false; /** * True if the numeric pad was used when the key was pressed, * false otherwise. */ - bool mNumericPad; + bool mNumericPad = false; }; } diff --git a/include/guisan/mouseinput.hpp b/include/guisan/mouseinput.hpp index 351d842..4d5ae12 100644 --- a/include/guisan/mouseinput.hpp +++ b/include/guisan/mouseinput.hpp @@ -78,7 +78,7 @@ namespace gcn /** * Constructor. */ - MouseInput() { }; + MouseInput() = default; /** * Constructor. @@ -220,28 +220,28 @@ namespace gcn /** * Holds the type of the mouse input. */ - unsigned int mType; + unsigned int mType = 0; /** * Holds the button of the mouse input. */ - unsigned int mButton; + unsigned int mButton = 0; - /** + /** * Holds the timestamp of the mouse input. Used to * check for double clicks. */ - int mTimeStamp; + int mTimeStamp = 0; - /** + /** * Holds the x coordinate of the mouse input. */ - int mX; + int mX = 0; - /** + /** * Holds the y coordinate of the mouse input. */ - int mY; + int mY = 0; }; } diff --git a/include/guisan/opengl/openglimage.hpp b/include/guisan/opengl/openglimage.hpp index 5f93c4b..acf9a77 100644 --- a/include/guisan/opengl/openglimage.hpp +++ b/include/guisan/opengl/openglimage.hpp @@ -151,13 +151,13 @@ namespace gcn void convertToDisplayFormat() override; protected: - GLuint mTextureHandle; - unsigned int* mPixels; - bool mAutoFree; - int mWidth; - int mHeight; - int mTextureWidth; - int mTextureHeight; + GLuint mTextureHandle = 0; + unsigned int* mPixels = nullptr; + bool mAutoFree = false; + int mWidth = 0; + int mHeight = 0; + int mTextureWidth = 0; + int mTextureHeight = 0; }; } diff --git a/include/guisan/rectangle.hpp b/include/guisan/rectangle.hpp index c56fb24..e907be4 100644 --- a/include/guisan/rectangle.hpp +++ b/include/guisan/rectangle.hpp @@ -73,10 +73,9 @@ namespace gcn public: /** - * Constructor. The default rectangle is an empty rectangle - * at the coordinates (0,0). + * Constructor. The default rectangle is an empty rectangle. */ - Rectangle(); + Rectangle() = default; /** * Constructor. @@ -176,22 +175,22 @@ namespace gcn /** * Holds the x coordinate of the rectangle. */ - int x; + int x = 0; /** * Holds the x coordinate of the rectangle. */ - int y; + int y = 0; /** * Holds the width of the rectangle. */ - int width; + int width = 0; /** * Holds the height of the rectangle. */ - int height; + int height = 0; }; } diff --git a/include/guisan/sdl/sdl2graphics.hpp b/include/guisan/sdl/sdl2graphics.hpp index fe9e614..98b2b9b 100644 --- a/include/guisan/sdl/sdl2graphics.hpp +++ b/include/guisan/sdl/sdl2graphics.hpp @@ -81,7 +81,7 @@ namespace gcn /** * Constructor. */ - SDL2Graphics(); + SDL2Graphics() = default; /** * Destructor. @@ -178,12 +178,12 @@ namespace gcn */ virtual void restoreRenderColor(); - SDL_Surface* mTarget; - SDL_Renderer* mRenderTarget; - SDL_Texture* mTexture; + SDL_Surface* mTarget = nullptr; + SDL_Renderer* mRenderTarget = nullptr; + SDL_Texture* mTexture = nullptr; Color mColor; - Uint8 r, g, b, a; //! to store previous color from renderer - bool mAlpha; + Uint8 r = 0, g = 0, b = 0, a = 0; //! to store previous color from renderer + bool mAlpha = false; }; } diff --git a/include/guisan/sdl/sdlgraphics.hpp b/include/guisan/sdl/sdlgraphics.hpp index de02d07..ad09d39 100644 --- a/include/guisan/sdl/sdlgraphics.hpp +++ b/include/guisan/sdl/sdlgraphics.hpp @@ -81,7 +81,7 @@ namespace gcn /** * Constructor. */ - SDLGraphics(); + SDLGraphics() = default; /** * Destructor. @@ -157,9 +157,9 @@ namespace gcn */ virtual void drawVLine(int x, int y1, int y2); - SDL_Surface* mTarget; + SDL_Surface* mTarget = nullptr; Color mColor; - bool mAlpha; + bool mAlpha = false; }; } diff --git a/include/guisan/sdl/sdlimage.hpp b/include/guisan/sdl/sdlimage.hpp index 6a925ce..2ecfcff 100644 --- a/include/guisan/sdl/sdlimage.hpp +++ b/include/guisan/sdl/sdlimage.hpp @@ -117,10 +117,10 @@ namespace gcn void convertToDisplayFormat() override; protected: - SDL_Surface* mSurface; - SDL_Texture* mTexture = NULL; - SDL_Renderer* mRenderer = NULL; - bool mAutoFree; + SDL_Surface* mSurface = nullptr; + SDL_Texture* mTexture = nullptr; + SDL_Renderer* mRenderer = nullptr; + bool mAutoFree = false; }; } diff --git a/include/guisan/sdl/sdlimageloader.hpp b/include/guisan/sdl/sdlimageloader.hpp index a9e0c0b..5fe2590 100644 --- a/include/guisan/sdl/sdlimageloader.hpp +++ b/include/guisan/sdl/sdlimageloader.hpp @@ -72,7 +72,7 @@ namespace gcn class GCN_EXTENSION_DECLSPEC SDLImageLoader : public ImageLoader { public: - SDLImageLoader(); + SDLImageLoader() = default; void setRenderer(SDL_Renderer* renderer); // Inherited from ImageLoader @@ -83,7 +83,7 @@ namespace gcn virtual SDL_Surface* loadSDLSurface(const std::string& filename); virtual SDL_Texture* loadSDLTexture(const std::string& filename); virtual SDL_Surface* convertToStandardFormat(SDL_Surface* surface); - SDL_Renderer* mRenderer; + SDL_Renderer* mRenderer = nullptr; }; } diff --git a/include/guisan/sdl/sdlinput.hpp b/include/guisan/sdl/sdlinput.hpp index dc2b836..d44a4d2 100644 --- a/include/guisan/sdl/sdlinput.hpp +++ b/include/guisan/sdl/sdlinput.hpp @@ -80,7 +80,7 @@ namespace gcn /** * Constructor. */ - SDLInput(); + SDLInput() = default; /** * Pushes an SDL event. It should be called at least once per frame to @@ -130,8 +130,8 @@ namespace gcn std::queue mKeyInputQueue; std::queue mMouseInputQueue; - bool mMouseDown; - bool mMouseInWindow; + bool mMouseDown = false; + bool mMouseInWindow = true; }; } diff --git a/include/guisan/sdl/sdltruetypefont.hpp b/include/guisan/sdl/sdltruetypefont.hpp index 85ab86b..cd185d5 100644 --- a/include/guisan/sdl/sdltruetypefont.hpp +++ b/include/guisan/sdl/sdltruetypefont.hpp @@ -145,14 +145,13 @@ namespace gcn Graphics* graphics, const std::string& text, int x, int y, bool enabled) override; protected: - TTF_Font *mFont; + std::string mFilename; + TTF_Font *mFont = nullptr; - int mHeight; - int mGlyphSpacing; - int mRowSpacing; + int mGlyphSpacing = 0; + int mRowSpacing = 0; - std::string mFilename; - bool mAntiAlias; + bool mAntiAlias = true; Color mColor; }; } diff --git a/include/guisan/widget.hpp b/include/guisan/widget.hpp index f37e5f2..e8e6495 100644 --- a/include/guisan/widget.hpp +++ b/include/guisan/widget.hpp @@ -1173,39 +1173,39 @@ namespace gcn /** * Holds the foreground color of the widget. */ - Color mForegroundColor; + Color mForegroundColor = 0x00'00'00; /** * Holds the background color of the widget. */ - Color mBackgroundColor; + Color mBackgroundColor = 0xFF'FF'FF; /** * Holds the base color of the widget. */ - Color mBaseColor; + Color mBaseColor = 0xDD'DD'E3; /** * Holds the selection color of the widget. */ - Color mSelectionColor; + Color mSelectionColor = 0xC3'D9'FF; /** * Holds the focus handler used by the widget. */ - FocusHandler* mFocusHandler; + FocusHandler* mFocusHandler = nullptr; /** * Holds the focus handler used by the widget. NULL * if no internal focus handler is used. */ - FocusHandler* mInternalFocusHandler; + FocusHandler* mInternalFocusHandler = nullptr; /** * Holds the parent of the widget. NULL if the widget * has no parent. */ - Widget* mParent; + Widget* mParent = nullptr; /** * Holds the dimension of the widget. @@ -1215,7 +1215,7 @@ namespace gcn /** * Holds the border size of the widget. */ - unsigned int mBorderSize; + unsigned int mBorderSize = 0; /** * Holds the action event of the widget. @@ -1225,27 +1225,27 @@ namespace gcn /** * True if the widget focusable, false otherwise. */ - bool mFocusable; + bool mFocusable = false; /** * True if the widget visible, false otherwise. */ - bool mVisible; + bool mVisible = true; /** * True if the widget has tab in enabled, false otherwise. */ - bool mTabIn; + bool mTabIn = true; /** * True if the widget has tab in enabled, false otherwise. */ - bool mTabOut; + bool mTabOut = true; /** * True if the widget is enabled, false otherwise. */ - bool mEnabled; + bool mEnabled = true; /** * Holds the id of the widget. @@ -1255,7 +1255,7 @@ namespace gcn /** * Holds the font used by the widget. */ - Font* mCurrentFont; + Font* mCurrentFont = nullptr; /** * Holds all children of the widget. diff --git a/include/guisan/widgets/button.hpp b/include/guisan/widgets/button.hpp index 772f49e..3d076d7 100644 --- a/include/guisan/widgets/button.hpp +++ b/include/guisan/widgets/button.hpp @@ -182,27 +182,27 @@ namespace gcn /** * True if the mouse is ontop of the button, false otherwise. */ - bool mHasMouse; + bool mHasMouse = false; /** * True if a key has been pressed, false otherwise. */ - bool mKeyPressed; + bool mKeyPressed = false; /** * True if a mouse has been pressed, false otherwise. */ - bool mMousePressed; + bool mMousePressed = false; /** * Holds the alignment of the caption. */ - Graphics::Alignment mAlignment; + Graphics::Alignment mAlignment = Graphics::Alignment::Center; /** * Holds the spacing between the border and the caption. */ - unsigned int mSpacing; + unsigned int mSpacing = 4; }; } diff --git a/include/guisan/widgets/checkbox.hpp b/include/guisan/widgets/checkbox.hpp index a8bc151..90e061f 100644 --- a/include/guisan/widgets/checkbox.hpp +++ b/include/guisan/widgets/checkbox.hpp @@ -167,14 +167,14 @@ namespace gcn virtual void toggleSelected(); /** - * True if the check box is selected, false otherwise. + * Holds the caption of the check box. */ - bool mSelected; + std::string mCaption; /** - * Holds the caption of the check box. + * True if the check box is selected, false otherwise. */ - std::string mCaption; + bool mSelected = false; }; } diff --git a/include/guisan/widgets/container.hpp b/include/guisan/widgets/container.hpp index bd06076..6b42ca0 100644 --- a/include/guisan/widgets/container.hpp +++ b/include/guisan/widgets/container.hpp @@ -79,12 +79,12 @@ namespace gcn public: /** - * Constructor. A container is opauqe as default, if you want a - * none opaque container call setQpaque(false). + * Constructor. A container is opaque as default, if you want a + * non-opaque container call setOpaque(false). * * @see setOpaque, isOpaque */ - Container(); + Container() = default; /** * Destructor. @@ -217,7 +217,7 @@ namespace gcn /** * True if the container is opaque, false otherwise. */ - bool mOpaque; + bool mOpaque = true; typedef std::list ContainerListenerList; diff --git a/include/guisan/widgets/dropdown.hpp b/include/guisan/widgets/dropdown.hpp index ca92166..a781a36 100644 --- a/include/guisan/widgets/dropdown.hpp +++ b/include/guisan/widgets/dropdown.hpp @@ -243,7 +243,7 @@ namespace gcn */ virtual void drawButton(Graphics *graphics); - bool mDroppedDown; + bool mDroppedDown = false; /** * Distributes a value changed event to all selection listeners @@ -257,20 +257,20 @@ namespace gcn * True if the drop down has been pushed with the mouse, false * otherwise. */ - bool mPushed; + bool mPushed = false; /** * Holds what the height is if the drop down is folded up. * Used when checking if the list of the drop down was clicked * or if the upper part of the drop down was clicked on a mouse click. */ - int mFoldedUpHeight; + int mFoldedUpHeight = 0; /** * The scroll area used. */ - ScrollArea* mScrollArea; - ListBox* mListBox; + ScrollArea* mScrollArea = nullptr; + ListBox* mListBox = nullptr; /** * The internal focus handler used to keep track of focus for the @@ -283,19 +283,19 @@ namespace gcn * has been passed to the drop down which the drop down should not * deleted in it's destructor. */ - bool mInternalScrollArea; + bool mInternalScrollArea = false; /** * True if an internal list box is used, false if a list box * has been passed to the drop down which the drop down should not * deleted in it's destructor. */ - bool mInternalListBox; + bool mInternalListBox = false; /** * True if the drop down is dragged. */ - bool mIsDragged; + bool mIsDragged = false; typedef std::list SelectionListenerList; diff --git a/include/guisan/widgets/icon.hpp b/include/guisan/widgets/icon.hpp index 2e43910..ee12acb 100644 --- a/include/guisan/widgets/icon.hpp +++ b/include/guisan/widgets/icon.hpp @@ -116,14 +116,14 @@ namespace gcn /** * The image to display. */ - const Image* mImage; + const Image* mImage = nullptr; /** * True if the image has been loaded internally, false otherwise. * An image not loaded internally should not be deleted in the * destructor. */ - bool mInternalImage; + bool mInternalImage = false; }; } diff --git a/include/guisan/widgets/imagebutton.hpp b/include/guisan/widgets/imagebutton.hpp index 158380f..c476ea3 100644 --- a/include/guisan/widgets/imagebutton.hpp +++ b/include/guisan/widgets/imagebutton.hpp @@ -119,14 +119,14 @@ namespace gcn void draw(gcn::Graphics* graphics) override; protected: - const Image* mImage; + const Image* mImage = nullptr; /** * True if the image has been loaded internally, false otherwise. * An image not loaded internally should not be deleted in the * destructor. */ - bool mInternalImage; + bool mInternalImage = false; }; } #endif diff --git a/include/guisan/widgets/imagetextbutton.hpp b/include/guisan/widgets/imagetextbutton.hpp index 50e5f38..67481eb 100644 --- a/include/guisan/widgets/imagetextbutton.hpp +++ b/include/guisan/widgets/imagetextbutton.hpp @@ -78,7 +78,7 @@ namespace gcn * @param filename The filename of the image to display. * @param caption The text to display. */ - ImageTextButton(const std::string& filename, std::string& caption); + ImageTextButton(const std::string& filename, const std::string& caption); /** * Constructor. @@ -86,7 +86,7 @@ namespace gcn * @param image The image to display. * @param caption The text to display. */ - ImageTextButton(Image* image, std::string& caption); + ImageTextButton(Image* image, const std::string& caption); /** * Destructor. @@ -141,15 +141,15 @@ namespace gcn }; protected: - gcn::Image* mImage; + gcn::Image* mImage = nullptr; /** * True if the image has been loaded internally, false otherwise. * An image not loaded internally should not be deleted in the * destructor. */ - bool mInternalImage; - unsigned int mAlignment; + bool mInternalImage = false; + unsigned int mAlignment = ImageTextButton::BOTTOM; }; } #endif diff --git a/include/guisan/widgets/inputbox.hpp b/include/guisan/widgets/inputbox.hpp index da5113a..99332b8 100644 --- a/include/guisan/widgets/inputbox.hpp +++ b/include/guisan/widgets/inputbox.hpp @@ -126,12 +126,12 @@ namespace gcn protected: std::string mMessage; - int mClickedButton; + int mClickedButton = -1; - Button *mButtonOK; - Button *mButtonCancel; - Label *mLabel; - TextField *mText; + Button *mButtonOK = nullptr; + Button *mButtonCancel = nullptr; + Label *mLabel = nullptr; + TextField *mText = nullptr; }; } diff --git a/include/guisan/widgets/label.hpp b/include/guisan/widgets/label.hpp index 8a24598..d041369 100644 --- a/include/guisan/widgets/label.hpp +++ b/include/guisan/widgets/label.hpp @@ -74,7 +74,7 @@ namespace gcn /** * Constructor. */ - Label(); + Label() = default; /** * Constructor. The label will be automatically resized @@ -138,7 +138,7 @@ namespace gcn /** * Holds the alignment of the caption. */ - Graphics::Alignment mAlignment; + Graphics::Alignment mAlignment = Graphics::Alignment::Left; }; } diff --git a/include/guisan/widgets/listbox.hpp b/include/guisan/widgets/listbox.hpp index bf4f15f..e468f7d 100644 --- a/include/guisan/widgets/listbox.hpp +++ b/include/guisan/widgets/listbox.hpp @@ -223,17 +223,17 @@ namespace gcn /** * The list model to use. */ - ListModel *mListModel; + ListModel *mListModel = nullptr; /** * The selected item as an index in the list model. */ - int mSelected; + int mSelected = -1; /** * True if wrapping is enabled, false otherwise. */ - bool mWrappingEnabled; + bool mWrappingEnabled = false; typedef std::list SelectionListenerList; diff --git a/include/guisan/widgets/messagebox.hpp b/include/guisan/widgets/messagebox.hpp index 6462868..0271a0c 100644 --- a/include/guisan/widgets/messagebox.hpp +++ b/include/guisan/widgets/messagebox.hpp @@ -215,11 +215,11 @@ namespace gcn protected: std::string mMessage; int mNbButtons; - Graphics::Alignment mButtonAlignment; - int mClickedButton; + Graphics::Alignment mButtonAlignment = Graphics::Alignment::Left; + int mClickedButton = -1; - Button **mButtons; - Label *mLabel; + Button **mButtons = nullptr; + Label *mLabel = nullptr; }; } diff --git a/include/guisan/widgets/progressbar.hpp b/include/guisan/widgets/progressbar.hpp index 84e2eee..6ddfe52 100644 --- a/include/guisan/widgets/progressbar.hpp +++ b/include/guisan/widgets/progressbar.hpp @@ -198,11 +198,11 @@ namespace gcn /** * Holds the alignment of the caption. */ - Graphics::Alignment mAlignment; - - unsigned int mStart; //! minimum value of the progressbar - unsigned int mEnd; //! maximum value of the progressbar - unsigned int mValue; //! current value of the progressbar + Graphics::Alignment mAlignment = Graphics::Alignment::Center; + + unsigned int mStart = 0; //! minimum value of the progressbar + unsigned int mEnd = 100; //! maximum value of the progressbar + unsigned int mValue = 0; //! current value of the progressbar }; } diff --git a/include/guisan/widgets/radiobutton.hpp b/include/guisan/widgets/radiobutton.hpp index c20e8ef..13ce3be 100644 --- a/include/guisan/widgets/radiobutton.hpp +++ b/include/guisan/widgets/radiobutton.hpp @@ -185,11 +185,6 @@ namespace gcn */ virtual void drawBox(Graphics *graphics); - /** - * True if the radio button is selected, false otherwise. - */ - bool mSelected; - /** * Holds the caption of the radio button. */ @@ -200,6 +195,11 @@ namespace gcn */ std::string mGroup; + /** + * True if the radio button is selected, false otherwise. + */ + bool mSelected = false; + /** * Typdef. */ diff --git a/include/guisan/widgets/scrollarea.hpp b/include/guisan/widgets/scrollarea.hpp index cf17923..c89f772 100644 --- a/include/guisan/widgets/scrollarea.hpp +++ b/include/guisan/widgets/scrollarea.hpp @@ -458,104 +458,104 @@ namespace gcn /** * Holds the vertical scroll amount. */ - int mVScroll; + int mVScroll = 0; /** * Holds the horizontal scroll amount. */ - int mHScroll; + int mHScroll = 0; /** * Holds the width of the scroll bars. */ - int mScrollbarWidth; + int mScrollbarWidth = 12; /** * Holds the horizontal scroll bar policy. */ - ScrollPolicy mHPolicy; + ScrollPolicy mHPolicy = ScrollPolicy::ShowAuto; /** * Holds the vertical scroll bar policy. */ - ScrollPolicy mVPolicy; + ScrollPolicy mVPolicy = ScrollPolicy::ShowAuto; /** * True if the vertical scroll bar is visible, false otherwise. */ - bool mVBarVisible; + bool mVBarVisible = false; /** * True if the horizontal scroll bar is visible, false otherwise. */ - bool mHBarVisible; + bool mHBarVisible = false; /** * True if the up button is pressed, false otherwise. */ - bool mUpButtonPressed; + bool mUpButtonPressed = false; /** * True if the down button is pressed, false otherwise. */ - bool mDownButtonPressed; + bool mDownButtonPressed = false; /** * True if the left button is pressed, false otherwise. */ - bool mLeftButtonPressed; + bool mLeftButtonPressed = false; /** * True if the right button is pressed, false otherwise. */ - bool mRightButtonPressed; + bool mRightButtonPressed = false; /** * Holds the up button scroll amount. */ - int mUpButtonScrollAmount; + int mUpButtonScrollAmount = 10; /** * Holds the down button scroll amount. */ - int mDownButtonScrollAmount; + int mDownButtonScrollAmount = 10; /** * Holds the left button scroll amount. */ - int mLeftButtonScrollAmount; + int mLeftButtonScrollAmount = 10; /** * Holds the right button scroll amount. */ - int mRightButtonScrollAmount; + int mRightButtonScrollAmount = 10; /** * True if the vertical marked is dragged. */ - bool mIsVerticalMarkerDragged; + bool mIsVerticalMarkerDragged = false; /** * True if the horizontal marked is dragged. */ - bool mIsHorizontalMarkerDragged; + bool mIsHorizontalMarkerDragged = false; /** * Holds the horizontal markers drag offset. */ - int mHorizontalMarkerDragOffset; + int mHorizontalMarkerDragOffset = 0; /** * Holds the vertical markers drag offset. */ - int mVerticalMarkerDragOffset; + int mVerticalMarkerDragOffset = 0; /** * True if the scroll area should be opaque * (that is display its background), * false otherwise. */ - bool mOpaque; + bool mOpaque = true; }; } diff --git a/include/guisan/widgets/slider.hpp b/include/guisan/widgets/slider.hpp index 703f021..a6c9576 100644 --- a/include/guisan/widgets/slider.hpp +++ b/include/guisan/widgets/slider.hpp @@ -267,7 +267,17 @@ namespace gcn /** * True if the slider is dragged, false otherwise. */ - bool mDragged; + bool mDragged = false; + + /** + * Holds the start value of the scale. + */ + double mScaleStart = 0; + + /** + * Holds the end value of the scale. + */ + double mScaleEnd; /** * Holds the current selected value. @@ -283,23 +293,13 @@ namespace gcn /** * 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; + int mMarkerLength = 10; /** * Holds the orientation of the slider. A slider can be drawn * vertically or horizontally. */ - Orientation mOrientation; + Orientation mOrientation = Orientation::Horizontal; }; } diff --git a/include/guisan/widgets/tab.hpp b/include/guisan/widgets/tab.hpp index 9292ede..67649c7 100644 --- a/include/guisan/widgets/tab.hpp +++ b/include/guisan/widgets/tab.hpp @@ -144,17 +144,17 @@ namespace gcn /** * Holds the label of the tab. */ - Label* mLabel; + Label* mLabel = nullptr; /** * Holds the tabbed area the tab is a part of. */ - TabbedArea* mTabbedArea; + TabbedArea* mTabbedArea = nullptr; /** * True if the tab has the mouse, false otherwise. */ - bool mHasMouse; + bool mHasMouse = false; }; } diff --git a/include/guisan/widgets/tabbedarea.hpp b/include/guisan/widgets/tabbedarea.hpp index a807e9c..b2e1a9b 100644 --- a/include/guisan/widgets/tabbedarea.hpp +++ b/include/guisan/widgets/tabbedarea.hpp @@ -267,17 +267,17 @@ namespace gcn /** * Holds the selected tab. */ - Tab* mSelectedTab; + Tab* mSelectedTab = nullptr; /** * Holds the container for the tabs. */ - Container* mTabContainer; + Container* mTabContainer = nullptr; /** * Holds the container for the widgets. */ - Container* mWidgetContainer; + Container* mWidgetContainer = nullptr; /** * Holds a vector of tabs to delete in the destructor. @@ -295,12 +295,12 @@ namespace gcn /** * True if the tabbed area is opaque, false otherwise. */ - bool mOpaque; + bool mOpaque = false; /** * True if the tabbed area is active, false otherwise. */ - bool tabActive; + bool tabActive = false; }; } diff --git a/include/guisan/widgets/textbox.hpp b/include/guisan/widgets/textbox.hpp index 1baf7e3..4140240 100644 --- a/include/guisan/widgets/textbox.hpp +++ b/include/guisan/widgets/textbox.hpp @@ -272,17 +272,17 @@ namespace gcn /** * Holds the text of the text box. */ - Text* mText; + Text* mText = nullptr; /** * True if the text box is editable, false otherwise. */ - bool mEditable; + bool mEditable = true; /** * True if the text box is editable, false otherwise. */ - bool mOpaque; + bool mOpaque = true; }; } diff --git a/include/guisan/widgets/textfield.hpp b/include/guisan/widgets/textfield.hpp index 2dacfb1..7f7fe9a 100644 --- a/include/guisan/widgets/textfield.hpp +++ b/include/guisan/widgets/textfield.hpp @@ -185,19 +185,19 @@ namespace gcn /** * True if the text field is editable, false otherwise. */ - bool mEditable; + bool mEditable = true; /** * Holds the text of the text field. */ - Text* mText; + Text* mText = nullptr; /** * 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; + int mXScroll = 0; }; } diff --git a/include/guisan/widgets/togglebutton.hpp b/include/guisan/widgets/togglebutton.hpp index 1a62c47..d85ae2f 100644 --- a/include/guisan/widgets/togglebutton.hpp +++ b/include/guisan/widgets/togglebutton.hpp @@ -81,7 +81,7 @@ namespace gcn /** * Constructor. */ - ToggleButton(); + ToggleButton() = default; /** * Constructor. @@ -124,11 +124,11 @@ namespace gcn * not being selected. */ virtual void toggleSelected(); - + /** - * True if the button is selected, false otherwise. + * True if the button is selected, false otherwise. */ - bool mSelected; + bool mSelected = false; }; } diff --git a/include/guisan/widgets/window.hpp b/include/guisan/widgets/window.hpp index b02f59d..dc178f4 100644 --- a/include/guisan/widgets/window.hpp +++ b/include/guisan/widgets/window.hpp @@ -215,12 +215,12 @@ namespace gcn /** * Holds the alignment of the caption. */ - Graphics::Alignment mAlignment; + Graphics::Alignment mAlignment = Graphics::Alignment::Center; /** * Holds the padding of the window. */ - unsigned int mPadding; + unsigned int mPadding = 2; /** * Holds the title bar height of the window. @@ -230,31 +230,31 @@ namespace gcn /** * True if the window is movable, false otherwise. */ - bool mMovable; + bool mMovable = true; /** * True if the window is opaque, false otherwise. */ - bool mOpaque; + bool mOpaque = true; /** * 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; + int mDragOffsetX = 0; /** * 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; + int mDragOffsetY = 0; /** * True if the window is being moved, false otherwise. */ - bool mMoved; + bool mMoved = false; }; } diff --git a/src/cliprectangle.cpp b/src/cliprectangle.cpp index 04bb367..1341a2a 100644 --- a/src/cliprectangle.cpp +++ b/src/cliprectangle.cpp @@ -62,20 +62,12 @@ namespace gcn { - ClipRectangle::ClipRectangle() - { - x = y = width = height = xOffset = yOffset = 0; - } - ClipRectangle::ClipRectangle(int x, int y, int width, int height, int xOffset, int yOffset) - { - this->x = x; - this->y = y; - this->width = width; - this->height = height; - this->xOffset = xOffset; - this->yOffset = yOffset; - } + ClipRectangle::ClipRectangle(int x, int y, int width, int height, int xOffset, int yOffset) : + Rectangle(x, y, width, height), + xOffset(xOffset), + yOffset(yOffset) + {} const ClipRectangle& ClipRectangle::operator=(const Rectangle& other) { diff --git a/src/color.cpp b/src/color.cpp index 704c0ba..cb39bf8 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -62,32 +62,15 @@ namespace gcn { - Color::Color() - : - r(0), - g(0), - b(0), - a(255) - { - } - Color::Color(int color) - : + Color::Color(int color) : r((color >> 16) & 0xFF), g((color >> 8) & 0xFF), - b((color >> 8) & 0xFF), - a(255) - { - } + b((color >> 8) & 0xFF) + {} - Color::Color(int ar, int ag, int ab, int aa) - : - r(ar), - g(ag), - b(ab), - a(aa) - { - } + Color::Color(int r, int g, int b, int a) : r(r), g(g), b(b), a(a) + {} Color Color::operator+(const Color& color) const { diff --git a/src/exception.cpp b/src/exception.cpp index aac3a35..2e352bc 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -62,21 +62,9 @@ namespace gcn { - Exception::Exception() - : mFunction("?"), - mMessage(""), - mFilename("?"), - mLine(0) - { - } - Exception::Exception(std::string message) - : mFunction("?"), - mMessage(std::move(message)), - mFilename("?"), - mLine(0) - { - } + Exception::Exception(std::string message) : mMessage(std::move(message)) + {} Exception::Exception(std::string message, std::string function, diff --git a/src/focushandler.cpp b/src/focushandler.cpp index b2109da..40acbc8 100644 --- a/src/focushandler.cpp +++ b/src/focushandler.cpp @@ -66,17 +66,6 @@ namespace gcn { - FocusHandler::FocusHandler() - :mFocusedWidget(NULL), - mModalFocusedWidget(NULL), - mModalMouseInputFocusedWidget(NULL), - mDraggedWidget(NULL), - mLastWidgetWithMouse(NULL), - mLastWidgetWithModalFocus(NULL), - mLastWidgetWithModalMouseInputFocus(NULL), - mLastWidgetPressed(NULL) - { - } void FocusHandler::requestFocus(Widget* widget) { diff --git a/src/graphics.cpp b/src/graphics.cpp index f5233d9..35eef7c 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -66,10 +66,6 @@ namespace gcn { - Graphics::Graphics() - { - mFont = NULL; - } bool Graphics::pushClipArea(Rectangle area) { diff --git a/src/gui.cpp b/src/gui.cpp index 1d4710a..655c3ae 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -74,24 +74,8 @@ namespace gcn { - Gui::Gui() - :mTop(NULL), - mGraphics(NULL), - mInput(NULL), - mTabbing(true), - mShiftPressed(false), - mMetaPressed(false), - mControlPressed(false), - mAltPressed(false), - mLastMousePressButton(0), - mLastMousePressTimeStamp(0), - mLastMouseX(0), - mLastMouseY(0), - mClickCount(1), - mLastMouseDragButton(0) - { - mFocusHandler = new FocusHandler(); - } + Gui::Gui() : mFocusHandler(new FocusHandler()) + {} Gui::~Gui() { diff --git a/src/imagefont.cpp b/src/imagefont.cpp index 1fd108f..3c47ec4 100644 --- a/src/imagefont.cpp +++ b/src/imagefont.cpp @@ -111,9 +111,6 @@ namespace gcn } mImage->convertToDisplayFormat(); - - mRowSpacing = 0; - mGlyphSpacing = 0; } ImageFont::ImageFont(Image* image, const std::string& glyphs) @@ -158,9 +155,6 @@ namespace gcn } mImage->convertToDisplayFormat(); - - mRowSpacing = 0; - mGlyphSpacing = 0; } ImageFont::ImageFont(const std::string& filename, diff --git a/src/keyinput.cpp b/src/keyinput.cpp index b263514..6a54c87 100644 --- a/src/keyinput.cpp +++ b/src/keyinput.cpp @@ -62,16 +62,8 @@ namespace gcn { - KeyInput::KeyInput(const Key& key, unsigned int type) - :mKey(key), - mType(type), - mShiftPressed(false), - mControlPressed(false), - mAltPressed(false), - mMetaPressed(false), - mNumericPad(false) - { - } + KeyInput::KeyInput(const Key& key, unsigned int type) : mKey(key), mType(type) + {} void KeyInput::setType(unsigned int type) { diff --git a/src/opengl/openglimage.cpp b/src/opengl/openglimage.cpp index a82d477..39cd3b2 100644 --- a/src/opengl/openglimage.cpp +++ b/src/opengl/openglimage.cpp @@ -64,14 +64,15 @@ namespace gcn { - OpenGLImage::OpenGLImage(const unsigned int* pixels, int width, int height, - bool convertToDisplayFormat) + OpenGLImage::OpenGLImage(const unsigned int* pixels, + int width, + int height, + bool convertToDisplayFormat) : + mAutoFree(true), + mWidth(width), + mHeight(height) { - mAutoFree = true; - - mWidth = width; - mHeight = height; - mTextureWidth = 1, mTextureHeight = 1; + mTextureWidth = 1, mTextureHeight = 1; while(mTextureWidth < mWidth) { @@ -121,15 +122,13 @@ namespace gcn } } - OpenGLImage::OpenGLImage(GLuint textureHandle, int width, int height, bool autoFree) + OpenGLImage::OpenGLImage(GLuint textureHandle, int width, int height, bool autoFree) : + mTextureHandle(textureHandle), + mAutoFree(autoFree), + mWidth(width), + mHeight(height) { - mTextureHandle = textureHandle; - mAutoFree = autoFree; - mPixels = NULL; - - mWidth = width; - mHeight = height; - mTextureWidth = 1, mTextureHeight = 1; + mTextureWidth = 1, mTextureHeight = 1; while(mTextureWidth < mWidth) { diff --git a/src/rectangle.cpp b/src/rectangle.cpp index 8d1328d..03366f4 100644 --- a/src/rectangle.cpp +++ b/src/rectangle.cpp @@ -62,21 +62,13 @@ namespace gcn { - Rectangle::Rectangle() - { - x = 0; - y = 0; - width = 0; - height = 0; - } - Rectangle::Rectangle(int x, int y, int width, int height) - { - this->x = x; - this->y = y; - this->width = width; - this->height = height; - } + Rectangle::Rectangle(int x, int y, int width, int height) : + x(x), + y(y), + width(width), + height(height) + {} void Rectangle::setAll(int x, int y, int width, int height) { diff --git a/src/sdl/sdl2graphics.cpp b/src/sdl/sdl2graphics.cpp index d3c6074..1d55a8d 100644 --- a/src/sdl/sdl2graphics.cpp +++ b/src/sdl/sdl2graphics.cpp @@ -74,11 +74,7 @@ namespace gcn { - SDL2Graphics::SDL2Graphics() - { - mAlpha = false; - } - + SDL2Graphics::~SDL2Graphics() { if(mRenderTarget != NULL) diff --git a/src/sdl/sdlgraphics.cpp b/src/sdl/sdlgraphics.cpp index 767534e..4907795 100644 --- a/src/sdl/sdlgraphics.cpp +++ b/src/sdl/sdlgraphics.cpp @@ -74,11 +74,7 @@ namespace gcn { - SDLGraphics::SDLGraphics() - { - mAlpha = false; - } - + SDLGraphics::~SDLGraphics() { diff --git a/src/sdl/sdlimage.cpp b/src/sdl/sdlimage.cpp index 752fdda..eb7f0d9 100644 --- a/src/sdl/sdlimage.cpp +++ b/src/sdl/sdlimage.cpp @@ -65,16 +65,16 @@ namespace gcn { - SDLImage::SDLImage(SDL_Surface* surface, bool autoFree, SDL_Renderer* renderer) + SDLImage::SDLImage(SDL_Surface* surface, bool autoFree, SDL_Renderer* renderer) : + mSurface(surface), + mRenderer(renderer), + mAutoFree(autoFree) { - mAutoFree = autoFree; - mSurface = surface; - mRenderer = renderer; if (renderer) { mTexture = SDL_CreateTextureFromSurface(renderer, surface); SDL_SetTextureBlendMode(mTexture, SDL_BLENDMODE_BLEND); - } + } } SDLImage::~SDLImage() diff --git a/src/sdl/sdlimageloader.cpp b/src/sdl/sdlimageloader.cpp index cd6ef21..8f86917 100644 --- a/src/sdl/sdlimageloader.cpp +++ b/src/sdl/sdlimageloader.cpp @@ -67,8 +67,6 @@ namespace gcn { - SDLImageLoader::SDLImageLoader() : mRenderer(NULL) - {} Image* SDLImageLoader::load(const std::string& filename, bool convertToDisplayFormat) diff --git a/src/sdl/sdlinput.cpp b/src/sdl/sdlinput.cpp index 15d8e45..2006900 100644 --- a/src/sdl/sdlinput.cpp +++ b/src/sdl/sdlinput.cpp @@ -101,12 +101,6 @@ namespace gcn } } - SDLInput::SDLInput() - { - mMouseInWindow = true; - mMouseDown = false; - } - bool SDLInput::isKeyQueueEmpty() { return mKeyInputQueue.empty(); diff --git a/src/sdl/sdltruetypefont.cpp b/src/sdl/sdltruetypefont.cpp index 63ac406..915159c 100644 --- a/src/sdl/sdltruetypefont.cpp +++ b/src/sdl/sdltruetypefont.cpp @@ -55,16 +55,10 @@ namespace gcn { - SDLTrueTypeFont::SDLTrueTypeFont(const std::string& filename, int size) + SDLTrueTypeFont::SDLTrueTypeFont(const std::string& filename, int size) : + mFilename(filename), + mFont(TTF_OpenFont(filename.c_str(), size)) { - mRowSpacing = 0; - mGlyphSpacing = 0; - mAntiAlias = true; - mFilename = filename; - mFont = nullptr; - - mFont = TTF_OpenFont(filename.c_str(), size); - if (mFont == nullptr) { throw GCN_EXCEPTION("SDLTrueTypeFont::SDLTrueTypeFont. "+std::string(TTF_GetError())); diff --git a/src/widget.cpp b/src/widget.cpp index ada3bb9..81c4bb8 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -78,25 +78,11 @@ namespace gcn { - Font* Widget::mGlobalFont = NULL; + Font* Widget::mGlobalFont = nullptr; DefaultFont Widget::mDefaultFont; std::list Widget::mWidgetInstances; Widget::Widget() - : mForegroundColor(0x000000), - mBackgroundColor(0xffffff), - mBaseColor(0xDDDDE3), - mSelectionColor(0xc3d9ff), - mFocusHandler(NULL), - mInternalFocusHandler(NULL), - mParent(NULL), - mBorderSize(0), - mFocusable(false), - mVisible(true), - mTabIn(true), - mTabOut(true), - mEnabled(true), - mCurrentFont(NULL) { mWidgetInstances.push_back(this); } diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 2ecc327..521509c 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -69,29 +69,10 @@ namespace gcn { - Button::Button() - : mHasMouse(false), - mKeyPressed(false), - mMousePressed(false), - mAlignment(Graphics::Center), - mSpacing(4) - { - setFocusable(true); - adjustSize(); - setFrameSize(1); - - addMouseListener(this); - addKeyListener(this); - addFocusListener(this); - } + Button::Button() : Button("") + {} - Button::Button(std::string caption) - : mCaption(std::move(caption)), - mHasMouse(false), - mKeyPressed(false), - mMousePressed(false), - mAlignment(Graphics::Center), - mSpacing(4) + Button::Button(std::string caption) : mCaption(std::move(caption)) { setFocusable(true); adjustSize(); diff --git a/src/widgets/checkbox.cpp b/src/widgets/checkbox.cpp index 75afaa0..b27238c 100644 --- a/src/widgets/checkbox.cpp +++ b/src/widgets/checkbox.cpp @@ -67,20 +67,13 @@ namespace gcn { - CheckBox::CheckBox() - { - setSelected(false); + CheckBox::CheckBox() : CheckBox("", false) + {} - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - } - - CheckBox::CheckBox(const std::string &caption, bool selected) + CheckBox::CheckBox(const std::string& caption, bool selected) : + mCaption(caption), + mSelected(selected) { - setCaption(caption); - setSelected(selected); - setFocusable(true); addMouseListener(this); addKeyListener(this); diff --git a/src/widgets/container.cpp b/src/widgets/container.cpp index 965c8c8..641578f 100644 --- a/src/widgets/container.cpp +++ b/src/widgets/container.cpp @@ -65,10 +65,6 @@ namespace gcn { - Container::Container() - { - mOpaque = true; - } Container::~Container() { diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index f1197ee..37b6610 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -68,38 +68,17 @@ namespace gcn { DropDown::DropDown(ListModel *listModel, - ScrollArea *scrollArea, - ListBox *listBox) + ScrollArea *scrollArea, ListBox* listBox) : + mScrollArea(scrollArea ? scrollArea : new ScrollArea()), + mListBox(listBox ? listBox : new ListBox()), + mInternalScrollArea(scrollArea == nullptr), + mInternalListBox(listBox == nullptr) { setWidth(100); setFocusable(true); - mDroppedDown = false; - mPushed = false; - mIsDragged = false; setInternalFocusHandler(&mInternalFocusHandler); - mInternalScrollArea = (scrollArea == NULL); - mInternalListBox = (listBox == NULL); - - if (mInternalScrollArea) - { - mScrollArea = new ScrollArea(); - } - else - { - mScrollArea = scrollArea; - } - - if (mInternalListBox) - { - mListBox = new ListBox(); - } - else - { - mListBox = listBox; - } - mScrollArea->setContent(mListBox); add(mScrollArea); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index e197bab..4327093 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -67,24 +67,16 @@ namespace gcn { Icon::Icon() - : mImage(0) - , mInternalImage(false) { setSize(0, 0); } - Icon::Icon(const std::string& filename) - : mImage(0), - mInternalImage(false) + Icon::Icon(const std::string& filename) : mImage(Image::load(filename)), mInternalImage(true) { - mImage = Image::load(filename); - mInternalImage = true; setSize(mImage->getWidth(), mImage->getHeight()); } - Icon::Icon(const Image* image) - : mImage(image), - mInternalImage(false) + Icon::Icon(const Image* image) : mImage(image) { setSize(mImage->getWidth(), mImage->getHeight()); } diff --git a/src/widgets/imagebutton.cpp b/src/widgets/imagebutton.cpp index 5f10c6d..f88f0ac 100644 --- a/src/widgets/imagebutton.cpp +++ b/src/widgets/imagebutton.cpp @@ -66,26 +66,20 @@ namespace gcn { ImageButton::ImageButton() - : mImage(0), - mInternalImage(false) { setWidth(0); setHeight(0); } - ImageButton::ImageButton(const std::string& filename) - : mImage(0), - mInternalImage(false) + ImageButton::ImageButton(const std::string& filename) : + mImage(Image::load(filename)), + mInternalImage(true) { - mImage = Image::load(filename); - mInternalImage = true; setWidth(mImage->getWidth() + mImage->getWidth() / 2); setHeight(mImage->getHeight() + mImage->getHeight() / 2); } - ImageButton::ImageButton(const Image* image) - : mImage(image), - mInternalImage(false) + ImageButton::ImageButton(const Image* image) : mImage(image) { setWidth(mImage->getWidth() + mImage->getWidth() / 2); setHeight(mImage->getHeight() + mImage->getHeight() / 2); diff --git a/src/widgets/imagetextbutton.cpp b/src/widgets/imagetextbutton.cpp index 4e9e135..dffce97 100644 --- a/src/widgets/imagetextbutton.cpp +++ b/src/widgets/imagetextbutton.cpp @@ -67,20 +67,18 @@ namespace gcn { - ImageTextButton::ImageTextButton(const std::string& filename, std::string& caption) : ImageButton(filename) + ImageTextButton::ImageTextButton(const std::string& filename, const std::string& caption) : ImageButton(filename) { setCaption(caption); setWidth(mImage->getWidth() + mImage->getWidth() / 2); setHeight(mImage->getHeight() + mImage->getHeight() / 2); - mAlignment = ImageTextButton::BOTTOM; } - ImageTextButton::ImageTextButton(Image* image, std::string& caption) : ImageButton(image) + ImageTextButton::ImageTextButton(Image* image, const std::string& caption) : ImageButton(image) { setCaption(caption); setWidth(mImage->getWidth() + mImage->getWidth() / 2); setHeight(mImage->getHeight() + mImage->getHeight() / 2); - mAlignment = ImageTextButton::BOTTOM; } ImageTextButton::~ImageTextButton() diff --git a/src/widgets/inputbox.cpp b/src/widgets/inputbox.cpp index 472c2ea..13a651d 100644 --- a/src/widgets/inputbox.cpp +++ b/src/widgets/inputbox.cpp @@ -68,19 +68,22 @@ namespace gcn { - InputBox::InputBox(const std::string& caption, const std::string& message, const std::string &ok, const std::string &cancel) - :Window(caption),mMessage(message),mClickedButton(-1) + InputBox::InputBox(const std::string& caption, + const std::string& message, + const std::string& ok, + const std::string& cancel) : + Window(caption), + mMessage(message) { - setCaption(caption); addMouseListener(this); setMovable(false); - + mLabel = new Label(message); mLabel->setAlignment(Graphics::Left); mLabel->adjustSize(); mText = new TextField(); - + mButtonOK = new Button(ok); mButtonOK->setAlignment(Graphics::Center); mButtonOK->addMouseListener(this); diff --git a/src/widgets/label.cpp b/src/widgets/label.cpp index 8e7dc12..dac870a 100644 --- a/src/widgets/label.cpp +++ b/src/widgets/label.cpp @@ -66,16 +66,9 @@ namespace gcn { - Label::Label() - { - mAlignment = Graphics::Left; - } - Label::Label(const std::string& caption) + Label::Label(const std::string& caption) : mCaption(caption) { - mCaption = caption; - mAlignment = Graphics::Left; - setWidth(getFont()->getWidth(caption)); setHeight(getFont()->getHeight() + 2); } diff --git a/src/widgets/listbox.cpp b/src/widgets/listbox.cpp index b3fd910..f849a73 100644 --- a/src/widgets/listbox.cpp +++ b/src/widgets/listbox.cpp @@ -69,16 +69,10 @@ namespace gcn { - ListBox::ListBox() : mListModel(NULL), mSelected(-1), mWrappingEnabled(false) - { - setWidth(100); - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - } + ListBox::ListBox() : ListBox(nullptr) + {} - ListBox::ListBox(ListModel *listModel) : mSelected(-1), mWrappingEnabled(false) + ListBox::ListBox(ListModel* listModel) { setWidth(100); setListModel(listModel); diff --git a/src/widgets/messagebox.cpp b/src/widgets/messagebox.cpp index dc8c401..ec29773 100644 --- a/src/widgets/messagebox.cpp +++ b/src/widgets/messagebox.cpp @@ -65,59 +65,31 @@ #include "guisan/graphics.hpp" #include "guisan/mouseinput.hpp" +#include + namespace gcn { - MessageBox::MessageBox(const std::string& caption, const std::string& message) - :Window(caption),mMessage(message),mClickedButton(-1) + MessageBox::MessageBox(const std::string& caption, const std::string& message) : + MessageBox(caption, message, std::vector{"OK"}.data(), 1) { - setCaption(caption); - addMouseListener(this); - setMovable(false); - - mLabel = new Label(message); - mLabel->setAlignment(Graphics::Left); - mLabel->adjustSize(); - - mNbButtons = 1; - mButtons = new Button*[1]; - mButtons[0] = new Button("OK"); - mButtons[0]->setAlignment(Graphics::Center); - mButtons[0]->addMouseListener(this); - - setHeight((int)getTitleBarHeight() + mLabel->getHeight() + 4*mPadding + mButtons[0]->getHeight()); - setWidth(mLabel->getWidth() + 4*mPadding); - if(mButtons[0]->getWidth() + 4*mPadding > getWidth()) - { - setWidth(mButtons[0]->getWidth() + 4*mPadding); - } - - this->add(mLabel, (getWidth() - mLabel->getWidth())/2 - mPadding, mPadding); - this->add(mButtons[0], (getWidth() - mButtons[0]->getWidth())/2, getHeight() - (int)getTitleBarHeight() - mPadding - mButtons[0]->getHeight()); - - try - { - requestModalFocus(); - } - catch (Exception e) - { - // Not having modal focus is not critical - } } - - MessageBox::MessageBox(const std::string& caption, const std::string& message, - const std::string *buttons, int size) - :Window(caption),mMessage(message),mClickedButton(-1) + + MessageBox::MessageBox(const std::string& caption, + const std::string& message, + const std::string* buttons, + int size) : + Window(caption), + mMessage(message) { - setCaption(caption); addMouseListener(this); setMovable(false); - + mLabel = new Label(message); mLabel->setAlignment(Graphics::Left); mLabel->adjustSize(); setWidth(mLabel->getWidth() + 4*mPadding); - + //Create buttons and label if(size > 0) { @@ -154,7 +126,7 @@ namespace gcn for(int i = 0 ; i < size ; i++) { add(mButtons[i], padding + (maxBtnWidth + mPadding)*i, getHeight() - (int)getTitleBarHeight() - mPadding - mButtons[0]->getHeight()); - } + } } try diff --git a/src/widgets/progressbar.cpp b/src/widgets/progressbar.cpp index 74113f9..9d53805 100644 --- a/src/widgets/progressbar.cpp +++ b/src/widgets/progressbar.cpp @@ -66,22 +66,12 @@ namespace gcn { - ProgressBar::ProgressBar() : Label() - { - mAlignment = Graphics::Center; - mStart = 0; - mValue = 0; - mEnd = 100; - - setHeight(getFont()->getHeight()); - setFrameSize(1); - } - + ProgressBar::ProgressBar() : ProgressBar(0, 100, 0) + {} + ProgressBar::ProgressBar(const unsigned int start, const unsigned int end, const unsigned int value) : Label() { - mAlignment = Graphics::Center; - if (start > end) { mStart = end; @@ -106,11 +96,8 @@ namespace gcn setFrameSize(1); } - ProgressBar::ProgressBar(const std::string& caption) : Label(caption) + ProgressBar::ProgressBar(const std::string& caption) : Label(caption), mCaption(caption) { - mCaption = caption; - mAlignment = Graphics::Center; - setHeight(getFont()->getHeight()); setFrameSize(1); } diff --git a/src/widgets/radiobutton.cpp b/src/widgets/radiobutton.cpp index 4f9ad51..10a7f2b 100644 --- a/src/widgets/radiobutton.cpp +++ b/src/widgets/radiobutton.cpp @@ -69,20 +69,12 @@ namespace gcn { RadioButton::GroupMap RadioButton::mGroupMap; - RadioButton::RadioButton() - { - setSelected(false); - - setFocusable(true); - addMouseListener(this); - addKeyListener(this); - } + RadioButton::RadioButton() : RadioButton("", "", false) + {} - RadioButton::RadioButton(const std::string& caption, - const std::string& group, - bool selected) + RadioButton::RadioButton(const std::string& caption, const std::string& group, bool selected) : + mCaption(caption) { - setCaption(caption); setGroup(group); setSelected(selected); diff --git a/src/widgets/scrollarea.cpp b/src/widgets/scrollarea.cpp index abcf507..6769106 100644 --- a/src/widgets/scrollarea.cpp +++ b/src/widgets/scrollarea.cpp @@ -65,70 +65,17 @@ namespace gcn { - ScrollArea::ScrollArea() - { - mVScroll = 0; - mHScroll = 0; - mHPolicy = ShowAuto; - mVPolicy = ShowAuto; - mScrollbarWidth = 12; - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mUpButtonScrollAmount = 10; - mDownButtonScrollAmount = 10; - mLeftButtonScrollAmount = 10; - mRightButtonScrollAmount = 10; - mIsVerticalMarkerDragged = false; - mIsHorizontalMarkerDragged =false; - mOpaque = true; + ScrollArea::ScrollArea() : ScrollArea(nullptr) + {} - addMouseListener(this); - } + ScrollArea::ScrollArea(Widget* content) : + ScrollArea(content, ScrollPolicy::ShowAuto, ScrollPolicy::ShowAuto) + {} - ScrollArea::ScrollArea(Widget *content) + ScrollArea::ScrollArea(Widget* content, ScrollPolicy hPolicy, ScrollPolicy vPolicy) : + mHPolicy(hPolicy), + mVPolicy(vPolicy) { - mVScroll = 0; - mHScroll = 0; - mHPolicy = ShowAuto; - mVPolicy = ShowAuto; - mScrollbarWidth = 12; - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mUpButtonScrollAmount = 10; - mDownButtonScrollAmount = 10; - mLeftButtonScrollAmount = 10; - mRightButtonScrollAmount = 10; - mIsVerticalMarkerDragged = false; - mIsHorizontalMarkerDragged =false; - mOpaque = true; - - setContent(content); - addMouseListener(this); - } - - ScrollArea::ScrollArea(Widget *content, ScrollPolicy hPolicy, ScrollPolicy vPolicy) - { - mVScroll = 0; - mHScroll = 0; - mHPolicy = hPolicy; - mVPolicy = vPolicy; - mScrollbarWidth = 12; - mUpButtonPressed = false; - mDownButtonPressed = false; - mLeftButtonPressed = false; - mRightButtonPressed = false; - mUpButtonScrollAmount = 10; - mDownButtonScrollAmount = 10; - mLeftButtonScrollAmount = 10; - mRightButtonScrollAmount = 10; - mIsVerticalMarkerDragged = false; - mIsHorizontalMarkerDragged =false; - mOpaque = true; - setContent(content); addMouseListener(this); } diff --git a/src/widgets/slider.cpp b/src/widgets/slider.cpp index 9e21b2c..a1d6e0a 100644 --- a/src/widgets/slider.cpp +++ b/src/widgets/slider.cpp @@ -66,37 +66,18 @@ namespace gcn { - Slider::Slider(double scaleEnd) - { - mDragged = false; - - mScaleStart = 0; - mScaleEnd = scaleEnd; - - setFocusable(true); - setFrameSize(1); - setOrientation(Horizontal); - setValue(0); - setStepLength(scaleEnd / 10); - setMarkerLength(10); + Slider::Slider(double scaleEnd) : Slider(0., scaleEnd) + {} - addMouseListener(this); - addKeyListener(this); - } - - Slider::Slider(double scaleStart, double scaleEnd) + Slider::Slider(double scaleStart, double scaleEnd) : + mScaleStart(scaleStart), + mScaleEnd(scaleEnd), + mValue(scaleStart) { - mDragged = false; - - mScaleStart = scaleStart; - mScaleEnd = scaleEnd; - setFocusable(true); setFrameSize(1); - setOrientation(Horizontal); - setValue(scaleStart); + setStepLength((scaleEnd - scaleStart) / 10); - setMarkerLength(10); addMouseListener(this); addKeyListener(this); diff --git a/src/widgets/tab.cpp b/src/widgets/tab.cpp index 38509e5..14f749b 100644 --- a/src/widgets/tab.cpp +++ b/src/widgets/tab.cpp @@ -68,9 +68,8 @@ namespace gcn { - Tab::Tab() : mTabbedArea(NULL), mHasMouse(false) + Tab::Tab() : mLabel(new Label()) { - mLabel = new Label(); mLabel->setPosition(6, 6); add(mLabel); setFrameSize(1); diff --git a/src/widgets/tabbedarea.cpp b/src/widgets/tabbedarea.cpp index 457bd58..b3c5042 100644 --- a/src/widgets/tabbedarea.cpp +++ b/src/widgets/tabbedarea.cpp @@ -72,16 +72,15 @@ namespace gcn { - TabbedArea::TabbedArea() : mSelectedTab(NULL), mOpaque(false) + TabbedArea::TabbedArea() : mTabContainer(new Container()), mWidgetContainer(new Container()) { setFrameSize(1); setFocusable(true); + addKeyListener(this); addMouseListener(this); - mTabContainer = new Container(); mTabContainer->setOpaque(false); - mWidgetContainer = new Container(); add(mTabContainer); add(mWidgetContainer); diff --git a/src/widgets/textbox.cpp b/src/widgets/textbox.cpp index 8fee1cc..c33b274 100644 --- a/src/widgets/textbox.cpp +++ b/src/widgets/textbox.cpp @@ -68,22 +68,11 @@ namespace gcn { - TextBox::TextBox() : mEditable(true), mOpaque(true) - { - mText = new Text(); - - setFocusable(true); - - addMouseListener(this); - addKeyListener(this); - adjustSize(); - setFrameSize(1); - } + TextBox::TextBox() : TextBox("") + {} - TextBox::TextBox(const std::string& text) : mEditable(true), mOpaque(true) + TextBox::TextBox(const std::string& text) : mText(new Text(text)) { - mText = new Text(text); - setFocusable(true); addMouseListener(this); diff --git a/src/widgets/textfield.cpp b/src/widgets/textfield.cpp index 87dd449..23f46c2 100644 --- a/src/widgets/textfield.cpp +++ b/src/widgets/textfield.cpp @@ -68,28 +68,24 @@ namespace gcn { - TextField::TextField() : mEditable(true), mXScroll(0) + TextField::TextField() : mText(new Text()) { - mText = new Text(); - mXScroll = 0; - setFocusable(true); addMouseListener(this); addKeyListener(this); + adjustHeight(); } - TextField::TextField(const std::string& text) : mEditable(true), mXScroll(0) + TextField::TextField(const std::string& text) : mText(new Text(text)) { - mText = new Text(text); - - adjustSize(); - setFocusable(true); addMouseListener(this); addKeyListener(this); + + adjustSize(); } void TextField::setText(const std::string& text) diff --git a/src/widgets/togglebutton.cpp b/src/widgets/togglebutton.cpp index 8116dff..59e2894 100644 --- a/src/widgets/togglebutton.cpp +++ b/src/widgets/togglebutton.cpp @@ -69,17 +69,9 @@ namespace gcn { - ToggleButton::ToggleButton() - : Button(), mSelected(false) - { - - } - ToggleButton::ToggleButton(const std::string& caption) - : Button(caption), mSelected(false) - { - - } + ToggleButton::ToggleButton(const std::string& caption) : Button(caption) + {} void ToggleButton::draw(Graphics* graphics) { diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index c3c9f9b..d7786e6 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -67,29 +67,14 @@ namespace gcn { - Window::Window() - :mMoved(false) - { - setFrameSize(1); - setPadding(2); - setTitleBarHeight(getFont()->getHeight() + 2); - setAlignment(Graphics::Center); - addMouseListener(this); - setMovable(true); - setOpaque(true); - } + Window::Window() : Window("") + {} Window::Window(const std::string& caption) - :mMoved(false) { setCaption(caption); - setFrameSize(1); - setPadding(2); setTitleBarHeight(getFont()->getHeight() + 2); - setAlignment(Graphics::Center); addMouseListener(this); - setMovable(true); - setOpaque(true); } Window::~Window()