-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringscreenfieldformatter.cpp
55 lines (46 loc) · 1.32 KB
/
stringscreenfieldformatter.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
//
// Created by phtran on 14/05/2016.
//
#include <sstream>
#include <iomanip>
#include "stringscreenfieldformatter.h"
#include "screenfield.h"
#include "terminal.h"
void UI::StringScreenFieldFormatter::draw(const ScreenField& f) const
{
UI::terminal().endEnhanced();
if (!f.readonly()) {
drawFrame(f);
}
drawContent(f);
}
void UI::StringScreenFieldFormatter::drawForEdit(const ScreenField& f) const
{
UI::terminal().endEnhanced();
if (f.readonly()) {
clearFrame(f);
} else {
drawFrame(f);
}
drawContentForEdit(f);
}
UI::StringScreenFieldFormatter* UI::StringScreenFieldFormatter::clone() const
{
return new StringScreenFieldFormatter(*this);
}
void UI::StringScreenFieldFormatter::drawContent( const ScreenField &f ) const
{
std::ostringstream s;
s << std::left << std::setw(f.length()) << std::setfill(' ') << f.get();
UI::terminal().gotoxy(f.xCoordinate(), f.yCoordinate());
UI::terminal().startBold();
UI::terminal().write(s.str());
}
void UI::StringScreenFieldFormatter::drawContentForEdit(const ScreenField& f) const
{
std::ostringstream s;
s << std::left << std::setw(f.length()) << std::setfill(' ') << f.get();
UI::terminal().gotoxy(f.xCoordinate(), f.yCoordinate());
UI::terminal().startBold();
UI::terminal().write(s.str());
}