00001 // -*- c++ -*- 00002 // 00003 // $Id: mainwindow.h,v 1.7 2008-02-13 20:47:48 rafi Exp $ 00004 // 00005 // YAPET -- Yet Another Password Encryption Tool 00006 // Copyright (C) 2008 Rafael Ostertag 00007 // 00008 // This program is free software: you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 00022 #ifndef _MAINWINDOW_H 00023 #define _MAINWINDOW_H 00024 00025 00026 #ifdef HAVE_CONFIG_H 00027 #include <config.h> 00028 #endif 00029 00030 #ifdef HAVE_NCURSES_H 00031 # include <ncurses.h> 00032 #else // HAVE_NCURSES_H 00033 # ifdef HAVE_CURSES_H 00034 # include <curses.h> 00035 # else 00036 # error "Neither curses.h nor ncurses.h available" 00037 # endif // HAVE_CURSES_H 00038 #endif // HAVE_NCURSES_H 00039 #include "curswa.h" // Leave this here. It depends on the above includes. 00040 00041 #include <file.h> 00042 #include <basewindow.h> 00043 #include <uiexception.h> 00044 #include <statusbar.h> 00045 #include <listwidget.h> 00046 00058 class MainWindow : protected YAPETUI::BaseWindow { 00059 private: 00060 WINDOW* toprightwin; 00061 WINDOW* bottomrightwin; 00062 YAPETUI::ListWidget<YAPET::PartDec>* recordlist; 00063 StatusBar statusbar; 00064 bool records_changed; 00065 00066 YAPET::Key* key; 00067 YAPET::File* file; 00068 00069 inline MainWindow(const MainWindow&) {} 00070 inline const MainWindow& operator=(const MainWindow&) { return *this;} 00071 00072 protected: 00073 void printTitle() throw (YAPETUI::UIException); 00074 00075 void topRightWinContent() throw(YAPETUI::UIException); 00076 00077 void bottomRightWinContent() throw(YAPETUI::UIException); 00078 00079 void createWindow() throw(YAPETUI::UIException); 00080 00081 void refresh() throw(YAPETUI::UIException); 00082 00083 void createFile(std::string& filename) throw(YAPETUI::UIException); 00084 void openFile(std::string filename) throw(YAPETUI::UIException); 00085 void saveFile(); 00086 void closeFile(); 00087 00088 void addNewRecord(); 00089 void editSelectedRecord(); 00090 void deleteSelectedRecord() throw(YAPETUI::UIException); 00091 bool quit(); 00092 void lockScreen() const throw(YAPETUI::UIException); 00093 void changePassword() throw(YAPETUI::UIException); 00094 public: 00095 MainWindow() throw(YAPETUI::UIException); 00096 virtual ~MainWindow(); 00097 00098 void run() throw(YAPETUI::UIException); 00099 void run(std::string fn); 00100 void resize() throw(YAPETUI::UIException); 00101 00102 #if defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H) 00103 void handle_signal(int signo); 00104 #endif // defined(HAVE_SIGACTION) && defined(HAVE_SIGNAL_H) 00105 }; 00106 00107 #endif // _MAINWINDOW_H