PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/ghost/ui/common.h

http://ghostcb.googlecode.com/
C++ Header | 108 lines | 72 code | 21 blank | 15 comment | 2 complexity | 6070f78c6b971b44890ba2b5d385c9ec MD5 | raw file
  1#ifndef COMMON_H
  2#define COMMON_H
  3
  4#ifdef WIN32
  5#	include <panel.h>
  6#else
  7#	ifdef USE_XCURSES
  8#		include <xpanel.h>
  9#	else
 10#		include <panel.h>
 11#	endif
 12#endif
 13
 14#include <string>
 15#include <vector>
 16using namespace std;
 17
 18// Safe Delete
 19#define SafeDelete(x) if((x)) { delete x; x = 0; }
 20#define SafeDeleteArray(x) if((x)) { delete[] x; x = 0; }
 21
 22typedef unsigned int uint;
 23
 24#ifdef __PDCURSES__
 25enum Color
 26{
 27	Null = 99,
 28	Black = 0,
 29	Blue,
 30	Green,
 31	Cyan,
 32	Red,
 33	Magenta,
 34	Yellow,
 35	White
 36};
 37#else
 38enum Color
 39{
 40	Null = 99,
 41	Black = 0,
 42	Red,
 43	Green,
 44	Yellow,
 45	Blue,
 46	Magenta,
 47	Cyan,
 48	White
 49};
 50#endif
 51
 52// Get attribute from bgcolor and fgcolor
 53attr_t attribute(Color bgcolor, Color fgcolor, bool bold = false);
 54
 55// Get color pair from bgcolor and fgcolor
 56uint colorpair(Color bgcolor, Color fgcolor);
 57
 58// Point (x, y)
 59class CPoint
 60{
 61public:
 62	CPoint(uint x = 0, uint y = 0);
 63
 64	// Set point
 65	void set(uint x, uint y);
 66
 67	// Get x
 68	uint x();
 69
 70	// Get y
 71	uint y();
 72
 73private:
 74	uint _x;
 75	uint _y;
 76};
 77
 78// Size (width, height)
 79class CSize
 80{
 81public:
 82	CSize(uint width = 0, uint height = 0);
 83
 84	// Set size
 85	void set(uint width, uint height);
 86
 87	// Get width
 88	uint width();
 89
 90	// Get height
 91	uint height();
 92
 93	// Set fixed size. If enabled, vertical layout will not
 94	// resize height and horizontal layout will not resize width.
 95	// Note: layout will correct the size, if it's invalid.
 96	void setFixed(bool enabled);
 97
 98	// Get fixed.
 99	bool fixed();
100
101private:
102	uint _width;
103	uint _height;
104
105	bool _fixed;
106};
107
108#endif