summaryrefslogtreecommitdiff
path: root/ycurses/src/examples/example2.cpp
blob: c93d79c5c486e5d51f3cc77c587050ccadab7a4a (plain)
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
#include "example2.h"

int example2()
{
  curses cur;
  cursor::set_invisible();

  window win_root(root);
  win_root.print(1, 1, "Press any key to continue...");

  coordinate coord(2, 0);;

  window win1(10, 40, coord); 
  window win2(10, 40, coord.displace(3, 6));
  window win3(10, 40, coord.displace(3, 6));

  win1.print(1, 1, "window 1");
  win2.print(1, 1, "window 2");
  win3.print(1, 1, "window 3");

  /* Initialize pwindows. */
  pwindow pwindow1(win1);
  pwindow pwindow2(win2);
  pwindow pwindow3(win3);


  /* Remove pwindow3, pwindow3 doesnt contain a valid pwindow any more! 
   * DONT USE THIS OBJECT AGAIN until re-init!!! 
   */
  pwindow3.remove();

  /* Re-init a new pwindow, using the old variable. Now the object
   * can be used again. 
   */
  pwindow3.reinit(win3);
  cur.pause();

  /* Remove the center pwindow. */
  pwindow2.remove();
  win3.print(2, 1, "pwindow 2 removed!");
  cur.pause();

  win1.print(2, 1, "Some text!");
  cur.pause();

  pwindow3.remove();
  win1.print(3, 1, "pwindow 3 removed!");
  cur.pause();

  return 0;
}