Alarmdialog programmiert
This commit is contained in:
@@ -313,4 +313,4 @@ class Anchor(Page):
|
||||
else:
|
||||
self.draw_config(ctx)
|
||||
if self._bd.alarm:
|
||||
self.draw_alarm(ctx)
|
||||
self.draw_alarm(ctx, self._bd.alarm_src, self._bd.alarm_id, self._bd.alarm_msg)
|
||||
|
||||
@@ -28,5 +28,6 @@ class OneValue(Page):
|
||||
ctx.show_text(self.ref1.format())
|
||||
else:
|
||||
#print(dir(self.bd))
|
||||
ctx.show_text("---") # self.bd.getPlaceholder())
|
||||
#ctx.show_text("---") # self.bd.getPlaceholder())
|
||||
ctx.show_text(self.placeholder)
|
||||
ctx.stroke()
|
||||
|
||||
@@ -82,6 +82,7 @@ class Page():
|
||||
self.icon['ILUM'] = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "lighton.png"))
|
||||
self.sym_lock = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "lock.png"))
|
||||
self.sym_swipe = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "swipe3.png"))
|
||||
self.sym_exclamation = cairo.ImageSurface.create_from_png(os.path.join(cfg['imgpath'], "exclamation.png"))
|
||||
self.buttonlabel = {
|
||||
1: '',
|
||||
2: '',
|
||||
@@ -208,8 +209,11 @@ class Page():
|
||||
ctx.show_text(self.buttonlabel[i+1])
|
||||
ctx.stroke()
|
||||
|
||||
def draw_alarm(self, ctx):
|
||||
def draw_alarm(self, ctx, source, alarmid, message):
|
||||
x, y, w, h = (50, 100, 300, 150)
|
||||
ctx.select_font_face("AtariST8x16SystemFont")
|
||||
ctx.set_font_size(16)
|
||||
# Dialogbox mit Rahmen
|
||||
ctx.set_line_width(1)
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.rectangle(x + 0.5, y + 0.5, w, h)
|
||||
@@ -220,7 +224,28 @@ class Page():
|
||||
ctx.set_source_rgb(*self.fgcolor)
|
||||
ctx.set_line_width(2)
|
||||
ctx.rectangle(x + 3, y + 3, w - 5, h - 5)
|
||||
ctx.clip_preserve()
|
||||
ctx.stroke()
|
||||
# Symbol
|
||||
ctx.save()
|
||||
ctx.set_source_surface(self.sym_exclamation, x + 16, y + 16)
|
||||
ctx.paint()
|
||||
ctx.restore()
|
||||
# Titel
|
||||
ctx.move_to(x + 64, y + 30)
|
||||
ctx.show_text("A L A R M")
|
||||
ctx.move_to(x + 64, y + 48)
|
||||
ctx.show_text(f"#{alarmid} from {source}")
|
||||
# Alarmmeldung, umgebrochen
|
||||
n = 0
|
||||
for l in wordwrap(message, (w - 16 - 8) / 8):
|
||||
ctx.move_to(x + 16, y + 80 + n)
|
||||
ctx.show_text(l)
|
||||
n += 16
|
||||
if n > 64:
|
||||
break
|
||||
# Button-Hinweis
|
||||
self.draw_text_center(ctx, x + w / 2, y + h - 16, "Press button 1 to dismiss alarm")
|
||||
|
||||
def clear(self):
|
||||
ctx.set_source_rgb(1, 1, 1)
|
||||
@@ -312,3 +337,22 @@ class Page():
|
||||
ctx.move_to(x + 4, y + h - 5 + 0.5)
|
||||
ctx.show_text(content)
|
||||
ctx.stroke()
|
||||
|
||||
def wordwrap(text, wrap):
|
||||
# Wrap long line to multiple lines, monospaced character set
|
||||
# e.g. used for alarm dialog boxes
|
||||
llen = 0
|
||||
l = 0
|
||||
lines = [""]
|
||||
for w in text.split():
|
||||
wordlength = len(w)
|
||||
if llen + 1 + wordlength <= wrap:
|
||||
if llen > 0:
|
||||
lines[l] += ' '
|
||||
lines[l] += w
|
||||
llen += wordlength + 1
|
||||
else:
|
||||
lines.append(w)
|
||||
l += 1
|
||||
llen = wordlength
|
||||
return lines
|
||||
|
||||
Reference in New Issue
Block a user