-
Notifications
You must be signed in to change notification settings - Fork 0
/
Save.java~
53 lines (45 loc) · 1.66 KB
/
Save.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
import GUI.*;
/**
* A <i>HelpBox</i> object represents the help menu. It can draw itself on a
* canvas.
*/
public class Save extends Widget {
/**
* The width of the box as it is shown on the screen.
*/
public static final int WIDTH = 100;
/**
* The height of the box as it is shown on the screen.
*/
public static final int HEIGHT = 70;
/**
* 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);
canvas.setPenColor(Canvas.BLACK);
canvas.setPenRadius(1.0);
canvas.rectangle(x+0.5, y+0.5, width-1, height-1);
// Draw some help text.
canvas.setFont(Canvas.DEFAULT_FONT);
canvas.textLeft(x + 15, y + 15, "Q - Quit");
canvas.textLeft(x + 15, y + 37.5, "Left button - Reveal");
canvas.textLeft(x + 15, y + 60, "Right button - Flag");
}
}