| 1 |
sf-pippijn |
1.1 |
/* panel.hh |
| 2 |
|
|
* This file is part of ncursesxx library |
| 3 |
|
|
* Copyright (c) 2003,2004 by Stanislav Ievlev |
| 4 |
|
|
* |
| 5 |
|
|
* This file is covered by the GNU Library General Public License, |
| 6 |
|
|
* which should be included with libncursesxx as the file COPYING. |
| 7 |
|
|
*/ |
| 8 |
|
|
#ifndef NCURSESXX_PANEL_HH__ |
| 9 |
|
|
#define NCURSESXX_PANEL_HH__ |
| 10 |
|
|
|
| 11 |
|
|
#include <vector> |
| 12 |
|
|
|
| 13 |
|
|
#include <panel.h> |
| 14 |
|
|
|
| 15 |
|
|
#include <ncurses/window.hh> |
| 16 |
|
|
|
| 17 |
|
|
namespace ncurses |
| 18 |
|
|
{ |
| 19 |
|
|
/** |
| 20 |
|
|
* meaning of coordinates |
| 21 |
|
|
*/ |
| 22 |
|
|
enum coords_type |
| 23 |
|
|
{ |
| 24 |
|
|
absolute, /**< absolute coordinate of screen */ |
| 25 |
|
|
relative, /**< relative to previous position coordinate */ |
| 26 |
|
|
rel_parent /**< relative to parent coordinate */ |
| 27 |
|
|
}; |
| 28 |
|
|
|
| 29 |
|
|
/** |
| 30 |
|
|
* Enchancement of Window, |
| 31 |
|
|
* Panel supports depth and overlapping feature |
| 32 |
|
|
*/ |
| 33 |
|
|
class panel |
| 34 |
|
|
: public window |
| 35 |
|
|
{ |
| 36 |
|
|
typedef std::vector<panel *> child_vector; /**< list of the panels */ |
| 37 |
|
|
|
| 38 |
|
|
public: |
| 39 |
|
|
panel (panel *parent = 0); |
| 40 |
|
|
virtual ~panel (); |
| 41 |
|
|
|
| 42 |
|
|
virtual void top (); /**< put this panel on top of all panels in the stack */ |
| 43 |
|
|
virtual void bottom (); /**< put this panel at the bottom of all panels */ |
| 44 |
|
|
virtual void show (); /**< makes a hidden panel visible by placing it on top of the panels */ |
| 45 |
|
|
virtual void hide (); /**< removes the given panel from the panel stack and thus hides it from view */ |
| 46 |
|
|
|
| 47 |
|
|
bool hidden () const; /**< are this widget hidden? */ |
| 48 |
|
|
bool higher (const panel &) const; /**< are we higher other panel */ |
| 49 |
|
|
|
| 50 |
|
|
|
| 51 |
|
|
virtual void draw (); /**< draw widget specific content over general panel */ |
| 52 |
|
|
|
| 53 |
|
|
void prepare (bool recursive = true); /**< draw this widget and all subwidgets */ |
| 54 |
|
|
void visualize (bool recursive = true); /**< equivalent of prepare + show */ |
| 55 |
|
|
|
| 56 |
|
|
/** |
| 57 |
|
|
* move panel to the other place, refresh state of other panels |
| 58 |
|
|
* @param x absolute or relative to previous position x coordinate |
| 59 |
|
|
* @param y absolute or relative to previous position y coordinate |
| 60 |
|
|
* @param |
| 61 |
|
|
*/ |
| 62 |
|
|
virtual void move (int x, int y, coords_type type = relative); |
| 63 |
|
|
|
| 64 |
|
|
panel *parent () const { return parent_; } |
| 65 |
|
|
|
| 66 |
|
|
protected: |
| 67 |
|
|
void add_child (panel *p); /**< helper to create panel's hieracly */ |
| 68 |
|
|
void del_child (panel *p); /**< delete from the childs list */ |
| 69 |
|
|
|
| 70 |
|
|
private: |
| 71 |
|
|
/* hide dangerous operations */ |
| 72 |
|
|
panel (const panel &other); |
| 73 |
|
|
panel &operator = (const panel &other); |
| 74 |
|
|
|
| 75 |
|
|
PANEL *panel_; /**< internal ncurses panel structure */ |
| 76 |
|
|
panel *parent_; /**< parent panel, if we have*/ |
| 77 |
|
|
child_vector childs_; /**< childs of this */ |
| 78 |
|
|
}; |
| 79 |
|
|
|
| 80 |
|
|
inline |
| 81 |
|
|
bool |
| 82 |
|
|
operator > (const panel &lhs, const panel &rhs) |
| 83 |
|
|
{ |
| 84 |
|
|
return lhs.higher (rhs); |
| 85 |
|
|
} |
| 86 |
|
|
|
| 87 |
|
|
inline |
| 88 |
|
|
bool |
| 89 |
|
|
operator < (const panel &lhs, const panel &rhs) |
| 90 |
|
|
{ |
| 91 |
|
|
return rhs.higher (lhs); |
| 92 |
|
|
} |
| 93 |
|
|
} |
| 94 |
|
|
|
| 95 |
|
|
#endif |