put classes related to ncurses into NCurses namespace
This commit is contained in:
259
src/window.h
259
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();
|
||||
|
||||
WINDOW *Raw() const { return itsWindow; }
|
||||
|
||||
size_t GetWidth() const;
|
||||
size_t GetHeight() const;
|
||||
size_t GetStartX() const;
|
||||
size_t GetStartY() 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 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 Hide(char = 32) const;
|
||||
void Bold(bool) const;
|
||||
void Reverse(bool) const;
|
||||
void AltCharset(bool) const;
|
||||
|
||||
void Display();
|
||||
virtual void Refresh();
|
||||
|
||||
virtual void MoveTo(size_t, size_t);
|
||||
virtual void Resize(size_t, size_t);
|
||||
virtual void Clear(bool = 1);
|
||||
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 };
|
||||
|
||||
void ReadKey(int &) const;
|
||||
void ReadKey() const;
|
||||
|
||||
//void Write(bool, const char *, ...) const;
|
||||
//void WriteXY(int, int, bool, const char *, ...) const;
|
||||
|
||||
void Scrollable(bool) const;
|
||||
virtual void Scroll(Where);
|
||||
|
||||
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 &);
|
||||
|
||||
Window &operator<<(const std::string &);
|
||||
Window &operator<<(const std::wstring &);
|
||||
|
||||
virtual Window *Clone() const { return new Window(*this); }
|
||||
virtual Window *EmptyClone() const;
|
||||
|
||||
static size_t Length(const std::wstring &);
|
||||
|
||||
protected:
|
||||
|
||||
class BadSize { };
|
||||
|
||||
void ShowBorder() const;
|
||||
void AdjustDimensions(size_t &, size_t &);
|
||||
|
||||
virtual void Recreate();
|
||||
|
||||
WINDOW *itsWindow;
|
||||
WINDOW *itsWinBorder;
|
||||
|
||||
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;
|
||||
};
|
||||
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;
|
||||
};
|
||||
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
Window(size_t, size_t, size_t, size_t, const std::string &, Color, Border);
|
||||
Window(const Window &);
|
||||
virtual ~Window();
|
||||
|
||||
WINDOW *Raw() const { return itsWindow; }
|
||||
|
||||
size_t GetWidth() const;
|
||||
size_t GetHeight() const;
|
||||
size_t GetStartX() const;
|
||||
size_t GetStartY() 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 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 Hide(char = 32) const;
|
||||
void Bold(bool) const;
|
||||
void Reverse(bool) const;
|
||||
void AltCharset(bool) const;
|
||||
|
||||
void Display();
|
||||
virtual void Refresh();
|
||||
|
||||
virtual void MoveTo(size_t, size_t);
|
||||
virtual void Resize(size_t, size_t);
|
||||
virtual void Clear(bool = 1);
|
||||
|
||||
void ReadKey(int &) const;
|
||||
void ReadKey() const;
|
||||
|
||||
//void Write(bool, const char *, ...) const;
|
||||
//void WriteXY(int, int, bool, const char *, ...) const;
|
||||
|
||||
void Scrollable(bool) const;
|
||||
virtual void Scroll(Where);
|
||||
|
||||
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 &);
|
||||
|
||||
Window &operator<<(const std::string &);
|
||||
Window &operator<<(const std::wstring &);
|
||||
|
||||
virtual Window *Clone() const { return new Window(*this); }
|
||||
virtual Window *EmptyClone() const;
|
||||
|
||||
static size_t Length(const std::wstring &);
|
||||
|
||||
protected:
|
||||
|
||||
class BadSize { };
|
||||
|
||||
void ShowBorder() const;
|
||||
void AdjustDimensions(size_t &, size_t &);
|
||||
|
||||
virtual void Recreate();
|
||||
|
||||
WINDOW *itsWindow;
|
||||
WINDOW *itsWinBorder;
|
||||
|
||||
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