This repository was archived by the owner on Apr 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.cpp
More file actions
113 lines (93 loc) · 2.1 KB
/
views.cpp
File metadata and controls
113 lines (93 loc) · 2.1 KB
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
103
104
105
106
107
108
109
110
111
112
113
#include "stdafx.hpp"
#include "views.hpp"
namespace curses {
// view
view::view(sp_pen&& p, rectangle&& rect) CURSES_NOEXCEPT:
parent_( CURSES_MOVE(sp_pen, p) ),
rect_( CURSES_MOVE(rectangle, rect) ),
display_(),
underground_(NULL)
{
display_ = parent_->sub_pen(rect_);
}
view::~view() CURSES_NOEXCEPT {
hide();
}
void view::copy_underground()
{
underground_ = parent_->clipt_rect(display_->get_relative());
}
void view::restore_underground()
{
parent_->paste_rect(display_->get_relative(), underground_);
underground_ = NULL;
}
void view::set_position_to(const position& pos)
{
hide();
rect_.move_to(pos.x,pos.y);
display_ = parent_->sub_pen(rect_);
show();
}
void view::resize(const bounds& bds)
{
hide();
rect_.resize(bds.width, bds.height);
display_ = parent_->sub_pen(rect_);
show();
}
sp_pen view::get_pen() const
{
return display_;
}
void view::hide()
{
if( visible() ) {
restore_underground();
}
}
void view::show()
{
if( !visible() ) {
copy_underground();
this->fill();
}
}
// box_view
box_view::box_view(sp_pen p, const rectangle& rect, const text_color& color):
view( move(p), CURSES_MOVE(rectangle,rect) ),
body_color_(color)
{
}
box_view::box_view(sp_pen&& p, rectangle&& rect, text_color&& color):
view(forward<sp_pen>(p),forward<rectangle>(rect)),
body_color_( CURSES_MOVE(text_color,color) )
{
}
box_view::~box_view() CURSES_NOEXCEPT
{
hide();
}
void box_view::fill() {
sp_pen p = display_pen();
p->set_color(body_color_);
bounds bds = rect().get_bounds();
p->out_box(0, 0, bds.width, bds.height, TEXT(' ') );
}
// bordered_box_view
bordered_box_view::bordered_box_view(sp_pen p,const rectangle& rect,const text_color& color,sp_border brd):
box_view(move(p),CURSES_MOVE(rectangle,rect),CURSES_MOVE(text_color,color)),
border_(brd)
{}
bordered_box_view::~bordered_box_view() CURSES_NOEXCEPT
{}
sp_pen bordered_box_view::get_pen() const
{
bounds bds = rect().get_bounds();
return display_pen()->sub_pen( 1, 1, bds.width-1, bds.height-1);
}
void bordered_box_view::fill() {
box_view::fill();
border_->out(display_pen().get(), rect().get_bounds());
}
} // namespace curses