forked from localhorst/reHDD
started to use the UI
This commit is contained in:
135
src/TUI/tui.cpp
135
src/TUI/tui.cpp
@ -4,16 +4,23 @@
|
||||
* @author hendrik schutter
|
||||
* @date 03.08.2020
|
||||
*/
|
||||
/*
|
||||
#include "../include/reHDD.h"
|
||||
*/
|
||||
|
||||
#include "../../include/reHDD.h"
|
||||
|
||||
|
||||
TUI::TUI(void){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief wipe drive with shred
|
||||
* \param pointer of Drive instance
|
||||
* \return void
|
||||
*/
|
||||
/*
|
||||
|
||||
void TUI::initTUI()
|
||||
{
|
||||
initscr();
|
||||
@ -30,10 +37,126 @@ void TUI::initTUI()
|
||||
init_color(COLOR_GRAY, 173, 170, 173);
|
||||
}
|
||||
|
||||
void TUI::updateTUI(TUI_DATA data){
|
||||
void TUI::updateTUI(vector <Drive>* pvecDrives) {
|
||||
|
||||
|
||||
werase(stdscr);
|
||||
|
||||
int stdscrX, stdscrY;
|
||||
getmaxyx(stdscr, stdscrY, stdscrX);
|
||||
|
||||
init_pair(COLOR_AREA_STDSCR,COLOR_WHITE, COLOR_BLUE);
|
||||
wbkgd(stdscr, COLOR_PAIR(COLOR_AREA_STDSCR));
|
||||
|
||||
mvprintw(0, 2, "reHDD - HDD refurbishing tool - Licensed under GPL 3.0 X:%d Y:%d",stdscrX,stdscrY);
|
||||
|
||||
refresh();
|
||||
|
||||
overview=createOverViewWindow((int)(stdscrX/3), (stdscrY-15));
|
||||
wrefresh(overview);
|
||||
|
||||
detailview=createDetailViewWindow(((stdscrX)-(int)(stdscrX/3)-7), (stdscrY-3), (int)(stdscrX/3)+5);
|
||||
wrefresh(detailview);
|
||||
|
||||
vWinDriveEntries.clear();
|
||||
|
||||
|
||||
int i = 0;
|
||||
|
||||
vector <Drive>::iterator it;
|
||||
for (it = pvecDrives->begin(); it != pvecDrives->end(); ++it)
|
||||
{
|
||||
|
||||
string sModelFamily = it->getModelFamily();
|
||||
string sModelName = it->getModelName();
|
||||
string sCapacity = it->sCapacityToText();
|
||||
|
||||
|
||||
|
||||
// WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (it - pvecDrives->begin()) )+3, sModelFamily, sModelName, sCapacity);
|
||||
|
||||
|
||||
WINDOW * tmp = createEntryWindow( ((int)(stdscrX/3) - 2), 5, 3, (5* (i) )+3, sModelFamily, sModelName, sCapacity);
|
||||
|
||||
}*/
|
||||
// vWinDriveEntries.push_back(tmp);
|
||||
wrefresh(tmp);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void TUI::centerTitle(WINDOW *pwin, const char * title) {
|
||||
int x, maxX, stringSize;
|
||||
getmaxyx(pwin, maxX, maxX);
|
||||
stringSize = 4 + strlen(title);
|
||||
x = (maxX - stringSize)/2;
|
||||
mvwaddch(pwin, 0, x, ACS_RTEE);
|
||||
waddch(pwin, ' ');
|
||||
waddstr(pwin, title);
|
||||
waddch(pwin, ' ');
|
||||
waddch(pwin, ACS_LTEE);
|
||||
}
|
||||
|
||||
WINDOW* TUI::createOverViewWindow( int iXSize, int iYSize) {
|
||||
WINDOW *newWindow;
|
||||
newWindow = newwin(iYSize, iXSize, 2, 2);
|
||||
init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_GRAY);
|
||||
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
|
||||
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
char buffer[80];
|
||||
|
||||
time (&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime(buffer,sizeof(buffer),"%d-%m-%Y %H:%M:%S",timeinfo);
|
||||
std::string str(buffer);
|
||||
|
||||
|
||||
centerTitle(newWindow, str.c_str());
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
|
||||
WINDOW* TUI::createDetailViewWindow( int iXSize, int iYSize, int iXStart) {
|
||||
WINDOW *newWindow;
|
||||
newWindow = newwin(iYSize, iXSize, 2, iXStart);
|
||||
init_pair(COLOR_AREA_OVERVIEW, COLOR_BLACK, COLOR_GRAY);
|
||||
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_OVERVIEW));
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
centerTitle(newWindow, "Selected Drive: xyz");
|
||||
|
||||
// mvaddstr(iXStart+1, 5, "Test");
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
|
||||
WINDOW* TUI::createEntryWindow(int iXSize, int iYSize, int iXStart, int iYStart, string sModelFamily, string sModelName, string sCapacity) {
|
||||
WINDOW *newWindow;
|
||||
newWindow = newwin(iYSize, iXSize, iYStart, iXStart);
|
||||
init_pair(COLOR_AREA_ENTRY, COLOR_BLACK, COLOR_GRAY);
|
||||
wbkgd(newWindow, COLOR_PAIR(COLOR_AREA_ENTRY));
|
||||
box(newWindow, ACS_VLINE, ACS_HLINE);
|
||||
|
||||
attron(COLOR_PAIR(COLOR_AREA_ENTRY));
|
||||
mvaddstr(iYStart+1, 5, "Test");
|
||||
|
||||
//addstr("test");
|
||||
|
||||
|
||||
//cout << "X: " << sModelFamily << endl;
|
||||
|
||||
// mvaddstr(iYStart+2, 5, sModelName.c_str());
|
||||
//mvaddstr(iYStart+3, 5, sCapacity.c_str());
|
||||
|
||||
refresh();
|
||||
|
||||
return newWindow;
|
||||
}
|
||||
|
Reference in New Issue
Block a user