GUI
Renderer.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 by Maciej Wiecierzewski
3  */
4 
5 #ifndef RENDERER_H
6 #define RENDERER_H
7 
8 #include <string>
9 
10 #include <allegro5/allegro5.h>
11 #include <allegro5/allegro_color.h>
12 #include <allegro5/allegro_font.h>
13 
14 namespace gui
15 {
16 
17 typedef ALLEGRO_COLOR Color;
18 
20 
21 class Renderer
22 {
23  public:
24  Renderer();
25  virtual ~Renderer();
26 
29  void setFont(ALLEGRO_FONT *font);
30 
33  void setBuffer(ALLEGRO_BITMAP *bitmap);
34 
37  Color color(unsigned char r, unsigned char g, unsigned char b);
38 
41  void setTarget();
42 
46  void setTarget(int x, int y, int w, int h);
47 
50  void clear();
51 
52  void drawFilledRect(int x1, int y1, int x2, int y2, Color color);
53  void drawRect(int x1, int y1, int x2, int y2, Color color, int thickness);
54  void drawText(int x, int y, std::string text, Color color);
55  void drawMultilineText(int x, int y, int maxWidth, float lineHeight, std::string text, Color color);
56  void drawLine(int x1, int y1, int x2, int y2, Color color, int thickness);
57  int getTextWidth(std::string text);
58  int getLineHeight();
59 
60  protected:
61 
62  private:
63  ALLEGRO_FONT *font;
64  ALLEGRO_BITMAP *buffer;
65  ALLEGRO_BITMAP *targetBitmap;
66 };
67 
68 }
69 
70 #endif // RENDERER_H