/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. #include "widget.h"
  4. /*
  5. CWindow initializes curses. It contains only one widget,
  6. which can be set using SetWidget(). CWindow is not the same
  7. as WINDOW in curses. It is the actual terminal window.
  8. Use setSize() to resize window. Size should be reasonable.
  9. Normally resizing crashes with aspect ratios smaller than 2:5
  10. and with too large y-values (85+), but setSize() avoids them.
  11. Call show() to show widgets. (The window is "hidden".)
  12. Use update() to update everything.
  13. Deleting CWindow deletes all the widgets and exits curses.
  14. Note: You can only have one instance of CWindow.
  15. */
  16. // Terminal window
  17. class CWindow : public CWidget
  18. {
  19. public:
  20. // Create new window
  21. CWindow();
  22. // Delete window and all of its widgets
  23. ~CWindow();
  24. // Set main widget. Widget's parent is this window.
  25. void setWidget(CWidget *widget);
  26. // Resize window
  27. void setSize(uint width, uint height);
  28. // Set title
  29. void setTitle(const string &title);
  30. // Show widgets
  31. void show();
  32. // Hide widgets
  33. void hide();
  34. // Update window
  35. void update();
  36. // Get pressed key
  37. int key();
  38. private:
  39. // Update input
  40. void updateInput();
  41. // Update mouse
  42. void updateMouse(int c);
  43. // Main Widget
  44. CWidget *_widget;
  45. // Pressed key from getch()
  46. int _key;
  47. };
  48. #endif