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