2017-05-23 20:55:31 +01:00
|
|
|
#include "frontends/ncurses/nframe.h"
|
2017-05-20 21:31:17 +01:00
|
|
|
|
2017-06-24 19:01:08 +01:00
|
|
|
Frame::Frame() : myColumns(-1), myRows(-1)
|
2017-05-20 21:31:17 +01:00
|
|
|
{
|
2017-06-24 19:01:08 +01:00
|
|
|
init(24, 40);
|
2017-05-20 21:31:17 +01:00
|
|
|
|
2017-05-23 17:52:41 +01:00
|
|
|
const int rows = 28;
|
|
|
|
const int cols = 30;
|
2017-05-20 21:31:17 +01:00
|
|
|
|
|
|
|
const int xpos = 0;
|
2017-05-23 17:52:41 +01:00
|
|
|
const int ypos = 0;
|
2017-05-20 21:31:17 +01:00
|
|
|
|
|
|
|
myBuffer.reset(newwin(rows, cols, ypos + 1, xpos + 1), delwin);
|
|
|
|
scrollok(myBuffer.get(), true);
|
|
|
|
wrefresh(myBuffer.get());
|
|
|
|
|
|
|
|
myBorders.reset(newwin(1 + rows + 1, 1 + cols + 1, ypos, xpos), delwin);
|
|
|
|
box(myBorders.get(), 0 , 0);
|
|
|
|
wrefresh(myBorders.get());
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:01:08 +01:00
|
|
|
void Frame::init(int rows, int columns)
|
2017-05-20 21:31:17 +01:00
|
|
|
{
|
2017-06-24 19:01:08 +01:00
|
|
|
if (myRows != rows || myColumns != columns)
|
2017-05-20 21:31:17 +01:00
|
|
|
{
|
2017-06-24 19:01:08 +01:00
|
|
|
if (columns < myColumns || rows < myRows)
|
2017-05-20 21:31:17 +01:00
|
|
|
{
|
2017-05-23 17:52:41 +01:00
|
|
|
werase(myStatus.get());
|
|
|
|
wrefresh(myStatus.get());
|
2017-05-20 21:31:17 +01:00
|
|
|
werase(myFrame.get());
|
|
|
|
wrefresh(myFrame.get());
|
|
|
|
}
|
|
|
|
|
2017-06-24 19:01:08 +01:00
|
|
|
myRows = rows;
|
2017-05-20 21:31:17 +01:00
|
|
|
myColumns = columns;
|
|
|
|
|
2017-05-23 17:52:41 +01:00
|
|
|
const int width = 1 + myColumns + 1;
|
|
|
|
const int left = (COLS - width) / 2;
|
|
|
|
|
2017-06-24 19:01:08 +01:00
|
|
|
myFrame.reset(newwin(1 + myRows + 1, width, 0, left), delwin);
|
2017-05-20 21:31:17 +01:00
|
|
|
box(myFrame.get(), 0 , 0);
|
|
|
|
wtimeout(myFrame.get(), 0);
|
|
|
|
keypad(myFrame.get(), true);
|
|
|
|
wrefresh(myFrame.get());
|
2017-05-23 17:52:41 +01:00
|
|
|
|
2017-06-24 19:01:08 +01:00
|
|
|
myStatus.reset(newwin(4, width, 1 + myRows + 1, left), delwin);
|
2017-05-23 17:52:41 +01:00
|
|
|
box(myStatus.get(), 0 , 0);
|
|
|
|
wrefresh(myStatus.get());
|
2017-05-20 21:31:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
WINDOW * Frame::getWindow()
|
|
|
|
{
|
|
|
|
return myFrame.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
WINDOW * Frame::getBuffer()
|
|
|
|
{
|
|
|
|
return myBuffer.get();
|
|
|
|
}
|
|
|
|
|
2017-05-23 17:52:41 +01:00
|
|
|
WINDOW * Frame::getStatus()
|
|
|
|
{
|
|
|
|
return myStatus.get();
|
|
|
|
}
|
|
|
|
|
2017-05-20 21:31:17 +01:00
|
|
|
int Frame::getColumns() const
|
|
|
|
{
|
|
|
|
return myColumns;
|
|
|
|
}
|