File: authors_note.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,711 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 "authors_note.h"
#include "console.h"
#include "font.h"
#include "viewwin.h"
#include "random.h"

using namespace std;

extern viewport view;

extern console cons;

extern void load_instrument ();

void authors_note::enter () {
  cons ("show-authors-note");
  cons.home ();
}

void authors_note::leave () {
  cons.clear ();
  cons << "Press F1 for help" << eol;
  cons << "Press TAB to enter command mode" << eol;
}

void authors_note::setup_widgets (vector<widget*>& widgets) {

  donate_now.add_screen (this);

  im_a_donor.add_screen (this);

  ticker.add_screen (this);

  donate_now.set_listener (this);
  im_a_donor.set_listener (this);

  widgets.push_back (&donate_now);
  widgets.push_back (&im_a_donor);
  widgets.push_back (&ticker);

}

void authors_note::update_widgets () {

  int lh = get_line_height ();
  ticker.toggle.set_label (">>>");
  ticker.toggle.set_pos (20, lh);
  const box<int>& e = ticker.toggle.get_extents ();
  ticker.xstart = e.right;
  ticker.dy = get_line_height ();
  ticker.twin (ticker.xstart, e.bottom - ticker.dy, view.xmax, e.bottom + lh);
  ticker.startx = view.xmax;
  int msgw = get_char_width (ticker_tape::message);
  ticker.leftxt = -msgw;
  ticker.rightxt = view.xmax;

  donate_now.set_label ("Donate Now!");
  donate_now.set_pos (20, 5 * lh);

  im_a_donor.set_label ("I'm a Donor!");
  im_a_donor.set_pos (20, 3 * lh);

  seed_rand_gen (clock());
  rnd<float> rd (0.5, 1);
  donate_now.set_color (rd(), rd(), rd());
  im_a_donor.set_color (rd(), rd(), rd());
  ticker.set_color (rd(), rd(), rd());

}

void authors_note::clicked (button& b) {
  if (&b == &donate_now) {
    cons ("source ~/.din/donate.tcl");
  } else {
    load_instrument ();
  }
}