PageRenderTime 50ms CodeModel.GetById 39ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/ghost/ui/window.h

http://ghostcb.googlecode.com/
C++ Header | 70 lines | 22 code | 17 blank | 31 comment | 0 complexity | b34362f5d0cce3370fddcfe71e33314d MD5 | raw file
 1#ifndef WINDOW_H
 2#define WINDOW_H
 3
 4#include "widget.h"
 5
 6/*
 7	CWindow initializes curses. It contains only one widget,
 8	which can be set using SetWidget(). CWindow is not the same
 9	as WINDOW in curses. It is the actual terminal window.
10
11	Use setSize() to resize window. Size should be reasonable.
12	Normally resizing crashes with aspect ratios smaller than 2:5
13	and with too large y-values (85+), but setSize() avoids them.
14
15	Call show() to show widgets. (The window is "hidden".)
16
17	Use update() to update everything.
18
19	Deleting CWindow deletes all the widgets and exits curses.
20
21	Note: You can only have one instance of CWindow.
22*/
23
24// Terminal window
25class CWindow : public CWidget
26{
27public:
28	// Create new window
29	CWindow();
30
31	// Delete window and all of its widgets
32	~CWindow();
33
34	// Set main widget. Widget's parent is this window.
35	void setWidget(CWidget *widget);
36
37	// Resize window
38	void setSize(uint width, uint height);
39
40	// Set title
41	void setTitle(const string &title);
42
43	// Show widgets
44	void show();
45
46	// Hide widgets
47	void hide();
48
49	// Update window
50	void update();
51
52	// Get pressed key
53	int key();
54
55private:
56	// Update input
57	void updateInput();
58
59	// Update mouse
60	void updateMouse(int c);
61
62	// Main Widget
63	CWidget *_widget;
64
65	// Pressed key from getch()
66	int _key;
67
68};
69
70#endif