Civilization
Button.hpp
1 // Generated by dia2code
2 #ifndef CLIENT__BUTTON__H
3 #define CLIENT__BUTTON__H
4 
5 #include <memory>
6 #include <SFML/Graphics.hpp>
7 #include <string>
8 
9 namespace client {
10  class PopUpWindow;
11 }
12 
13 #include "PopUpWindow.hpp"
14 
15 namespace client {
16 
18  class Button {
19  // Associations
20  // Attributes
21  public:
22  std::shared_ptr<sf::RectangleShape> buttonRect;
23  std::shared_ptr<sf::Text> buttonText;
24  bool redBorder;
25  int maxTextSize;
26  // Operations
27  public:
28  std::string operator() ();
29  Button (sf::Vector2f buttonSize, sf::Vector2f buttonPos, sf::Color buttonColor, bool border = false);
30  void setText (int textSize, sf::Vector2f textOffset, std::string text, sf::Font& font, int size = 0);
31  void addChar (std::string ch);
32  void delChar ();
33  void centerText (bool centerAllAxis = true, sf::Vector2f textOffset = {0, 0});
34  void setActive ();
35  void setInactive ();
36  bool clickButton ();
37  void drawButton (std::shared_ptr<sf::RenderWindow> window);
38  // Setters and Getters
39  };
40 
41 };
42 
43 #endif
class Button -
Definition: Button.hpp:18
void setText(int textSize, sf::Vector2f textOffset, std::string text, sf::Font &font, int size=0)
Set the text of the Button.
Definition: Button.cpp:49
void centerText(bool centerAllAxis=true, sf::Vector2f textOffset={0, 0})
Center the text.
Definition: Button.cpp:92
void setActive()
Put the border into red border.
Definition: Button.cpp:112
bool clickButton()
Click on the button.
Definition: Button.cpp:132
Button(sf::Vector2f buttonSize, sf::Vector2f buttonPos, sf::Color buttonColor, bool border=false)
Constructor.
Definition: Button.cpp:15
void drawButton(std::shared_ptr< sf::RenderWindow > window)
Draw a button with its text on a window.
Definition: Button.cpp:149
void setInactive()
Put the border into black border.
Definition: Button.cpp:122
void delChar()
Delete a char to the text.
Definition: Button.cpp:78
std::string operator()()
operator()
Definition: Button.cpp:36
void addChar(std::string ch)
Add a char to the text.
Definition: Button.cpp:65