/* vim:set ts=4 sw=4 sts=4 et cindent: */ /* * nanodc - The ncurses DC++ client * Copyright © 2005-2006 Markus Lindqvist * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Contributor(s): * */ #ifndef _SCREEN_H_ #define _SCREEN_H_ #include #include #include #include #include namespace display { /** Wrapper for general ncurses functions. */ class Screen { public: /** Initialize the curses-stuff. * @throw std::runtime_error if something fails. */ static void initialize() throw(std::runtime_error); /** Returns the width of the screen. */ static unsigned int get_width() { int x, y; getmaxyx(stdscr, y, x); return x; } /** Returns the height of the screen. */ static unsigned int get_height() { int x, y; getmaxyx(stdscr, y, x); return y; } /** Check if screen has been resized since last call. * @return True if screen has been resized, false otherwise. */ static bool is_resized(); /** Copy the buffer to the screen. */ static void do_update() { utils::Lock lock(m_mutex); doupdate(); } /** Locks the screen mutex. */ static void lock() { m_mutex.lock(); } /** Unlocks the screen mutex. */ static void unlock() { m_mutex.unlock(); } private: Screen(); //!< Forbidden Screen(const Screen &); //!< Forbidden Screen& operator=(const Screen &); //!< Forbidden static utils::Mutex m_mutex; //!< The screen lock }; } // namespace display #endif // _SCREEN_H_