• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

yapet/statusbar.cc

Go to the documentation of this file.
00001 // $Id: statusbar.cc 3342 2010-09-17 18:32:00Z java $
00002 //
00003 // Copyright (C) 2008-2010  Rafael Ostertag
00004 //
00005 // This file is part of YAPET.
00006 //
00007 // YAPET is free software: you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the Free Software
00009 // Foundation, either version 3 of the License, or (at your option) any later
00010 // version.
00011 //
00012 // YAPET is distributed in the hope that it will be useful, but WITHOUT ANY
00013 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015 // details.
00016 //
00017 // You should have received a copy of the GNU General Public License along with
00018 // YAPET.  If not, see <http://www.gnu.org/licenses/>.
00019 //
00020 
00021 #include "../intl.h"
00022 #include "statusbar.h"
00023 
00024 void
00025 StatusBar::createWindow() throw (YAPET::UI::UIException) {
00026     if (statusbar != NULL)
00027         throw YAPET::UI::UIException (_ ("May you consider deleting the window before allocating") );
00028 
00029     statusbar = newwin (1, maxX(), maxY() - 1, minX() );
00030 
00031     if (statusbar == NULL)
00032         throw YAPET::UI::UIException (_ ("statusbar could not be initialized") );
00033 
00034     int retval = wattron (statusbar, A_REVERSE);
00035 
00036     if (retval == ERR)
00037         throw YAPET::UI::UIException (_ ("Error setting attribute") );
00038 
00039     retval = wbkgd (statusbar, ' ' | A_REVERSE);
00040 
00041     if (retval == ERR)
00042         throw YAPET::UI::UIException (_ ("Error setting the statusbar background") );
00043 
00044     refresh();
00045 }
00046 
00047 StatusBar::StatusBar() throw (YAPET::UI::UIException) : BaseWindow(),
00048         statusbar (NULL) {
00049     createWindow();
00050 }
00051 
00052 StatusBar::~StatusBar() {
00053     wclear (statusbar);
00054     delwin (statusbar);
00055 }
00056 
00057 void
00058 StatusBar::putMsg (std::string msg) throw (YAPET::UI::UIException) {
00059     message = msg;
00060     int retval = wclear (statusbar);
00061 
00062     if (retval == ERR)
00063         throw YAPET::UI::UIException (_ ("Error erasing status bar") );
00064 
00065     retval = mywaddstr (statusbar, message.c_str() );
00066 
00067     if (retval == ERR)
00068         throw YAPET::UI::UIException (_ ("Error adding status message") );
00069 
00070     retval = wrefresh (statusbar);
00071 
00072     if (retval == ERR)
00073         throw YAPET::UI::UIException (_ ("Error refreshing status bar") );
00074 }
00075 
00076 void
00077 StatusBar::refresh() {
00078     // Does a refresh
00079     putMsg (message);
00080 }
00081 
00082 void
00083 StatusBar::resize() {
00084     int retval = delwin (statusbar);
00085 
00086     if (retval == ERR)
00087         throw YAPET::UI::UIException (_ ("status bar could not be deleted") );
00088 
00089     statusbar = NULL;
00090     createWindow();
00091 }

Generated on Sun Sep 19 2010 15:37:14 for YAPET by  doxygen 1.7.1