-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnotificationdialogue.py
75 lines (61 loc) · 2.33 KB
/
notificationdialogue.py
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
72
73
74
75
from menu import Menu
from displayhelper import *
from textdecorator import *
from textelement import Text
# This class represents a simple message dialogue that displays a message:
#
# ----------------------
# | |
# | |
# | Message |
# | |
# | |
# ----------------------
#
# This class handles all the drawing and input updates. The client simply has to
# call the appropriate methods.
#
class NotificationDialogue(Menu):
# Creates a new message dialogue
# message must be a Text object that may be decorated. If the underlying text
# contains more than 60 characters, it gets truncated
# displayhelper must be a DisplayHelper object that's used to draw the elements
# on the screen. It must always hold a reference to the correct console size to function.
def __init__(self, message, displayhelper):
if (len(message.getRawText()) > 60):
message = Text(message.getRawText()[:57] + "...")
self.heading = message
self.active = False
self.displayhelper = displayhelper
# Sets this menu's active flag to the value of state
# state must be boolean
def setActive(self, state):
self.active = state
# This function has no effect in this dialogue.
def getSelectedIndex(self):
pass
# This function has no effect in this dialogue.
def getSelectedAction(self):
pass
# Forces the menu to be (re)drawn
def redrawMenu(self):
boxWidth = 30
boxHeight = 5
boxPosition = self.displayhelper.createCenteredBox(boxWidth, boxHeight, 47)
headingText = ColoredText(HighlightedText(LeftAlignedText(self.heading, boxPosition[0] + 4), 47), 30)
self.displayhelper.writeToLine(boxPosition[1] + 2, headingText)
# This function has no effect in this dialogue.
def moveSelectionUp(self):
pass
# This function has no effect in this dialogue.
def moveSelectionDown(self):
pass
# This function has no effect in this dialogue.
def moveSelectionLeft(self):
pass
# This function has no effect in this dialogue.
def moveSelectionRight(self):
pass
# This function has no effect in this dialogue.
def selectionMade(self):
pass