1 // -*- mode: c++ -*- 2 // 3 // This file is part of libyacurs. 4 // Copyright (C) 2013 Rafael Ostertag 5 // 6 // This program is free software: you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License as 8 // published by the Free Software Foundation, either version 3 of the 9 // License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, but 12 // WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 // General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program. If not, see 18 // <http://www.gnu.org/licenses/>. 19 // 20 // 21 // $Id$ 22 23 #ifndef WIDGET_H 24 #define WIDGET_H 1 25 26 #include <cstdlib> 27 #include <string> 28 29 #include "widgetbase.h" 30 #include "yacurscurses.h" 31 32 namespace YACURS { 33 /** 34 * Implements a Widget. 35 * 36 * @subsection Basics 37 * 38 * Upon realize(), only the Curses Window will be created. refresh() 39 * only calls wrefresh() or wnoutrefresh(). unrealize() will destroy 40 * the Curses Window. 41 * 42 * @subsection Content 43 * 44 * Content in Curses Window should only be drawn upon refresh(). 45 */ 46 class Widget : public WidgetBase { 47 private: 48 /** 49 * curses subwin used by widgets 50 */ 51 YACURS::INTERNAL::CursWin* _widget_subwin; 52 53 protected: 54 void redraw_handler(Event& e); 55 56 void force_refresh_handler(Event& e); 57 58 void unrealize(); 59 60 YACURS::INTERNAL::CursWin* widget_subwin() const; 61 62 public: 63 Widget(); 64 Widget& operator=(const Widget&) = delete; 65 Widget& operator=(Widget&&) = delete; 66 Widget(const Widget&) = delete; 67 Widget(Widget&&) = delete; 68 virtual ~Widget(); 69 70 // Must be overriden in derived classes 71 // bool size_change(); 72 73 // Inherited from Realizeable 74 void refresh(bool immediate); 75 76 void resize(const Area& a); 77 78 /** 79 * Realize the widget. 80 * 81 * realizes the widget by setting up a curses subwindow, which 82 * can be used by derived classes. 83 */ 84 void realize(); 85 }; 86 } // namespace YACURS 87 #endif // WIDGET_H 88