enhancement: merge updates from Preview

- GUI and Guisan updates
- RTG Harware cursor support
- OpenGL updates
- Input updates
- DraCo updates
- Audio updates
- Tablet support updates
This commit is contained in:
Dimitris Panokostas 2024-01-25 17:44:02 +01:00
parent a281bd3f03
commit bfe1574c0c
No known key found for this signature in database
GPG Key ID: 330156A68E9E0929
172 changed files with 5970 additions and 4384 deletions

1
.gitignore vendored
View File

@ -224,3 +224,4 @@ Brewfile.lock.json
cmake-build-debug-remote-host
cmake-build-release-remote-host
cmake-build-debug-opengl

View File

@ -81,7 +81,6 @@ add_executable(${PROJECT_NAME}
src/blkdev_cdimage.cpp
src/bsdsocket.cpp
src/calc.cpp
src/casablanca.cpp
src/cd32_fmv.cpp
src/cd32_fmv_genlock.cpp
src/cdrom.cpp
@ -100,6 +99,7 @@ add_executable(${PROJECT_NAME}
src/diskutil.cpp
src/dlopen.cpp
src/dongle.cpp
src/draco.cpp
src/drawing.cpp
src/driveclick.cpp
src/ethernet.cpp
@ -347,6 +347,10 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR ARCHITECTURE MATCHES "arm64")
)
endif ()
if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR ARCHITECTURE MATCHES "arm64")
add_definitions(-DCPU_AARCH64)
endif ()
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)

View File

@ -473,7 +473,6 @@ OBJS = \
src/blkdev_cdimage.o \
src/bsdsocket.o \
src/calc.o \
src/casablanca.o \
src/cd32_fmv.o \
src/cd32_fmv_genlock.o \
src/cdrom.o \
@ -492,6 +491,7 @@ OBJS = \
src/diskutil.o \
src/dlopen.o \
src/dongle.o \
src/draco.o \
src/drawing.o \
src/driveclick.o \
src/ethernet.o \

View File

@ -115,10 +115,11 @@
class Widget;
extern "C" {
extern "C"
{
/**
* Gets the the version of Guisan. As it is a C function
* it can be used to check for Guichan with autotools.
* it can be used to check for Guisan with autotools.
*
* @return the version of Guisan.
*/

View File

@ -82,7 +82,7 @@ namespace gcn
* @param source the source widget of the event.
* @param id the identifier of the event.
*/
ActionEvent(Widget* source, std::string id);
ActionEvent(Widget* source, const std::string& id);
/**
* Destructor.
@ -94,7 +94,7 @@ namespace gcn
*
* @return the id of the event.
*/
[[nodiscard]] const std::string& getId() const;
const std::string& getId() const;
protected:
std::string mId;

View File

@ -78,7 +78,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~ActionListener() = default;
virtual ~ActionListener() { }
/**
* Called when an action is received from a Widget. It is used

View File

@ -82,30 +82,30 @@ namespace gcn
// Inherited from Widget
void moveToTop(Widget* widget) override;
virtual void moveToTop(Widget* widget);
void moveToBottom(Widget* widget) override;
virtual void moveToBottom(Widget* widget);
Rectangle getChildrenArea() override;
virtual Rectangle getChildrenArea();
void focusNext() override;
virtual void focusNext();
void focusPrevious() override;
virtual void focusPrevious();
void logic() override;
virtual void logic();
void _setFocusHandler(FocusHandler* focusHandler) override;
virtual void _setFocusHandler(FocusHandler* focusHandler);
void setInternalFocusHandler(FocusHandler* focusHandler) override;
void setInternalFocusHandler(FocusHandler* focusHandler);
void showWidgetPart(Widget* widget, Rectangle area) override;
virtual void showWidgetPart(Widget* widget, Rectangle area);
Widget* getWidgetAt(int x, int y) override;
virtual Widget* getWidgetAt(int x, int y);
// Inherited from DeathListener
void death(const Event& event) override;
virtual void death(const Event& event);
protected:
/**
@ -113,7 +113,7 @@ namespace gcn
*
* @param widget the widget to add.
*/
virtual void add(Widget* widget);
void add(Widget* widget);
/**
* Removes a widget from the basic container.

View File

@ -78,8 +78,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~DeathListener()
= default;
virtual ~DeathListener() { }
/**
* Called when a widget dies. It is used to be able to receive

View File

@ -73,8 +73,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~DefaultFont()
= default;
virtual ~DefaultFont() { }
/**
* Draws a glyph as a rectangle. The glyphs always be drawn as
@ -95,13 +94,13 @@ namespace gcn
// Inherited from Font
void drawString(Graphics* graphics, const std::string& text, int x, int y) override;
virtual void drawString(Graphics* graphics, const std::string& text, int x, int y);
[[nodiscard]] int getWidth(const std::string& text) const override;
virtual int getWidth(const std::string& text) const;
[[nodiscard]] int getHeight() const override;
virtual int getHeight() const;
int getStringIndexAt(const std::string& text, int x) override;
virtual int getStringIndexAt(const std::string& text, int x);
};
}

View File

@ -90,12 +90,12 @@ namespace gcn
*
* @return the source widget of the event.
*/
[[nodiscard]] Widget* getSource() const;
Widget* getSource() const;
protected:
Widget* mSource;
unsigned int mType{};
unsigned int mType;
};
}

View File

@ -108,7 +108,7 @@ namespace gcn
*
* @param message the error message.
*/
Exception(std::string message);
Exception(const std::string& message);
/**
* Constructor.
@ -120,9 +120,9 @@ namespace gcn
* @param filename the name of the file.
* @param line the line number.
*/
Exception(std::string message,
std::string function,
std::string filename,
Exception(const std::string& message,
const std::string& function,
const std::string& filename,
int line);
/**
@ -130,28 +130,28 @@ namespace gcn
*
* @return the function name in which the exception was thrown.
*/
[[nodiscard]] const std::string& getFunction() const;
const std::string& getFunction() const;
/**
* Gets the error message of the exception.
*
* @return the error message.
*/
[[nodiscard]] const std::string& getMessage() const;
const std::string& getMessage() const;
/**
* Gets the filename in which the exceptions was thrown.
*
* @return the filename in which the exception was thrown.
*/
[[nodiscard]] const std::string& getFilename() const;
const std::string& getFilename() const;
/**
* Gets the line number of the line where the exception was thrown.
*
* @return the line number of the line where the exception was thrown.
*/
[[nodiscard]] int getLine() const;
int getLine() const;
protected:
std::string mFunction;

View File

@ -90,8 +90,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~FocusHandler()
= default;;
virtual ~FocusHandler() { }
/**
* Sets focus to a widget. A focus event will also be sent to the widget's
@ -143,7 +142,7 @@ namespace gcn
* @return the Widget with focus. NULL will be returned if
* no Widget has focus.
*/
[[nodiscard]] virtual Widget* getFocused() const;
virtual Widget* getFocused() const;
/**
* Gets the widget with modal focus.
@ -151,7 +150,7 @@ namespace gcn
* @return the Widget with modal focus. NULL will be returned
* if no Widget has modal focus.
*/
[[nodiscard]] virtual Widget* getModalFocused() const;
virtual Widget* getModalFocused() const;
/**
* Gets the widget with modal mouse input focus.
@ -159,7 +158,7 @@ namespace gcn
* @return the widget with modal mouse input focus. NULL will be returned
* if no widget has modal mouse input focus.
*/
[[nodiscard]] virtual Widget* getModalMouseInputFocused() const;
virtual Widget* getModalMouseInputFocused() const;
/**
* Focuses the next Widget. If no Widget has focus the first

View File

@ -78,26 +78,21 @@ namespace gcn
/**
* Destructor.
*/
virtual ~FocusListener()
= default;
virtual ~FocusListener() { }
/**
* Called when a widget gains focus.
*
* @param event describes the event.
*/
virtual void focusGained(const Event& event)
{
};
virtual void focusGained(const Event& event) { };
/**
* Called when a widget loses focus.
*
* @param event discribes the event.
*/
virtual void focusLost(const Event& event)
{
};
virtual void focusLost(const Event& event) { };
};
}

View File

@ -77,7 +77,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~Font() = default;
virtual ~Font() { }
/**
* Gets the width of a string. The width of a string is not necesserily
@ -86,14 +86,14 @@ namespace gcn
* @param text the string to return the width of.
* @return the width of a string.
*/
[[nodiscard]] virtual int getWidth(const std::string& text) const = 0;
virtual int getWidth(const std::string& text) const = 0;
/**
* Gets the height of the glyphs in the font.
*
* @return the height of the glyphs int the font.
*/
[[nodiscard]] virtual int getHeight() const = 0;
virtual int getHeight() const = 0;
/**
* Gets a string index in a string providing an x coordinate.

View File

@ -149,15 +149,15 @@ namespace gcn
// Inherited from Input
bool isKeyQueueEmpty() override;
virtual bool isKeyQueueEmpty();
KeyInput dequeueKeyInput() override;
virtual KeyInput dequeueKeyInput();
bool isMouseQueueEmpty() override;
virtual bool isMouseQueueEmpty();
MouseInput dequeueMouseInput() override;
virtual MouseInput dequeueMouseInput();
void _pollInput() override;
virtual void _pollInput();
protected:
std::queue<KeyInput> mKeyInputQueue;

View File

@ -61,11 +61,12 @@
#include "platform.hpp"
extern "C" {
/**
* Exists to be able to check for Guichan GLUT with autotools.
*/
GCN_EXTENSION_DECLSPEC extern void gcnGLUT();
extern "C"
{
/**
* Exists to be able to check for Guichan GLUT with autotools.
*/
GCN_EXTENSION_DECLSPEC extern void gcnGLUT();
}
#endif // end GCN_GLUT_HPP

View File

@ -103,8 +103,7 @@ namespace gcn
public:
Graphics();
virtual ~Graphics()
= default;
virtual ~Graphics() { }
/**
* Initializes drawing. Called by the Gui when Gui::draw() is called.
@ -117,9 +116,7 @@ namespace gcn
*
* @see _endDraw, Gui::draw
*/
virtual void _beginDraw()
{
}
virtual void _beginDraw() { }
/**
* Deinitializes drawing. Called by the Gui when a Gui::draw() is done.
@ -130,9 +127,7 @@ namespace gcn
*
* @see _beginDraw, Gui::draw
*/
virtual void _endDraw()
{
}
virtual void _endDraw() { }
/**
* Pushes a clip area onto the stack. The x and y coordinates in the

View File

@ -117,7 +117,7 @@ namespace gcn
*
* @return the top widget. NULL if no top widget has been set.
*/
[[nodiscard]] virtual Widget* getTop() const;
virtual Widget* getTop() const;
/**
* Sets the Graphics object to use for drawing.
@ -133,7 +133,7 @@ namespace gcn
* @return the Graphics object used for drawing. NULL if no
* Graphics object has been set.
*/
[[nodiscard]] virtual Graphics* getGraphics() const;
virtual Graphics* getGraphics() const;
/**
* Sets the Input object to use for input handling.
@ -149,7 +149,7 @@ namespace gcn
* @return the Input object used for handling input. NULL if no
* Input object has been set.
*/
[[nodiscard]] virtual Input* getInput() const;
virtual Input* getInput() const;
/**
* Performs the Gui logic. By calling this function all logic

View File

@ -132,14 +132,14 @@ namespace gcn
*
* @return the image width
*/
[[nodiscard]] virtual int getWidth() const = 0;
virtual int getWidth() const = 0;
/**
* Gets the height of the Image.
*
* @return the image height
*/
[[nodiscard]] virtual int getHeight() const = 0;
virtual int getHeight() const = 0;
/**
* Gets the color of a pixel at coordinate (x, y) in the image.

View File

@ -123,7 +123,7 @@ pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); @endcode
* @throws Exception when glyph bondaries are incorrect or the font
* file is corrupt or if no ImageLoader exists.
*/
explicit ImageFont(const std::string& filename, unsigned char glyphsFrom = 32,
ImageFont(const std::string& filename, unsigned char glyphsFrom = 32,
unsigned char glyphsTo = 126);
/**
@ -184,19 +184,19 @@ pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); @endcode
* @param glyph the glyph which width will be returned
* @return the width of a glyph
*/
[[nodiscard]] virtual int getWidth(unsigned char glyph) const;
virtual int getWidth(unsigned char glyph) const;
// Inherited from Font
[[nodiscard]] int getWidth(const std::string& text) const override;
virtual int getWidth(const std::string& text) const;
void drawString(Graphics* graphics, const std::string& text,
int x, int y) override;
virtual void drawString(Graphics* graphics, const std::string& text,
int x, int y);
[[nodiscard]] int getHeight() const override;
virtual int getHeight() const;
int getStringIndexAt(const std::string& text, int x) override;
virtual int getStringIndexAt(const std::string& text, int x);
protected:
void addGlyph(unsigned char c, int& x, int& y, const Color& separator);

View File

@ -77,8 +77,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~ImageLoader()
= default;
virtual ~ImageLoader() { }
/**
* Loads an image by calling the image's ImageLoader.

View File

@ -80,8 +80,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~Input()
= default;
virtual ~Input() { }
/**
* Checks whether the key queue is empty or not.

View File

@ -92,28 +92,28 @@ namespace gcn
*
* @return true if shift was pressed at the same time as the key.
*/
[[nodiscard]] bool isShiftPressed() const;
bool isShiftPressed() const;
/**
* Checks whether control is pressed.
*
* @return true if control was pressed at the same time as the key.
*/
[[nodiscard]] bool isControlPressed() const;
bool isControlPressed() const;
/**
* Checks whether alt is pressed.
*
* @return true if alt was pressed at the same time as the key.
*/
[[nodiscard]] bool isAltPressed() const;
bool isAltPressed() const;
/**
* Checks whether meta is pressed.
*
* @return true if meta was pressed at the same time as the key.
*/
[[nodiscard]] bool isMetaPressed() const;
bool isMetaPressed() const;
/**
* Marks the event as consumed. How widgets should act on consumed
@ -126,7 +126,7 @@ namespace gcn
*
* @return true if the input event is consumed, false otherwise.
*/
[[nodiscard]] bool isConsumed() const;
bool isConsumed() const;
protected:
bool mShiftPressed;

View File

@ -80,28 +80,28 @@ namespace gcn
*
* @return true if the key is a letter, number or whitespace.
*/
[[nodiscard]] bool isCharacter() const;
bool isCharacter() const;
/**
* Checks whether a key is a number.
*
* @return true if the key is a number (0-9).
*/
[[nodiscard]] bool isNumber() const;
bool isNumber() const;
/**
* Checks whether a key is a letter.
*
* @return true if the key is a letter (a-z,A-Z).
*/
[[nodiscard]] bool isLetter() const;
bool isLetter() const;
/*
* Checks if the key is a symbol
/**
* Checks whether a key is printable.
*
* @return true if the key is a symbol (-/+.; etc)
* @return true if the key is printable
*/
[[nodiscard]] bool isSymbol() const;
bool isPrintable() const;
/**
* Gets the value of the key. If an ascii value exists it will be
@ -109,28 +109,14 @@ namespace gcn
*
* @return the value of the key.
*/
[[nodiscard]] int getValue() const;
int getValue() const;
/**
* Gets the char value of the key if available.
*
* @return the char value of the key, the null character otherwise
*/
[[nodiscard]] char getChar() const;
/**
* Gets the value represented by SHIFT + numeric key
*
* @return the char value of the key, the null character otherwise
*/
[[nodiscard]] char getShiftedNumeric() const;
/**
* Gets the value represented by SHIFT + symbol key
*
* @return the char value of the key, the null character otherwise
*/
[[nodiscard]] char getShiftedSymbol() const;
char getChar() const;
/**
* An enum with key values.

View File

@ -104,21 +104,21 @@ namespace gcn
*
* @return the type of the event.
*/
[[nodiscard]] unsigned int getType() const;
unsigned int getType() const;
/**
* Checks whether the key event occured on the numeric pad.
*
* @return true if key event occured on the numeric pad.
*/
[[nodiscard]] bool isNumericPad() const;
bool isNumericPad() const;
/**
* Gets the key of the event.
*
* @return the key of the event.
*/
[[nodiscard]] const Key& getKey() const;
const Key& getKey() const;
/**
* Key event types.

View File

@ -73,8 +73,7 @@ namespace gcn
/**
* Constructor.
*/
KeyInput()
= default;;
KeyInput() { }
/**
* Constructor.
@ -96,7 +95,7 @@ namespace gcn
*
* @return the input type.
*/
[[nodiscard]] int getType() const;
int getType() const;
/**
* Sets the key the input concerns.
@ -110,7 +109,7 @@ namespace gcn
*
* @return the Key the input concerns.
*/
[[nodiscard]] const Key& getKey() const;
const Key& getKey() const;
/**
* Checks whether shift is pressed.
@ -118,7 +117,7 @@ namespace gcn
* @return true if shift was pressed at the same time as the key.
* @since 0.6.0
*/
[[nodiscard]] bool isShiftPressed() const;
bool isShiftPressed() const;
/**
* Sets the shift pressed flag.
@ -134,7 +133,7 @@ namespace gcn
* @return true if control was pressed at the same time as the key.
* @since 0.6.0
*/
[[nodiscard]] bool isControlPressed() const;
bool isControlPressed() const;
/**
* Sets the control pressed flag.
@ -150,7 +149,7 @@ namespace gcn
* @return true if alt was pressed at the same time as the key.
* @since 0.6.0
*/
[[nodiscard]] bool isAltPressed() const;
bool isAltPressed() const;
/**
* Sets the alt pressed flag.
@ -166,7 +165,7 @@ namespace gcn
* @return true if meta was pressed at the same time as the key.
* @since 0.6.0
*/
[[nodiscard]] bool isMetaPressed() const;
bool isMetaPressed() const;
/**
* Sets the meta pressed flag.
@ -182,7 +181,7 @@ namespace gcn
* @return true if key pressed at the numeric pad.
* @since 0.6.0
*/
[[nodiscard]] bool isNumericPad() const;
bool isNumericPad() const;
/**
* Sets the numeric pad flag.
@ -204,13 +203,13 @@ namespace gcn
protected:
Key mKey;
int mType{};
int mButton{};
bool mShiftPressed{};
bool mControlPressed{};
bool mAltPressed{};
bool mMetaPressed{};
bool mNumericPad{};
int mType;
int mButton;
bool mShiftPressed;
bool mControlPressed;
bool mAltPressed;
bool mMetaPressed;
bool mNumericPad;
};
}

View File

@ -80,8 +80,7 @@ namespace gcn
/**
* Destructor
*/
virtual ~KeyListener()
= default;
virtual ~KeyListener() { }
/**
* Called if a key is pressed when the widget has keyboard focus.
@ -90,18 +89,14 @@ namespace gcn
*
* @param keyEvent discribes the event.
*/
virtual void keyPressed(KeyEvent& keyEvent)
{
}
virtual void keyPressed(KeyEvent& keyEvent) { }
/**
* Called if a key is released when the widget has keyboard focus.
*
* @param keyEvent discribes the event.
*/
virtual void keyReleased(KeyEvent& keyEvent)
{
}
virtual void keyReleased(KeyEvent& keyEvent) { }
protected:
/**
@ -112,8 +107,7 @@ namespace gcn
* you must inherit from this class and implement it's
* functions.
*/
KeyListener()
= default;
KeyListener() { }
};
}

View File

@ -75,8 +75,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~ListModel()
= default;
virtual ~ListModel() = default;
/**
* Gets the number of elements in the ListModel.
@ -94,11 +93,10 @@ namespace gcn
virtual std::string getElementAt(int i) = 0;
// Add a new element
virtual int add_element(const char* elem) = 0;
virtual void add(const std::string& str) { }
// Clear all elements
virtual void clear_elements()
{}
virtual void clear() { }
};
}

View File

@ -104,7 +104,7 @@ namespace gcn
*
* @return the button of the mouse event.
*/
[[nodiscard]] unsigned int getButton() const;
unsigned int getButton() const;
/**
* Gets the x coordinate of the mouse event. The coordinate is relative to
@ -112,7 +112,7 @@ namespace gcn
*
* @return the x coordinate of the mouse event.
*/
[[nodiscard]] int getX() const;
int getX() const;
/**
* Gets the y coordinate of the mouse event. The coordinate is relative to
@ -120,21 +120,21 @@ namespace gcn
*
* @return the y coordinate of the mouse event.
*/
[[nodiscard]] int getY() const;
int getY() const;
/**
* Gets the click count.
*
* @return the click count of the mouse event.
*/
[[nodiscard]] int getClickCount() const;
int getClickCount() const;
/**
* Gets the type of the event.
*
* @return the type of the event.
*/
[[nodiscard]] unsigned int getType() const;
unsigned int getType() const;
/**
* Mouse event types.

View File

@ -77,8 +77,7 @@ namespace gcn
/**
* Constructor.
*/
MouseInput()
= default;;
MouseInput() { }
/**
* Constructor.
@ -107,7 +106,7 @@ namespace gcn
*
* @return the input type.
*/
[[nodiscard]] unsigned int getType() const;
unsigned int getType() const;
/**
* Sets the button pressed.
@ -121,7 +120,7 @@ namespace gcn
*
* @return the button pressed.
*/
[[nodiscard]] unsigned int getButton() const;
unsigned int getButton() const;
/**
* Sets the timestamp for the input.
@ -135,7 +134,7 @@ namespace gcn
*
* @return the time stamp of the input.
*/
[[nodiscard]] int getTimeStamp() const;
int getTimeStamp() const;
/**
* Sets the x coordinate of the input.
@ -151,7 +150,7 @@ namespace gcn
* @return the x coordinate of the input.
* @since 0.6.0
*/
[[nodiscard]] int getX() const;
int getX() const;
/**
* Sets the y coordinate of the input.
@ -165,7 +164,7 @@ namespace gcn
* Gets the y coordinate of the input.
* @since 0.6.0
*/
[[nodiscard]] int getY() const;
int getY() const;
/**
* Mouse input event types. This enum partially corresponds
@ -192,11 +191,11 @@ namespace gcn
};
protected:
unsigned int mType{};
unsigned int mButton{};
int mTimeStamp{};
int mX{};
int mY{};
unsigned int mType;
unsigned int mButton;
int mTimeStamp;
int mX;
int mY;
};
}

View File

@ -77,8 +77,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~MouseListener()
= default;
virtual ~MouseListener() { }
/**
* Called when the mouse has entered into the widget area.
@ -88,6 +87,7 @@ namespace gcn
*/
virtual void mouseEntered(MouseEvent& mouseEvent)
{
}
/**
@ -97,6 +97,7 @@ namespace gcn
*/
virtual void mouseExited(MouseEvent& mouseEvent)
{
}
/**
@ -110,6 +111,7 @@ namespace gcn
*/
virtual void mousePressed(MouseEvent& mouseEvent)
{
}
/**
@ -119,6 +121,7 @@ namespace gcn
*/
virtual void mouseReleased(MouseEvent& mouseEvent)
{
}
/**
@ -130,6 +133,7 @@ namespace gcn
*/
virtual void mouseClicked(MouseEvent& mouseEvent)
{
}
/**
@ -140,6 +144,7 @@ namespace gcn
*/
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent)
{
}
/**
@ -150,6 +155,7 @@ namespace gcn
*/
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent)
{
}
/**
@ -161,6 +167,7 @@ namespace gcn
*/
virtual void mouseMoved(MouseEvent& mouseEvent)
{
}
/**
@ -172,6 +179,7 @@ namespace gcn
*/
virtual void mouseDragged(MouseEvent& mouseEvent)
{
}
protected:
@ -183,8 +191,7 @@ namespace gcn
* you must inherit from this class and implement it's
* functions.
*/
MouseListener()
= default;
MouseListener() { }
};
}

View File

@ -62,11 +62,12 @@
#include "guisan/platform.hpp"
extern "C" {
/**
* Exists to be able to check for Guichan OpenGL with autotools.
*/
GCN_EXTENSION_DECLSPEC extern void gcnOpenGL();
extern "C"
{
/**
* Exists to be able to check for Guichan OpenGL with autotools.
*/
GCN_EXTENSION_DECLSPEC extern void gcnOpenGL();
}
#endif // end GCN_OPENGL_HPP

View File

@ -106,7 +106,7 @@ namespace gcn
* @param x the point x coordinate.
* @param y the point y coordinate.
*/
[[nodiscard]] bool isPointInRect(int x, int y) const;
bool isPointInRect(int x, int y) const;
int x;
int y;

View File

@ -66,11 +66,12 @@
#include "platform.hpp"
extern "C" {
/**
* Exists to be able to check for Guichan SDL with autotools.
*/
GCN_EXTENSION_DECLSPEC extern void gcnSDL();
extern "C"
{
/**
* Exists to be able to check for Guisan SDL with autotools.
*/
GCN_EXTENSION_DECLSPEC extern void gcnSDL();
}
#endif // end GCN_SDL_HPP

View File

@ -102,7 +102,7 @@ namespace gcn
*
* @return the target SDL_Renderer.
*/
[[nodiscard]] virtual SDL_Renderer* getTarget() const;
virtual SDL_Renderer* getTarget() const;
/**
* Draws an SDL_Surface on the target surface. Normally you'll
@ -180,11 +180,11 @@ namespace gcn
*/
virtual void restoreRenderColor();
SDL_Surface* mTarget{};
SDL_Renderer* mRenderTarget{};
SDL_Texture* mTexture{};
SDL_Surface* mTarget;
SDL_Renderer* mRenderTarget;
SDL_Texture* mTexture;
Color mColor;
Uint8 r{}, g{}, b{}, a{}; //! to store previous color from renderer
Uint8 r, g, b, a; //! to store previous color from renderer
bool mAlpha;
};
}

View File

@ -102,7 +102,7 @@ namespace gcn
*
* @return the target SDL_Surface.
*/
[[nodiscard]] virtual SDL_Surface* getTarget() const;
virtual SDL_Surface* getTarget() const;
/**
* Draws an SDL_Surface on the target surface. Normally you'll
@ -117,29 +117,29 @@ namespace gcn
// Inherited from Graphics
void _beginDraw() override;
virtual void _beginDraw();
void _endDraw() override;
virtual void _endDraw();
bool pushClipArea(Rectangle area) override;
virtual bool pushClipArea(Rectangle area);
void popClipArea() override;
virtual void popClipArea();
void drawImage(const Image* image, int srcX, int srcY,
virtual void drawImage(const Image* image, int srcX, int srcY,
int dstX, int dstY, int width,
int height) override;
int height);
void drawPoint(int x, int y) override;
virtual void drawPoint(int x, int y);
void drawLine(int x1, int y1, int x2, int y2) override;
virtual void drawLine(int x1, int y1, int x2, int y2);
void drawRectangle(const Rectangle& rectangle) override;
virtual void drawRectangle(const Rectangle& rectangle);
void fillRectangle(const Rectangle& rectangle) override;
virtual void fillRectangle(const Rectangle& rectangle);
void setColor(const Color& color) override;
virtual void setColor(const Color& color);
const Color& getColor() override;
virtual const Color& getColor();
protected:
/**
@ -160,7 +160,7 @@ namespace gcn
*/
virtual void drawVLine(int x, int y1, int y2);
SDL_Surface* mTarget{};
SDL_Surface* mTarget;
Color mColor;
bool mAlpha;
};

View File

@ -83,7 +83,7 @@ namespace gcn
* @param autoFree true if the surface should automatically be deleted.
* @param renderer renderer object to create the texture (last parameter to avoid breaking stuff)
*/
SDLImage(SDL_Surface* surface, bool autoFree, SDL_Renderer* renderer = nullptr);
SDLImage(SDL_Surface* surface, bool autoFree, SDL_Renderer* renderer = NULL);
/**
* Destructor.
@ -95,33 +95,33 @@ namespace gcn
*
* @return the SDL surface for the image.
*/
[[nodiscard]] virtual SDL_Surface* getSurface() const;
virtual SDL_Surface* getSurface() const;
/**
* Gets the SDL texture for the image.
*
* @return the SDL texture for the image.
*/
[[nodiscard]] virtual SDL_Texture* getTexture() const;
virtual SDL_Texture* getTexture() const;
// Inherited from Image
void free() override;
virtual void free();
[[nodiscard]] int getWidth() const override;
virtual int getWidth() const;
[[nodiscard]] int getHeight() const override;
virtual int getHeight() const;
Color getPixel(int x, int y) override;
virtual Color getPixel(int x, int y);
void putPixel(int x, int y, const Color& color) override;
virtual void putPixel(int x, int y, const Color& color);
void convertToDisplayFormat() override;
virtual void convertToDisplayFormat();
protected:
SDL_Surface* mSurface;
SDL_Texture* mTexture{};
SDL_Renderer* mRenderer{};
SDL_Texture* mTexture = NULL;
SDL_Renderer* mRenderer = NULL;
bool mAutoFree;
};
}

View File

@ -95,20 +95,18 @@ namespace gcn
* 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
{
}
virtual void _pollInput() { }
// Inherited from Input
bool isKeyQueueEmpty() override;
virtual bool isKeyQueueEmpty();
KeyInput dequeueKeyInput() override;
virtual KeyInput dequeueKeyInput();
bool isMouseQueueEmpty() override;
virtual bool isMouseQueueEmpty();
MouseInput dequeueMouseInput() override;
virtual MouseInput dequeueMouseInput();
protected:
/**
@ -118,7 +116,7 @@ namespace gcn
* @param button an SDL mouse button.
* @return a Guisan mouse button.
*/
static int convertMouseButton(int button);
int convertMouseButton(int button);
/**
* Converts an SDL event key to a key value.
@ -127,7 +125,7 @@ namespace gcn
* @return a key value.
* @see Key
*/
static int convertKeyCharacter(SDL_Event event);
int convertKeyCharacter(SDL_Event event);
std::queue<KeyInput> mKeyInputQueue;
std::queue<MouseInput> mMouseInputQueue;

View File

@ -239,7 +239,6 @@ namespace gcn
break;
case 3:
unsigned int c;
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
{
unsigned int r = (p[0] * (255 - color.a) + color.r * color.a) >> 8;

View File

@ -67,7 +67,7 @@ namespace gcn
* @author Walluce Pinkham
* @author Olof Naessén
*/
class GCN_EXTENSION_DECLSPEC SDLTrueTypeFont : public Font
class GCN_EXTENSION_DECLSPEC SDLTrueTypeFont: public Font
{
public:
@ -131,16 +131,16 @@ namespace gcn
// Inherited from Font
[[nodiscard]] int getWidth(const std::string& text) const override;
virtual int getWidth(const std::string& text) const;
[[nodiscard]] int getHeight() const override;
virtual int getHeight() const;
void drawString(Graphics* graphics, const std::string& text, int x, int y) override;
virtual void drawString(Graphics* graphics, const std::string& text, int x, int y);
protected:
TTF_Font* mFont;
TTF_Font *mFont;
int mHeight{};
int mHeight;
int mGlyphSpacing;
int mRowSpacing;

View File

@ -80,8 +80,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~SelectionListener()
= default;
virtual ~SelectionListener() { }
/**
* Called when a value has been changed in a Widget. It is used
@ -90,9 +89,7 @@ namespace gcn
* @param event the event of the value change.
* @since 0.8.0
*/
virtual void valueChanged(const SelectionEvent& event)
{
}
virtual void valueChanged(const SelectionEvent& event) { }
};
}

View File

@ -124,9 +124,7 @@ namespace gcn
*
* @param graphics a Graphics object to draw with.
*/
virtual void drawBorder(Graphics* graphics)
{
}
virtual void drawBorder(Graphics* graphics) { }
/**
* Called for all widgets in the gui each time Gui::logic is called.
@ -134,9 +132,7 @@ namespace gcn
*
* @see Gui
*/
virtual void logic()
{
}
virtual void logic() { }
/**
* Gets the widget parent container.
@ -144,35 +140,35 @@ namespace gcn
* @return the widget parent container. Returns NULL if the widget
* has no parent.
*/
[[nodiscard]] virtual Widget* getParent() const;
virtual Widget* getParent() const;
/**
* Sets the width of the widget in pixels.
*
* @param width the widget width in pixels.
*/
virtual void setWidth(int width);
void setWidth(int width);
/**
* Gets the width of the widget in pixels.
*
* @return the widget with in pixels.
*/
[[nodiscard]] int getWidth() const;
int getWidth() const;
/**
* Sets the height of the widget in pixels.
*
* @param height the widget height in pixels.
*/
virtual void setHeight(int height);
void setHeight(int height);
/**
* Gets the height of the widget in pixels.
*
* @return the widget height in pixels.
*/
[[nodiscard]] auto getHeight() const -> int;
int getHeight() const;
/**
* Sets the size of the widget.
@ -180,7 +176,7 @@ namespace gcn
* @param width the width.
* @param height the height.
*/
virtual void setSize(int width, int height);
void setSize(int width, int height);
/**
* Set the widget x coordinate. It is relateive to it's parent.
@ -194,7 +190,7 @@ namespace gcn
*
* @return the widget x coordinate.
*/
[[nodiscard]] int getX() const;
int getX() const;
/**
* Set the widget y coordinate. It is relative to it's parent.
@ -208,7 +204,7 @@ namespace gcn
*
* @return the widget y coordinate.
*/
[[nodiscard]] int getY() const;
int getY() const;
/**
* Sets the widget position. It is relative to it's parent.
@ -223,7 +219,7 @@ namespace gcn
*
* @param dimension the widget dimension.
*/
virtual void setDimension(const Rectangle& dimension);
void setDimension(const Rectangle& dimension);
/**
* Sets the size of the border, or the width if you so like. The size
@ -243,14 +239,14 @@ namespace gcn
* @return the size of the border.
* @see drawBorder
*/
[[nodiscard]] unsigned int getBorderSize() const;
unsigned int getBorderSize() const;
/**
* Gets the dimension of the widget. It is relative to it's parent.
*
* @return the widget dimension.
*/
[[nodiscard]] const Rectangle& getDimension() const;
const Rectangle& getDimension() const;
/**
* Sets a widgets focusability.
@ -264,14 +260,14 @@ namespace gcn
*
* @return true if the widget is focusable.
*/
[[nodiscard]] bool isFocusable() const;
bool isFocusable() const;
/**
* Checks if the widget is focused.
*
* @return true if the widget currently has focus.
*/
[[nodiscard]] virtual bool isFocused() const;
virtual bool isFocused() const;
/**
* Sets the widget to be disabled or enabled. A disabled
@ -279,14 +275,14 @@ namespace gcn
*
* @param enabled true if widget is enabled.
*/
virtual void setEnabled(bool enabled);
void setEnabled(bool enabled);
/**
* Checks if a widget is disabled or not.
*
* @return true if the widget should be enabled.
*/
[[nodiscard]] bool isEnabled() const;
bool isEnabled() const;
/**
* Sets the widget to be visible.
@ -300,7 +296,7 @@ namespace gcn
*
* @return true if the widget is visible.
*/
[[nodiscard]] bool isVisible() const;
bool isVisible() const;
/**
* Sets the base color. The base color is the background
@ -308,56 +304,56 @@ namespace gcn
*
* @param color the baseground color.
*/
virtual void setBaseColor(const Color& color);
void setBaseColor(const Color& color);
/**
* Gets the base color.
*
* @return the foreground color.
*/
[[nodiscard]] const Color& getBaseColor() const;
const Color& getBaseColor() const;
/**
* Sets the foreground color.
*
* @param color the foreground color.
*/
virtual void setForegroundColor(const Color& color);
void setForegroundColor(const Color& color);
/**
* Gets the foreground color.
*
* @return the foreground color.
*/
[[nodiscard]] const Color& getForegroundColor() const;
const Color& getForegroundColor() const;
/**
* Sets the background color.
*
* @param color the background Color.
*/
virtual void setBackgroundColor(const Color& color);
void setBackgroundColor(const Color& color);
/**
* Gets the background color.
*
* @return the background color.
*/
[[nodiscard]] const Color& getBackgroundColor() const;
const Color& getBackgroundColor() const;
/**
* Sets the selection color.
*
* @param color the selection color.
*/
virtual void setSelectionColor(const Color& color);
void setSelectionColor(const Color& color);
/**
* Gets the selection color.
*
* @return the selection color.
*/
[[nodiscard]] const Color& getSelectionColor() const;
const Color& getSelectionColor() const;
/**
* Requests focus for the widget. A widget will only recieve focus
@ -513,7 +509,7 @@ namespace gcn
*
* @return the action event identifier.
*/
[[nodiscard]] const std::string& getActionEventId() const;
const std::string& getActionEventId() const;
/**
* Gets the absolute position on the screen for the widget.
@ -542,7 +538,7 @@ namespace gcn
*
* @return the used Font.
*/
[[nodiscard]] Font* getFont() const;
Font* getFont() const;
/**
* Sets the global font to be used by default for all widgets.
@ -556,16 +552,14 @@ namespace gcn
*
* @param font the Font.
*/
virtual void setFont(Font* font);
void setFont(Font* font);
/**
* Called when the font has changed. If the change is global,
* this function will only be called if the widget don't have a
* font already set.
*/
virtual void fontChanged()
{
}
virtual void fontChanged() { }
/**
* Checks whether a widget exists or not, that is if it still exists
@ -583,7 +577,7 @@ namespace gcn
*
* @return true if tab in is enabled.
*/
[[nodiscard]] bool isTabInEnabled() const;
bool isTabInEnabled() const;
/**
* Sets tab in enabled. Tab in means that you can set focus
@ -603,7 +597,7 @@ namespace gcn
*
* @return true if tab out is enabled.
*/
[[nodiscard]] bool isTabOutEnabled() const;
bool isTabOutEnabled() const;
/**
* Sets tab out enabled. Tab out means that you can lose
@ -650,14 +644,14 @@ namespace gcn
/**
* Checks if the widget or it's parent has modal focus.
*/
[[nodiscard]] virtual bool hasModalFocus() const;
virtual bool hasModalFocus() const;
/**
* Checks if the widget or it's parent has modal mouse input focus.
*
* @since 0.6.0
*/
[[nodiscard]] virtual bool hasModalMouseInputFocus() const;
virtual bool hasModalMouseInputFocus() const;
/**
* Gets a widget from a certain position in the widget.
@ -721,7 +715,7 @@ namespace gcn
*
* @param focusHandler the FocusHandler to be used.
*/
virtual void setInternalFocusHandler(FocusHandler* focusHandler);
void setInternalFocusHandler(FocusHandler* focusHandler);
/**
* Moves a widget to the top of this widget. The moved widget will be
@ -729,9 +723,7 @@ namespace gcn
*
* @param widget the widget to move.
*/
virtual void moveToTop(Widget* widget)
{
};
virtual void moveToTop(Widget* widget) { };
/**
* Moves a widget in this widget to the bottom of this widget.
@ -739,23 +731,17 @@ namespace gcn
*
* @param widget the widget to move.
*/
virtual void moveToBottom(Widget* widget)
{
};
virtual void moveToBottom(Widget* widget) { };
/**
* Focuses the next widget in the widget.
*/
virtual void focusNext()
{
};
virtual void focusNext() { };
/**
* Focuses the previous widget in the widget.
*/
virtual void focusPrevious()
{
};
virtual void focusPrevious() { };
/**
* Tries to show a specific part of a widget by moving it. Used if the
@ -764,9 +750,7 @@ namespace gcn
* @param widget the target widget.
* @param area the area to show.
*/
virtual void showWidgetPart(Widget* widget, Rectangle area)
{
};
virtual void showWidgetPart(Widget* widget, Rectangle area) { };
/**
* Sets an id of a widget. An id can be useful if a widget needs to be
@ -788,7 +772,7 @@ namespace gcn
* @param id the id to set to the widget.
* @see BasicContainer::findWidgetById
*/
const std::string& getId() const;
const std::string& getId();
protected:
/**

View File

@ -81,8 +81,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~WidgetListener()
= default;
virtual ~WidgetListener() { }
/**
* Invoked when a widget changes its size.
@ -90,9 +89,7 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
virtual void widgetResized(const Event& event)
{
}
virtual void widgetResized(const Event& event) { }
/**
* Invoked when a widget is moved.
@ -100,9 +97,7 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
virtual void widgetMoved(const Event& event)
{
}
virtual void widgetMoved(const Event& event) { }
/**
* Invoked when a widget is hidden, i.e it's set to be
@ -111,9 +106,7 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
virtual void widgetHidden(const Event& event)
{
}
virtual void widgetHidden(const Event& event) { }
/**
* Invoked when a widget is shown, i.e it's set to be
@ -122,9 +115,7 @@ namespace gcn
* @param event Describes the event.
* @since 0.8.0
*/
virtual void widgetShown(const Event& event)
{
}
virtual void widgetShown(const Event& event) { }
};
}

View File

@ -92,7 +92,7 @@ namespace gcn
*
* @param caption the caption of the Button.
*/
explicit Button(std::string caption);
Button(const std::string& caption);
/**
* Sets the Button caption.
@ -106,7 +106,7 @@ namespace gcn
*
* @return the Button caption.
*/
[[nodiscard]] const std::string& getCaption() const;
const std::string& getCaption() const;
/**
* Sets the alignment for the caption.
@ -114,14 +114,14 @@ namespace gcn
* @param alignment Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT
* @see Graphics
*/
virtual void setAlignment(unsigned int alignment);
void setAlignment(unsigned int alignment);
/**
* Gets the alignment for the caption.
*
* @return alignment of caption.
*/
[[nodiscard]] virtual unsigned int getAlignment() const;
unsigned int getAlignment() const;
/**
* Sets the spacing between the border of this button and its caption.
@ -136,51 +136,51 @@ namespace gcn
*
* @return spacing.
*/
[[nodiscard]] unsigned int getSpacing() const;
unsigned int getSpacing() const;
/**
* Adjusts the buttons size to fit the content.
*/
virtual void adjustSize();
void adjustSize();
/**
* Checks if the button is pressed down. Useful when drawing.
*
* @return true if the button is pressed down.
*/
[[nodiscard]] bool isPressed() const;
bool isPressed() const;
//Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
// Inherited from FocusListener
void focusLost(const Event& event) override;
virtual void focusLost(const Event& event);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseReleased(MouseEvent& mouseEvent) override;
virtual void mouseReleased(MouseEvent& mouseEvent);
void mouseEntered(MouseEvent& mouseEvent) override;
virtual void mouseEntered(MouseEvent& mouseEvent);
void mouseExited(MouseEvent& mouseEvent) override;
virtual void mouseExited(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
void keyReleased(KeyEvent& keyEvent) override;
virtual void keyReleased(KeyEvent& keyEvent);
protected:
std::string mCaption;

View File

@ -98,8 +98,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~CheckBox()
= default;
virtual ~CheckBox() { }
/**
* Checks if the check box is selected.
@ -107,7 +106,7 @@ namespace gcn
* @return True if the check box is selected, false otherwise.
* @see setSelected
*/
[[nodiscard]] bool isSelected() const;
bool isSelected() const;
/**
* Sets the check box to be selected.
@ -123,7 +122,7 @@ namespace gcn
* @return The caption of the check box.
* @see setCaption
*/
[[nodiscard]] const std::string& getCaption() const;
const std::string& getCaption() const;
/**
* Sets the caption of the check box. It's advisable to call
@ -143,21 +142,21 @@ namespace gcn
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
// Inherited from MouseListener
void mouseClicked(MouseEvent& mouseEvent) override;
virtual void mouseClicked(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
protected:
@ -177,7 +176,7 @@ namespace gcn
/**
* True if the check box is selected, false otherwise.
*/
bool mSelected{};
bool mSelected;
/**
* Holds the caption of the check box.

View File

@ -102,7 +102,7 @@ namespace gcn
* @param opaque True if the container should be opaque, false otherwise.
* @see isOpaque
*/
virtual void setOpaque(bool opaque);
void setOpaque(bool opaque);
/**
* Checks if the container is opaque or not.
@ -110,7 +110,7 @@ namespace gcn
* @return true if the container is opaque, false otherwise.
* @see setOpaque
*/
[[nodiscard]] bool isOpaque() const;
bool isOpaque() const;
/**
* Adds a widget to the container.
@ -118,7 +118,7 @@ namespace gcn
* @param widget The widget to add.
* @see remove, clear
*/
void add(Widget* widget) override;
virtual void add(Widget* widget);
/**
* Adds a widget to the container and also specifies the widget's
@ -140,14 +140,14 @@ namespace gcn
* container.
* @see add, clear
*/
void remove(Widget* widget) override;
virtual void remove(Widget* widget);
/**
* Clears the container of all widgets.
*
* @see add, remove
*/
void clear() override;
virtual void clear();
/**
* Finds a widget given an id.
@ -157,14 +157,14 @@ namespace gcn
* is found.
* @see Widget::setId
*/
Widget* findWidgetById(const std::string& id) override;
virtual Widget* findWidgetById(const std::string& id);
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
protected:
/**

View File

@ -105,9 +105,9 @@ namespace gcn
* @param listBox the listBox to use.
* @see ListModel, ScrollArea, ListBox.
*/
DropDown(ListModel* listModel = nullptr,
ScrollArea* scrollArea = nullptr,
ListBox* listBox = nullptr);
DropDown(ListModel* listModel = NULL,
ScrollArea* scrollArea = NULL,
ListBox* listBox = NULL);
/**
* Destructor.
@ -120,7 +120,7 @@ namespace gcn
* @return the selected item as an index in the list model.
* @see setSelected
*/
[[nodiscard]] int getSelected() const;
int getSelected() const;
/**
* Sets the selected item. The selected item is represented by
@ -134,7 +134,7 @@ namespace gcn
/*
* Clears any selected item
*/
virtual void clearSelected(void) const;
void clearSelected(void) const;
/**
* Sets the list model to use when displaying the list.
@ -150,7 +150,7 @@ namespace gcn
* @return the ListModel used.
* @see setListModel
*/
[[nodiscard]] ListModel* getListModel() const;
ListModel* getListModel();
/**
* Adjusts the height of the drop down to fit the height of the
@ -180,76 +180,76 @@ namespace gcn
/*
* Returns the current Dropdown status
*/
[[nodiscard]] virtual bool isDroppedDown() const;
bool isDroppedDown();
/**
* Sets the DropDown Widget to dropped-down mode.
*/
void dropDown();
virtual void dropDown();
/**
* Sets the DropDown Widget to folded-up mode.
*/
void foldUp();
virtual void foldUp();
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
void setBaseColor(const Color& color) override;
void setBaseColor(const Color& color);
void setBackgroundColor(const Color& color) override;
void setBackgroundColor(const Color& color);
void setForegroundColor(const Color& color) override;
void setForegroundColor(const Color& color);
void setFont(Font* font) override;
void setFont(Font* font);
void setSelectionColor(const Color& color) override;
void setSelectionColor(const Color& color);
// Inherited from BasicContainer
Rectangle getChildrenArea() override;
virtual Rectangle getChildrenArea();
// Inherited from FocusListener
void focusLost(const Event& event) override;
virtual void focusLost(const Event& event);
// Inherited from ActionListener
void action(const ActionEvent& actionEvent) override;
virtual void action(const ActionEvent& actionEvent);
// Inherited from DeathListener
void death(const Event& event) override;
virtual void death(const Event& event);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseReleased(MouseEvent& mouseEvent) override;
virtual void mouseReleased(MouseEvent& mouseEvent);
void mouseWheelMovedUp(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
void mouseWheelMovedDown(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
// Inherited from SelectionListener
void valueChanged(const SelectionEvent& event) override;
virtual void valueChanged(const SelectionEvent& event);
protected:
@ -277,7 +277,7 @@ namespace gcn
* 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;
/**
* The scroll area used.

View File

@ -91,9 +91,9 @@ namespace gcn
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
protected:
/**

View File

@ -67,7 +67,7 @@ namespace gcn
/**
* A simple button that displays an image instead of a caption.
*/
class GCN_CORE_DECLSPEC ImageButton : public Button
class GCN_CORE_DECLSPEC ImageButton : public gcn::Button
{
public:
/**
@ -92,29 +92,29 @@ namespace gcn
/**
* Adjusts the size of the image button to fit the image.
*/
void adjustSize() override;
void adjustSize();
/**
* Sets the image to display.
*
* @param image The image to display.
*/
virtual void setImage(Image* image);
void setImage(Image* image);
/**
* Gets the image of the image button.
*
* @return The image of the image button.
*/
virtual Image* getImage();
Image* getImage();
// Inherited from Widget
void draw(Graphics* graphics) override;
void draw(gcn::Graphics* graphics);
protected:
Image* mImage;
gcn::Image* mImage;
/**
* True if the image has been loaded internally, false otherwise.

View File

@ -88,7 +88,7 @@ namespace gcn
* @return The caption of the label.
* @see setCaption
*/
[[nodiscard]] virtual const std::string& getCaption() const;
const std::string& getCaption() const;
/**
* Sets the caption of the label. It's advisable to call
@ -98,7 +98,7 @@ namespace gcn
* @param caption The caption of the label.
* @see getCaption, adjustSize
*/
virtual void setCaption(const std::string& caption);
void setCaption(const std::string& caption);
/**
* Sets the alignment for the caption. The alignment is relative
@ -107,7 +107,7 @@ namespace gcn
* @param alignment Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.
* @see getAlignment, Graphics
*/
virtual void setAlignment(unsigned int alignment);
void setAlignment(unsigned int alignment);
/**
* Gets the alignment for the caption. The alignment is relative to
@ -116,19 +116,19 @@ namespace gcn
* @return alignment of caption. Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.
* @see setAlignment, Graphics
*/
[[nodiscard]] virtual unsigned int getAlignment() const;
unsigned int getAlignment() const;
/**
* Adjusts the label's size to fit the caption size.
*/
virtual void adjustSize();
void adjustSize();
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
protected:
/**

View File

@ -101,8 +101,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~ListBox()
= default;
virtual ~ListBox() { }
/**
* Gets the selected item as an index in the list model.
@ -110,7 +109,7 @@ namespace gcn
* @return the selected item as an index in the list model.
* @see setSelected
*/
[[nodiscard]] int getSelected() const;
int getSelected() const;
/**
* Sets the selected item. The selected item is represented by
@ -135,7 +134,7 @@ namespace gcn
* @return the list model used.
* @see setListModel
*/
[[nodiscard]] ListModel* getListModel() const;
ListModel* getListModel();
/**
* Adjusts the size of the list box to fit it's list model.
@ -153,7 +152,7 @@ namespace gcn
* @return true if wrapping is enabled, false otherwise.
* @see setWrappingEnabled
*/
[[nodiscard]] bool isWrappingEnabled() const;
bool isWrappingEnabled() const;
/**
* Sets the list box to wrap or not when selecting items with a keyboard.
@ -188,27 +187,27 @@ namespace gcn
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
void logic() override;
virtual void logic();
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseWheelMovedUp(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
void mouseWheelMovedDown(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
protected:
@ -223,7 +222,7 @@ namespace gcn
/**
* The list model to use.
*/
ListModel* mListModel{};
ListModel* mListModel;
/**
* The selected item as an index in the list model.

View File

@ -202,9 +202,9 @@ namespace gcn
*/
unsigned int 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
unsigned int mStart; //! minimum value of the progressbar
unsigned int mEnd; //! maximum value of the progressbar
unsigned int mValue; //! current value of the progressbar
};
}

View File

@ -111,7 +111,7 @@ namespace gcn
* @return True if the radio button is selecte, false otherwise.
* @see setSelected
*/
[[nodiscard]] bool isSelected() const;
bool isSelected() const;
/**
* Sets the radio button to selected or not.
@ -128,7 +128,7 @@ namespace gcn
* @return The caption of the radio button.
* @see setCaption
*/
[[nodiscard]] const std::string& getCaption() const;
const std::string& getCaption() const;
/**
* Sets the caption of the radio button. It's advisable to call
@ -138,7 +138,7 @@ namespace gcn
* @param caption The caption of the radio button.
* @see getCaption, adjustSize
*/
void setCaption(std::string caption);
void setCaption(const std::string caption);
/**
* Sets the group the radio button should belong to. Note that
@ -156,7 +156,7 @@ namespace gcn
* @return The group the radio button belongs to.
* @see setGroup
*/
[[nodiscard]] const std::string& getGroup() const;
const std::string& getGroup() const;
/**
* Adjusts the radio button's size to fit the caption.
@ -166,21 +166,21 @@ namespace gcn
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
// Inherited from MouseListener
void mouseClicked(MouseEvent& mouseEvent) override;
virtual void mouseClicked(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
protected:
/**
@ -193,7 +193,7 @@ namespace gcn
/**
* True if the radio button is selected, false otherwise.
*/
bool mSelected{};
bool mSelected;
/**
* Holds the caption of the radio button.

View File

@ -134,7 +134,7 @@ namespace gcn
* @return the policy for the horizontal scrollbar policy. See enum with
* policies.
*/
[[nodiscard]] unsigned int getHorizontalScrollPolicy() const;
unsigned int getHorizontalScrollPolicy() const;
/**
* Sets the vertical scrollbar policy. See enum with policies.
@ -150,7 +150,7 @@ namespace gcn
* @return the policy for the vertical scrollbar. See enum with
* policies.
*/
[[nodiscard]] unsigned int getVerticalScrollPolicy() const;
unsigned int getVerticalScrollPolicy() const;
/**
* Sets the horizontal and vertical scrollbar policy. See enum with policies.
@ -173,7 +173,7 @@ namespace gcn
* Gets the amount that is scrolled vertically.
* @return the scroll amount on vertical scroll.
*/
[[nodiscard]] int getVerticalScrollAmount() const;
int getVerticalScrollAmount() const;
/**
* Sets the amount to scroll horizontally.
@ -187,7 +187,7 @@ namespace gcn
*
* @return the scroll amount on horizontal scroll.
*/
[[nodiscard]] int getHorizontalScrollAmount() const;
int getHorizontalScrollAmount() const;
/**
* Sets the amount to scroll horizontally and vertically.
@ -223,7 +223,7 @@ namespace gcn
* @return the width of the ScrollBar.
*/
[[nodiscard]] int getScrollbarWidth() const;
int getScrollbarWidth() const;
/**
* Sets the amount to scroll in pixels when the left scroll button is
@ -255,7 +255,7 @@ namespace gcn
*
* @return the amount to scroll when the left scroll button is pushed.
*/
[[nodiscard]] int getLeftButtonScrollAmount() const;
int getLeftButtonScrollAmount() const;
/**
* Gets the amount to scroll in pixels when the right scroll button is
@ -263,7 +263,7 @@ namespace gcn
*
* @return the amount to scroll when the right scroll button is pushed.
*/
[[nodiscard]] int getRightButtonScrollAmount() const;
int getRightButtonScrollAmount() const;
/**
* Gets the amount to scroll in pixels when the up scroll button is
@ -271,7 +271,7 @@ namespace gcn
*
* @return the amount to scroll when the up scroll button is pushed.
*/
[[nodiscard]] int getUpButtonScrollAmount() const;
int getUpButtonScrollAmount() const;
/**
* Gets the amount to scroll in pixels when the down scroll button is
@ -279,44 +279,44 @@ namespace gcn
*
* @return the amount to scroll when the down scroll button is pushed.
*/
[[nodiscard]] int getDownButtonScrollAmount() const;
int getDownButtonScrollAmount() const;
// Inherited from BasicContainer
void showWidgetPart(Widget* widget, Rectangle area) override;
virtual void showWidgetPart(Widget* widget, Rectangle area);
Rectangle getChildrenArea() override;
virtual Rectangle getChildrenArea();
Widget* getWidgetAt(int x, int y) override;
virtual Widget* getWidgetAt(int x, int y);
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
void logic() override;
virtual void logic();
void setWidth(int width) override;
void setWidth(int width);
void setHeight(int height) override;
void setHeight(int height);
void setDimension(const Rectangle& dimension) override;
void setDimension(const Rectangle& dimension);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseReleased(MouseEvent& mouseEvent) override;
virtual void mouseReleased(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
void mouseWheelMovedUp(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
void mouseWheelMovedDown(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
/**
@ -410,42 +410,42 @@ namespace gcn
*
* @return the dimension of the up button.
*/
Rectangle getUpButtonDimension() const;
Rectangle getUpButtonDimension();
/**
* Gets the down button dimension.
*
* @return the dimension of the down button.
*/
Rectangle getDownButtonDimension() const;
Rectangle getDownButtonDimension();
/**
* Gets the left button dimension.
*
* @return the dimension of the left button.
*/
Rectangle getLeftButtonDimension() const;
Rectangle getLeftButtonDimension();
/**
* Gets the right button dimension.
*
* @return the dimension of the right button.
*/
Rectangle getRightButtonDimension() const;
Rectangle getRightButtonDimension();
/**
* Gets the vertical scrollbar dimension.
*
* @return the dimension of the vertical scrollbar.
*/
Rectangle getVerticalBarDimension() const;
Rectangle getVerticalBarDimension();
/**
* Gets the horizontal scrollbar dimension.
*
* @return the dimension of the horizontal scrollbar.
*/
Rectangle getHorizontalBarDimension() const;
Rectangle getHorizontalBarDimension();
/**
* Gets the vertical marker dimension.
@ -466,8 +466,8 @@ namespace gcn
int mScrollbarWidth;
unsigned int mHPolicy;
unsigned int mVPolicy;
bool mVBarVisible{};
bool mHBarVisible{};
bool mVBarVisible;
bool mHBarVisible;
bool mUpButtonPressed;
bool mDownButtonPressed;
bool mLeftButtonPressed;
@ -478,8 +478,8 @@ namespace gcn
int mRightButtonScrollAmount;
bool mIsVerticalMarkerDragged;
bool mIsHorizontalMarkerDragged;
int mHorizontalMarkerDragOffset{};
int mVerticalMarkerDragOffset{};
int mHorizontalMarkerDragOffset;
int mVerticalMarkerDragOffset;
};
}

View File

@ -94,8 +94,7 @@ namespace gcn
/**
* Destructor.
*/
virtual ~Slider()
= default;
virtual ~Slider() { }
/**
* Sets the scale.
@ -110,7 +109,7 @@ namespace gcn
*
* @return the scale start.
*/
[[nodiscard]] double getScaleStart() const;
double getScaleStart() const;
/**
* Sets the scale start.
@ -124,7 +123,7 @@ namespace gcn
*
* @return the scale end.
*/
[[nodiscard]] double getScaleEnd() const;
double getScaleEnd() const;
/**
* Sets the scale end.
@ -138,7 +137,7 @@ namespace gcn
*
* @return the current value.
*/
[[nodiscard]] double getValue() const;
double getValue() const;
/**
* Sets the current value.
@ -152,7 +151,7 @@ namespace gcn
*
* @param graphics a graphics object to draw with.
*/
virtual void drawMarker(Graphics* graphics);
virtual void drawMarker(gcn::Graphics* graphics);
/**
* Sets the length of the marker.
@ -166,7 +165,7 @@ namespace gcn
*
* @return the length of the marker.
*/
[[nodiscard]] int getMarkerLength() const;
int getMarkerLength() const;
/**
* Sets the orientation of the slider. A slider can be drawn verticaly
@ -181,7 +180,7 @@ namespace gcn
*
* @return the orientation of the slider.
*/
[[nodiscard]] unsigned int getOrientation() const;
unsigned int getOrientation() const;
/**
* Sets the step length. Step length is used when the keys left and
@ -196,30 +195,30 @@ namespace gcn
*
* @return the step length.
*/
[[nodiscard]] double getStepLength() const;
double getStepLength() const;
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(gcn::Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(gcn::Graphics* graphics);
// Inherited from MouseListener.
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
void mouseWheelMovedUp(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
void mouseWheelMovedDown(MouseEvent& mouseEvent) override;
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
/**
* Draw orientations for the slider. It can be drawn vertically or
@ -238,7 +237,7 @@ namespace gcn
* @param v the position to convert.
* @return the value corresponding to the position.
*/
[[nodiscard]] virtual double markerPositionToValue(int v) const;
virtual double markerPositionToValue(int v) const;
/**
* Converts a value to a marker position.
@ -246,22 +245,22 @@ namespace gcn
* @param value the value to convert.
* @return the position corresponding to the value.
*/
[[nodiscard]] virtual int valueToMarkerPosition(double value) const;
virtual int valueToMarkerPosition(double value) const;
/**
* Gets the marker position for the current value.
*
* @return the marker position for the current value.
*/
[[nodiscard]] virtual int getMarkerPosition() const;
virtual int getMarkerPosition() const;
bool mMouseDrag;
double mValue{};
double mStepLength{};
int mMarkerLength{};
double mValue;
double mStepLength;
int mMarkerLength;
double mScaleStart;
double mScaleEnd;
unsigned int mOrientation{};
unsigned int mOrientation;
};
}

View File

@ -105,7 +105,7 @@ namespace gcn
*
* @return The tabbed are the tab is a part of.
*/
[[nodiscard]] TabbedArea* getTabbedArea() const;
TabbedArea* getTabbedArea();
/**
* Sets the caption of the tab.
@ -119,25 +119,25 @@ namespace gcn
*
* @return The caption of the tab.
*/
[[nodiscard]] const std::string& getCaption() const;
const std::string& getCaption() const;
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
// Inherited from MouseListener
void mouseEntered(MouseEvent& mouseEvent) override;
virtual void mouseEntered(MouseEvent& mouseEvent);
void mouseExited(MouseEvent& mouseEvent) override;
virtual void mouseExited(MouseEvent& mouseEvent);
protected:
Label* mLabel;
TabbedArea* mTabbedArea{};
TabbedArea* mTabbedArea;
std::string mCaption;
bool mHasMouse;
};

View File

@ -130,7 +130,7 @@ namespace gcn
* @param index The index of the tab to check.
* @return True if the tab is selected, false otherwise.
*/
virtual auto isTabSelected(unsigned int index) const -> bool;
virtual bool isTabSelected(unsigned int index) const;
/**
* Checks whether a tab is selected or not.
@ -160,7 +160,7 @@ namespace gcn
* @return The index of the selected tab.
* If no tab is selected -1 will be returned.
*/
[[nodiscard]] virtual int getSelectedTabIndex() const;
virtual int getSelectedTabIndex() const;
/**
* Gets the selected tab.
@ -172,39 +172,39 @@ namespace gcn
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
void logic() override;
virtual void logic();
void setWidth(int width) override;
void setWidth(int width);
void setHeight(int height) override;
void setHeight(int height);
void setSize(int width, int height) override;
void setSize(int width, int height);
void setDimension(const Rectangle& dimension) override;
void setDimension(const Rectangle& dimension);
// Inherited from ActionListener
void action(const ActionEvent& actionEvent) override;
void action(const ActionEvent& actionEvent);
// Inherited from DeathListener
void death(const Event& event) override;
virtual void death(const Event& event);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
protected:

View File

@ -103,14 +103,14 @@ namespace gcn
* Gets the text.
* @return the text of the TextBox.
*/
[[nodiscard]] std::string getText() const;
std::string getText() const;
/**
* Gets the row of a text.
*
* @return the text of a certain row in the TextBox.
*/
[[nodiscard]] const std::string& getTextRow(int row) const;
const std::string& getTextRow(int row) const;
/**
* Sets the text of a certain row in a TextBox.
@ -125,14 +125,14 @@ namespace gcn
*
* @return the number of rows in the text.
*/
[[nodiscard]] unsigned int getNumberOfRows() const;
unsigned int getNumberOfRows() const;
/**
* Gets the caret position in the text.
*
* @return the caret position in the text.
*/
[[nodiscard]] unsigned int getCaretPosition() const;
unsigned int getCaretPosition() const;
/**
* Sets the position of the caret in the text.
@ -146,7 +146,7 @@ namespace gcn
*
* @return the row the caret is in in the text.
*/
[[nodiscard]] unsigned int getCaretRow() const;
unsigned int getCaretRow() const;
/**
* Sets the row the caret should be in in the text.
@ -160,7 +160,7 @@ namespace gcn
*
* @return the column the caret is in in the text.
*/
[[nodiscard]] unsigned int getCaretColumn() const;
unsigned int getCaretColumn() const;
/**
* Sets the column the caret should be in in the text.
@ -187,7 +187,7 @@ namespace gcn
*
* @return true it the TextBox is editable.
*/
[[nodiscard]] bool isEditable() const;
bool isEditable() const;
/**
* Sets if the TextBox should be editable or not.
@ -201,14 +201,14 @@ namespace gcn
*
* @param row a row.
*/
virtual void addRow(std::string row);
virtual void addRow(const std::string row);
/**
* Checks if the TextBox is opaque
*
* @return true if the TextBox is opaque
*/
[[nodiscard]] bool isOpaque() const;
bool isOpaque();
/**
* Sets the TextBox to be opaque.
@ -220,23 +220,23 @@ namespace gcn
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
void fontChanged() override;
virtual void fontChanged();
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
protected:
/**

View File

@ -99,7 +99,7 @@ namespace gcn
*
* @return the text of the TextField.
*/
[[nodiscard]] const std::string& getText() const;
const std::string& getText() const;
/**
* Draws the caret (the little marker in the text that shows where the
@ -137,28 +137,28 @@ namespace gcn
*
* @return the caret position.
*/
[[nodiscard]] unsigned int getCaretPosition() const;
unsigned int getCaretPosition() const;
// Inherited from Widget
void fontChanged() override;
virtual void fontChanged();
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
// Inherited from KeyListener
void keyPressed(KeyEvent& keyEvent) override;
virtual void keyPressed(KeyEvent& keyEvent);
protected:
/**

View File

@ -96,7 +96,7 @@ namespace gcn
* @return True if the button is selected, false otherwise.
* @see setSelected
*/
[[nodiscard]] bool isSelected() const;
bool isSelected() const;
/**
* Sets the button to be selected.
@ -109,17 +109,17 @@ namespace gcn
//Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
// Inherited from MouseListener
void mouseReleased(MouseEvent& mouseEvent) override;
virtual void mouseReleased(MouseEvent& mouseEvent);
// Inherited from KeyListener
void keyReleased(KeyEvent& keyEvent) override;
virtual void keyReleased(KeyEvent& keyEvent);
protected:
/**

View File

@ -94,28 +94,28 @@ namespace gcn
*
* @param caption the Window caption.
*/
virtual void setCaption(const std::string& caption);
void setCaption(const std::string& caption);
/**
* Gets the Window caption.
*
* @return the Window caption.
*/
[[nodiscard]] virtual const std::string& getCaption() const;
const std::string& getCaption() const;
/**
* Sets the alignment for the caption.
*
* @param alignment Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.
*/
virtual void setAlignment(unsigned int alignment);
void setAlignment(unsigned int alignment);
/**
* Gets the alignment for the caption.
*
* @return alignment of caption.
*/
[[nodiscard]] virtual unsigned int getAlignment() const;
unsigned int getAlignment() const;
/**
* Sets the padding of the window which is the distance between the
@ -123,28 +123,28 @@ namespace gcn
*
* @param padding the padding value.
*/
virtual void setPadding(unsigned int padding);
void setPadding(unsigned int padding);
/**
* Gets the padding.
*
* @return the padding value.
*/
[[nodiscard]] virtual unsigned int getPadding() const;
unsigned int getPadding() const;
/**
* Sets the title bar height.
*
* @param height the title height value.
*/
virtual void setTitleBarHeight(unsigned int height);
void setTitleBarHeight(unsigned int height);
/**
* Gets the title bar height.
*
* @return the title bar height.
*/
virtual unsigned int getTitleBarHeight();
unsigned int getTitleBarHeight();
/**
* Sets the Window to be moveable.
@ -158,7 +158,7 @@ namespace gcn
*
* @return true or false.
*/
[[nodiscard]] virtual bool isMovable() const;
bool isMovable() const;
/**
* Sets the Window to be opaque. If it's not opaque, the content area
@ -166,14 +166,14 @@ namespace gcn
*
* @param opaque true or false.
*/
void setOpaque(bool opaque) override;
void setOpaque(bool opaque);
/**
* Checks if the Window is opaque.
*
* @return true or false.
*/
virtual bool isOpaque();
bool isOpaque();
/**
* Resizes the container to fit the content exactly.
@ -183,33 +183,33 @@ namespace gcn
// Inherited from BasicContainer
Rectangle getChildrenArea() override;
virtual Rectangle getChildrenArea();
// Inherited from Widget
void draw(Graphics* graphics) override;
virtual void draw(Graphics* graphics);
void drawBorder(Graphics* graphics) override;
virtual void drawBorder(Graphics* graphics);
// Inherited from MouseListener
void mousePressed(MouseEvent& mouseEvent) override;
virtual void mousePressed(MouseEvent& mouseEvent);
void mouseDragged(MouseEvent& mouseEvent) override;
virtual void mouseDragged(MouseEvent& mouseEvent);
void mouseReleased(MouseEvent& mouseEvent) override;
virtual void mouseReleased(MouseEvent& mouseEvent);
protected:
std::string mCaption;
unsigned int mAlignment{};
unsigned int mPadding{};
unsigned int mTitleBarHeight{};
bool mMovable{};
bool mOpaque{};
int mDragOffsetX{};
int mDragOffsetY{};
unsigned int mAlignment;
unsigned int mPadding;
unsigned int mTitleBarHeight;
bool mMovable;
bool mOpaque;
int mDragOffsetX;
int mDragOffsetY;
bool mIsMoving;
};
}

View File

@ -58,17 +58,15 @@
* For comments regarding functions please see the header file.
*/
#include <utility>
#include "guisan/actionevent.hpp"
namespace gcn
{
ActionEvent::ActionEvent(Widget* source, std::string id)
ActionEvent::ActionEvent(Widget* source, const std::string& id)
: Event(source),
mId(std::move(id))
mId(id)
{
}
ActionEvent::~ActionEvent()

View File

@ -71,7 +71,7 @@ namespace gcn
{
BasicContainer::~BasicContainer()
{
BasicContainer::clear();
clear();
}
void BasicContainer::moveToTop(Widget* widget)
@ -130,7 +130,7 @@ namespace gcn
}
}
const auto end = it;
const WidgetListIterator end = it;
if (it == mWidgets.end())
{
@ -166,7 +166,7 @@ namespace gcn
}
}
const auto end = it;
const WidgetListReverseIterator end = it;
++it;
@ -192,11 +192,11 @@ namespace gcn
Widget* BasicContainer::getWidgetAt(int x, int y)
{
const auto r = getChildrenArea();
const Rectangle r = getChildrenArea();
if (!r.isPointInRect(x, y))
{
return nullptr;
return NULL;
}
x -= r.x;
@ -210,7 +210,7 @@ namespace gcn
}
}
return nullptr;
return NULL;
}
void BasicContainer::logic()
@ -222,7 +222,7 @@ namespace gcn
{
Widget::_setFocusHandler(focusHandler);
if (mInternalFocusHandler != nullptr)
if (mInternalFocusHandler != NULL)
{
return;
}
@ -237,7 +237,7 @@ namespace gcn
{
mWidgets.push_back(widget);
if (mInternalFocusHandler == nullptr)
if (mInternalFocusHandler == NULL)
{
widget->_setFocusHandler(_getFocusHandler());
}
@ -257,8 +257,8 @@ namespace gcn
if (*iter == widget)
{
mWidgets.erase(iter);
widget->_setFocusHandler(nullptr);
widget->_setParent(nullptr);
widget->_setFocusHandler(NULL);
widget->_setParent(NULL);
widget->removeDeathListener(this);
return;
}
@ -271,8 +271,8 @@ namespace gcn
{
for (auto& mWidget : mWidgets)
{
mWidget->_setFocusHandler(nullptr);
mWidget->_setParent(nullptr);
mWidget->_setFocusHandler(NULL);
mWidget->_setParent(NULL);
mWidget->removeDeathListener(this);
}
@ -291,7 +291,7 @@ namespace gcn
// draw it before drawing the widget
if (mWidget->getBorderSize() > 0)
{
auto rec = mWidget->getDimension();
Rectangle rec = mWidget->getDimension();
rec.x -= static_cast<int>(mWidget->getBorderSize());
rec.y -= static_cast<int>(mWidget->getBorderSize());
rec.width += 2 * static_cast<int>(mWidget->getBorderSize());
@ -320,7 +320,7 @@ namespace gcn
void BasicContainer::showWidgetPart(Widget* widget, Rectangle area)
{
const auto widgetArea = getChildrenArea();
const Rectangle widgetArea = getChildrenArea();
area.x += widget->getX();
area.y += widget->getY();
@ -352,7 +352,7 @@ namespace gcn
for (auto& mWidget : mWidgets)
{
if (mInternalFocusHandler == nullptr)
if (mInternalFocusHandler == NULL)
{
mWidget->_setFocusHandler(_getFocusHandler());
}
@ -372,19 +372,19 @@ namespace gcn
return mWidget;
}
auto* basicContainer = dynamic_cast<BasicContainer*>(mWidget);
BasicContainer *basicContainer = dynamic_cast<BasicContainer*>(mWidget);
if (basicContainer != nullptr)
if (basicContainer != NULL)
{
auto* const widget = basicContainer->findWidgetById(id);
Widget *widget = basicContainer->findWidgetById(id);
if (widget != nullptr)
if (widget != NULL)
{
return widget;
}
}
}
return nullptr;
return NULL;
}
}

View File

@ -69,6 +69,7 @@ namespace gcn
b(0),
a(255)
{
}
Color::Color(int color)
@ -78,6 +79,7 @@ namespace gcn
b(color >> 8 & 0xFF),
a(255)
{
}
Color::Color(int ar, int ag, int ab, int aa)
@ -87,6 +89,7 @@ namespace gcn
b(ab),
a(aa)
{
}
Color Color::operator+(const Color& color) const

View File

@ -65,6 +65,7 @@ namespace gcn
Event::Event(Widget* source)
: mSource(source)
{
}
Event::~Event()

View File

@ -58,9 +58,6 @@
* For comments regarding functions please see the header file.
*/
#include <utility>
#include "guisan/exception.hpp"
namespace gcn
@ -71,25 +68,28 @@ namespace gcn
mFilename("?"),
mLine(0)
{
}
Exception::Exception(std::string message)
Exception::Exception(const std::string& message)
: mFunction("?"),
mMessage(std::move(message)),
mMessage(message),
mFilename("?"),
mLine(0)
{
}
Exception::Exception(std::string message,
std::string function,
std::string filename,
Exception::Exception(const std::string& message,
const std::string& function,
const std::string& filename,
int line)
: mFunction(std::move(function)),
mMessage(std::move(message)),
mFilename(std::move(filename)),
: mFunction(function),
mMessage(message),
mFilename(filename),
mLine(line)
{
}
const std::string& Exception::getFunction() const

View File

@ -67,26 +67,27 @@
namespace gcn
{
FocusHandler::FocusHandler()
: mFocusedWidget(nullptr),
mModalFocusedWidget(nullptr),
mModalMouseInputFocusedWidget(nullptr),
mDraggedWidget(nullptr),
mLastWidgetWithMouse(nullptr),
mLastWidgetWithModalFocus(nullptr),
mLastWidgetWithModalMouseInputFocus(nullptr),
mLastWidgetPressed(nullptr)
: mFocusedWidget(NULL),
mModalFocusedWidget(NULL),
mModalMouseInputFocusedWidget(NULL),
mDraggedWidget(NULL),
mLastWidgetWithMouse(NULL),
mLastWidgetWithModalFocus(NULL),
mLastWidgetWithModalMouseInputFocus(NULL),
mLastWidgetPressed(NULL)
{
}
void FocusHandler::requestFocus(Widget* widget)
{
if (widget == nullptr
if (widget == NULL
|| widget == mFocusedWidget)
{
return;
}
auto toBeFocusedIndex = -1;
int toBeFocusedIndex = -1;
for (unsigned int i = 0; i < mWidgets.size(); ++i)
{
if (mWidgets[i] == widget)
@ -101,13 +102,13 @@ namespace gcn
throw GCN_EXCEPTION("Trying to focus a non-existing widget.");
}
auto* oldFocused = mFocusedWidget;
Widget *oldFocused = mFocusedWidget;
if (oldFocused != widget)
{
mFocusedWidget = mWidgets.at(toBeFocusedIndex);
if (oldFocused != nullptr)
if (oldFocused != NULL)
{
const Event focusEvent(oldFocused);
distributeFocusLostEvent(focusEvent);
@ -120,14 +121,14 @@ namespace gcn
void FocusHandler::requestModalFocus(Widget* widget)
{
if (mModalFocusedWidget != nullptr && mModalFocusedWidget != widget)
if (mModalFocusedWidget != NULL && mModalFocusedWidget != widget)
{
throw GCN_EXCEPTION("Another widget already has modal focus.");
}
mModalFocusedWidget = widget;
if (mFocusedWidget != nullptr && !mFocusedWidget->hasModalFocus())
if (mFocusedWidget != NULL && !mFocusedWidget->hasModalFocus())
{
focusNone();
}
@ -135,7 +136,7 @@ namespace gcn
void FocusHandler::requestModalMouseInputFocus(Widget* widget)
{
if (mModalMouseInputFocusedWidget != nullptr
if (mModalMouseInputFocusedWidget != NULL
&& mModalMouseInputFocusedWidget != widget)
{
throw GCN_EXCEPTION("Another widget already has modal input focus.");
@ -148,7 +149,7 @@ namespace gcn
{
if (mModalFocusedWidget == widget)
{
mModalFocusedWidget = nullptr;
mModalFocusedWidget = NULL;
}
}
@ -156,7 +157,7 @@ namespace gcn
{
if (mModalMouseInputFocusedWidget == widget)
{
mModalMouseInputFocusedWidget = nullptr;
mModalMouseInputFocusedWidget = NULL;
}
}
@ -178,7 +179,7 @@ namespace gcn
void FocusHandler::focusNext()
{
int i;
auto focusedWidget = -1;
int focusedWidget = -1;
for (i = 0; i < static_cast<int>(mWidgets.size()); ++i)
{
if (mWidgets[i] == mFocusedWidget)
@ -186,7 +187,7 @@ namespace gcn
focusedWidget = i;
}
}
const auto focused = focusedWidget;
const int focused = focusedWidget;
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
@ -234,12 +235,12 @@ namespace gcn
{
if (mWidgets.empty())
{
mFocusedWidget = nullptr;
mFocusedWidget = NULL;
return;
}
int i;
auto focusedWidget = -1;
int focusedWidget = -1;
for (i = 0; i < static_cast<int>(mWidgets.size()); ++i)
{
if (mWidgets[i] == mFocusedWidget)
@ -247,7 +248,7 @@ namespace gcn
focusedWidget = i;
}
}
const auto focused = focusedWidget;
const int focused = focusedWidget;
// i is a counter that ensures that the following loop
// won't get stuck in an infinite loop
@ -304,7 +305,7 @@ namespace gcn
{
if (isFocused(widget))
{
mFocusedWidget = nullptr;
mFocusedWidget = NULL;
}
for (auto iter = mWidgets.begin(); iter != mWidgets.end(); ++iter)
@ -318,41 +319,41 @@ namespace gcn
if (mDraggedWidget == widget)
{
mDraggedWidget = nullptr;
mDraggedWidget = NULL;
return;
}
if (mLastWidgetWithMouse == widget)
{
mLastWidgetWithMouse = nullptr;
mLastWidgetWithMouse = NULL;
return;
}
if (mLastWidgetWithModalFocus == widget)
{
mLastWidgetWithModalFocus = nullptr;
mLastWidgetWithModalFocus = NULL;
return;
}
if (mLastWidgetWithModalMouseInputFocus == widget)
{
mLastWidgetWithModalMouseInputFocus = nullptr;
mLastWidgetWithModalMouseInputFocus = NULL;
return;
}
if (mLastWidgetPressed == widget)
{
mLastWidgetPressed = nullptr;
mLastWidgetPressed = NULL;
return;
}
}
void FocusHandler::focusNone()
{
if (mFocusedWidget != nullptr)
if (mFocusedWidget != NULL)
{
auto* const focused = mFocusedWidget;
mFocusedWidget = nullptr;
Widget* focused = mFocusedWidget;
mFocusedWidget = NULL;
const Event focusEvent(focused);
distributeFocusLostEvent(focusEvent);
@ -361,7 +362,7 @@ namespace gcn
void FocusHandler::tabNext()
{
if (mFocusedWidget != nullptr)
if (mFocusedWidget != NULL)
{
if (!mFocusedWidget->isTabOutEnabled())
{
@ -371,12 +372,12 @@ namespace gcn
if (mWidgets.empty())
{
mFocusedWidget = nullptr;
mFocusedWidget = NULL;
return;
}
int i;
auto focusedWidget = -1;
int focusedWidget = -1;
for (i = 0; i < static_cast<int>(mWidgets.size()); ++i)
{
if (mWidgets[i] == mFocusedWidget)
@ -384,8 +385,8 @@ namespace gcn
focusedWidget = i;
}
}
const auto focused = focusedWidget;
auto done = false;
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
@ -414,7 +415,7 @@ namespace gcn
if (mWidgets.at(focusedWidget)->isFocusable() &&
mWidgets.at(focusedWidget)->isTabInEnabled() &&
(mModalFocusedWidget == nullptr ||
(mModalFocusedWidget == NULL ||
mWidgets.at(focusedWidget)->hasModalFocus()))
{
done = true;
@ -438,7 +439,7 @@ namespace gcn
void FocusHandler::tabPrevious()
{
if (mFocusedWidget != nullptr)
if (mFocusedWidget != NULL)
{
if (!mFocusedWidget->isTabOutEnabled())
{
@ -448,12 +449,12 @@ namespace gcn
if (mWidgets.empty())
{
mFocusedWidget = nullptr;
mFocusedWidget = NULL;
return;
}
int i;
auto focusedWidget = -1;
int focusedWidget = -1;
for (i = 0; i < static_cast<int>(mWidgets.size()); ++i)
{
if (mWidgets[i] == mFocusedWidget)
@ -461,8 +462,8 @@ namespace gcn
focusedWidget = i;
}
}
const auto focused = focusedWidget;
auto done = false;
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
@ -491,7 +492,7 @@ namespace gcn
if (mWidgets.at(focusedWidget)->isFocusable() &&
mWidgets.at(focusedWidget)->isTabInEnabled() &&
(mModalFocusedWidget == nullptr ||
(mModalFocusedWidget == NULL ||
mWidgets.at(focusedWidget)->hasModalFocus()))
{
done = true;
@ -515,7 +516,7 @@ namespace gcn
void FocusHandler::distributeFocusLostEvent(const Event& focusEvent)
{
auto* sourceWidget = focusEvent.getSource();
Widget* sourceWidget = focusEvent.getSource();
auto focusListeners = sourceWidget->_getFocusListeners();
@ -528,7 +529,7 @@ namespace gcn
void FocusHandler::distributeFocusGainedEvent(const Event& focusEvent)
{
auto* sourceWidget = focusEvent.getSource();
Widget* sourceWidget = focusEvent.getSource();
auto focusListeners = sourceWidget->_getFocusListeners();

View File

@ -66,7 +66,7 @@ namespace gcn
{
int Font::getStringIndexAt(const std::string& text, int x)
{
auto size = 0;
int size = 0;
for (unsigned int i = 0; i < text.size(); ++i)
{

View File

@ -141,7 +141,7 @@ namespace gcn
throw GCN_EXCEPTION("The queue is empty.");
}
const auto keyInput = mKeyInputQueue.front();
const KeyInput keyInput = mKeyInputQueue.front();
mKeyInputQueue.pop();
return keyInput;
@ -159,7 +159,7 @@ namespace gcn
throw GCN_EXCEPTION("The queue is empty.");
}
const auto mouseInput = mMouseInputQueue.front();
const MouseInput mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
return mouseInput;

View File

@ -85,7 +85,7 @@ namespace gcn
return true;
}
const auto top = mClipStack.top();
const ClipRectangle top = mClipStack.top();
ClipRectangle carea;
carea = area;
carea.xOffset = top.xOffset + carea.x;
@ -114,7 +114,7 @@ namespace gcn
carea.height = top.height;
}
const auto result = carea.intersect(top);
const bool result = carea.intersect(top);
mClipStack.push(carea);

View File

@ -74,9 +74,9 @@
namespace gcn
{
Gui::Gui()
: mTop(nullptr),
mGraphics(nullptr),
mInput(nullptr),
: mTop(NULL),
mGraphics(NULL),
mInput(NULL),
mTabbing(true),
mShiftPressed(false),
mMetaPressed(false),
@ -96,7 +96,7 @@ namespace gcn
{
if (Widget::widgetExists(mTop))
{
Gui::setTop(nullptr);
setTop(NULL);
}
delete mFocusHandler;
@ -104,11 +104,11 @@ namespace gcn
void Gui::setTop(Widget* top)
{
if (mTop != nullptr)
if (mTop != NULL)
{
mTop->_setFocusHandler(nullptr);
mTop->_setFocusHandler(NULL);
}
if (top != nullptr)
if (top != NULL)
{
top->_setFocusHandler(mFocusHandler);
}
@ -143,7 +143,7 @@ namespace gcn
void Gui::logic()
{
if (mTop == nullptr)
if (mTop == NULL)
{
throw GCN_EXCEPTION("No top widget set");
}
@ -151,7 +151,7 @@ namespace gcn
handleModalFocus();
handleModalMouseInputFocus();
if (mInput != nullptr)
if (mInput != NULL)
{
mInput->_pollInput();
@ -164,11 +164,11 @@ namespace gcn
void Gui::draw()
{
if (mTop == nullptr)
if (mTop == NULL)
{
throw GCN_EXCEPTION("No top widget set");
}
if (mGraphics == nullptr)
if (mGraphics == NULL)
{
throw GCN_EXCEPTION("No graphics set");
}
@ -184,7 +184,7 @@ namespace gcn
// draw it before drawing top
if (mTop->getBorderSize() > 0)
{
auto rec = mTop->getDimension();
Rectangle rec = mTop->getDimension();
rec.x -= static_cast<int>(mTop->getBorderSize());
rec.y -= static_cast<int>(mTop->getBorderSize());
rec.width += 2 * static_cast<int>(mTop->getBorderSize());
@ -230,7 +230,7 @@ namespace gcn
{
while (!mInput->isMouseQueueEmpty())
{
auto mouseInput = mInput->dequeueMouseInput();
MouseInput mouseInput = mInput->dequeueMouseInput();
// Save the current mouse state. It will be needed if modal focus
// changes or modal mouse input focus changes.
@ -256,6 +256,7 @@ namespace gcn
break;
default:
throw GCN_EXCEPTION("Unknown mouse input type.");
break;
}
}
}
@ -264,7 +265,7 @@ namespace gcn
{
while (!mInput->isKeyQueueEmpty())
{
auto keyInput = mInput->dequeueKeyInput();
KeyInput keyInput = mInput->dequeueKeyInput();
// Save modifiers state
mShiftPressed = keyInput.isShiftPressed();
@ -272,14 +273,14 @@ namespace gcn
mControlPressed = keyInput.isControlPressed();
mAltPressed = keyInput.isAltPressed();
KeyEvent keyEventToGlobalKeyListeners(nullptr,
mShiftPressed,
mControlPressed,
mAltPressed,
mMetaPressed,
keyInput.getType(),
keyInput.isNumericPad(),
keyInput.getKey());
KeyEvent keyEventToGlobalKeyListeners(NULL,
mShiftPressed,
mControlPressed,
mAltPressed,
mMetaPressed,
keyInput.getType(),
keyInput.isNumericPad(),
keyInput.getKey());
distributeKeyEventToGlobalKeyListeners(keyEventToGlobalKeyListeners);
@ -290,10 +291,10 @@ namespace gcn
continue;
}
auto keyEventConsumed = false;
bool keyEventConsumed = false;
// Send key inputs to the focused widgets
if (mFocusHandler->getFocused() != nullptr)
if (mFocusHandler->getFocused() != NULL)
{
KeyEvent keyEvent(getKeyEventSource(),
mShiftPressed,
@ -349,17 +350,17 @@ namespace gcn
// Distribute an event to all widgets in the "widget with mouse" queue.
while (!mWidgetWithMouseQueue.empty())
{
auto* const widget = mWidgetWithMouseQueue.front();
Widget* widget = mWidgetWithMouseQueue.front();
if (Widget::widgetExists(widget))
{
distributeMouseEvent(widget,
MouseEvent::EXITED,
static_cast<int>(mouseInput.getButton()),
mouseInput.getX(),
mouseInput.getX(),
true,
true);
MouseEvent::EXITED,
static_cast<int>(mouseInput.getButton()),
mouseInput.getX(),
mouseInput.getX(),
true,
true);
}
mWidgetWithMouseQueue.pop_front();
@ -370,7 +371,7 @@ namespace gcn
// Check if there is a need to send mouse exited events by
// traversing the "widget with mouse" queue.
auto widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty();
bool widgetWithMouseQueueCheckDone = mWidgetWithMouseQueue.empty();
while (!widgetWithMouseQueueCheckDone)
{
unsigned int iterations = 0;
@ -379,7 +380,7 @@ namespace gcn
iter != mWidgetWithMouseQueue.end();
++iter)
{
auto* widget = *iter;
Widget* widget = *iter;
// If a widget in the "widget with mouse queue" doesn't
// exists anymore it should be removed from the queue.
@ -388,26 +389,29 @@ namespace gcn
mWidgetWithMouseQueue.erase(iter);
break;
}
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())
else
{
distributeMouseEvent(widget,
MouseEvent::EXITED,
static_cast<int>(mouseInput.getButton()),
mouseInput.getX(),
mouseInput.getX(),
true,
true);
mClickCount = 1;
mLastMousePressTimeStamp = 0;
mWidgetWithMouseQueue.erase(iter);
break;
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,
static_cast<int>(mouseInput.getButton()),
mouseInput.getX(),
mouseInput.getX(),
true,
true);
mClickCount = 1;
mLastMousePressTimeStamp = 0;
mWidgetWithMouseQueue.erase(iter);
break;
}
}
iterations++;
@ -420,15 +424,15 @@ namespace gcn
// 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.
auto* parent = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
auto* widget = parent;
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 want 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() != nullptr
if (mFocusHandler->getModalMouseInputFocused() != NULL
&& widget == mFocusHandler->getModalMouseInputFocused()
&& Widget::widgetExists(widget))
{
@ -440,16 +444,16 @@ namespace gcn
|| x + widget->getWidth() <= mouseInput.getX()
|| y + widget->getHeight() <= mouseInput.getY())
{
parent = nullptr;
parent = NULL;
}
}
while (parent != nullptr)
while (parent != NULL)
{
parent = static_cast<Widget*>(widget->getParent());
// Check if the widget is present in the "widget with mouse" queue.
auto widgetIsPresentInQueue = false;
bool widgetIsPresentInQueue = false;
std::deque<Widget*>::iterator iter;
for (iter = mWidgetWithMouseQueue.begin();
iter != mWidgetWithMouseQueue.end();
@ -477,12 +481,12 @@ namespace gcn
mWidgetWithMouseQueue.push_front(widget);
}
auto* swap = widget;
Widget* swap = widget;
widget = parent;
parent = static_cast<Widget*>(swap->getParent());
}
if (mFocusHandler->getDraggedWidget() != nullptr)
if (mFocusHandler->getDraggedWidget() != NULL)
{
distributeMouseEvent(mFocusHandler->getDraggedWidget(),
MouseEvent::DRAGGED,
@ -492,7 +496,7 @@ namespace gcn
}
else
{
auto* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
Widget* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
distributeMouseEvent(sourceWidget,
MouseEvent::MOVED,
static_cast<int>(mouseInput.getButton()),
@ -503,9 +507,9 @@ namespace gcn
void Gui::handleMousePressed(const MouseInput& mouseInput)
{
auto* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
Widget* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
if (mFocusHandler->getDraggedWidget() != nullptr)
if (mFocusHandler->getDraggedWidget() != NULL)
{
sourceWidget = mFocusHandler->getDraggedWidget();
}
@ -521,9 +525,9 @@ namespace gcn
mFocusHandler->setLastWidgetPressed(sourceWidget);
if ((mFocusHandler->getModalFocused() != nullptr
&& sourceWidget->hasModalFocus())
|| mFocusHandler->getModalFocused() == nullptr)
if (mFocusHandler->getModalFocused() != NULL
&& sourceWidget->hasModalFocus()
|| mFocusHandler->getModalFocused() == NULL)
{
sourceWidget->requestFocus();
}
@ -547,9 +551,9 @@ namespace gcn
void Gui::handleMouseWheelMovedDown(const MouseInput& mouseInput)
{
auto* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
Widget* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
if (mFocusHandler->getDraggedWidget() != nullptr)
if (mFocusHandler->getDraggedWidget() != NULL)
{
sourceWidget = mFocusHandler->getDraggedWidget();
}
@ -566,9 +570,9 @@ namespace gcn
void Gui::handleMouseWheelMovedUp(const MouseInput& mouseInput)
{
auto* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
Widget* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
if (mFocusHandler->getDraggedWidget() != nullptr)
if (mFocusHandler->getDraggedWidget() != NULL)
{
sourceWidget = mFocusHandler->getDraggedWidget();
}
@ -585,13 +589,13 @@ namespace gcn
void Gui::handleMouseReleased(const MouseInput& mouseInput)
{
auto* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
Widget* sourceWidget = getMouseEventSource(mouseInput.getX(), mouseInput.getY());
if (mFocusHandler->getDraggedWidget() != nullptr)
if (mFocusHandler->getDraggedWidget() != NULL)
{
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
{
mFocusHandler->setLastWidgetPressed(nullptr);
mFocusHandler->setLastWidgetPressed(NULL);
}
sourceWidget = mFocusHandler->getDraggedWidget();
@ -615,7 +619,7 @@ namespace gcn
mouseInput.getX(),
mouseInput.getY());
mFocusHandler->setLastWidgetPressed(nullptr);
mFocusHandler->setLastWidgetPressed(NULL);
}
else
{
@ -623,21 +627,21 @@ namespace gcn
mClickCount = 0;
}
if (mFocusHandler->getDraggedWidget() != nullptr)
if (mFocusHandler->getDraggedWidget() != NULL)
{
mFocusHandler->setDraggedWidget(nullptr);
mFocusHandler->setDraggedWidget(NULL);
}
}
Widget* Gui::getWidgetAt(int x, int y)
{
// If the widget's parent has no child then we have found the widget..
auto* parent = mTop;
auto* child = mTop;
Widget* parent = mTop;
Widget* child = mTop;
while (child != nullptr)
while (child != NULL)
{
auto* swap = child;
Widget* swap = child;
int parentX, parentY;
parent->getAbsolutePosition(parentX, parentY);
child = parent->getWidgetAt(x - parentX, y - parentY);
@ -649,9 +653,9 @@ namespace gcn
Widget* Gui::getMouseEventSource(int x, int y)
{
auto* widget = getWidgetAt(x, y);
Widget* widget = getWidgetAt(x, y);
if (mFocusHandler->getModalMouseInputFocused() != nullptr
if (mFocusHandler->getModalMouseInputFocused() != NULL
&& !widget->hasModalMouseInputFocus())
{
return mFocusHandler->getModalMouseInputFocused();
@ -662,10 +666,10 @@ namespace gcn
Widget* Gui::getKeyEventSource()
{
auto* widget = mFocusHandler->getFocused();
Widget* widget = mFocusHandler->getFocused();
while (widget->_getInternalFocusHandler() != nullptr
&& widget->_getInternalFocusHandler()->getFocused() != nullptr)
while (widget->_getInternalFocusHandler() != NULL
&& widget->_getInternalFocusHandler()->getFocused() != NULL)
{
widget = widget->_getInternalFocusHandler()->getFocused();
}
@ -681,17 +685,17 @@ namespace gcn
bool force,
bool toSourceOnly)
{
auto* parent = source;
auto* widget = source;
Widget* parent = source;
Widget* widget = source;
if (mFocusHandler->getModalFocused() != nullptr
if (mFocusHandler->getModalFocused() != NULL
&& !widget->hasModalFocus()
&& !force)
{
return;
}
if (mFocusHandler->getModalMouseInputFocused() != nullptr
if (mFocusHandler->getModalMouseInputFocused() != NULL
&& !widget->hasModalMouseInputFocus()
&& !force)
{
@ -709,7 +713,7 @@ namespace gcn
y,
mClickCount);
while (parent != nullptr)
while (parent != NULL)
{
// If the widget has been removed due to input
// cancel the distribution.
@ -773,13 +777,13 @@ namespace gcn
}
}
auto* swap = widget;
Widget* swap = widget;
widget = parent;
parent = static_cast<Widget*>(swap->getParent());
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
if (mFocusHandler->getModalFocused() != nullptr
if (mFocusHandler->getModalFocused() != NULL
&& !widget->hasModalFocus())
{
break;
@ -787,7 +791,7 @@ namespace gcn
// If a non modal mouse input focused widget has been reach
// and we have modal mouse input focus cancel the distribution.
if (mFocusHandler->getModalMouseInputFocused() != nullptr
if (mFocusHandler->getModalMouseInputFocused() != NULL
&& !widget->hasModalMouseInputFocus())
{
break;
@ -797,22 +801,22 @@ namespace gcn
void Gui::distributeKeyEvent(KeyEvent& keyEvent)
{
auto* parent = keyEvent.getSource();
auto* widget = keyEvent.getSource();
Widget* parent = keyEvent.getSource();
Widget* widget = keyEvent.getSource();
if (mFocusHandler->getModalFocused() != nullptr
if (mFocusHandler->getModalFocused() != NULL
&& !widget->hasModalFocus())
{
return;
}
if (mFocusHandler->getModalMouseInputFocused() != nullptr
if (mFocusHandler->getModalMouseInputFocused() != NULL
&& !widget->hasModalMouseInputFocus())
{
return;
}
while (parent != nullptr)
while (parent != NULL)
{
// If the widget has been removed due to input
// cancel the distribution.
@ -844,13 +848,13 @@ namespace gcn
}
}
auto* swap = widget;
Widget* swap = widget;
widget = parent;
parent = static_cast<Widget*>(swap->getParent());
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
if (mFocusHandler->getModalFocused() != nullptr
if (mFocusHandler->getModalFocused() != NULL
&& !widget->hasModalFocus())
{
break;
@ -884,40 +888,40 @@ namespace gcn
void Gui::handleModalMouseInputFocus()
{
// Check if modal mouse input focus has been gained by a widget.
if (mFocusHandler->getLastWidgetWithModalMouseInputFocus()
!= mFocusHandler->getModalMouseInputFocused()
&& mFocusHandler->getLastWidgetWithModalMouseInputFocus() == nullptr)
if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus()
!= mFocusHandler->getModalMouseInputFocused())
&& (mFocusHandler->getLastWidgetWithModalMouseInputFocus() == NULL))
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalMouseInputFocus(mFocusHandler->getModalMouseInputFocused());
}
// Check if modal mouse input focus has been released.
else if (mFocusHandler->getLastWidgetWithModalMouseInputFocus()
!= mFocusHandler->getModalMouseInputFocused()
&& mFocusHandler->getLastWidgetWithModalMouseInputFocus() != nullptr)
else if ((mFocusHandler->getLastWidgetWithModalMouseInputFocus()
!= mFocusHandler->getModalMouseInputFocused())
&& (mFocusHandler->getLastWidgetWithModalMouseInputFocus() != NULL))
{
handleModalFocusReleased();
mFocusHandler->setLastWidgetWithModalMouseInputFocus(nullptr);
mFocusHandler->setLastWidgetWithModalMouseInputFocus(NULL);
}
}
void Gui::handleModalFocus()
{
// Check if modal focus has been gained by a widget.
if (mFocusHandler->getLastWidgetWithModalFocus()
!= mFocusHandler->getModalFocused()
&& mFocusHandler->getLastWidgetWithModalFocus() == nullptr)
if ((mFocusHandler->getLastWidgetWithModalFocus()
!= mFocusHandler->getModalFocused())
&& (mFocusHandler->getLastWidgetWithModalFocus() == NULL))
{
handleModalFocusGained();
mFocusHandler->setLastWidgetWithModalFocus(mFocusHandler->getModalFocused());
}
// Check if modal focus has been released.
else if (mFocusHandler->getLastWidgetWithModalFocus()
!= mFocusHandler->getModalFocused()
&& mFocusHandler->getLastWidgetWithModalFocus() != nullptr)
else if ((mFocusHandler->getLastWidgetWithModalFocus()
!= mFocusHandler->getModalFocused())
&&( mFocusHandler->getLastWidgetWithModalFocus() != NULL))
{
handleModalFocusReleased();
mFocusHandler->setLastWidgetWithModalFocus(nullptr);
mFocusHandler->setLastWidgetWithModalFocus(NULL);
}
}
@ -926,17 +930,17 @@ namespace gcn
// Distribute an event to all widgets in the "widget with mouse" queue.
while (!mWidgetWithMouseQueue.empty())
{
auto* widget = mWidgetWithMouseQueue.front();
Widget* widget = mWidgetWithMouseQueue.front();
if (Widget::widgetExists(widget))
{
distributeMouseEvent(widget,
MouseEvent::EXITED,
static_cast<int>(mLastMousePressButton),
mLastMouseX,
mLastMouseY,
true,
true);
MouseEvent::EXITED,
static_cast<int>(mLastMousePressButton),
mLastMouseX,
mLastMouseY,
true,
true);
}
mWidgetWithMouseQueue.pop_front();
@ -951,15 +955,15 @@ namespace gcn
// 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.
auto* widget = getMouseEventSource(mLastMouseX, mLastMouseY);
auto* parent = widget;
Widget* widget = getMouseEventSource(mLastMouseX, mLastMouseY);
Widget* parent = widget;
while (parent != nullptr)
while (parent != NULL)
{
parent = static_cast<Widget*>(widget->getParent());
// Check if the widget is present in the "widget with mouse" queue.
auto widgetIsPresentInQueue = false;
bool widgetIsPresentInQueue = false;
std::deque<Widget*>::iterator iter;
for (iter = mWidgetWithMouseQueue.begin();
iter != mWidgetWithMouseQueue.end();
@ -978,16 +982,16 @@ namespace gcn
&& Widget::widgetExists(widget))
{
distributeMouseEvent(widget,
MouseEvent::ENTERED,
static_cast<int>(mLastMousePressButton),
mLastMouseX,
mLastMouseY,
false,
true);
MouseEvent::ENTERED,
static_cast<int>(mLastMousePressButton),
mLastMouseX,
mLastMouseY,
false,
true);
mWidgetWithMouseQueue.push_front(widget);
}
auto* swap = widget;
Widget* swap = widget;
widget = parent;
parent = static_cast<Widget*>(swap->getParent());
}

View File

@ -59,9 +59,10 @@
* For comments regarding functions please see the header file.
*/
extern "C" {
const char* gcnGuisanVersion()
extern "C"
{
return "0.9.0";
}
const char* gcnGuisanVersion()
{
return "1.0.0";
}
}

View File

@ -65,7 +65,7 @@
namespace gcn
{
ImageLoader* Image::mImageLoader = nullptr;
ImageLoader* Image::mImageLoader = NULL;
Image::Image()
= default;
@ -85,7 +85,7 @@ namespace gcn
Image* Image::load(const std::string& filename, bool convertToDisplayFormat)
{
if (mImageLoader == nullptr)
if (mImageLoader == NULL)
{
throw GCN_EXCEPTION("Trying to load an image but no image loader is set.");
}

View File

@ -74,7 +74,7 @@ namespace gcn
mFilename = filename;
mImage = Image::load(filename, false);
const auto separator = mImage->getPixel(0, 0);
const Color separator = mImage->getPixel(0, 0);
int i;
for (i = 0;
@ -98,11 +98,12 @@ namespace gcn
}
mHeight = j;
auto x = 0, y = 0;
int x = 0, y = 0;
unsigned char k;
for (i = 0; i < static_cast<int>(glyphs.size()); ++i)
{
const unsigned char k = glyphs.at(i);
k = glyphs.at(i);
addGlyph(k, x, y, separator);
}
@ -120,7 +121,7 @@ namespace gcn
mFilename = filename;
mImage = Image::load(filename, false);
const auto separator = mImage->getPixel(0, 0);
const Color separator = mImage->getPixel(0, 0);
int i;
for (i = 0; separator == mImage->getPixel(i, 0)
@ -143,7 +144,7 @@ namespace gcn
}
mHeight = j;
auto x = 0, y = 0;
int x = 0, y = 0;
for (i = glyphsFrom; i < glyphsTo + 1; i++)
{
@ -182,7 +183,7 @@ namespace gcn
int x, int y)
{
// This is needed for drawing the Glyph in the middle if we have spacing
const auto yoffset = getRowSpacing() >> 1;
const int yoffset = getRowSpacing() >> 1;
if (mGlyph[glyph].width == 0)
{
@ -291,11 +292,11 @@ namespace gcn
int ImageFont::getWidth(const std::string& text) const
{
auto size = 0;
int size = 0;
for (auto i : text)
for (unsigned int i = 0; i < text.size(); ++i)
{
size += getWidth(i);
size += getWidth(text.at(i));
}
return size - mGlyphSpacing;
@ -303,9 +304,9 @@ namespace gcn
int ImageFont::getStringIndexAt(const std::string& text, int x)
{
auto size = 0;
int size = 0;
for (auto i = 0; i < static_cast<int>(text.size()); ++i)
for (unsigned int i = 0; i < text.size(); ++i)
{
size += getWidth(text.at(i));

View File

@ -74,6 +74,7 @@ namespace gcn
mMetaPressed(isMetaPressed),
mIsConsumed(false)
{
}
bool InputEvent::isShiftPressed() const

View File

@ -87,16 +87,9 @@ namespace gcn
&& (mValue != 215) && (mValue != 247));
}
bool Key::isSymbol() const
bool Key::isPrintable() const
{
// ,-./
// ;'
// [\]
// = `
return (mValue >= 44 && mValue <= 47)
|| mValue == 59 || mValue == 39
|| (mValue >= 91 && mValue <= 93)
|| mValue == 61 || mValue == 96;
return 0 < mValue && mValue < 1000;
}
int Key::getValue() const
@ -111,59 +104,4 @@ namespace gcn
return '\0';
}
char Key::getShiftedNumeric() const
{
// 1 -> !
if (mValue == 49) return static_cast<char>(33);
// 2 -> @
if (mValue == 50) return static_cast<char>(64);
// 3 -> #
if (mValue == 51) return static_cast<char>(35);
// 4 -> $
if (mValue == 52) return static_cast<char>(36);
// 5 -> %
if (mValue == 53) return static_cast<char>(37);
// 6 -> ^
if (mValue == 54) return static_cast<char>(94);
// 7 -> &
if (mValue == 55) return static_cast<char>(38);
// 8 -> *
if (mValue == 56) return static_cast<char>(42);
// 9 -> (
if (mValue == 57) return static_cast<char>(40);
// 0 -> )
if (mValue == 48) return static_cast<char>(41);
return '\0';
}
char Key::getShiftedSymbol() const
{
// , -> <
if (mValue == 44) return static_cast<char>(60);
// - -> _
if (mValue == 45) return static_cast<char>(95);
// . -> >
if (mValue == 46) return static_cast<char>(62);
// / -> ?
if (mValue == 47) return static_cast<char>(63);
// ; -> :
if (mValue == 59) return static_cast<char>(58);
// ' -> "
if (mValue == 39) return static_cast<char>(34);
// [ -> {
if (mValue == 91) return static_cast<char>(123);
// \ -> |
if (mValue == 92) return static_cast<char>(124);
// ] -> }
if (mValue == 93) return static_cast<char>(125);
// = -> +
if (mValue == 61) return static_cast<char>(43);
// ` -> ~
if (mValue == 96) return static_cast<char>(126);
return '\0';
}
}

View File

@ -79,6 +79,7 @@ namespace gcn
mIsNumericPad(isNumericPad),
mKey(key)
{
}
KeyEvent::~KeyEvent()

View File

@ -71,6 +71,7 @@ namespace gcn
mMetaPressed(false),
mNumericPad(false)
{
}
void KeyInput::setType(int type)

View File

@ -83,6 +83,7 @@ namespace gcn
mY(y),
mClickCount(clickCount)
{
}
unsigned int MouseEvent::getButton() const

View File

@ -93,6 +93,7 @@ namespace gcn
OpenGLGraphics::~OpenGLGraphics()
{
}
void OpenGLGraphics::_beginDraw()

View File

@ -60,8 +60,7 @@
#include "guisan/sdl.hpp"
extern "C" {
void gcnSDL()
extern "C"
{
}
void gcnSDL() { }
}

View File

@ -81,7 +81,7 @@ namespace gcn
SDL2Graphics::~SDL2Graphics()
{
if (mRenderTarget != nullptr)
if (mRenderTarget != NULL)
{
SDL_DestroyTexture(mTexture);
SDL_FreeSurface(mTarget);
@ -108,7 +108,7 @@ namespace gcn
mRenderTarget = renderer;
// An internal surface is still required to be able to handle surfaces and colorkeys
mTarget = SDL_CreateRGBSurface(0, width, height, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
SDL_FillRect(mTarget, nullptr, SDL_MapRGB(mTarget->format, 0xff, 0, 0xff));
SDL_FillRect(mTarget, NULL, SDL_MapRGB(mTarget->format, 0xff, 0, 0xff));
SDL_SetColorKey(mTarget, SDL_TRUE, SDL_MapRGB(mTarget->format, 0xff, 0, 0xff)); // magenta, Guisan default
SDL_SetSurfaceBlendMode(mTarget, SDL_BLENDMODE_NONE); // needed to cleanup temp data properly
mTexture = SDL_CreateTextureFromSurface(mRenderTarget, mTarget);
@ -118,9 +118,9 @@ namespace gcn
bool SDL2Graphics::pushClipArea(Rectangle area)
{
SDL_Rect rect;
const auto result = Graphics::pushClipArea(area);
bool result = Graphics::pushClipArea(area);
const auto& carea = mClipStack.top();
const ClipRectangle& carea = mClipStack.top();
rect.x = carea.x;
rect.y = carea.y;
rect.w = carea.width;
@ -140,7 +140,7 @@ namespace gcn
return;
}
const auto& carea = mClipStack.top();
const ClipRectangle& carea = mClipStack.top();
SDL_Rect rect;
rect.x = carea.x;
rect.y = carea.y;
@ -165,7 +165,7 @@ namespace gcn
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
SDL_Rect src;
SDL_Rect dst;
SDL_Rect temp;
@ -182,14 +182,14 @@ namespace gcn
temp.w = width;
temp.h = height;
const auto* const srcImage = dynamic_cast<const SDLImage*>(image);
const SDLImage* srcImage = dynamic_cast<const SDLImage*>(image);
if (srcImage == nullptr)
if (srcImage == NULL)
{
throw GCN_EXCEPTION("Trying to draw an image of unknown format, must be an SDLImage.");
}
if (srcImage->getTexture() == nullptr)
if (srcImage->getTexture() == NULL)
{
SDL_FillRect(mTarget, &temp, SDL_MapRGBA(mTarget->format, 0xff, 0, 0xff, 0));
SDL_BlitSurface(srcImage->getSurface(), &src, mTarget, &temp);
@ -210,9 +210,9 @@ namespace gcn
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
auto area = rectangle;
Rectangle area = rectangle;
area.x += top.xOffset;
area.y += top.yOffset;
@ -223,10 +223,10 @@ namespace gcn
if (mAlpha)
{
const auto x1 = area.x > top.x ? area.x : top.x;
const auto y1 = area.y > top.y ? area.y : top.y;
const auto x2 = area.x + area.width < top.x + top.width ? area.x + area.width : top.x + top.width;
const auto y2 = area.y + area.height < top.y + top.height ? area.y + area.height : top.y + top.height;
const int x1 = area.x > top.x ? area.x : top.x;
const int y1 = area.y > top.y ? area.y : top.y;
const int x2 = area.x + area.width < top.x + top.width ? area.x + area.width : top.x + top.width;
const int y2 = area.y + area.height < top.y + top.height ? area.y + area.height : top.y + top.height;
SDL_Rect rect;
rect.x = x1;
@ -247,7 +247,6 @@ namespace gcn
rect.w = area.width;
rect.h = area.height;
auto color = SDL_MapRGBA(mTarget->format, mColor.r, mColor.g, mColor.b, mColor.a);
saveRenderColor();
SDL_SetRenderDrawColor(mRenderTarget, mColor.r, mColor.g, mColor.b, mColor.a);
SDL_RenderFillRect(mRenderTarget, &rect);
@ -263,7 +262,7 @@ namespace gcn
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x += top.xOffset;
y += top.yOffset;
@ -293,7 +292,7 @@ SDLputPixel(mTarget, x, y, mColor);
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x1 += top.xOffset;
y += top.yOffset;
@ -340,7 +339,7 @@ SDLputPixel(mTarget, x, y, mColor);
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x += top.xOffset;
y1 += top.yOffset;
@ -382,10 +381,10 @@ SDLputPixel(mTarget, x, y, mColor);
void SDL2Graphics::drawRectangle(const Rectangle& rectangle)
{
const auto x1 = rectangle.x;
const auto x2 = rectangle.x + rectangle.width - 1;
const auto y1 = rectangle.y;
const auto y2 = rectangle.y + rectangle.height - 1;
const int x1 = rectangle.x;
const int x2 = rectangle.x + rectangle.width - 1;
const int y1 = rectangle.y;
const int y2 = rectangle.y + rectangle.height - 1;
drawHLine(x1, y1, x2);
drawHLine(x1, y2, x2);
@ -401,7 +400,7 @@ SDLputPixel(mTarget, x, y, mColor);
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x1 += top.xOffset;
y1 += top.yOffset;
@ -434,7 +433,7 @@ SDLputPixel(mTarget, x, y, mColor);
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
destination.x += top.xOffset;
destination.y += top.yOffset;
@ -460,7 +459,7 @@ SDLputPixel(mTarget, x, y, mColor);
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
destination.x += top.xOffset;
destination.y += top.yOffset;

View File

@ -105,9 +105,9 @@ namespace gcn
bool SDLGraphics::pushClipArea(Rectangle area)
{
SDL_Rect rect;
const auto result = Graphics::pushClipArea(area);
const bool result = Graphics::pushClipArea(area);
const auto& carea = mClipStack.top();
const ClipRectangle& carea = mClipStack.top();
rect.x = carea.x;
rect.y = carea.y;
rect.w = carea.width;
@ -127,7 +127,7 @@ namespace gcn
return;
}
const auto& carea = mClipStack.top();
const ClipRectangle& carea = mClipStack.top();
SDL_Rect rect;
rect.x = carea.x;
rect.y = carea.y;
@ -152,7 +152,7 @@ namespace gcn
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
SDL_Rect src;
SDL_Rect dst;
src.x = srcX;
@ -162,9 +162,9 @@ namespace gcn
dst.x = dstX + top.xOffset;
dst.y = dstY + top.yOffset;
const auto* srcImage = dynamic_cast<const SDLImage*>(image);
const SDLImage* srcImage = dynamic_cast<const SDLImage*>(image);
if (srcImage == nullptr)
if (srcImage == NULL)
{
throw GCN_EXCEPTION("Trying to draw an image of unknown format, must be an SDLImage.");
}
@ -180,9 +180,9 @@ namespace gcn
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
auto area = rectangle;
Rectangle area = rectangle;
area.x += top.xOffset;
area.y += top.yOffset;
@ -193,15 +193,15 @@ namespace gcn
if (mAlpha)
{
const auto x1 = area.x > top.x ? area.x : top.x;
const auto y1 = area.y > top.y ? area.y : top.y;
const auto x2 = area.x + area.width < top.x + top.width ? area.x + area.width : top.x + top.width;
const auto y2 = area.y + area.height < top.y + top.height ? area.y + area.height : top.y + top.height;
const int x1 = area.x > top.x ? area.x : top.x;
const int y1 = area.y > top.y ? area.y : top.y;
const int x2 = area.x + area.width < top.x + top.width ? area.x + area.width : top.x + top.width;
const int y2 = area.y + area.height < top.y + top.height ? area.y + area.height : top.y + top.height;
SDL_LockSurface(mTarget);
for (auto y = y1; y < y2; y++)
for (int y = y1; y < y2; y++)
{
for (auto x = x1; x < x2; x++)
for (int x = x1; x < x2; x++)
{
SDLputPixelAlpha(mTarget, x, y, mColor);
}
@ -216,7 +216,7 @@ namespace gcn
rect.w = area.width;
rect.h = area.height;
const auto color = SDL_MapRGBA(mTarget->format, mColor.r, mColor.g, mColor.b, mColor.a);
const Uint32 color = SDL_MapRGBA(mTarget->format, mColor.r, mColor.g, mColor.b, mColor.a);
SDL_FillRect(mTarget, &rect, color);
}
}
@ -229,7 +229,7 @@ namespace gcn
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x += top.xOffset;
y += top.yOffset;
@ -254,7 +254,7 @@ namespace gcn
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x1 += top.xOffset;
y += top.yOffset;
@ -292,9 +292,9 @@ namespace gcn
SDL_LockSurface(mTarget);
auto p = static_cast<Uint8*>(mTarget->pixels) + y * mTarget->pitch + x1 * bpp;
Uint8 *p = static_cast<Uint8*>(mTarget->pixels) + y * mTarget->pitch + x1 * bpp;
auto pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b);
Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b);
switch (bpp)
{
@ -309,7 +309,7 @@ namespace gcn
case 2:
{
auto* q = reinterpret_cast<Uint16*>(p);
Uint16* q = reinterpret_cast<Uint16*>(p);
for (; x1 <= x2; ++x1)
{
*(q++) = pixel;
@ -344,7 +344,7 @@ namespace gcn
case 4:
{
auto* q = reinterpret_cast<Uint32*>(p);
Uint32* q = reinterpret_cast<Uint32*>(p);
for (; x1 <= x2; ++x1)
{
if (mAlpha)
@ -371,7 +371,7 @@ namespace gcn
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x += top.xOffset;
y1 += top.yOffset;
@ -409,9 +409,9 @@ namespace gcn
SDL_LockSurface(mTarget);
auto* p = static_cast<Uint8*>(mTarget->pixels) + y1 * mTarget->pitch + x * bpp;
Uint8* p = static_cast<Uint8*>(mTarget->pixels) + y1 * mTarget->pitch + x * bpp;
auto pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b);
Uint32 pixel = SDL_MapRGB(mTarget->format, mColor.r, mColor.g, mColor.b);
switch (bpp)
{
@ -483,10 +483,10 @@ namespace gcn
void SDLGraphics::drawRectangle(const Rectangle& rectangle)
{
const auto x1 = rectangle.x;
const auto x2 = rectangle.x + rectangle.width - 1;
const auto y1 = rectangle.y;
const auto y2 = rectangle.y + rectangle.height - 1;
const int x1 = rectangle.x;
const int x2 = rectangle.x + rectangle.width - 1;
const int y1 = rectangle.y;
const int y2 = rectangle.y + rectangle.height - 1;
drawHLine(x1, y1, x2);
drawHLine(x1, y2, x2);
@ -513,7 +513,7 @@ namespace gcn
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
x1 += top.xOffset;
y1 += top.yOffset;
@ -522,8 +522,8 @@ namespace gcn
// Draw a line with Bresenham
const auto dx = ABS(x2 - x1);
const auto dy = ABS(y2 - y1);
const int dx = ABS(x2 - x1);
const int dy = ABS(y2 - y1);
if (dx > dy)
{
@ -542,10 +542,10 @@ namespace gcn
if (y1 < y2)
{
auto y = y1;
auto p = 0;
int y = y1;
int p = 0;
for (auto x = x1; x <= x2; x++)
for (int x = x1; x <= x2; x++)
{
if (top.isPointInRect(x, y))
{
@ -570,10 +570,10 @@ namespace gcn
}
else
{
auto y = y1;
auto p = 0;
int y = y1;
int p = 0;
for (auto x = x1; x <= x2; x++)
for (int x = x1; x <= x2; x++)
{
if (top.isPointInRect(x, y))
{
@ -614,10 +614,10 @@ namespace gcn
if (x1 < x2)
{
auto x = x1;
auto p = 0;
int x = x1;
int p = 0;
for (auto y = y1; y <= y2; y++)
for (int y = y1; y <= y2; y++)
{
if (top.isPointInRect(x, y))
{
@ -642,10 +642,10 @@ namespace gcn
}
else
{
auto x = x1;
auto p = 0;
int x = x1;
int p = 0;
for (auto y = y1; y <= y2; y++)
for (int y = y1; y <= y2; y++)
{
if (top.isPointInRect(x, y))
{
@ -691,7 +691,7 @@ namespace gcn
throw GCN_EXCEPTION("Clip stack is empty, perhaps you"
"called a draw function outside of _beginDraw() and _endDraw()?");
}
const auto& top = mClipStack.top();
const ClipRectangle& top = mClipStack.top();
destination.x += top.xOffset;
destination.y += top.yOffset;

View File

@ -97,7 +97,7 @@ namespace gcn
int SDLImage::getWidth() const
{
if (mSurface == nullptr)
if (mSurface == NULL)
{
throw GCN_EXCEPTION("Trying to get the width of a non loaded image.");
}
@ -107,7 +107,7 @@ namespace gcn
int SDLImage::getHeight() const
{
if (mSurface == nullptr)
if (mSurface == NULL)
{
throw GCN_EXCEPTION("Trying to get the height of a non loaded image.");
}
@ -117,7 +117,7 @@ namespace gcn
Color SDLImage::getPixel(int x, int y)
{
if (mSurface == nullptr)
if (mSurface == NULL)
{
throw GCN_EXCEPTION("Trying to get a pixel from a non loaded image.");
}
@ -127,7 +127,7 @@ namespace gcn
void SDLImage::putPixel(int x, int y, const Color& color)
{
if (mSurface == nullptr)
if (mSurface == NULL)
{
throw GCN_EXCEPTION("Trying to put a pixel in a non loaded image.");
}
@ -137,14 +137,13 @@ namespace gcn
void SDLImage::convertToDisplayFormat()
{
if (mSurface == nullptr)
if (mSurface == NULL)
{
throw GCN_EXCEPTION("Trying to convert a non loaded image to display format.");
}
int i;
auto hasPink = false;
auto hasAlpha = false;
bool hasPink = false;
unsigned int surfaceMask = SDL_PIXELFORMAT_RGBX8888;
@ -171,9 +170,9 @@ namespace gcn
}
}
auto* tmp = SDL_ConvertSurfaceFormat(mSurface, surfaceMask, 0);
SDL_Surface* tmp = SDL_ConvertSurfaceFormat(mSurface, surfaceMask, 0);
SDL_FreeSurface(mSurface);
mSurface = nullptr;
mSurface = NULL;
if (hasPink)
{
@ -188,7 +187,7 @@ namespace gcn
if (mRenderer)
{
auto* tmpTexture = SDL_CreateTextureFromSurface(mRenderer, tmp);
SDL_Texture* tmpTexture = SDL_CreateTextureFromSurface(mRenderer, tmp);
SDL_SetTextureBlendMode(tmpTexture, SDL_BLENDMODE_BLEND);
SDL_DestroyTexture(mTexture);
mTexture = tmpTexture;

View File

@ -70,18 +70,18 @@ namespace gcn
Image* SDLImageLoader::load(const std::string& filename,
bool convertToDisplayFormat)
{
auto* loadedSurface = loadSDLSurface(filename);
SDL_Surface* loadedSurface = loadSDLSurface(filename);
if (loadedSurface == nullptr)
if (loadedSurface == NULL)
{
throw GCN_EXCEPTION(
std::string("Unable to load image file: ") + filename);
}
auto* surface = convertToStandardFormat(loadedSurface);
SDL_Surface* surface = convertToStandardFormat(loadedSurface);
SDL_FreeSurface(loadedSurface);
if (surface == nullptr)
if (surface == NULL)
{
throw GCN_EXCEPTION(
std::string("Not enough memory to load: ") + filename);
@ -136,13 +136,13 @@ namespace gcn
amask = 0xff000000;
#endif
auto* colorSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
SDL_Surface* colorSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
0, 0, 32,
rmask, gmask, bmask, amask);
SDL_Surface* tmp = nullptr;
SDL_Surface* tmp = NULL;
if (colorSurface != nullptr)
if (colorSurface != NULL)
{
tmp = SDL_ConvertSurface(surface, colorSurface->format,
SDL_SWSURFACE);

View File

@ -62,384 +62,419 @@
#include "guisan/exception.hpp"
namespace gcn
{
SDLInput::SDLInput()
{
namespace gcn {
//--------------------------------------------------------------------------
static Uint32 utf8ToUnicode(const char *text) {
const Uint32 c0 = static_cast<unsigned char>(text[0]);
if ((c0 & 0xF8) == 0xF0) {
if (((text[1] & 0xC0) != 0x80) && ((text[2] & 0xC0) != 0x80)
&& ((text[3] & 0xC0) != 0x80)) {
throw GCN_EXCEPTION("invalid utf8");
}
const unsigned char c1 = text[1] & 0x3F;
const unsigned char c2 = text[2] & 0x3F;
const unsigned char c3 = text[3] & 0x3F;
return ((c0 & 0x07) << 18) | (c1 << 12) | (c2 << 6) | c3;
} else if ((c0 & 0xF0) == 0xE0) {
if (((text[1] & 0xC0) != 0x80) && ((text[2] & 0xC0) != 0x80)) {
throw GCN_EXCEPTION("invalid utf8");
}
const unsigned char c1 = text[1] & 0x3F;
const unsigned char c2 = text[2] & 0x3F;
return ((c0 & 0x0F) << 12) | (c1 << 6) | c2;
} else if ((c0 & 0xE0) == 0xC0) {
if (((text[1] & 0xC0) != 0x80)) {
throw GCN_EXCEPTION("invalid utf8");
}
const unsigned char c1 = text[1] & 0x3F;
return ((c0 & 0x1F) << 6) | c1;
} else {
if ((c0 & 0x80) != 0) {
throw GCN_EXCEPTION("invalid utf8");
}
return (c0 & 0x7F);
}
}
SDLInput::SDLInput() {
mMouseInWindow = true;
mMouseDown = false;
}
bool SDLInput::isKeyQueueEmpty()
{
bool SDLInput::isKeyQueueEmpty() {
return mKeyInputQueue.empty();
}
KeyInput SDLInput::dequeueKeyInput()
{
if (mKeyInputQueue.empty())
{
KeyInput SDLInput::dequeueKeyInput() {
KeyInput keyInput;
if (mKeyInputQueue.empty()) {
throw GCN_EXCEPTION("The queue is empty.");
}
const auto keyInput = mKeyInputQueue.front();
keyInput = mKeyInputQueue.front();
mKeyInputQueue.pop();
return keyInput;
}
bool SDLInput::isMouseQueueEmpty()
{
bool SDLInput::isMouseQueueEmpty() {
return mMouseInputQueue.empty();
}
MouseInput SDLInput::dequeueMouseInput()
{
if (mMouseInputQueue.empty())
{
MouseInput SDLInput::dequeueMouseInput() {
MouseInput mouseInput;
if (mMouseInputQueue.empty()) {
throw GCN_EXCEPTION("The queue is empty.");
}
const auto mouseInput = mMouseInputQueue.front();
mouseInput = mMouseInputQueue.front();
mMouseInputQueue.pop();
return mouseInput;
}
void SDLInput::pushInput(SDL_Event event)
{
void SDLInput::pushInput(SDL_Event event) {
KeyInput keyInput;
MouseInput mouseInput;
switch (event.type)
{
case SDL_KEYDOWN:
keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setType(KeyInput::PRESSED);
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
keyInput.setMetaPressed(event.key.keysym.mod & KMOD_GUI);
keyInput.setNumericPad(event.key.keysym.sym >= SDLK_KP_0
&& event.key.keysym.sym <= SDLK_KP_EQUALS);
switch (event.type) {
case SDL_TEXTINPUT:
keyInput.setKey(utf8ToUnicode(event.text.text));
keyInput.setType(KeyInput::PRESSED);
keyInput.setShiftPressed(false);
keyInput.setControlPressed(false);
keyInput.setAltPressed(false);
keyInput.setMetaPressed(false);
keyInput.setNumericPad(false);
mKeyInputQueue.push(keyInput);
break;
mKeyInputQueue.push(keyInput);
break;
case SDL_KEYDOWN:
keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setType(KeyInput::PRESSED);
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
keyInput.setMetaPressed(event.key.keysym.mod & KMOD_GUI);
keyInput.setNumericPad(event.key.keysym.sym >= SDLK_KP_0
&& event.key.keysym.sym <= SDLK_KP_EQUALS);
case SDL_KEYUP:
keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setType(KeyInput::RELEASED);
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
keyInput.setMetaPressed(event.key.keysym.mod & KMOD_GUI);
keyInput.setNumericPad(event.key.keysym.sym >= SDLK_KP_0
&& event.key.keysym.sym <= SDLK_KP_EQUALS);
mKeyInputQueue.push(keyInput);
break;
case SDL_MOUSEBUTTONDOWN:
mMouseDown = true;
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
mouseInput.setButton(convertMouseButton(event.button.button));
mouseInput.setType(MouseInput::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
case SDL_MOUSEBUTTONUP:
mMouseDown = false;
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
mouseInput.setButton(convertMouseButton(event.button.button));
mouseInput.setType(MouseInput::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
case SDL_MOUSEMOTION:
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
mouseInput.setButton(MouseInput::EMPTY);
mouseInput.setType(MouseInput::MOVED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
case SDL_MOUSEWHEEL:
if (event.wheel.y > 0)
mouseInput.setType(MouseInput::WHEEL_MOVED_UP);
else
mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN);
break;
case SDL_WINDOWEVENT:
/*
* This occurs when the mouse leaves the window and the Gui-chan
* application loses its mousefocus.
*/
if (event.window.event & SDL_WINDOWEVENT_LEAVE)
{
mMouseInWindow = false;
if (!mMouseDown)
{
mouseInput.setX(-1);
mouseInput.setY(-1);
mouseInput.setButton(MouseInput::EMPTY);
mouseInput.setType(MouseInput::MOVED);
mMouseInputQueue.push(mouseInput);
if (!keyInput.getKey().isPrintable() || keyInput.isAltPressed()
|| keyInput.isControlPressed()) {
mKeyInputQueue.push(keyInput);
}
}
break;
if (event.window.event & SDL_WINDOWEVENT_ENTER)
{
mMouseInWindow = true;
}
break;
case SDL_KEYUP:
keyInput.setKey(Key(convertKeyCharacter(event)));
keyInput.setType(KeyInput::RELEASED);
keyInput.setShiftPressed(event.key.keysym.mod & KMOD_SHIFT);
keyInput.setControlPressed(event.key.keysym.mod & KMOD_CTRL);
keyInput.setAltPressed(event.key.keysym.mod & KMOD_ALT);
keyInput.setMetaPressed(event.key.keysym.mod & KMOD_GUI);
keyInput.setNumericPad(event.key.keysym.sym >= SDLK_KP_0
&& event.key.keysym.sym <= SDLK_KP_EQUALS);
mKeyInputQueue.push(keyInput);
break;
case SDL_MOUSEBUTTONDOWN:
mMouseDown = true;
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
mouseInput.setButton(convertMouseButton(event.button.button));
mouseInput.setType(MouseInput::PRESSED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
case SDL_MOUSEBUTTONUP:
mMouseDown = false;
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
mouseInput.setButton(convertMouseButton(event.button.button));
mouseInput.setType(MouseInput::RELEASED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
case SDL_MOUSEMOTION:
mouseInput.setX(event.button.x);
mouseInput.setY(event.button.y);
mouseInput.setButton(MouseInput::EMPTY);
mouseInput.setType(MouseInput::MOVED);
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
case SDL_MOUSEWHEEL:
if (event.wheel.y > 0)
mouseInput.setType(MouseInput::WHEEL_MOVED_UP);
else
mouseInput.setType(MouseInput::WHEEL_MOVED_DOWN);
break;
case SDL_WINDOWEVENT:
/*
* This occurs when the mouse leaves the window and the Gui-chan
* application loses its mousefocus.
*/
if (event.window.event & SDL_WINDOWEVENT_LEAVE) {
mMouseInWindow = false;
if (!mMouseDown) {
mouseInput.setX(-1);
mouseInput.setY(-1);
mouseInput.setButton(MouseInput::EMPTY);
mouseInput.setType(MouseInput::MOVED);
mMouseInputQueue.push(mouseInput);
}
}
if (event.window.event & SDL_WINDOWEVENT_ENTER) {
mMouseInWindow = true;
}
break;
} // end switch
}
int SDLInput::convertMouseButton(int button)
{
switch (button)
{
case SDL_BUTTON_LEFT:
return MouseInput::LEFT;
case SDL_BUTTON_RIGHT:
return MouseInput::RIGHT;
case SDL_BUTTON_MIDDLE:
return MouseInput::MIDDLE;
default:
// We have an unknown mouse type which is ignored.
return button;
int SDLInput::convertMouseButton(int button) {
switch (button) {
case SDL_BUTTON_LEFT:
return MouseInput::LEFT;
break;
case SDL_BUTTON_RIGHT:
return MouseInput::RIGHT;
break;
case SDL_BUTTON_MIDDLE:
return MouseInput::MIDDLE;
break;
default:
// We have an unknown mouse type which is ignored.
return button;
}
}
int SDLInput::convertKeyCharacter(SDL_Event event)
{
const auto keysym = event.key.keysym;
int SDLInput::convertKeyCharacter(SDL_Event event) {
SDL_Keysym keysym = event.key.keysym;
int value;
switch (keysym.sym)
{
case SDLK_TAB:
value = Key::TAB;
break;
case SDLK_LALT:
value = Key::LEFT_ALT;
break;
case SDLK_RALT:
value = Key::RIGHT_ALT;
break;
case SDLK_LSHIFT:
value = Key::LEFT_SHIFT;
break;
case SDLK_RSHIFT:
value = Key::RIGHT_SHIFT;
break;
case SDLK_LCTRL:
value = Key::LEFT_CONTROL;
break;
case SDLK_RCTRL:
value = Key::RIGHT_CONTROL;
break;
case SDLK_BACKSPACE:
value = Key::BACKSPACE;
break;
case SDLK_PAUSE:
value = Key::PAUSE;
break;
case SDLK_SPACE:
value = Key::SPACE;
break;
case SDLK_ESCAPE:
value = Key::ESCAPE;
break;
case SDLK_DELETE:
value = Key::DELETE;
break;
case SDLK_INSERT:
value = Key::INSERT;
break;
case SDLK_HOME:
value = Key::HOME;
break;
case SDLK_END:
value = Key::END;
break;
case SDLK_PAGEUP:
value = Key::PAGE_UP;
break;
case SDLK_PRINTSCREEN:
value = Key::PRINT_SCREEN;
break;
case SDLK_PAGEDOWN:
value = Key::PAGE_DOWN;
break;
case SDLK_F1:
value = Key::F1;
break;
case SDLK_F2:
value = Key::F2;
break;
case SDLK_F3:
value = Key::F3;
break;
case SDLK_F4:
value = Key::F4;
break;
case SDLK_F5:
value = Key::F5;
break;
case SDLK_F6:
value = Key::F6;
break;
case SDLK_F7:
value = Key::F7;
break;
case SDLK_F8:
value = Key::F8;
break;
case SDLK_F9:
value = Key::F9;
break;
case SDLK_F10:
value = Key::F10;
break;
case SDLK_F11:
value = Key::F11;
break;
case SDLK_F12:
value = Key::F12;
break;
case SDLK_F13:
value = Key::F13;
break;
case SDLK_F14:
value = Key::F14;
break;
case SDLK_F15:
value = Key::F15;
break;
case SDLK_NUMLOCKCLEAR:
value = Key::NUM_LOCK;
break;
case SDLK_CAPSLOCK:
value = Key::CAPS_LOCK;
break;
case SDLK_SCROLLLOCK:
value = Key::SCROLL_LOCK;
break;
case SDLK_RGUI:
value = Key::RIGHT_META;
break;
case SDLK_LGUI:
value = Key::LEFT_META;
break;
case SDLK_MODE:
value = Key::ALT_GR;
break;
case SDLK_UP:
value = Key::UP;
break;
case SDLK_DOWN:
value = Key::DOWN;
break;
case SDLK_LEFT:
value = Key::LEFT;
break;
case SDLK_RIGHT:
value = Key::RIGHT;
break;
case SDLK_RETURN:
value = Key::ENTER;
break;
case SDLK_KP_ENTER:
value = Key::ENTER;
break;
default:
value = keysym.sym;
break;
}
if (!(keysym.mod & KMOD_NUM))
{
switch (keysym.sym)
{
case SDLK_KP_0:
int value = 0;
switch (keysym.sym) {
case SDLK_TAB:
value = Key::TAB;
break;
case SDLK_LALT:
value = Key::LEFT_ALT;
break;
case SDLK_RALT:
value = Key::RIGHT_ALT;
break;
case SDLK_LSHIFT:
value = Key::LEFT_SHIFT;
break;
case SDLK_RSHIFT:
value = Key::RIGHT_SHIFT;
break;
case SDLK_LCTRL:
value = Key::LEFT_CONTROL;
break;
case SDLK_RCTRL:
value = Key::RIGHT_CONTROL;
break;
case SDLK_BACKSPACE:
value = Key::BACKSPACE;
break;
case SDLK_PAUSE:
value = Key::PAUSE;
break;
case SDLK_SPACE:
value = Key::SPACE;
break;
case SDLK_ESCAPE:
value = Key::ESCAPE;
break;
case SDLK_DELETE:
value = Key::DELETE;
break;
case SDLK_INSERT:
value = Key::INSERT;
break;
case SDLK_KP_1:
value = Key::END;
break;
case SDLK_KP_2:
value = Key::DOWN;
break;
case SDLK_KP_3:
value = Key::PAGE_DOWN;
break;
case SDLK_KP_4:
value = Key::LEFT;
break;
case SDLK_KP_5:
value = 0;
break;
case SDLK_KP_6:
value = Key::RIGHT;
break;
case SDLK_KP_7:
case SDLK_HOME:
value = Key::HOME;
break;
case SDLK_KP_8:
value = Key::UP;
case SDLK_END:
value = Key::END;
break;
case SDLK_KP_9:
case SDLK_PAGEUP:
value = Key::PAGE_UP;
break;
default:
case SDLK_PRINTSCREEN:
value = Key::PRINT_SCREEN;
break;
case SDLK_PAGEDOWN:
value = Key::PAGE_DOWN;
break;
case SDLK_F1:
value = Key::F1;
break;
case SDLK_F2:
value = Key::F2;
break;
case SDLK_F3:
value = Key::F3;
break;
case SDLK_F4:
value = Key::F4;
break;
case SDLK_F5:
value = Key::F5;
break;
case SDLK_F6:
value = Key::F6;
break;
case SDLK_F7:
value = Key::F7;
break;
case SDLK_F8:
value = Key::F8;
break;
case SDLK_F9:
value = Key::F9;
break;
case SDLK_F10:
value = Key::F10;
break;
case SDLK_F11:
value = Key::F11;
break;
case SDLK_F12:
value = Key::F12;
break;
case SDLK_F13:
value = Key::F13;
break;
case SDLK_F14:
value = Key::F14;
break;
case SDLK_F15:
value = Key::F15;
break;
case SDLK_NUMLOCKCLEAR:
value = Key::NUM_LOCK;
break;
case SDLK_CAPSLOCK:
value = Key::CAPS_LOCK;
break;
case SDLK_SCROLLLOCK:
value = Key::SCROLL_LOCK;
break;
case SDLK_RGUI:
value = Key::RIGHT_META;
break;
case SDLK_LGUI:
value = Key::LEFT_META;
break;
case SDLK_MODE:
value = Key::ALT_GR;
break;
case SDLK_UP:
value = Key::UP;
break;
case SDLK_DOWN:
value = Key::DOWN;
break;
case SDLK_LEFT:
value = Key::LEFT;
break;
case SDLK_RIGHT:
value = Key::RIGHT;
break;
case SDLK_RETURN:
value = Key::ENTER;
break;
case SDLK_KP_ENTER:
value = Key::ENTER;
break;
default:
value = keysym.sym;
break;
}
}
else
{
switch (keysym.sym)
{
case SDLK_KP_0:
value = SDLK_0;
break;
case SDLK_KP_1:
value = SDLK_1;
break;
case SDLK_KP_2:
value = SDLK_2;
break;
case SDLK_KP_3:
value = SDLK_3;
break;
case SDLK_KP_4:
value = SDLK_4;
break;
case SDLK_KP_5:
value = SDLK_5;
break;
case SDLK_KP_6:
value = SDLK_6;
break;
case SDLK_KP_7:
value = SDLK_7;
break;
case SDLK_KP_8:
value = SDLK_8;
break;
case SDLK_KP_9:
value = SDLK_9;
break;
default:
break;
if (!(keysym.mod & KMOD_NUM)) {
switch (keysym.sym) {
case SDLK_KP_0:
value = Key::INSERT;
break;
case SDLK_KP_1:
value = Key::END;
break;
case SDLK_KP_2:
value = Key::DOWN;
break;
case SDLK_KP_3:
value = Key::PAGE_DOWN;
break;
case SDLK_KP_4:
value = Key::LEFT;
break;
case SDLK_KP_5:
value = 0;
break;
case SDLK_KP_6:
value = Key::RIGHT;
break;
case SDLK_KP_7:
value = Key::HOME;
break;
case SDLK_KP_8:
value = Key::UP;
break;
case SDLK_KP_9:
value = Key::PAGE_UP;
break;
default:
break;
}
} else {
switch (keysym.sym) {
case SDLK_KP_0:
value = SDLK_0;
break;
case SDLK_KP_1:
value = SDLK_1;
break;
case SDLK_KP_2:
value = SDLK_2;
break;
case SDLK_KP_3:
value = SDLK_3;
break;
case SDLK_KP_4:
value = SDLK_4;
break;
case SDLK_KP_5:
value = SDLK_5;
break;
case SDLK_KP_6:
value = SDLK_6;
break;
case SDLK_KP_7:
value = SDLK_7;
break;
case SDLK_KP_8:
value = SDLK_8;
break;
case SDLK_KP_9:
value = SDLK_9;
break;
default:
break;
}
}

View File

@ -61,11 +61,11 @@ namespace gcn
mGlyphSpacing = 0;
mAntiAlias = true;
mFilename = filename;
mFont = nullptr;
mFont = NULL;
mFont = TTF_OpenFont(filename.c_str(), size);
if (mFont == nullptr)
if (mFont == NULL)
{
throw GCN_EXCEPTION("SDLTrueTypeFont::SDLTrueTypeFont. "+std::string(TTF_GetError()));
}
@ -89,25 +89,25 @@ namespace gcn
return TTF_FontHeight(mFont) + mRowSpacing;
}
void SDLTrueTypeFont::drawString(Graphics* graphics, const std::string& text, const int x, const int y)
void SDLTrueTypeFont::drawString(gcn::Graphics* graphics, const std::string& text, const int x, const int y)
{
if (text == "")
{
return;
}
auto* sdlGraphics = dynamic_cast<SDLGraphics*>(graphics);
auto* sdl2Graphics = dynamic_cast<SDL2Graphics*>(graphics);
gcn::SDLGraphics* sdlGraphics = dynamic_cast<gcn::SDLGraphics*>(graphics);
gcn::SDL2Graphics* sdl2Graphics = dynamic_cast<gcn::SDL2Graphics*>(graphics);
if (sdlGraphics == nullptr && sdl2Graphics == nullptr)
if (sdlGraphics == NULL && sdl2Graphics == NULL)
{
throw GCN_EXCEPTION("SDLTrueTypeFont::drawString. Graphics object not an SDL graphics object!");
return;
}
// This is needed for drawing the Glyph in the middle if we have spacing
const auto yoffset = getRowSpacing() / 2;
const int yoffset = getRowSpacing() / 2;
Color col;
if (sdlGraphics)

View File

@ -65,6 +65,7 @@ namespace gcn
SelectionEvent::SelectionEvent(Widget* source)
: Event(source)
{
}
SelectionEvent::~SelectionEvent()

View File

@ -76,7 +76,7 @@
namespace gcn
{
Font* Widget::mGlobalFont = nullptr;
Font* Widget::mGlobalFont = NULL;
DefaultFont Widget::mDefaultFont;
std::list<Widget*> Widget::mWidgets;
@ -85,16 +85,16 @@ namespace gcn
mBackgroundColor(0xffffff),
mBaseColor(0xDDDDE3),
mSelectionColor(0xc3d9ff),
mFocusHandler(nullptr),
mInternalFocusHandler(nullptr),
mParent(nullptr),
mFocusHandler(NULL),
mInternalFocusHandler(NULL),
mParent(NULL),
mBorderSize(0),
mFocusable(false),
mVisible(true),
mTabIn(true),
mTabOut(true),
mEnabled(true),
mCurrentFont(nullptr)
mCurrentFont(NULL)
{
mWidgets.push_back(this);
}
@ -107,7 +107,7 @@ namespace gcn
mDeathListener->death(event);
}
Widget::_setFocusHandler(nullptr);
_setFocusHandler(NULL);
mWidgets.remove(this);
}
@ -124,7 +124,7 @@ namespace gcn
void Widget::setWidth(int width)
{
auto newDimension = mDimension;
Rectangle newDimension = mDimension;
newDimension.width = width;
setDimension(newDimension);
@ -137,7 +137,7 @@ namespace gcn
void Widget::setHeight(int height)
{
auto newDimension = mDimension;
Rectangle newDimension = mDimension;
newDimension.height = height;
setDimension(newDimension);
@ -150,7 +150,7 @@ namespace gcn
void Widget::setX(int x)
{
auto newDimension = mDimension;
Rectangle newDimension = mDimension;
newDimension.x = x;
setDimension(newDimension);
@ -163,7 +163,7 @@ namespace gcn
void Widget::setY(int y)
{
auto newDimension = mDimension;
Rectangle newDimension = mDimension;
newDimension.y = y;
setDimension(newDimension);
@ -176,7 +176,7 @@ namespace gcn
void Widget::setPosition(int x, int y)
{
auto newDimension = mDimension;
Rectangle newDimension = mDimension;
newDimension.x = x;
newDimension.y = y;
@ -185,7 +185,7 @@ namespace gcn
void Widget::setDimension(const Rectangle& dimension)
{
const auto oldDimension = mDimension;
const Rectangle oldDimension = mDimension;
mDimension = dimension;
if (mDimension.width != oldDimension.width
@ -253,7 +253,7 @@ namespace gcn
void Widget::requestFocus()
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?).");
}
@ -301,7 +301,7 @@ namespace gcn
bool Widget::isVisible() const
{
if (getParent() == nullptr)
if (getParent() == NULL)
{
return mVisible;
}
@ -431,7 +431,7 @@ namespace gcn
void Widget::getAbsolutePosition(int& x, int& y) const
{
if (getParent() == nullptr)
if (getParent() == NULL)
{
x = mDimension.x;
y = mDimension.y;
@ -458,9 +458,9 @@ namespace gcn
Font* Widget::getFont() const
{
if (mCurrentFont == nullptr)
if (mCurrentFont == NULL)
{
if (mGlobalFont == nullptr)
if (mGlobalFont == NULL)
{
return &mDefaultFont;
}
@ -477,7 +477,7 @@ namespace gcn
for (auto& mWidget : mWidgets)
{
if (mWidget->mCurrentFont == nullptr)
if (mWidget->mCurrentFont == NULL)
{
mWidget->fontChanged();
}
@ -525,7 +525,7 @@ namespace gcn
void Widget::setSize(int width, int height)
{
auto newDimension = mDimension;
Rectangle newDimension = mDimension;
newDimension.width = width;
newDimension.height = height;
@ -544,7 +544,7 @@ namespace gcn
void Widget::requestModalFocus()
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?).");
}
@ -554,7 +554,7 @@ namespace gcn
void Widget::requestModalMouseInputFocus()
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?).");
}
@ -564,7 +564,7 @@ namespace gcn
void Widget::releaseModalFocus()
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
return;
}
@ -574,7 +574,7 @@ namespace gcn
void Widget::releaseModalMouseInputFocus()
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
return;
}
@ -584,12 +584,12 @@ namespace gcn
bool Widget::hasModalFocus() const
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?).");
}
if (getParent() != nullptr)
if (getParent() != NULL)
{
return mFocusHandler->getModalFocused() == this || getParent()->hasModalFocus();
}
@ -599,12 +599,12 @@ namespace gcn
bool Widget::hasModalMouseInputFocus() const
{
if (mFocusHandler == nullptr)
if (mFocusHandler == NULL)
{
throw GCN_EXCEPTION("No focushandler set (did you add the widget to the gui?).");
}
if (getParent() != nullptr)
if (getParent() != NULL)
{
return mFocusHandler->getModalMouseInputFocused() == this || getParent()->hasModalMouseInputFocus();
}
@ -614,7 +614,7 @@ namespace gcn
Widget* Widget::getWidgetAt(int x, int y)
{
return nullptr;
return NULL;
}
const std::list<MouseListener*>& Widget::_getMouseListeners()
@ -652,7 +652,7 @@ namespace gcn
mId = id;
}
const std::string& Widget::getId() const
const std::string& Widget::getId()
{
return mId;
}

View File

@ -58,9 +58,6 @@
* For comments regarding functions please see the header file.
*/
#include <utility>
#include "guisan/widgets/button.hpp"
#include "guisan/exception.hpp"
@ -80,7 +77,7 @@ namespace gcn
mSpacing(4)
{
setFocusable(true);
Button::adjustSize();
adjustSize();
setBorderSize(1);
addMouseListener(this);
@ -88,8 +85,8 @@ namespace gcn
addFocusListener(this);
}
Button::Button(std::string caption)
: mCaption(std::move(caption)),
Button::Button(const std::string& caption)
: mCaption(caption),
mHasMouse(false),
mKeyPressed(false),
mMousePressed(false),
@ -97,7 +94,7 @@ namespace gcn
mSpacing(4)
{
setFocusable(true);
Button::adjustSize();
adjustSize();
setBorderSize(1);
addMouseListener(this);
@ -137,9 +134,9 @@ namespace gcn
void Button::draw(Graphics* graphics)
{
auto faceColor = getBaseColor();
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
const auto alpha = getBaseColor().a;
int alpha = getBaseColor().a;
if (isPressed())
{
@ -174,19 +171,19 @@ namespace gcn
else
graphics->setColor(Color(128, 128, 128));
int text_x;
const auto text_y = getHeight() / 2 - getFont()->getHeight() / 2;
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
switch (getAlignment())
{
case Graphics::LEFT:
text_x = static_cast<int>(mSpacing);
textX = static_cast<int>(mSpacing);
break;
case Graphics::CENTER:
text_x = getWidth() / 2;
textX = getWidth() / 2;
break;
case Graphics::RIGHT:
text_x = getWidth() - static_cast<int>(mSpacing);
textX = getWidth() - static_cast<int>(mSpacing);
break;
default:
throw GCN_EXCEPTION("Unknown alignment.");
@ -196,11 +193,11 @@ namespace gcn
if (isPressed())
{
graphics->drawText(getCaption(), text_x + 1, text_y + 1, getAlignment());
graphics->drawText(getCaption(), textX + 1, textY + 1, getAlignment());
}
else
{
graphics->drawText(getCaption(), text_x, text_y, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment());
if (isFocused())
{
@ -212,16 +209,18 @@ namespace gcn
void Button::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
int height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);
@ -289,7 +288,7 @@ namespace gcn
void Button::keyPressed(KeyEvent& keyEvent)
{
const auto key = keyEvent.getKey();
const Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER
|| key.getValue() == Key::SPACE)
@ -301,7 +300,7 @@ namespace gcn
void Button::keyReleased(KeyEvent& keyEvent)
{
const auto key = keyEvent.getKey();
const Key key = keyEvent.getKey();
if ((key.getValue() == Key::ENTER
|| key.getValue() == Key::SPACE)

View File

@ -98,23 +98,25 @@ namespace gcn
else
graphics->setColor(Color(128, 128, 128));
const auto h = getHeight() + getHeight() / 2;
const int h = getHeight() + getHeight() / 2;
graphics->drawText(getCaption(), h - 2, 1);
}
void CheckBox::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
int height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);
@ -127,13 +129,13 @@ namespace gcn
void CheckBox::drawBox(Graphics* graphics)
{
const auto h = getHeight() - 2;
const auto alpha = getBaseColor().a;
auto faceColor = getBaseColor();
const int h = getHeight() - 2;
const int alpha = getBaseColor().a;
Color faceColor = getBaseColor();
faceColor.a = alpha;
auto highlightColor = faceColor + 0x303030;
Color highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
graphics->setColor(shadowColor);
@ -144,7 +146,7 @@ namespace gcn
graphics->drawLine(h, 1, h, h);
graphics->drawLine(1, h, h - 1, h);
auto backCol = getBackgroundColor();
Color backCol = getBackgroundColor();
if (!isEnabled())
backCol = backCol - 0x303030;
graphics->setColor(backCol);
@ -189,7 +191,7 @@ namespace gcn
void CheckBox::keyPressed(KeyEvent& keyEvent)
{
const auto key = keyEvent.getKey();
const Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER ||
key.getValue() == Key::SPACE)
@ -214,7 +216,7 @@ namespace gcn
void CheckBox::adjustSize()
{
const auto height = getFont()->getHeight() + 2;
const int height = getFont()->getHeight() + 2;
setHeight(height);
setWidth(getFont()->getWidth(mCaption) + height + height / 2);

View File

@ -86,16 +86,18 @@ namespace gcn
void Container::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
int height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);

View File

@ -71,16 +71,16 @@ namespace gcn
ScrollArea* scrollArea,
ListBox* listBox)
{
Widget::setWidth(100);
setWidth(100);
setFocusable(true);
mDroppedDown = false;
mPushed = false;
mIsDragged = false;
BasicContainer::setInternalFocusHandler(&mInternalFocusHandler);
setInternalFocusHandler(&mInternalFocusHandler);
mInternalScrollArea = (scrollArea == nullptr);
mInternalListBox = (listBox == nullptr);
mInternalScrollArea = (scrollArea == NULL);
mInternalListBox = (listBox == NULL);
if (mInternalScrollArea)
{
@ -101,7 +101,7 @@ namespace gcn
}
mScrollArea->setContent(mListBox);
BasicContainer::add(mScrollArea);
add(mScrollArea);
mListBox->addActionListener(this);
mListBox->addSelectionListener(this);
@ -132,7 +132,7 @@ namespace gcn
if (mInternalListBox)
delete mListBox;
BasicContainer::setInternalFocusHandler(nullptr);
setInternalFocusHandler(NULL);
}
void DropDown::draw(Graphics* graphics)
@ -148,15 +148,15 @@ namespace gcn
h = getHeight();
}
const auto alpha = getBaseColor().a;
auto faceColor = getBaseColor();
int alpha = getBaseColor().a;
Color faceColor = getBaseColor();
faceColor.a = alpha;
auto highlightColor = faceColor + 0x303030;
Color highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
auto backCol = getBackgroundColor();
Color backCol = getBackgroundColor();
if (!isEnabled())
backCol = backCol - 0x303030;
graphics->setColor(backCol);
@ -196,16 +196,18 @@ namespace gcn
void DropDown::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
int height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);
@ -220,7 +222,7 @@ namespace gcn
{
Color faceColor, highlightColor, shadowColor;
int offset;
const auto alpha = getBaseColor().a;
const int alpha = getBaseColor().a;
if (mPushed)
{
@ -252,8 +254,8 @@ namespace gcn
{
h = getHeight();
}
const auto x = getWidth() - h;
const auto y = 0;
const int x = getWidth() - h;
const int y = 0;
graphics->setColor(faceColor);
graphics->fillRectangle(Rectangle(x + 1,
@ -286,10 +288,11 @@ namespace gcn
else
graphics->setColor(Color(128, 128, 128));
const auto hh = h / 3;
const auto hx = x + h / 2;
const auto hy = y + (h * 2) / 3;
for (auto i = 0; i < hh; i++)
int i;
const int hh = h / 3;
const int hx = x + h / 2;
const int hy = y + (h * 2) / 3;
for (i = 0; i < hh; i++)
{
graphics->drawLine(hx - i + offset,
hy - i + offset,
@ -321,7 +324,7 @@ namespace gcn
if (keyEvent.isConsumed())
return;
const auto key = keyEvent.getKey();
const Key key = keyEvent.getKey();
if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
&& !mDroppedDown)
@ -429,21 +432,21 @@ namespace gcn
adjustHeight();
}
ListModel* DropDown::getListModel() const
ListModel* DropDown::getListModel()
{
return mListBox->getListModel();
}
void DropDown::adjustHeight()
{
if (mScrollArea == nullptr)
if (mScrollArea == NULL)
throw GCN_EXCEPTION("Scroll Area has been deleted.");
if (mListBox == nullptr)
if (mListBox == NULL)
throw GCN_EXCEPTION("List box has been deleted.");
const auto listBoxHeight = mListBox->getHeight();
const auto h2 = getFont()->getHeight() + 2;
const int listBoxHeight = mListBox->getHeight();
const int h2 = getFont()->getHeight() + 2;
setHeight(h2);
@ -452,7 +455,7 @@ namespace gcn
if (mDroppedDown && getParent())
{
const auto h = getParent()->getChildrenArea().height - getY();
const int h = getParent()->getChildrenArea().height - getY();
if (listBoxHeight > h - h2 - 2)
{
@ -489,7 +492,7 @@ namespace gcn
mListBox->requestFocus();
}
bool DropDown::isDroppedDown() const
bool DropDown::isDroppedDown()
{
return mDroppedDown;
}
@ -515,7 +518,7 @@ namespace gcn
{
if (event.getSource() == mScrollArea)
{
mScrollArea = nullptr;
mScrollArea = NULL;
}
BasicContainer::death(event);
}

View File

@ -70,16 +70,16 @@ namespace gcn
{
mImage = Image::load(filename);
mInternalImage = true;
Widget::setHeight(mImage->getHeight());
Widget::setWidth(mImage->getWidth());
setHeight(mImage->getHeight());
setWidth(mImage->getWidth());
}
Icon::Icon(Image* image)
{
mImage = image;
mInternalImage = false;
Widget::setHeight(mImage->getHeight());
Widget::setWidth(mImage->getWidth());
setHeight(mImage->getHeight());
setWidth(mImage->getWidth());
}
Icon::~Icon()
@ -97,16 +97,18 @@ namespace gcn
void Icon::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
int height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);

View File

@ -69,16 +69,16 @@ namespace gcn
{
mImage = Image::load(filename);
mInternalImage = true;
Widget::setWidth(mImage->getWidth() + mImage->getWidth() / 2);
Widget::setHeight(mImage->getHeight() + mImage->getHeight() / 2);
setWidth(mImage->getWidth() + mImage->getWidth() / 2);
setHeight(mImage->getHeight() + mImage->getHeight() / 2);
}
ImageButton::ImageButton(Image* image)
{
mImage = image;
mInternalImage = false;
Widget::setWidth(mImage->getWidth() + mImage->getWidth() / 2);
Widget::setHeight(mImage->getHeight() + mImage->getHeight() / 2);
setWidth(mImage->getWidth() + mImage->getWidth() / 2);
setHeight(mImage->getHeight() + mImage->getHeight() / 2);
}
ImageButton::~ImageButton()
@ -108,9 +108,9 @@ namespace gcn
void ImageButton::draw(Graphics* graphics)
{
auto faceColor = getBaseColor();
Color highlightColor, shadowColor;
const auto alpha = getBaseColor().a;
gcn::Color faceColor = getBaseColor();
gcn::Color highlightColor, shadowColor;
const int alpha = getBaseColor().a;
if (isPressed())
{
@ -142,16 +142,16 @@ namespace gcn
graphics->setColor(getForegroundColor());
const auto text_x = getWidth() / 2 - mImage->getWidth() / 2;
const auto text_y = getHeight() / 2 - mImage->getHeight() / 2;
const int textX = getWidth() / 2 - mImage->getWidth() / 2;
const int textY = getHeight() / 2 - mImage->getHeight() / 2;
if (isPressed())
{
graphics->drawImage(mImage, text_x + 1, text_y + 1);
graphics->drawImage(mImage, textX + 1, textY + 1);
}
else
{
graphics->drawImage(mImage, text_x, text_y);
graphics->drawImage(mImage, textX, textY);
if (isFocused())
{

View File

@ -76,8 +76,8 @@ namespace gcn
mCaption = caption;
mAlignment = Graphics::LEFT;
Widget::setWidth(getFont()->getWidth(caption));
Widget::setHeight(getFont()->getHeight() + 2);
setWidth(getFont()->getWidth(caption));
setHeight(getFont()->getHeight() + 2);
}
const std::string& Label::getCaption() const
@ -102,44 +102,46 @@ namespace gcn
void Label::draw(Graphics* graphics)
{
int text_x;
const auto text_y = getHeight() / 2 - getFont()->getHeight() / 2;
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
switch (getAlignment())
{
case Graphics::LEFT:
text_x = 0;
textX = 0;
break;
case Graphics::CENTER:
text_x = getWidth() / 2;
textX = getWidth() / 2;
break;
case Graphics::RIGHT:
text_x = getWidth();
textX = getWidth();
break;
default:
throw GCN_EXCEPTION("Unknown alignment.");
}
graphics->setFont(getFont());
auto color = getForegroundColor();
Color color = getForegroundColor();
if (!isEnabled())
color = Color(128, 128, 128);
graphics->setColor(color);
graphics->drawText(getCaption(), text_x, text_y, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment());
}
void Label::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + getBorderSize() * 2 - 1;
int height = getHeight() + getBorderSize() * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);

View File

@ -73,9 +73,9 @@ namespace gcn
ListBox::ListBox()
{
mSelected = -1;
mListModel = nullptr;
mListModel = NULL;
mWrappingEnabled = false;
Widget::setWidth(100);
setWidth(100);
setFocusable(true);
addMouseListener(this);
@ -86,7 +86,7 @@ namespace gcn
{
mSelected = -1;
mWrappingEnabled = false;
Widget::setWidth(100);
setWidth(100);
setListModel(listModel);
setFocusable(true);
@ -99,7 +99,7 @@ namespace gcn
graphics->setColor(getBackgroundColor());
graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
if (mListModel == nullptr)
if (mListModel == NULL)
{
return;
}
@ -173,16 +173,18 @@ namespace gcn
void ListBox::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + getBorderSize() * 2 - 1;
int height = getHeight() + getBorderSize() * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);
@ -205,7 +207,7 @@ namespace gcn
void ListBox::setSelected(int selected)
{
if (mListModel == nullptr)
if (mListModel == NULL)
{
mSelected = -1;
}
@ -224,8 +226,8 @@ namespace gcn
mSelected = selected;
}
auto* par = getParent();
if (par == nullptr)
Widget* par = getParent();
if (par == NULL)
{
return;
}
@ -250,7 +252,7 @@ namespace gcn
void ListBox::keyPressed(KeyEvent& keyEvent)
{
const auto key = keyEvent.getKey();
const Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
{
@ -345,14 +347,14 @@ namespace gcn
adjustSize();
}
ListModel* ListBox::getListModel() const
ListModel* ListBox::getListModel()
{
return mListModel;
}
void ListBox::adjustSize()
{
if (mListModel != nullptr)
if (mListModel != NULL)
{
setHeight(getFont()->getHeight() * mListModel->getNumberOfElements());
}

View File

@ -140,69 +140,71 @@ namespace gcn
graphics->setColor(getBackgroundColor());
graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
int text_x;
const auto text_y = getHeight() / 2 - getFont()->getHeight() / 2;
int textX;
int textY = getHeight() / 2 - getFont()->getHeight() / 2;
graphics->setColor(getSelectionColor());
int progress_width;
int progressWidth;
if (mStart == 0 && mEnd == 0)
{
// Infinite scrollbar
progress_width = getWidth() / 5;
const auto bar_x = getWidth() * static_cast<int>(mValue) / 100;
progressWidth = getWidth() / 5;
int barX = getWidth() * static_cast<int>(mValue) / 100;
if (bar_x + progress_width > getWidth())
if (barX + progressWidth > getWidth())
{
graphics->fillRectangle(Rectangle(bar_x, 0, getWidth() - bar_x, getHeight()));
graphics->fillRectangle(Rectangle(0, 0, progress_width - (getWidth() - bar_x), getHeight()));
graphics->fillRectangle(Rectangle(barX, 0, getWidth() - barX, getHeight()));
graphics->fillRectangle(Rectangle(0, 0, progressWidth - (getWidth() - barX), getHeight()));
}
else
{
graphics->fillRectangle(Rectangle(bar_x, 0, progress_width, getHeight()));
graphics->fillRectangle(Rectangle(barX, 0, progressWidth, getHeight()));
}
}
else
{
// Standard scrollbar
progress_width = getWidth() * static_cast<int>(mValue) / static_cast<int>(mEnd - mStart);
graphics->fillRectangle(Rectangle(0, 0, progress_width, getHeight()));
progressWidth = getWidth() * static_cast<int>(mValue) / static_cast<int>(mEnd - mStart);
graphics->fillRectangle(Rectangle(0, 0, progressWidth, getHeight()));
}
switch (getAlignment())
{
case Graphics::LEFT:
text_x = 0;
textX = 0;
break;
case Graphics::CENTER:
text_x = getWidth() / 2;
textX = getWidth() / 2;
break;
case Graphics::RIGHT:
text_x = getWidth();
textX = getWidth();
break;
default:
throw GCN_EXCEPTION("Unknown alignment.");
}
graphics->setFont(getFont());
auto color = getForegroundColor();
Color color = getForegroundColor();
if (!isEnabled())
color = color - 0x303030;
graphics->setColor(color);
graphics->drawText(getCaption(), text_x, text_y, getAlignment());
graphics->drawText(getCaption(), textX, textY, getAlignment());
}
void ProgressBar::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + getBorderSize() * 2 - 1;
int height = getHeight() + getBorderSize() * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (int i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);

View File

@ -117,23 +117,25 @@ namespace gcn
graphics->drawRectangle(Rectangle(0,0, getWidth(), getHeight()));
}
const auto h = getHeight() + getHeight() / 2;
const int h = getHeight() + getHeight() / 2;
graphics->drawText(getCaption(), h - 2, 0);
}
void RadioButton::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + getBorderSize() * 2 - 1;
int height = getHeight() + getBorderSize() * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (int i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);
@ -157,21 +159,21 @@ namespace gcn
h = getHeight() - 3;
}
const auto alpha = getBaseColor().a;
auto faceColor = getBaseColor();
const int alpha = getBaseColor().a;
Color faceColor = getBaseColor();
faceColor.a = alpha;
auto highlightColor = faceColor + 0x303030;
Color highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
auto backCol = getBackgroundColor();
Color backCol = getBackgroundColor();
if (!isEnabled())
backCol = backCol - 0x303030;
graphics->setColor(backCol);
int i;
const auto hh = (h + 1) / 2;
const int hh = (h + 1) / 2;
for (i = 1; i <= hh; ++i)
{
@ -199,7 +201,7 @@ namespace gcn
graphics->setColor(getForegroundColor());
const auto hhh = hh - 3;
const int hhh = hh - 3;
if (mSelected)
{
for (i = 0; i < hhh; ++i)
@ -222,9 +224,9 @@ namespace gcn
{
if (selected && !mGroup.empty())
{
const auto iterEnd = mGroupMap.upper_bound(mGroup);
const GroupIterator iterEnd = mGroupMap.upper_bound(mGroup);
for (auto iter = mGroupMap.lower_bound(mGroup);
for (GroupIterator iter = mGroupMap.lower_bound(mGroup);
iter != iterEnd;
++iter)
{
@ -250,7 +252,7 @@ namespace gcn
void RadioButton::keyPressed(KeyEvent& keyEvent)
{
const auto key = keyEvent.getKey();
const Key key = keyEvent.getKey();
if (key.getValue() == Key::ENTER ||
key.getValue() == Key::SPACE)
@ -279,9 +281,9 @@ namespace gcn
{
if (!mGroup.empty())
{
const auto iterEnd = mGroupMap.upper_bound(mGroup);
const GroupIterator iterEnd = mGroupMap.upper_bound(mGroup);
for (auto iter = mGroupMap.lower_bound(mGroup);
for (GroupIterator iter = mGroupMap.lower_bound(mGroup);
iter != iterEnd;
++iter)
{
@ -309,7 +311,7 @@ namespace gcn
void RadioButton::adjustSize()
{
const auto height = getFont()->getHeight();
const int height = getFont()->getHeight();
setHeight(height);
setWidth(getFont()->getWidth(getCaption()) + height + height / 2);

View File

@ -132,12 +132,12 @@ namespace gcn
ScrollArea::~ScrollArea()
{
setContent(nullptr);
setContent(NULL);
}
void ScrollArea::setContent(Widget* widget)
{
if (widget != nullptr)
if (widget != NULL)
{
clear();
add(widget);
@ -158,7 +158,7 @@ namespace gcn
return *mWidgets.begin();
}
return nullptr;
return NULL;
}
void ScrollArea::setHorizontalScrollPolicy(unsigned int hPolicy)
@ -192,7 +192,7 @@ namespace gcn
void ScrollArea::setVerticalScrollAmount(int vScroll)
{
const auto max = getVerticalMaxScroll();
const int max = getVerticalMaxScroll();
mVScroll = vScroll;
@ -214,7 +214,7 @@ namespace gcn
void ScrollArea::setHorizontalScrollAmount(int hScroll)
{
const auto max = getHorizontalMaxScroll();
const int max = getHorizontalMaxScroll();
mHScroll = hScroll;
@ -243,12 +243,12 @@ namespace gcn
{
checkPolicies();
if (getContent() == nullptr)
if (getContent() == NULL)
{
return 0;
}
const auto value = getContent()->getWidth() - getChildrenArea().width +
const int value = getContent()->getWidth() - getChildrenArea().width +
2 * static_cast<int>(getContent()->getBorderSize());
if (value < 0)
@ -263,12 +263,12 @@ namespace gcn
{
checkPolicies();
if (getContent() == nullptr)
if (getContent() == NULL)
{
return 0;
}
const auto value = getContent()->getHeight() - getChildrenArea().height +
const int value = getContent()->getHeight() - getChildrenArea().height +
2 * static_cast<int>(getContent()->getBorderSize());
if (value < 0)
@ -298,8 +298,8 @@ namespace gcn
void ScrollArea::mousePressed(MouseEvent& mouseEvent)
{
const auto x = mouseEvent.getX();
const auto y = mouseEvent.getY();
const int x = mouseEvent.getX();
const int y = mouseEvent.getY();
if (getUpButtonDimension().isPointInRect(x, y))
{
@ -383,10 +383,10 @@ namespace gcn
{
if (mIsVerticalMarkerDragged)
{
const auto pos = mouseEvent.getY() - getVerticalBarDimension().y - mVerticalMarkerDragOffset;
const auto length = getVerticalMarkerDimension().height;
const int pos = mouseEvent.getY() - getVerticalBarDimension().y - mVerticalMarkerDragOffset;
const int length = getVerticalMarkerDimension().height;
const auto barDim = getVerticalBarDimension();
const Rectangle barDim = getVerticalBarDimension();
if ((barDim.height - length) > 0)
{
@ -401,10 +401,10 @@ namespace gcn
if (mIsHorizontalMarkerDragged)
{
const auto pos = mouseEvent.getX() - getHorizontalBarDimension().x - mHorizontalMarkerDragOffset;
const auto length = getHorizontalMarkerDimension().width;
const int pos = mouseEvent.getX() - getHorizontalBarDimension().x - mHorizontalMarkerDragOffset;
const int length = getHorizontalMarkerDimension().width;
const auto barDim = getHorizontalBarDimension();
const Rectangle barDim = getHorizontalBarDimension();
if ((barDim.width - length) > 0)
{
@ -454,16 +454,18 @@ namespace gcn
void ScrollArea::drawBorder(Graphics* graphics)
{
const auto faceColor = getBaseColor();
const auto alpha = getBaseColor().a;
const auto width = getWidth() + static_cast<int>(getBorderSize()) * 2 - 1;
const auto height = getHeight() + static_cast<int>(getBorderSize()) * 2 - 1;
auto highlightColor = faceColor + 0x303030;
Color faceColor = getBaseColor();
Color highlightColor, shadowColor;
int alpha = getBaseColor().a;
int width = getWidth() + getBorderSize() * 2 - 1;
int height = getHeight() + getBorderSize() * 2 - 1;
highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
for (auto i = 0; i < static_cast<int>(getBorderSize()); ++i)
unsigned int i;
for (i = 0; i < getBorderSize(); ++i)
{
graphics->setColor(shadowColor);
graphics->drawLine(i, i, width - i, i);
@ -476,14 +478,14 @@ namespace gcn
void ScrollArea::drawHBar(Graphics* graphics)
{
const auto dim = getHorizontalBarDimension();
const Rectangle dim = getHorizontalBarDimension();
graphics->pushClipArea(dim);
const auto alpha = getBaseColor().a;
auto trackColor = getBaseColor() - 0x101010;
const int alpha = getBaseColor().a;
Color trackColor = getBaseColor() - 0x101010;
trackColor.a = alpha;
auto shadowColor = getBaseColor() - 0x303030;
Color shadowColor = getBaseColor() - 0x303030;
shadowColor.a = alpha;
graphics->setColor(trackColor);
@ -497,14 +499,14 @@ namespace gcn
void ScrollArea::drawVBar(Graphics* graphics)
{
const auto dim = getVerticalBarDimension();
const Rectangle dim = getVerticalBarDimension();
graphics->pushClipArea(dim);
const auto alpha = getBaseColor().a;
auto trackColor = getBaseColor() - 0x101010;
const int alpha = getBaseColor().a;
Color trackColor = getBaseColor() - 0x101010;
trackColor.a = alpha;
auto shadowColor = getBaseColor() - 0x303030;
Color shadowColor = getBaseColor() - 0x303030;
shadowColor.a = alpha;
graphics->setColor(trackColor);
@ -524,14 +526,14 @@ namespace gcn
void ScrollArea::drawUpButton(Graphics* graphics)
{
const auto dim = getUpButtonDimension();
const Rectangle dim = getUpButtonDimension();
graphics->pushClipArea(dim);
Color highlightColor;
Color shadowColor;
Color faceColor;
int offset;
const auto alpha = getBaseColor().a;
const int alpha = getBaseColor().a;
if (mUpButtonPressed)
{
@ -569,9 +571,9 @@ namespace gcn
graphics->setColor(getForegroundColor());
const auto w = dim.height / 2;
const auto h = w / 2 + 2;
for (auto i = 0; i < w / 2; ++i)
const int w = dim.height / 2;
const int h = w / 2 + 2;
for (int i = 0; i < w / 2; ++i)
{
graphics->drawLine(w - i + offset,
i + h + offset,
@ -584,14 +586,14 @@ namespace gcn
void ScrollArea::drawDownButton(Graphics* graphics)
{
const auto dim = getDownButtonDimension();
const Rectangle dim = getDownButtonDimension();
graphics->pushClipArea(dim);
Color highlightColor;
Color shadowColor;
Color faceColor;
int offset;
const auto alpha = getBaseColor().a;
const int alpha = getBaseColor().a;
if (mDownButtonPressed)
{
@ -629,9 +631,9 @@ namespace gcn
graphics->setColor(getForegroundColor());
const auto w = dim.height / 2;
const auto h = w + 1;
for (auto i = 0; i < w / 2; ++i)
const int w = dim.height / 2;
const int h = w + 1;
for (int i = 0; i < w / 2; ++i)
{
graphics->drawLine(w - i + offset,
-i + h + offset,
@ -644,14 +646,14 @@ namespace gcn
void ScrollArea::drawLeftButton(Graphics* graphics)
{
const auto dim = getLeftButtonDimension();
const Rectangle dim = getLeftButtonDimension();
graphics->pushClipArea(dim);
Color highlightColor;
Color shadowColor;
Color faceColor;
int offset;
const auto alpha = getBaseColor().a;
const int alpha = getBaseColor().a;
if (mLeftButtonPressed)
{
@ -689,9 +691,9 @@ namespace gcn
graphics->setColor(getForegroundColor());
const auto w = dim.width / 2;
const auto h = w - 2;
for (auto i = 0; i < w / 2; ++i)
const int w = dim.width / 2;
const int h = w - 2;
for (int i = 0; i < w / 2; ++i)
{
graphics->drawLine(i + h + offset,
w - i + offset,
@ -704,14 +706,14 @@ namespace gcn
void ScrollArea::drawRightButton(Graphics* graphics)
{
const auto dim = getRightButtonDimension();
const Rectangle dim = getRightButtonDimension();
graphics->pushClipArea(dim);
Color highlightColor;
Color shadowColor;
Color faceColor;
int offset;
const auto alpha = getBaseColor().a;
const int alpha = getBaseColor().a;
if (mRightButtonPressed)
{
@ -749,9 +751,9 @@ namespace gcn
graphics->setColor(getForegroundColor());
const auto w = dim.width / 2;
const auto h = w + 1;
for (auto i = 0; i < w / 2; ++i)
const int w = dim.width / 2;
const int h = w + 1;
for (int i = 0; i < w / 2; ++i)
{
graphics->drawLine(-i + h + offset,
w - i + offset,
@ -764,15 +766,15 @@ namespace gcn
void ScrollArea::drawVMarker(Graphics* graphics)
{
const auto dim = getVerticalMarkerDimension();
const Rectangle dim = getVerticalMarkerDimension();
graphics->pushClipArea(dim);
const auto alpha = getBaseColor().a;
auto faceColor = getBaseColor();
const int alpha = getBaseColor().a;
Color faceColor = getBaseColor();
faceColor.a = alpha;
auto highlightColor = faceColor + 0x303030;
Color highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
graphics->setColor(faceColor);
@ -791,15 +793,15 @@ namespace gcn
void ScrollArea::drawHMarker(Graphics* graphics)
{
const auto dim = getHorizontalMarkerDimension();
const Rectangle dim = getHorizontalMarkerDimension();
graphics->pushClipArea(dim);
const auto alpha = getBaseColor().a;
auto faceColor = getBaseColor();
const int alpha = getBaseColor().a;
Color faceColor = getBaseColor();
faceColor.a = alpha;
auto highlightColor = faceColor + 0x303030;
Color highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
auto shadowColor = faceColor - 0x303030;
Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
graphics->setColor(faceColor);
@ -823,18 +825,18 @@ namespace gcn
setVerticalScrollAmount(getVerticalScrollAmount());
setHorizontalScrollAmount(getHorizontalScrollAmount());
if (getContent() != nullptr)
if (getContent() != NULL)
{
getContent()->setPosition(-mHScroll + static_cast<int>(getContent()->getBorderSize()),
-mVScroll + static_cast<int>(getContent()->getBorderSize()));
-mVScroll + static_cast<int>(getContent()->getBorderSize()));
getContent()->logic();
}
}
void ScrollArea::checkPolicies()
{
const auto w = getWidth();
const auto h = getHeight();
const int w = getWidth();
const int h = getHeight();
mHBarVisible = false;
mVBarVisible = false;
@ -926,7 +928,7 @@ namespace gcn
}
}
Rectangle ScrollArea::getUpButtonDimension() const
Rectangle ScrollArea::getUpButtonDimension()
{
if (!mVBarVisible)
{
@ -939,7 +941,7 @@ namespace gcn
mScrollbarWidth);
}
Rectangle ScrollArea::getDownButtonDimension() const
Rectangle ScrollArea::getDownButtonDimension()
{
if (!mVBarVisible)
{
@ -960,7 +962,7 @@ namespace gcn
mScrollbarWidth);
}
Rectangle ScrollArea::getLeftButtonDimension() const
Rectangle ScrollArea::getLeftButtonDimension()
{
if (!mHBarVisible)
{
@ -973,7 +975,7 @@ namespace gcn
mScrollbarWidth);
}
Rectangle ScrollArea::getRightButtonDimension() const
Rectangle ScrollArea::getRightButtonDimension()
{
if (!mHBarVisible)
{
@ -1015,7 +1017,7 @@ namespace gcn
return Rectangle(0, 0, getWidth(), getHeight());
}
Rectangle ScrollArea::getVerticalBarDimension() const
Rectangle ScrollArea::getVerticalBarDimension()
{
if (!mVBarVisible)
{
@ -1041,7 +1043,7 @@ namespace gcn
- getDownButtonDimension().height);
}
Rectangle ScrollArea::getHorizontalBarDimension() const
Rectangle ScrollArea::getHorizontalBarDimension()
{
if (!mHBarVisible)
{
@ -1075,7 +1077,7 @@ namespace gcn
}
int length, pos;
const auto barDim = getVerticalBarDimension();
const Rectangle barDim = getVerticalBarDimension();
if (getContent() && getContent()->getHeight() != 0)
{
@ -1118,7 +1120,7 @@ namespace gcn
}
int length, pos;
const auto barDim = getHorizontalBarDimension();
const Rectangle barDim = getHorizontalBarDimension();
if (getContent() && getContent()->getWidth() != 0)
{
@ -1173,7 +1175,7 @@ namespace gcn
return getContent();
}
return nullptr;
return NULL;
}
void ScrollArea::mouseWheelMovedUp(MouseEvent& mouseEvent)
@ -1261,4 +1263,4 @@ namespace gcn
/*
* Wow! This is a looooong source file.
*/
*/

Some files were not shown because too many files have changed in this diff Show More