-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUIBoardArea.h
More file actions
40 lines (36 loc) · 1.45 KB
/
Copy pathGUIBoardArea.h
File metadata and controls
40 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef BOARDAREA_H
#define BOARDAREA_H
#include <memory>
#include <map>
#include <gtkmm/drawingarea.h>
#include "BoardSubject.h"
struct PImplBoardArea
{
std::shared_ptr<BoardSubject> subject_;//allows for access to boardSubject data
int sideLength_;//side length of a square
int borderSize_;//distance between the board and the edge of the window
int textAreaSize_;//length of space where the level #, score, etc. are shown
};
//This GUI element stores the actual game board
//It consists of 18x11 squares that will be filled in
class BoardArea : public Gtk::DrawingArea
{
public:
BoardArea(std::shared_ptr<BoardSubject> bs);//Ctor
virtual ~BoardArea();
//Maps from chars ('T', 'L', etc.) to RGB colour values (0-255)
//Each block's colour is the same as its colour in any
//official Tetris game (e.g. purple for T)
//Bonus blocks are: Pink (W Block), Lime Green (V Block), Turquoise (X Block)
static std::map<char, int> redValue;
static std::map<char, int> greenValue;
static std::map<char, int> blueValue;
protected:
//Override default signal handler:
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
private:
std::shared_ptr<PImplBoardArea> ba_;
void fillSquare(const Cairo::RefPtr<Cairo::Context>& cr, int x, int y, char type);
void drawSquareBorder(const Cairo::RefPtr<Cairo::Context>& cr, int x, int y);
};
#endif