-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocwindow.cpp
103 lines (89 loc) · 2.29 KB
/
docwindow.cpp
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//*****************************************************************************
//
// Copyright (C) 2005 Steve Connet. All rights reserved.
//
// Source File Name : docwindow.cpp
// Author : Steve Connet
//
// File Overview : window that can contain a document
//
//*****************************************************************************
#include "datasafe.h"
#include "docwindow.h"
#include <cstdlib>
DocWindow::DocWindow(DOCTYPE type, int height, int width, int starty, int startx) :
Window(height, width, starty, startx),
doctype(type)
{
// wattron(win, COLOR_PAIR(7) | A_BOLD);
}
DocWindow::~DocWindow()
{
// wattroff(win, COLOR_PAIR(7) | A_BOLD);
}
void DocWindow::paint()
{
wclear(win);
wmove(win, 0, 0);
switch(doctype)
{
case BOOK:
for(Books::iterator i = document->books.begin();
i != document->books.end();
++i)
{
wprintw(win, "%.*s\n", width - 1, i->first.c_str());
}
break;
case PAGE:
for(Pages::iterator i = document->iBook->second.begin();
i != document->iBook->second.end();
++i)
{
wprintw(win, "%.*s\n", width - 1, i->first.c_str());
}
break;
case TEXT:
for(Sentences::iterator i = document->iPage->second.begin();
i != document->iPage->second.end();
++i)
{
wprintw(win, "%.*s\n", width - 1, i->c_str());
}
break;
}
Window::paint();
}
void DocWindow::cursorMove(DIRECTION dir)
{
bool move = false;
switch(doctype)
{
case BOOK:
if(DOWN == dir)
{
move = document->nextBook();
}
else if(UP == dir)
{
move = document->prevBook();
}
break;
case PAGE:
if(DOWN == dir)
{
move = document->nextPage();
}
else if(UP == dir)
{
move = document->prevPage();
}
break;
case TEXT:
break;
}
if(move)
{
Window::cursorMove(dir);
}
}