File: ticker_tape.cc

package info (click to toggle)
din 5.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,152 kB
  • ctags: 2,490
  • sloc: cpp: 9,369; sh: 6,563; ansic: 2,977; tcl: 1,770; makefile: 285
file content (78 lines) | stat: -rw-r--r-- 1,769 bytes parent folder | download | duplicates (3)
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
76
77
78
#include "ticker_tape.h"
#include "viewwin.h"
#include "font.h"
#include "random.h"
#include "color.h"
#include "console.h"

using namespace std;

extern viewport view;

const string ticker_tape::message ("-^- Many thanks to our donors so far: Jack Coghill ($100), Set Hallstrom ($76.19), Samuel Chintha ($50), Aaron Wolf ($28.41), Artem Popov ($10), Sebastian Thewes ($10), Louigi Verona ($10), Edward Diehl ($5) & Guido Lang ($5).  To join this list of Donors, please click on Donate Now! -^-");

ticker_tape::ticker_tape () {
  show_text = 1;
  mr = 0.4; mg = 0.5; mb = 1;
  add_child (&toggle);
  toggle.set_listener (this);
}

void ticker_tape::clicked (button& b) {
  if (&b == &toggle) {
    toggle_text ();
  }
}

int ticker_tape::handle_input () {
  int ret = toggle.handle_input ();
  return ret;
}

void ticker_tape::toggle_text () {
  show_text = !show_text;
  const box<int>& e = toggle.get_extents ();
  if (show_text) {
    toggle.set_pos (0, e.bottom);
    toggle.set_label (">>>");
  } else {
    toggle.set_pos (view.xmax - e.width, e.bottom);
    toggle.set_label ("<<<");
  }
}

void ticker_tape::draw () {

  toggle.draw ();

  if (!show_text) return;

  static int drip = 0;
  if (++drip >= 4) {
    if (--startx < leftxt) startx = rightxt;
    drip = 0;
  }

  glViewport (twin.left, 0, twin.width, twin.height + dy);

  glMatrixMode (GL_MODELVIEW);
  glPushMatrix ();
  glLoadIdentity ();

  glMatrixMode (GL_PROJECTION);
  glPushMatrix ();
  glLoadIdentity ();
  glOrtho (twin.left, twin.right, twin.bottom - dy, twin.top, 1, -1);

  glColor3f (mr, mg, mb);

  draw_string (message, startx, twin.bottom);

  glPopMatrix ();
  glMatrixMode (GL_MODELVIEW);
  glPopMatrix ();

  extern viewport view;
  glViewport (0, 0, view.xmax, view.ymax);

}