put classes related to ncurses into NCurses namespace
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "menu.h"
|
||||
|
||||
using namespace NCurses;
|
||||
|
||||
void List::SelectCurrent()
|
||||
{
|
||||
if (Empty())
|
||||
|
||||
326
src/menu.h
326
src/menu.h
@@ -25,154 +25,156 @@
|
||||
#include "strbuffer.h"
|
||||
#include "misc.h"
|
||||
|
||||
class List
|
||||
namespace NCurses
|
||||
{
|
||||
public:
|
||||
|
||||
class InvalidItem { };
|
||||
|
||||
List() { }
|
||||
virtual ~List() { }
|
||||
|
||||
virtual void Select(int, bool) = 0;
|
||||
virtual void Static(int, bool) = 0;
|
||||
virtual bool Empty() const = 0;
|
||||
virtual bool isSelected(int = -1) const = 0;
|
||||
virtual bool isStatic(int = -1) const = 0;
|
||||
virtual bool hasSelected() const = 0;
|
||||
virtual void GetSelected(std::vector<size_t> &) const = 0;
|
||||
virtual void Highlight(size_t) = 0;
|
||||
virtual size_t Size() const = 0;
|
||||
virtual size_t Choice() const = 0;
|
||||
virtual size_t RealChoice() const = 0;
|
||||
|
||||
void SelectCurrent();
|
||||
void ReverseSelection(size_t = 0);
|
||||
bool Deselect();
|
||||
|
||||
virtual void ApplyFilter(const std::string &, size_t = 0, bool = 0) = 0;
|
||||
virtual const std::string &GetFilter() = 0;
|
||||
virtual std::string GetOption(size_t) = 0;
|
||||
|
||||
virtual bool isFiltered() = 0;
|
||||
//virtual void ShowAll() = 0;
|
||||
//virtual void ShowFiltered() = 0;
|
||||
|
||||
};
|
||||
|
||||
template <class T> class Menu : public Window, public List
|
||||
{
|
||||
typedef void (*ItemDisplayer) (const T &, void *, Menu<T> *);
|
||||
typedef std::string (*GetStringFunction) (const T &, void *);
|
||||
|
||||
struct Option
|
||||
class List
|
||||
{
|
||||
Option() : isBold(0), isSelected(0), isStatic(0) { }
|
||||
Option(const T &t, bool is_bold, bool is_static) :
|
||||
Item(t), isBold(is_bold), isSelected(0), isStatic(is_static) { }
|
||||
public:
|
||||
|
||||
T Item;
|
||||
bool isBold;
|
||||
bool isSelected;
|
||||
bool isStatic;
|
||||
class InvalidItem { };
|
||||
|
||||
List() { }
|
||||
virtual ~List() { }
|
||||
|
||||
virtual void Select(int, bool) = 0;
|
||||
virtual void Static(int, bool) = 0;
|
||||
virtual bool Empty() const = 0;
|
||||
virtual bool isSelected(int = -1) const = 0;
|
||||
virtual bool isStatic(int = -1) const = 0;
|
||||
virtual bool hasSelected() const = 0;
|
||||
virtual void GetSelected(std::vector<size_t> &) const = 0;
|
||||
virtual void Highlight(size_t) = 0;
|
||||
virtual size_t Size() const = 0;
|
||||
virtual size_t Choice() const = 0;
|
||||
virtual size_t RealChoice() const = 0;
|
||||
|
||||
void SelectCurrent();
|
||||
void ReverseSelection(size_t = 0);
|
||||
bool Deselect();
|
||||
|
||||
virtual void ApplyFilter(const std::string &, size_t = 0, bool = 0) = 0;
|
||||
virtual const std::string &GetFilter() = 0;
|
||||
virtual std::string GetOption(size_t) = 0;
|
||||
|
||||
virtual bool isFiltered() = 0;
|
||||
};
|
||||
|
||||
typedef typename std::vector<Option *>::iterator option_iterator;
|
||||
typedef typename std::vector<Option *>::const_iterator option_const_iterator;
|
||||
template <class T> class Menu : public Window, public List
|
||||
{
|
||||
typedef void (*ItemDisplayer) (const T &, void *, Menu<T> *);
|
||||
typedef std::string (*GetStringFunction) (const T &, void *);
|
||||
|
||||
public:
|
||||
Menu(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Menu(const Menu &);
|
||||
virtual ~Menu();
|
||||
struct Option
|
||||
{
|
||||
Option() : isBold(0), isSelected(0), isStatic(0) { }
|
||||
Option(const T &t, bool is_bold, bool is_static) :
|
||||
Item(t), isBold(is_bold), isSelected(0), isStatic(is_static) { }
|
||||
|
||||
void SetItemDisplayer(ItemDisplayer ptr) { itsItemDisplayer = ptr; }
|
||||
void SetItemDisplayerUserData(void *data) { itsItemDisplayerUserdata = data; }
|
||||
T Item;
|
||||
bool isBold;
|
||||
bool isSelected;
|
||||
bool isStatic;
|
||||
};
|
||||
|
||||
void SetGetStringFunction(GetStringFunction f) { itsGetStringFunction = f; }
|
||||
void SetGetStringFunctionUserData(void *data) { itsGetStringFunctionUserData = data; }
|
||||
typedef typename std::vector<Option *>::iterator option_iterator;
|
||||
typedef typename std::vector<Option *>::const_iterator option_const_iterator;
|
||||
|
||||
void Reserve(size_t size);
|
||||
void ResizeBuffer(size_t size);
|
||||
void AddOption(const T &item, bool is_bold = 0, bool is_static = 0);
|
||||
void AddSeparator();
|
||||
void InsertOption(size_t pos, const T &Item, bool is_bold = 0, bool is_static = 0);
|
||||
void InsertSeparator(size_t pos);
|
||||
void DeleteOption(size_t pos);
|
||||
void IntoSeparator(size_t pos);
|
||||
void Swap(size_t, size_t);
|
||||
public:
|
||||
Menu(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Menu(const Menu &);
|
||||
virtual ~Menu();
|
||||
|
||||
bool isBold(int id = -1);
|
||||
void BoldOption(int, bool);
|
||||
void SetItemDisplayer(ItemDisplayer ptr) { itsItemDisplayer = ptr; }
|
||||
void SetItemDisplayerUserData(void *data) { itsItemDisplayerUserdata = data; }
|
||||
|
||||
virtual void Select(int id, bool value);
|
||||
virtual void Static(int id, bool value);
|
||||
virtual bool isSelected(int id = -1) const;
|
||||
virtual bool isStatic(int id = -1) const;
|
||||
virtual bool hasSelected() const;
|
||||
virtual void GetSelected(std::vector<size_t> &v) const;
|
||||
virtual void Highlight(size_t);
|
||||
virtual size_t Size() const;
|
||||
virtual size_t Choice() const;
|
||||
virtual size_t RealChoice() const;
|
||||
void SetGetStringFunction(GetStringFunction f) { itsGetStringFunction = f; }
|
||||
void SetGetStringFunctionUserData(void *data) { itsGetStringFunctionUserData = data; }
|
||||
|
||||
virtual void ApplyFilter(const std::string &filter, size_t beginning = 0, bool case_sensitive = 0);
|
||||
virtual const std::string &GetFilter();
|
||||
virtual std::string GetOption(size_t pos);
|
||||
void Reserve(size_t size);
|
||||
void ResizeBuffer(size_t size);
|
||||
void AddOption(const T &item, bool is_bold = 0, bool is_static = 0);
|
||||
void AddSeparator();
|
||||
void InsertOption(size_t pos, const T &Item, bool is_bold = 0, bool is_static = 0);
|
||||
void InsertSeparator(size_t pos);
|
||||
void DeleteOption(size_t pos);
|
||||
void IntoSeparator(size_t pos);
|
||||
void Swap(size_t, size_t);
|
||||
|
||||
virtual bool isFiltered() { return itsOptionsPtr == &itsFilteredOptions; }
|
||||
bool isBold(int id = -1);
|
||||
void BoldOption(int, bool);
|
||||
|
||||
void ShowAll() { itsOptionsPtr = &itsOptions; }
|
||||
void ShowFiltered() { itsOptionsPtr = &itsFilteredOptions; }
|
||||
virtual void Select(int id, bool value);
|
||||
virtual void Static(int id, bool value);
|
||||
virtual bool isSelected(int id = -1) const;
|
||||
virtual bool isStatic(int id = -1) const;
|
||||
virtual bool hasSelected() const;
|
||||
virtual void GetSelected(std::vector<size_t> &v) const;
|
||||
virtual void Highlight(size_t);
|
||||
virtual size_t Size() const;
|
||||
virtual size_t Choice() const;
|
||||
virtual size_t RealChoice() const;
|
||||
|
||||
virtual void Refresh();
|
||||
virtual void Scroll(Where);
|
||||
virtual void Reset();
|
||||
virtual void Clear(bool clrscr = 1);
|
||||
virtual void ApplyFilter(const std::string &filter, size_t beginning = 0, bool case_sensitive = 0);
|
||||
virtual const std::string &GetFilter();
|
||||
virtual std::string GetOption(size_t pos);
|
||||
|
||||
void SetSelectPrefix(Buffer *b) { itsSelectedPrefix = b; }
|
||||
void SetSelectSuffix(Buffer *b) { itsSelectedSuffix = b; }
|
||||
virtual bool isFiltered() { return itsOptionsPtr == &itsFilteredOptions; }
|
||||
|
||||
void HighlightColor(Color col) { itsHighlightColor = col; }
|
||||
void Highlighting(bool hl) { highlightEnabled = hl; }
|
||||
void ShowAll() { itsOptionsPtr = &itsOptions; }
|
||||
void ShowFiltered() { itsOptionsPtr = &itsFilteredOptions; }
|
||||
|
||||
virtual bool Empty() const { return itsOptionsPtr->empty(); }
|
||||
virtual void Refresh();
|
||||
virtual void Scroll(Where);
|
||||
virtual void Reset();
|
||||
virtual void Clear(bool clrscr = 1);
|
||||
|
||||
T &Back();
|
||||
const T &Back() const;
|
||||
T &Current();
|
||||
const T &Current() const;
|
||||
T &at(size_t i);
|
||||
const T &at(size_t i) const;
|
||||
const T &operator[](size_t i) const;
|
||||
T &operator[](size_t i);
|
||||
void SetSelectPrefix(Buffer *b) { itsSelectedPrefix = b; }
|
||||
void SetSelectSuffix(Buffer *b) { itsSelectedSuffix = b; }
|
||||
|
||||
virtual Menu<T> *Clone() const { return new Menu<T>(*this); }
|
||||
virtual Menu<T> *EmptyClone() const;
|
||||
void HighlightColor(Color col) { itsHighlightColor = col; }
|
||||
void Highlighting(bool hl) { highlightEnabled = hl; }
|
||||
|
||||
protected:
|
||||
ItemDisplayer itsItemDisplayer;
|
||||
void *itsItemDisplayerUserdata;
|
||||
GetStringFunction itsGetStringFunction;
|
||||
void *itsGetStringFunctionUserData;
|
||||
virtual bool Empty() const { return itsOptionsPtr->empty(); }
|
||||
|
||||
std::string itsFilter;
|
||||
T &Back();
|
||||
const T &Back() const;
|
||||
T &Current();
|
||||
const T &Current() const;
|
||||
T &at(size_t i);
|
||||
const T &at(size_t i) const;
|
||||
const T &operator[](size_t i) const;
|
||||
T &operator[](size_t i);
|
||||
|
||||
std::vector<Option *> *itsOptionsPtr;
|
||||
std::vector<Option *> itsOptions;
|
||||
std::vector<Option *> itsFilteredOptions;
|
||||
std::vector<size_t> itsFilteredRealPositions;
|
||||
virtual Menu<T> *Clone() const { return new Menu<T>(*this); }
|
||||
virtual Menu<T> *EmptyClone() const;
|
||||
|
||||
int itsBeginning;
|
||||
int itsHighlight;
|
||||
protected:
|
||||
ItemDisplayer itsItemDisplayer;
|
||||
void *itsItemDisplayerUserdata;
|
||||
GetStringFunction itsGetStringFunction;
|
||||
void *itsGetStringFunctionUserData;
|
||||
|
||||
Color itsHighlightColor;
|
||||
bool highlightEnabled;
|
||||
std::string itsFilter;
|
||||
|
||||
Buffer *itsSelectedPrefix;
|
||||
Buffer *itsSelectedSuffix;
|
||||
};
|
||||
std::vector<Option *> *itsOptionsPtr;
|
||||
std::vector<Option *> itsOptions;
|
||||
std::vector<Option *> itsFilteredOptions;
|
||||
std::vector<size_t> itsFilteredRealPositions;
|
||||
|
||||
template <class T> Menu<T>::Menu(size_t startx,
|
||||
int itsBeginning;
|
||||
int itsHighlight;
|
||||
|
||||
Color itsHighlightColor;
|
||||
bool highlightEnabled;
|
||||
|
||||
Buffer *itsSelectedPrefix;
|
||||
Buffer *itsSelectedSuffix;
|
||||
};
|
||||
|
||||
template <> std::string Menu<std::string>::GetOption(size_t pos);
|
||||
}
|
||||
|
||||
template <class T> NCurses::Menu<T>::Menu(size_t startx,
|
||||
size_t starty,
|
||||
size_t width,
|
||||
size_t height,
|
||||
@@ -194,7 +196,7 @@ template <class T> Menu<T>::Menu(size_t startx,
|
||||
{
|
||||
}
|
||||
|
||||
template <class T> Menu<T>::Menu(const Menu &m) : Window(m)
|
||||
template <class T> NCurses::Menu<T>::Menu(const Menu &m) : Window(m)
|
||||
{
|
||||
itsOptions = m.itsOptions;
|
||||
itsItemDisplayer = m.itsItemDisplayer;
|
||||
@@ -205,18 +207,18 @@ template <class T> Menu<T>::Menu(const Menu &m) : Window(m)
|
||||
highlightEnabled = m.highlightEnabled;
|
||||
}
|
||||
|
||||
template <class T> Menu<T>::~Menu()
|
||||
template <class T> NCurses::Menu<T>::~Menu()
|
||||
{
|
||||
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Reserve(size_t size)
|
||||
template <class T> void NCurses::Menu<T>::Reserve(size_t size)
|
||||
{
|
||||
itsOptions.reserve(size);
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::ResizeBuffer(size_t size)
|
||||
template <class T> void NCurses::Menu<T>::ResizeBuffer(size_t size)
|
||||
{
|
||||
itsOptions.resize(size);
|
||||
for (size_t i = 0; i < size; i++)
|
||||
@@ -224,27 +226,27 @@ template <class T> void Menu<T>::ResizeBuffer(size_t size)
|
||||
itsOptions[i] = new Option();
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::AddOption(const T &item, bool is_bold, bool is_static)
|
||||
template <class T> void NCurses::Menu<T>::AddOption(const T &item, bool is_bold, bool is_static)
|
||||
{
|
||||
itsOptions.push_back(new Option(item, is_bold, is_static));
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::AddSeparator()
|
||||
template <class T> void NCurses::Menu<T>::AddSeparator()
|
||||
{
|
||||
itsOptions.push_back(0);
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::InsertOption(size_t pos, const T &item, bool is_bold, bool is_static)
|
||||
template <class T> void NCurses::Menu<T>::InsertOption(size_t pos, const T &item, bool is_bold, bool is_static)
|
||||
{
|
||||
itsOptions.insert(itsOptions.begin()+pos, new Option(item, is_bold, is_static));
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::InsertSeparator(size_t pos)
|
||||
template <class T> void NCurses::Menu<T>::InsertSeparator(size_t pos)
|
||||
{
|
||||
itsOptions.insert(itsOptions.begin()+pos, 0);
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::DeleteOption(size_t pos)
|
||||
template <class T> void NCurses::Menu<T>::DeleteOption(size_t pos)
|
||||
{
|
||||
if (itsOptions.empty())
|
||||
return;
|
||||
@@ -266,13 +268,13 @@ template <class T> void Menu<T>::DeleteOption(size_t pos)
|
||||
Window::Clear();
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::IntoSeparator(size_t pos)
|
||||
template <class T> void NCurses::Menu<T>::IntoSeparator(size_t pos)
|
||||
{
|
||||
delete itsOptions.at(pos);
|
||||
itsOptions[pos] = 0;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::BoldOption(int index, bool bold)
|
||||
template <class T> void NCurses::Menu<T>::BoldOption(int index, bool bold)
|
||||
{
|
||||
if (!itsOptions.at(index))
|
||||
return;
|
||||
@@ -280,12 +282,12 @@ template <class T> void Menu<T>::BoldOption(int index, bool bold)
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Menu<T>::Swap(size_t one, size_t two)
|
||||
void NCurses::Menu<T>::Swap(size_t one, size_t two)
|
||||
{
|
||||
std::swap(itsOptions.at(one), itsOptions.at(two));
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Refresh()
|
||||
template <class T> void NCurses::Menu<T>::Refresh()
|
||||
{
|
||||
if (itsOptionsPtr->empty())
|
||||
{
|
||||
@@ -348,7 +350,7 @@ template <class T> void Menu<T>::Refresh()
|
||||
Window::Refresh();
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Scroll(Where where)
|
||||
template <class T> void NCurses::Menu<T>::Scroll(Where where)
|
||||
{
|
||||
if (itsOptionsPtr->empty())
|
||||
return;
|
||||
@@ -454,13 +456,13 @@ template <class T> void Menu<T>::Scroll(Where where)
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Reset()
|
||||
template <class T> void NCurses::Menu<T>::Reset()
|
||||
{
|
||||
itsHighlight = 0;
|
||||
itsBeginning = 0;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Clear(bool clrscr)
|
||||
template <class T> void NCurses::Menu<T>::Clear(bool clrscr)
|
||||
{
|
||||
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
||||
delete *it;
|
||||
@@ -473,7 +475,7 @@ template <class T> void Menu<T>::Clear(bool clrscr)
|
||||
Window::Clear();
|
||||
}
|
||||
|
||||
template <class T> bool Menu<T>::isBold(int id)
|
||||
template <class T> bool NCurses::Menu<T>::isBold(int id)
|
||||
{
|
||||
id = id == -1 ? itsHighlight : id;
|
||||
if (!itsOptionsPtr->at(id))
|
||||
@@ -481,21 +483,21 @@ template <class T> bool Menu<T>::isBold(int id)
|
||||
return (*itsOptionsPtr)[id]->isBold;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Select(int id, bool value)
|
||||
template <class T> void NCurses::Menu<T>::Select(int id, bool value)
|
||||
{
|
||||
if (!itsOptionsPtr->at(id))
|
||||
return;
|
||||
(*itsOptionsPtr)[id]->isSelected = value;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Static(int id, bool value)
|
||||
template <class T> void NCurses::Menu<T>::Static(int id, bool value)
|
||||
{
|
||||
if (!itsOptionsPtr->at(id))
|
||||
return;
|
||||
(*itsOptionsPtr)[id]->isStatic = value;
|
||||
}
|
||||
|
||||
template <class T> bool Menu<T>::isSelected(int id) const
|
||||
template <class T> bool NCurses::Menu<T>::isSelected(int id) const
|
||||
{
|
||||
id = id == -1 ? itsHighlight : id;
|
||||
if (!itsOptionsPtr->at(id))
|
||||
@@ -503,7 +505,7 @@ template <class T> bool Menu<T>::isSelected(int id) const
|
||||
return (*itsOptionsPtr)[id]->isSelected;
|
||||
}
|
||||
|
||||
template <class T> bool Menu<T>::isStatic(int id) const
|
||||
template <class T> bool NCurses::Menu<T>::isStatic(int id) const
|
||||
{
|
||||
id = id == -1 ? itsHighlight : id;
|
||||
if (!itsOptionsPtr->at(id))
|
||||
@@ -511,7 +513,7 @@ template <class T> bool Menu<T>::isStatic(int id) const
|
||||
return (*itsOptionsPtr)[id]->isStatic;
|
||||
}
|
||||
|
||||
template <class T> bool Menu<T>::hasSelected() const
|
||||
template <class T> bool NCurses::Menu<T>::hasSelected() const
|
||||
{
|
||||
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->end(); it++)
|
||||
if (*it && (*it)->isSelected)
|
||||
@@ -519,30 +521,30 @@ template <class T> bool Menu<T>::hasSelected() const
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::GetSelected(std::vector<size_t> &v) const
|
||||
template <class T> void NCurses::Menu<T>::GetSelected(std::vector<size_t> &v) const
|
||||
{
|
||||
for (size_t i = 0; i < itsOptionsPtr->size(); i++)
|
||||
if ((*itsOptionsPtr)[i]->isSelected)
|
||||
v.push_back(i);
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::Highlight(size_t pos)
|
||||
template <class T> void NCurses::Menu<T>::Highlight(size_t pos)
|
||||
{
|
||||
itsHighlight = pos;
|
||||
itsBeginning = pos-itsHeight/2;
|
||||
}
|
||||
|
||||
template <class T> size_t Menu<T>::Size() const
|
||||
template <class T> size_t NCurses::Menu<T>::Size() const
|
||||
{
|
||||
return itsOptionsPtr->size();
|
||||
}
|
||||
|
||||
template <class T> size_t Menu<T>::Choice() const
|
||||
template <class T> size_t NCurses::Menu<T>::Choice() const
|
||||
{
|
||||
return itsHighlight;
|
||||
}
|
||||
|
||||
template <class T> size_t Menu<T>::RealChoice() const
|
||||
template <class T> size_t NCurses::Menu<T>::RealChoice() const
|
||||
{
|
||||
size_t result = 0;
|
||||
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->begin()+itsHighlight; it++)
|
||||
@@ -551,7 +553,7 @@ template <class T> size_t Menu<T>::RealChoice() const
|
||||
return result;
|
||||
}
|
||||
|
||||
template <class T> void Menu<T>::ApplyFilter(const std::string &filter, size_t beginning, bool case_sensitive)
|
||||
template <class T> void NCurses::Menu<T>::ApplyFilter(const std::string &filter, size_t beginning, bool case_sensitive)
|
||||
{
|
||||
if (filter == itsFilter)
|
||||
return;
|
||||
@@ -585,12 +587,12 @@ template <class T> void Menu<T>::ApplyFilter(const std::string &filter, size_t b
|
||||
Window::Clear();
|
||||
}
|
||||
|
||||
template <class T> const std::string &Menu<T>::GetFilter()
|
||||
template <class T> const std::string &NCurses::Menu<T>::GetFilter()
|
||||
{
|
||||
return itsFilter;
|
||||
}
|
||||
|
||||
template <class T> std::string Menu<T>::GetOption(size_t pos)
|
||||
template <class T> std::string NCurses::Menu<T>::GetOption(size_t pos)
|
||||
{
|
||||
if (itsOptionsPtr->at(pos) && itsGetStringFunction)
|
||||
return itsGetStringFunction((*itsOptionsPtr)[pos]->Item, itsGetStringFunctionUserData);
|
||||
@@ -598,67 +600,65 @@ template <class T> std::string Menu<T>::GetOption(size_t pos)
|
||||
return "";
|
||||
}
|
||||
|
||||
template <> std::string Menu<std::string>::GetOption(size_t pos);
|
||||
|
||||
template <class T> T &Menu<T>::Back()
|
||||
template <class T> T &NCurses::Menu<T>::Back()
|
||||
{
|
||||
if (!itsOptionsPtr->back())
|
||||
throw InvalidItem();
|
||||
return itsOptionsPtr->back()->Item;
|
||||
}
|
||||
|
||||
template <class T> const T &Menu<T>::Back() const
|
||||
template <class T> const T &NCurses::Menu<T>::Back() const
|
||||
{
|
||||
if (!itsOptionsPtr->back())
|
||||
throw InvalidItem();
|
||||
return itsOptionsPtr->back()->Item;
|
||||
}
|
||||
|
||||
template <class T> T &Menu<T>::Current()
|
||||
template <class T> T &NCurses::Menu<T>::Current()
|
||||
{
|
||||
if (!itsOptionsPtr->at(itsHighlight))
|
||||
throw InvalidItem();
|
||||
return (*itsOptionsPtr)[itsHighlight]->Item;
|
||||
}
|
||||
|
||||
template <class T> const T &Menu<T>::Current() const
|
||||
template <class T> const T &NCurses::Menu<T>::Current() const
|
||||
{
|
||||
if (!itsOptionsPtr->at(itsHighlight))
|
||||
throw InvalidItem();
|
||||
return (*itsOptionsPtr)[itsHighlight]->Item;
|
||||
}
|
||||
|
||||
template <class T> T &Menu<T>::at(size_t i)
|
||||
template <class T> T &NCurses::Menu<T>::at(size_t i)
|
||||
{
|
||||
if (!itsOptionsPtr->at(i))
|
||||
throw InvalidItem();
|
||||
return (*itsOptionsPtr)[i]->Item;
|
||||
}
|
||||
|
||||
template <class T> const T &Menu<T>::at(size_t i) const
|
||||
template <class T> const T &NCurses::Menu<T>::at(size_t i) const
|
||||
{
|
||||
if (!itsOptions->at(i))
|
||||
throw InvalidItem();
|
||||
return (*itsOptionsPtr)[i]->Item;
|
||||
}
|
||||
|
||||
template <class T> const T &Menu<T>::operator[](size_t i) const
|
||||
template <class T> const T &NCurses::Menu<T>::operator[](size_t i) const
|
||||
{
|
||||
if (!(*itsOptionsPtr)[i])
|
||||
throw InvalidItem();
|
||||
return (*itsOptionsPtr)[i]->Item;
|
||||
}
|
||||
|
||||
template <class T> T &Menu<T>::operator[](size_t i)
|
||||
template <class T> T &NCurses::Menu<T>::operator[](size_t i)
|
||||
{
|
||||
if (!(*itsOptionsPtr)[i])
|
||||
throw InvalidItem();
|
||||
return (*itsOptionsPtr)[i]->Item;
|
||||
}
|
||||
|
||||
template <class T> Menu<T> *Menu<T>::EmptyClone() const
|
||||
template <class T> NCurses::Menu<T> *NCurses::Menu<T>::EmptyClone() const
|
||||
{
|
||||
return new Menu<T>(GetStartX(), GetStartY(), GetWidth(), GetHeight(), itsTitle, itsBaseColor, itsBorder);
|
||||
return new NCurses::Menu<T>(GetStartX(), GetStartY(), GetWidth(), GetHeight(), itsTitle, itsBaseColor, itsBorder);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
40
src/misc.cpp
40
src/misc.cpp
@@ -76,52 +76,52 @@ std::string IntoStr(mpd_TagItems tag) // this is only for left column's title in
|
||||
}
|
||||
}
|
||||
|
||||
std::string IntoStr(Color color)
|
||||
std::string IntoStr(NCurses::Color color)
|
||||
{
|
||||
std::string result;
|
||||
|
||||
if (color == clDefault)
|
||||
if (color == NCurses::clDefault)
|
||||
result = "default";
|
||||
else if (color == clBlack)
|
||||
else if (color == NCurses::clBlack)
|
||||
result = "black";
|
||||
else if (color == clRed)
|
||||
else if (color == NCurses::clRed)
|
||||
result = "red";
|
||||
else if (color == clGreen)
|
||||
else if (color == NCurses::clGreen)
|
||||
result = "green";
|
||||
else if (color == clYellow)
|
||||
else if (color == NCurses::clYellow)
|
||||
result = "yellow";
|
||||
else if (color == clBlue)
|
||||
else if (color == NCurses::clBlue)
|
||||
result = "blue";
|
||||
else if (color == clMagenta)
|
||||
else if (color == NCurses::clMagenta)
|
||||
result = "magenta";
|
||||
else if (color == clCyan)
|
||||
else if (color == NCurses::clCyan)
|
||||
result = "cyan";
|
||||
else if (color == clWhite)
|
||||
else if (color == NCurses::clWhite)
|
||||
result = "white";
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Color IntoColor(const std::string &color)
|
||||
NCurses::Color IntoColor(const std::string &color)
|
||||
{
|
||||
Color result = clDefault;
|
||||
NCurses::Color result = NCurses::clDefault;
|
||||
|
||||
if (color == "black")
|
||||
result = clBlack;
|
||||
result = NCurses::clBlack;
|
||||
else if (color == "red")
|
||||
result = clRed;
|
||||
result = NCurses::clRed;
|
||||
else if (color == "green")
|
||||
result = clGreen;
|
||||
result = NCurses::clGreen;
|
||||
else if (color == "yellow")
|
||||
result = clYellow;
|
||||
result = NCurses::clYellow;
|
||||
else if (color == "blue")
|
||||
result = clBlue;
|
||||
result = NCurses::clBlue;
|
||||
else if (color == "magenta")
|
||||
result = clMagenta;
|
||||
result = NCurses::clMagenta;
|
||||
else if (color == "cyan")
|
||||
result = clCyan;
|
||||
result = NCurses::clCyan;
|
||||
else if (color == "white")
|
||||
result = clWhite;
|
||||
result = NCurses::clWhite;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ std::string IntoStr(int);
|
||||
|
||||
std::string IntoStr(mpd_TagItems);
|
||||
|
||||
std::string IntoStr(Color);
|
||||
std::string IntoStr(NCurses::Color);
|
||||
|
||||
Color IntoColor(const std::string &);
|
||||
NCurses::Color IntoColor(const std::string &);
|
||||
|
||||
mpd_TagItems IntoTagItem(char);
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
vFoundPositions.clear(); \
|
||||
} while (0)
|
||||
|
||||
using namespace NCurses;
|
||||
|
||||
typedef std::pair<std::string, std::string> string_pair;
|
||||
|
||||
const int ncmpcpp_window_timeout = 500;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "scrollpad.h"
|
||||
|
||||
using namespace NCurses;
|
||||
using std::string;
|
||||
|
||||
Scrollpad::Scrollpad(size_t startx,
|
||||
|
||||
@@ -24,49 +24,52 @@
|
||||
#include "window.h"
|
||||
#include "strbuffer.h"
|
||||
|
||||
class Scrollpad: public Window
|
||||
namespace NCurses
|
||||
{
|
||||
public:
|
||||
Scrollpad(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Scrollpad(const Scrollpad &);
|
||||
virtual ~Scrollpad() { }
|
||||
class Scrollpad: public Window
|
||||
{
|
||||
public:
|
||||
Scrollpad(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Scrollpad(const Scrollpad &);
|
||||
virtual ~Scrollpad() { }
|
||||
|
||||
void Flush();
|
||||
void SetFormatting(short, const std::basic_string<my_char_t> &, short, bool for_each = 1);
|
||||
std::basic_string<my_char_t> Content() { return itsBuffer.Str(); }
|
||||
void Flush();
|
||||
void SetFormatting(short, const std::basic_string<my_char_t> &, short, bool for_each = 1);
|
||||
std::basic_string<my_char_t> Content() { return itsBuffer.Str(); }
|
||||
|
||||
virtual void Refresh();
|
||||
virtual void Scroll(Where);
|
||||
virtual void Refresh();
|
||||
virtual void Scroll(Where);
|
||||
|
||||
virtual void Resize(size_t, size_t);
|
||||
virtual void Clear(bool = 1);
|
||||
virtual void Resize(size_t, size_t);
|
||||
virtual void Clear(bool = 1);
|
||||
|
||||
template <class T> Scrollpad &operator<<(const T &t)
|
||||
{
|
||||
itsBuffer << t;
|
||||
return *this;
|
||||
}
|
||||
template <class T> Scrollpad &operator<<(const T &t)
|
||||
{
|
||||
itsBuffer << t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Scrollpad &operator<<(std::ostream &(*os)(std::ostream &));
|
||||
Scrollpad &operator<<(std::ostream &(*os)(std::ostream &));
|
||||
|
||||
# ifdef _UTF8
|
||||
void SetFormatting(short vb, const std::string &s, short ve, bool for_each = 1) { SetFormatting(vb, ToWString(s), ve, for_each); }
|
||||
Scrollpad &operator<<(const char *s);
|
||||
Scrollpad &operator<<(const std::string &s);
|
||||
# endif // _UTF8
|
||||
# ifdef _UTF8
|
||||
void SetFormatting(short vb, const std::string &s, short ve, bool for_each = 1) { SetFormatting(vb, ToWString(s), ve, for_each); }
|
||||
Scrollpad &operator<<(const char *s);
|
||||
Scrollpad &operator<<(const std::string &s);
|
||||
# endif // _UTF8
|
||||
|
||||
virtual Scrollpad *Clone() const { return new Scrollpad(*this); }
|
||||
virtual Scrollpad *EmptyClone() const;
|
||||
virtual Scrollpad *Clone() const { return new Scrollpad(*this); }
|
||||
virtual Scrollpad *EmptyClone() const;
|
||||
|
||||
protected:
|
||||
virtual void Recreate();
|
||||
protected:
|
||||
virtual void Recreate();
|
||||
|
||||
basic_buffer<my_char_t> itsBuffer;
|
||||
basic_buffer<my_char_t> itsBuffer;
|
||||
|
||||
int itsBeginning;
|
||||
int itsBeginning;
|
||||
|
||||
size_t itsRealHeight;
|
||||
};
|
||||
size_t itsRealHeight;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
105
src/strbuffer.h
105
src/strbuffer.h
@@ -26,54 +26,57 @@
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
|
||||
template <class C> class basic_buffer
|
||||
namespace NCurses
|
||||
{
|
||||
struct FormatPos
|
||||
template <class C> class basic_buffer
|
||||
{
|
||||
size_t Position;
|
||||
short Value;
|
||||
|
||||
bool operator<(const FormatPos &f)
|
||||
struct FormatPos
|
||||
{
|
||||
return Position < f.Position;
|
||||
}
|
||||
size_t Position;
|
||||
short Value;
|
||||
|
||||
bool operator<(const FormatPos &f)
|
||||
{
|
||||
return Position < f.Position;
|
||||
}
|
||||
};
|
||||
|
||||
std::basic_ostringstream<C> itsString;
|
||||
std::list<FormatPos> itsFormat;
|
||||
std::basic_string<C> *itsTempString;
|
||||
|
||||
public:
|
||||
basic_buffer() : itsTempString(0) { }
|
||||
|
||||
std::basic_string<C> Str() const;
|
||||
void SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each = 1);
|
||||
void SetTemp(std::basic_string<C> *);
|
||||
void Clear();
|
||||
|
||||
template <class T> basic_buffer<C> &operator<<(const T &t)
|
||||
{
|
||||
itsString << t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
basic_buffer<C> &operator<<(std::ostream &(*os)(std::ostream &));
|
||||
basic_buffer<C> &operator<<(const Color &color);
|
||||
basic_buffer<C> &operator<<(const Format &f);
|
||||
basic_buffer<C> &operator<<(const basic_buffer<C> &buf);
|
||||
|
||||
friend Window &operator<< <>(Window &, const basic_buffer<C> &);
|
||||
};
|
||||
|
||||
std::basic_ostringstream<C> itsString;
|
||||
std::list<FormatPos> itsFormat;
|
||||
std::basic_string<C> *itsTempString;
|
||||
typedef basic_buffer<char> Buffer;
|
||||
typedef basic_buffer<wchar_t> WBuffer;
|
||||
}
|
||||
|
||||
public:
|
||||
basic_buffer() : itsTempString(0) { }
|
||||
|
||||
std::basic_string<C> Str() const;
|
||||
void SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each = 1);
|
||||
void SetTemp(std::basic_string<C> *);
|
||||
void Clear();
|
||||
|
||||
template <class T> basic_buffer<C> &operator<<(const T &t)
|
||||
{
|
||||
itsString << t;
|
||||
return *this;
|
||||
}
|
||||
|
||||
basic_buffer<C> &operator<<(std::ostream &(*os)(std::ostream &));
|
||||
basic_buffer<C> &operator<<(const Color &color);
|
||||
basic_buffer<C> &operator<<(const Format &f);
|
||||
basic_buffer<C> &operator<<(const basic_buffer<C> &buf);
|
||||
|
||||
friend Window &operator<< <>(Window &, const basic_buffer<C> &);
|
||||
};
|
||||
|
||||
typedef basic_buffer<char> Buffer;
|
||||
typedef basic_buffer<wchar_t> WBuffer;
|
||||
|
||||
template <class C> std::basic_string<C> basic_buffer<C>::Str() const
|
||||
template <class C> std::basic_string<C> NCurses::basic_buffer<C>::Str() const
|
||||
{
|
||||
return itsString.str();
|
||||
}
|
||||
|
||||
template <class C> void basic_buffer<C>::SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each)
|
||||
template <class C> void NCurses::basic_buffer<C>::SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each)
|
||||
{
|
||||
std::basic_string<C> base = itsString.str();
|
||||
FormatPos fp;
|
||||
@@ -92,24 +95,24 @@ template <class C> void basic_buffer<C>::SetFormatting(short vb, const std::basi
|
||||
}
|
||||
}
|
||||
|
||||
template <class C> void basic_buffer<C>::SetTemp(std::basic_string<C> *tmp)
|
||||
template <class C> void NCurses::basic_buffer<C>::SetTemp(std::basic_string<C> *tmp)
|
||||
{
|
||||
itsTempString = tmp;
|
||||
}
|
||||
|
||||
template <class C> void basic_buffer<C>::Clear()
|
||||
template <class C> void NCurses::basic_buffer<C>::Clear()
|
||||
{
|
||||
itsString.str(std::basic_string<C>());
|
||||
itsFormat.clear();
|
||||
}
|
||||
|
||||
template <class C> basic_buffer<C> &basic_buffer<C>::operator<<(std::ostream &(*os)(std::ostream&))
|
||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(std::ostream &(*os)(std::ostream&))
|
||||
{
|
||||
itsString << os;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class C> basic_buffer<C> &basic_buffer<C>::operator<<(const Color &color)
|
||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const Color &color)
|
||||
{
|
||||
FormatPos f;
|
||||
f.Position = itsString.str().length();
|
||||
@@ -118,24 +121,24 @@ template <class C> basic_buffer<C> &basic_buffer<C>::operator<<(const Color &col
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class C> basic_buffer<C> &basic_buffer<C>::operator<<(const Format &f)
|
||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const Format &f)
|
||||
{
|
||||
return operator<<(Color(f));
|
||||
}
|
||||
|
||||
template <class C> basic_buffer<C> &basic_buffer<C>::operator<<(const basic_buffer<C> &buf)
|
||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const NCurses::basic_buffer<C> &buf)
|
||||
{
|
||||
size_t len = itsString.str().length();
|
||||
itsString << buf.itsString.str();
|
||||
std::list<FormatPos> tmp = buf.itsFormat;
|
||||
if (len)
|
||||
for (typename std::list<typename basic_buffer<C>::FormatPos>::iterator it = tmp.begin(); it != tmp.end(); it++)
|
||||
for (typename std::list<typename NCurses::basic_buffer<C>::FormatPos>::iterator it = tmp.begin(); it != tmp.end(); it++)
|
||||
it->Position += len;
|
||||
itsFormat.merge(tmp);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class C> Window &operator<<(Window &w, const basic_buffer<C> &buf)
|
||||
template <class C> NCurses::Window &operator<<(NCurses::Window &w, const NCurses::basic_buffer<C> &buf)
|
||||
{
|
||||
const std::basic_string<C> &s = buf.itsTempString ? *buf.itsTempString : buf.itsString.str();
|
||||
if (buf.itsFormat.empty())
|
||||
@@ -145,8 +148,8 @@ template <class C> Window &operator<<(Window &w, const basic_buffer<C> &buf)
|
||||
else
|
||||
{
|
||||
std::basic_string<C> tmp;
|
||||
typename std::list<typename basic_buffer<C>::FormatPos>::const_iterator b = buf.itsFormat.begin();
|
||||
typename std::list<typename basic_buffer<C>::FormatPos>::const_iterator e = buf.itsFormat.end();
|
||||
typename std::list<typename NCurses::basic_buffer<C>::FormatPos>::const_iterator b = buf.itsFormat.begin();
|
||||
typename std::list<typename NCurses::basic_buffer<C>::FormatPos>::const_iterator e = buf.itsFormat.end();
|
||||
for (size_t i = 0; i < s.length() || b != e; i++)
|
||||
{
|
||||
while (b != e && i == b->Position)
|
||||
@@ -156,10 +159,10 @@ template <class C> Window &operator<<(Window &w, const basic_buffer<C> &buf)
|
||||
w << tmp;
|
||||
tmp.clear();
|
||||
}
|
||||
if (b->Value < fmtNone)
|
||||
w << Color(b->Value);
|
||||
if (b->Value < NCurses::fmtNone)
|
||||
w << NCurses::Color(b->Value);
|
||||
else
|
||||
w << Format(b->Value);
|
||||
w << NCurses::Format(b->Value);
|
||||
b++;
|
||||
}
|
||||
if (i < s.length())
|
||||
|
||||
@@ -23,10 +23,12 @@
|
||||
|
||||
#include "window.h"
|
||||
|
||||
using namespace NCurses;
|
||||
|
||||
using std::string;
|
||||
using std::wstring;
|
||||
|
||||
void InitScreen(bool enable_colors)
|
||||
void NCurses::InitScreen(bool enable_colors)
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
initscr();
|
||||
@@ -44,7 +46,7 @@ void InitScreen(bool enable_colors)
|
||||
curs_set(0);
|
||||
}
|
||||
|
||||
void DestroyScreen()
|
||||
void NCurses::DestroyScreen()
|
||||
{
|
||||
curs_set(1);
|
||||
endwin();
|
||||
|
||||
211
src/window.h
211
src/window.h
@@ -41,140 +41,143 @@
|
||||
# define TO_WSTRING(x) x
|
||||
#endif
|
||||
|
||||
enum Color { clDefault, clBlack, clRed, clGreen, clYellow, clBlue, clMagenta, clCyan, clWhite, clEnd };
|
||||
enum Format { fmtNone = 100, fmtBold, fmtBoldEnd, fmtReverse, fmtReverseEnd, fmtAltCharset, fmtAltCharsetEnd };
|
||||
enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite };
|
||||
enum Where { wUp, wDown, wPageUp, wPageDown, wHome, wEnd };
|
||||
|
||||
typedef void (*GetStringHelper)(const std::wstring &);
|
||||
|
||||
void InitScreen(bool);
|
||||
void DestroyScreen();
|
||||
|
||||
struct Colors
|
||||
{
|
||||
Colors(Color one, Color two = clDefault) : fg(one), bg(two) { }
|
||||
Color fg;
|
||||
Color bg;
|
||||
};
|
||||
|
||||
struct XY
|
||||
{
|
||||
XY(int xx, int yy) : x(xx), y(yy) { }
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
char *ToString(const wchar_t *);
|
||||
wchar_t *ToWString(const char *);
|
||||
std::string ToString(const std::wstring &);
|
||||
std::wstring ToWString(const std::string &);
|
||||
|
||||
class Window
|
||||
namespace NCurses
|
||||
{
|
||||
public:
|
||||
Window(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Window(const Window &);
|
||||
virtual ~Window();
|
||||
enum Color { clDefault, clBlack, clRed, clGreen, clYellow, clBlue, clMagenta, clCyan, clWhite, clEnd };
|
||||
enum Format { fmtNone = 100, fmtBold, fmtBoldEnd, fmtReverse, fmtReverseEnd, fmtAltCharset, fmtAltCharsetEnd };
|
||||
enum Border { brNone, brBlack, brRed, brGreen, brYellow, brBlue, brMagenta, brCyan, brWhite };
|
||||
enum Where { wUp, wDown, wPageUp, wPageDown, wHome, wEnd };
|
||||
|
||||
WINDOW *Raw() const { return itsWindow; }
|
||||
typedef void (*GetStringHelper)(const std::wstring &);
|
||||
|
||||
size_t GetWidth() const;
|
||||
size_t GetHeight() const;
|
||||
size_t GetStartX() const;
|
||||
size_t GetStartY() const;
|
||||
void InitScreen(bool);
|
||||
void DestroyScreen();
|
||||
|
||||
const std::string &GetTitle() const;
|
||||
Color GetColor() const;
|
||||
Border GetBorder() const;
|
||||
std::string GetString(const std::string &, size_t = -1, size_t = 0, bool = 0) const;
|
||||
std::string GetString(size_t length = -1, size_t width = 0, bool encrypted = 0) const { return GetString("", length, width, encrypted); }
|
||||
void GetXY(int &, int &);
|
||||
void GotoXY(int, int);
|
||||
const int &X() const;
|
||||
const int &Y() const;
|
||||
struct Colors
|
||||
{
|
||||
Colors(Color one, Color two = clDefault) : fg(one), bg(two) { }
|
||||
Color fg;
|
||||
Color bg;
|
||||
};
|
||||
|
||||
void SetGetStringHelper(GetStringHelper helper) { itsGetStringHelper = helper; }
|
||||
void SetColor(Color, Color = clDefault);
|
||||
void SetBaseColor(Color, Color = clDefault);
|
||||
void SetBorder(Border);
|
||||
void SetTimeout(int);
|
||||
void SetTitle(const std::string &);
|
||||
struct XY
|
||||
{
|
||||
XY(int xx, int yy) : x(xx), y(yy) { }
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
void Hide(char = 32) const;
|
||||
void Bold(bool) const;
|
||||
void Reverse(bool) const;
|
||||
void AltCharset(bool) const;
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Window(const Window &);
|
||||
virtual ~Window();
|
||||
|
||||
void Display();
|
||||
virtual void Refresh();
|
||||
WINDOW *Raw() const { return itsWindow; }
|
||||
|
||||
virtual void MoveTo(size_t, size_t);
|
||||
virtual void Resize(size_t, size_t);
|
||||
virtual void Clear(bool = 1);
|
||||
size_t GetWidth() const;
|
||||
size_t GetHeight() const;
|
||||
size_t GetStartX() const;
|
||||
size_t GetStartY() const;
|
||||
|
||||
void ReadKey(int &) const;
|
||||
void ReadKey() const;
|
||||
const std::string &GetTitle() const;
|
||||
Color GetColor() const;
|
||||
Border GetBorder() const;
|
||||
std::string GetString(const std::string &, size_t = -1, size_t = 0, bool = 0) const;
|
||||
std::string GetString(size_t length = -1, size_t width = 0, bool encrypted = 0) const { return GetString("", length, width, encrypted); }
|
||||
void GetXY(int &, int &);
|
||||
void GotoXY(int, int);
|
||||
const int &X() const;
|
||||
const int &Y() const;
|
||||
|
||||
//void Write(bool, const char *, ...) const;
|
||||
//void WriteXY(int, int, bool, const char *, ...) const;
|
||||
void SetGetStringHelper(GetStringHelper helper) { itsGetStringHelper = helper; }
|
||||
void SetColor(Color, Color = clDefault);
|
||||
void SetBaseColor(Color, Color = clDefault);
|
||||
void SetBorder(Border);
|
||||
void SetTimeout(int);
|
||||
void SetTitle(const std::string &);
|
||||
|
||||
void Scrollable(bool) const;
|
||||
virtual void Scroll(Where);
|
||||
void Hide(char = 32) const;
|
||||
void Bold(bool) const;
|
||||
void Reverse(bool) const;
|
||||
void AltCharset(bool) const;
|
||||
|
||||
Window &operator<<(int (*)(WINDOW *));
|
||||
Window &operator<<(const Colors &);
|
||||
Window &operator<<(const Color &);
|
||||
Window &operator<<(const Format &);
|
||||
Window &operator<<(const XY &);
|
||||
Window &operator<<(const char *);
|
||||
Window &operator<<(const char &);
|
||||
Window &operator<<(const wchar_t *);
|
||||
Window &operator<<(const wchar_t &);
|
||||
Window &operator<<(const int &);
|
||||
Window &operator<<(const double &);
|
||||
Window &operator<<(const size_t &);
|
||||
void Display();
|
||||
virtual void Refresh();
|
||||
|
||||
Window &operator<<(const std::string &);
|
||||
Window &operator<<(const std::wstring &);
|
||||
virtual void MoveTo(size_t, size_t);
|
||||
virtual void Resize(size_t, size_t);
|
||||
virtual void Clear(bool = 1);
|
||||
|
||||
virtual Window *Clone() const { return new Window(*this); }
|
||||
virtual Window *EmptyClone() const;
|
||||
void ReadKey(int &) const;
|
||||
void ReadKey() const;
|
||||
|
||||
static size_t Length(const std::wstring &);
|
||||
//void Write(bool, const char *, ...) const;
|
||||
//void WriteXY(int, int, bool, const char *, ...) const;
|
||||
|
||||
protected:
|
||||
void Scrollable(bool) const;
|
||||
virtual void Scroll(Where);
|
||||
|
||||
class BadSize { };
|
||||
Window &operator<<(int (*)(WINDOW *));
|
||||
Window &operator<<(const Colors &);
|
||||
Window &operator<<(const Color &);
|
||||
Window &operator<<(const Format &);
|
||||
Window &operator<<(const XY &);
|
||||
Window &operator<<(const char *);
|
||||
Window &operator<<(const char &);
|
||||
Window &operator<<(const wchar_t *);
|
||||
Window &operator<<(const wchar_t &);
|
||||
Window &operator<<(const int &);
|
||||
Window &operator<<(const double &);
|
||||
Window &operator<<(const size_t &);
|
||||
|
||||
void ShowBorder() const;
|
||||
void AdjustDimensions(size_t &, size_t &);
|
||||
Window &operator<<(const std::string &);
|
||||
Window &operator<<(const std::wstring &);
|
||||
|
||||
virtual void Recreate();
|
||||
virtual Window *Clone() const { return new Window(*this); }
|
||||
virtual Window *EmptyClone() const;
|
||||
|
||||
WINDOW *itsWindow;
|
||||
WINDOW *itsWinBorder;
|
||||
static size_t Length(const std::wstring &);
|
||||
|
||||
GetStringHelper itsGetStringHelper;
|
||||
protected:
|
||||
|
||||
size_t itsStartX;
|
||||
size_t itsStartY;
|
||||
size_t itsWidth;
|
||||
size_t itsHeight;
|
||||
class BadSize { };
|
||||
|
||||
int itsWindowTimeout;
|
||||
int itsX;
|
||||
int itsY;
|
||||
void ShowBorder() const;
|
||||
void AdjustDimensions(size_t &, size_t &);
|
||||
|
||||
std::string itsTitle;
|
||||
std::stack<Colors> itsColors;
|
||||
virtual void Recreate();
|
||||
|
||||
Color itsColor;
|
||||
Color itsBaseColor;
|
||||
Color itsBgColor;
|
||||
Color itsBaseBgColor;
|
||||
WINDOW *itsWindow;
|
||||
WINDOW *itsWinBorder;
|
||||
|
||||
Border itsBorder;
|
||||
};
|
||||
GetStringHelper itsGetStringHelper;
|
||||
|
||||
size_t itsStartX;
|
||||
size_t itsStartY;
|
||||
size_t itsWidth;
|
||||
size_t itsHeight;
|
||||
|
||||
int itsWindowTimeout;
|
||||
int itsX;
|
||||
int itsY;
|
||||
|
||||
std::string itsTitle;
|
||||
std::stack<Colors> itsColors;
|
||||
|
||||
Color itsColor;
|
||||
Color itsBaseColor;
|
||||
Color itsBgColor;
|
||||
Color itsBaseBgColor;
|
||||
|
||||
Border itsBorder;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user