00001 // $Id: statusbar.cc 2360 2009-06-11 15:06:24Z rafi $ 00002 // 00003 // Copyright (C) 2008, 2009 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(YAPETUI::UIException){ 00026 if (statusbar != NULL) 00027 throw YAPETUI::UIException(_("May you consider deleting the window before allocating")); 00028 00029 statusbar = newwin (1, maxX(), maxY() - 1, minX()); 00030 if (statusbar == NULL) 00031 throw YAPETUI::UIException (_("statusbar could not be initialized")); 00032 00033 int retval = wattron (statusbar, A_REVERSE); 00034 if (retval == ERR) 00035 throw YAPETUI::UIException (_("Error setting attribute")); 00036 00037 retval = wbkgd (statusbar, ' ' | A_REVERSE); 00038 if (retval == ERR) 00039 throw YAPETUI::UIException (_("Error setting the statusbar background")); 00040 00041 refresh(); 00042 } 00043 00044 StatusBar::StatusBar() throw (YAPETUI::UIException) : BaseWindow(), 00045 statusbar(NULL) { 00046 createWindow(); 00047 } 00048 00049 StatusBar::~StatusBar() { 00050 wclear(statusbar); 00051 delwin (statusbar); 00052 } 00053 00054 void 00055 StatusBar::putMsg (std::string msg) throw (YAPETUI::UIException) { 00056 message = msg; 00057 int retval = wclear (statusbar); 00058 if (retval == ERR) 00059 throw YAPETUI::UIException (_("Error erasing status bar")); 00060 retval = mywaddstr (statusbar, message.c_str()); 00061 if (retval == ERR) 00062 throw YAPETUI::UIException (_("Error adding status message")); 00063 retval = wrefresh(statusbar); 00064 if (retval == ERR) 00065 throw YAPETUI::UIException(_("Error refreshing status bar")); 00066 } 00067 00068 void 00069 StatusBar::refresh() { 00070 // Does a refresh 00071 putMsg (message); 00072 } 00073 00074 void 00075 StatusBar::resize() { 00076 int retval = delwin(statusbar); 00077 if (retval == ERR) 00078 throw YAPETUI::UIException(_("status bar could not be deleted")); 00079 00080 statusbar = NULL; 00081 00082 createWindow(); 00083 }