-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tlist.cpp
38 lines (33 loc) · 879 Bytes
/
Tlist.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
//
// Created by Michal on 04.06.2021.
//
#include "headers/Tlist.h"
int Tlist::_nCounter{};
Tlist::Tlist(const std::string &sName, Tscreen *ptrScreen) : _sName(sName), _ptrScreen(ptrScreen) {
_nCounter++;
_nId = _nCounter;
}
std::string Tlist::showName(bool resize) {
std::string sTemp{};
if (resize) {
sTemp += std::to_string(this->_nId) + ".";
sTemp += _sName;
if (sTemp.length() > constants::nListWidth - 2) {
sTemp.resize(constants::nListWidth - 5);
sTemp += "...";
}
} else {
sTemp += _sName;
if (sTemp.length() > constants::nScreenWidth - 3) {
sTemp.resize(constants::nScreenWidth - 6);
sTemp += "...";
}
}
return sTemp;
}
Tlist::~Tlist() {
_nCounter--;
}
void Tlist::setName(const std::string &sNewName) {
_sName = sNewName;
}