-
Notifications
You must be signed in to change notification settings - Fork 0
/
HelpBox.java
64 lines (57 loc) · 2.11 KB
/
HelpBox.java
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
/*----------------------------------------------------------------
* Author: Apurva Gandhi
* Email: ahgand22@g.holycross.edu
* Written: 12/01/2018
*
* HelpBox just displays some helpful text in a box on the scren.
*----------------------------------------------------------------*/
import GUI.*;
/**
* A <i>HelpBox</i> object represents the help menu. It can draw itself on a
* canvas.
*/
public class HelpBox extends Widget
{
/**
* The width of the box as it is shown on the screen.
*/
public static final int WIDTH = 200;
/**
* The height of the box as it is shown on the screen.
*/
public static final int HEIGHT = 75;
/**
* Initialize a new HelpBox object. It will be drawn at the specified
* position.
* @param x the x coordinate where the help box will be drawn.
* @param y the y coordinate where the help box will be drawn.
*/
public HelpBox(int x, int y)
{
super(x, y, WIDTH, HEIGHT);
}
/**
* Paint the help box on a canvas. Don't call this directly, it is called by
* the GUI system automatically. This function should draw something on the
* canvas. Usually the drawing should stay within the bounds (x, y, width,
* height) which are protected member variables of GUI.Widget, which this
* class extends.
* @param canvas the canvas on which to draw.
*/
public void repaint(GUI.Canvas canvas)
{
// Draw a white box with a black outline.
canvas.setPenColor(Canvas.WHITE);
canvas.filledRectangle(x, y, width, height + 39);
canvas.setPenColor(Canvas.BLACK);
canvas.setPenRadius(1.0);
canvas.rectangle(x+0.5, y+0.5, width-1, height-1 + 39);
// Draw some help text.
canvas.setFont(Canvas.DEFAULT_FONT);
canvas.textLeft(x + 15, y + 37.5, "Left button - Reveal");
canvas.textLeft(x + 15, y + 60, "Right button - Flag");
canvas.textLeft(x + 15, y + 80, "S - Save");
canvas.textLeft(x + 15, y + 100, "R - Restore");
canvas.textLeft(x + 15, y + 15, "Q - Quit");
}//end of repain
}// end of HelpBox