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