-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuiDraw.h
More file actions
71 lines (60 loc) · 2.33 KB
/
uiDraw.h
File metadata and controls
71 lines (60 loc) · 2.33 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***********************************************************************
* Header File:
* User Interface Draw : put pixels on the screen
* Author:
* Br. Helfrich
* Summary:
* This is the code necessary to draw on the screen. ogstream works
* much like COUT except it also has some convenient methods for
* drawing chess pieces on the screen.
************************************************************************/
#pragma once
#include <sstream> // for OSTRINGSTRING
using std::string;
/*************************************************************************
* GRAPHICS STREAM
* A graphics stream that behaves much like COUT except on a drawn screen.
* Special methods are added to facilitate drawing simulator elements.
*************************************************************************/
class ogstream : public std::ostringstream
{
public:
ogstream() : x(0), y(0) { }
ogstream(int position): x(0), y(0) { }
~ogstream() { flush(); }
// Methods specific to drawing text on the screen
virtual void flush();
void setPosition(int x, int y) { flush(); this->x = x; this->y = y;}
// Methods to draw the chess pieces on the screen
virtual void drawKing( int position, bool black);
virtual void drawQueen( int position, bool black);
virtual void drawRook( int position, bool black);
virtual void drawPawn( int position, bool black);
virtual void drawBishop(int position, bool black);
virtual void drawKnight(int position, bool black);
// Methods to draw the board
virtual void drawBoard();
virtual void drawSelected(int position);
virtual void drawHover( int position);
virtual void drawPossible(int osition);
protected:
int x; // location of text on the screen
int y;
private:
// One rectangle, for drawing pieces.
struct Rect
{
int x0;
int y0;
int x1;
int y1;
int x2;
int y2;
int x3;
int y3;
};
// Draw a piece with a collection of rectangles
void drawPiece(int x, int y, bool black, Rect rectangle[], int num) const;
// Put text at location X, Y
void drawText(int x, int y, const char* text) const;
};