Skip to content

Commit

Permalink
Apply guichan's change 8565f3e8ce86c771551dadc2d91cf883d7f9d917 (dec …
Browse files Browse the repository at this point in the history
…22th 2007)

- Documentation has been enhanced.
- The alignment `enum` in `Graphics`, the orientation `enum` in `Slider` and the scroll policy `enum` in `ScrollArea` are no longer anonymous enums.
- Locale variable names have in some places been changed to better reflect their purpose.
- move some methods from `public` to `protected`.
  • Loading branch information
Jarod42 committed Dec 1, 2023
1 parent 5cba1e2 commit d7cc38d
Show file tree
Hide file tree
Showing 29 changed files with 641 additions and 352 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Continue rebasing from 8565f3e8ce86c771551dadc2d91cf883d7f9d917
* Continue rebasing from 753608c0c8cd0196c19c467db0f8df5f61d99b3c
* Add a focus listener interface.
* Make focus apply synchronously.
* Graphics and input objects for DirectX.
Expand Down
21 changes: 11 additions & 10 deletions include/guisan/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ namespace gcn
class GCN_CORE_DECLSPEC Graphics
{
public:
/**
* Alignments for text drawing.
*/
enum Alignment
{
LEFT = 0,
CENTER,
RIGHT
};

Graphics();

virtual ~Graphics() { }
Expand Down Expand Up @@ -254,16 +264,7 @@ namespace gcn
* @throws Exception when no Font is set.
*/
virtual void drawText(const std::string& text, int x, int y,
unsigned int alignment = LEFT);
/**
* Alignments for text drawing.
*/
enum
{
LEFT = 0,
CENTER,
RIGHT
};
Alignment alignment = LEFT);

protected:
std::stack<ClipRectangle> mClipStack;
Expand Down
22 changes: 11 additions & 11 deletions include/guisan/widget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace gcn

/**
* Widget base class. Contains basic widget functions every widget should
* have. Widgets should inherit from this class and implements it's
* have. Widgets should inherit from this class and implements its
* functions.
*
* NOTE: Functions begining with underscore "_" should not
Expand Down Expand Up @@ -179,43 +179,43 @@ namespace gcn
void setSize(int width, int height);

/**
* Set the widget x coordinate. It is relateive to it's parent.
* Set the widget x coordinate. It is relateive to its parent.
*
* @param x the widget x coordinate.
*/
void setX(int x);

/**
* Gets the widget x coordinate. It is relative to it's parent.
* Gets the widget x coordinate. It is relative to its parent.
*
* @return the widget x coordinate.
*/
int getX() const;

/**
* Set the widget y coordinate. It is relative to it's parent.
* Set the widget y coordinate. It is relative to its parent.
*
* @param y the widget y coordinate.
*/
void setY(int y);

/**
* Gets the widget y coordinate. It is relative to it's parent.
* Gets the widget y coordinate. It is relative to its parent.
*
* @return the widget y coordinate.
*/
int getY() const;

/**
* Sets the widget position. It is relative to it's parent.
* Sets the widget position. It is relative to its parent.
*
* @param x the widget x coordinate.
* @param y the widgets y coordinate.
*/
void setPosition(int x, int y);

/**
* Sets the dimension of the widget. It is relative to it's parent.
* Sets the dimension of the widget. It is relative to its parent.
*
* @param dimension the widget dimension.
*/
Expand All @@ -242,7 +242,7 @@ namespace gcn
unsigned int getBorderSize() const;

/**
* Gets the dimension of the widget. It is relative to it's parent.
* Gets the dimension of the widget. It is relative to its parent.
*
* @return the widget dimension.
*/
Expand Down Expand Up @@ -611,7 +611,7 @@ namespace gcn

/**
* Requests modal focus. When a widget has modal focus, only that
* widget and it's children may recieve input.
* widget and its children may recieve input.
*
* @throws Exception if another widget already has modal focus.
*/
Expand Down Expand Up @@ -642,12 +642,12 @@ namespace gcn
virtual void releaseModalMouseInputFocus();

/**
* Checks if the widget or it's parent has modal focus.
* Checks if the widget or its parent has modal focus.
*/
virtual bool hasModalFocus() const;

/**
* Checks if the widget or it's parent has modal mouse input focus.
* Checks if the widget or its parent has modal mouse input focus.
*
* @since 0.6.0
*/
Expand Down
55 changes: 40 additions & 15 deletions include/guisan/widgets/button.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

#include "guisan/focuslistener.hpp"
#include "guisan/keylistener.hpp"
#include "guisan/graphics.hpp"
#include "guisan/mouseevent.hpp"
#include "guisan/mouselistener.hpp"
#include "guisan/platform.hpp"
Expand Down Expand Up @@ -109,30 +110,30 @@ namespace gcn
const std::string& getCaption() const;

/**
* Sets the alignment for the caption.
* Sets the alignment of the caption.
*
* @param alignment Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT
* @param alignment The alignment of the caption.
* @see Graphics
*/
void setAlignment(unsigned int alignment);
void setAlignment(Graphics::Alignment alignment);

/**
* Gets the alignment for the caption.
* Gets the alignment of the caption.
*
* @return alignment of caption.
*/
unsigned int getAlignment() const;
Graphics::Alignment getAlignment() const;

/**
* Sets the spacing between the border of this button and its caption.
* Sets the spacing between the border of the button and its caption.
*
* @param spacing is a number between 0 and 255. The default value for
spacing is 4 and can be changed using this method.
*/
void setSpacing(unsigned int spacing);

/**
* Gets the spacing between the border of this button and its caption.
* Gets the spacing between the border of the button and its caption.
*
* @return spacing.
*/
Expand All @@ -143,13 +144,6 @@ namespace gcn
*/
void adjustSize();

/**
* Checks if the button is pressed down. Useful when drawing.
*
* @return true if the button is pressed down.
*/
bool isPressed() const;


//Inherited from Widget

Expand Down Expand Up @@ -183,11 +177,42 @@ namespace gcn
virtual void keyReleased(KeyEvent& keyEvent);

protected:
/**
* Checks if the button is pressed. Convenient method to use
* when overloading the draw method of the button.
*
* @return True if the button is pressed, false otherwise.
*/
bool isPressed() const;

/**
* Holds the caption of the button.
*/
std::string mCaption;

/**
* True if the mouse is ontop of the button, false otherwise.
*/
bool mHasMouse;

/**
* True if a key has been pressed, false otherwise.
*/
bool mKeyPressed;

/**
* True if a mouse has been pressed, false otherwise.
*/
bool mMousePressed;
unsigned int mAlignment;

/**
* Holds the alignment of the caption.
*/
Graphics::Alignment mAlignment;

/**
* Holds the spacing between the border and the caption.
*/
unsigned int mSpacing;
};
}
Expand Down
4 changes: 2 additions & 2 deletions include/guisan/widgets/checkbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace gcn

/**
* Constructor. The check box will be automatically resized
* to fit it's caption.
* to fit the caption.
*
* @param caption The caption of the check box.
* @param marked True if the check box is selected, false otherwise.
Expand All @@ -109,7 +109,7 @@ namespace gcn
bool isSelected() const;

/**
* Sets the check box to be selected.
* Sets the check box to be selected or not.
*
* @param selected True if the check box should be set as selected.
* @see isSelected
Expand Down
6 changes: 3 additions & 3 deletions include/guisan/widgets/container.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ namespace gcn

/**
* Sets the container to be opaque or not. If the container
* is opaque it's background will be drawn, if it's not opaque
* it's background will not be drawn, and thus making the container
* is opaque its background will be drawn, if it's not opaque
* its background will not be drawn, and thus making the container
* completely transparent.
*
* NOTE: This is not the same as to set visibility. A non visible
* container will not itself nor will it draw it's content.
* container will not itself nor will it draw its content.
*
* @param opaque True if the container should be opaque, false otherwise.
* @see isOpaque
Expand Down
2 changes: 1 addition & 1 deletion include/guisan/widgets/dropdown.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace gcn
/**
* Adjusts the height of the drop down to fit the height of the
* drop down's parent's height. It's used to not make the drop down
* draw itself outside of it's parent if folded down.
* draw itself outside of its parent if folded down.
*/
void adjustHeight();

Expand Down
20 changes: 11 additions & 9 deletions include/guisan/widgets/label.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

#include <string>

#include "guisan/graphics.hpp"
#include "guisan/platform.hpp"
#include "guisan/widget.hpp"

Expand All @@ -76,7 +77,8 @@ namespace gcn
Label();

/**
* Constructor.
* Constructor. The label will be automatically resized
* to fit the caption.
*
* @param caption The caption of the label.
*/
Expand All @@ -101,25 +103,25 @@ namespace gcn
void setCaption(const std::string& caption);

/**
* Sets the alignment for the caption. The alignment is relative
* Sets the alignment of the caption. The alignment is relative
* to the center of the label.
*
* @param alignemnt Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.
* @param alignemnt The alignment of the caption of the label.
* @see getAlignment, Graphics
*/
void setAlignment(unsigned int alignment);
void setAlignment(Graphics::Alignment alignment);

/**
* Gets the alignment for the caption. The alignment is relative to
* Gets the alignment of the caption. The alignment is relative to
* the center of the label.
*
* @return alignment of caption. Graphics::LEFT, Graphics::CENTER or Graphics::RIGHT.
* @return The alignment of caption of the label.
* @see setAlignment, Graphics
*/
unsigned int getAlignment() const;
Graphics::Alignment getAlignment() const;

/**
* Adjusts the label's size to fit the caption size.
* Adjusts the label's size to fit the caption.
*/
void adjustSize();

Expand All @@ -139,7 +141,7 @@ namespace gcn
/**
* Holds the alignment of the caption.
*/
unsigned int mAlignment;
Graphics::Alignment mAlignment;
};
}

Expand Down
2 changes: 1 addition & 1 deletion include/guisan/widgets/listbox.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace gcn
ListModel *getListModel();

/**
* Adjusts the size of the list box to fit it's list model.
* Adjusts the size of the list box to fit its list model.
*/
void adjustSize();

Expand Down
Loading

0 comments on commit d7cc38d

Please sign in to comment.