00001 // -*- c++ -*- 00002 // 00003 // $Id: searchdialog.h 2360 2009-06-11 15:06:24Z rafi $ 00004 // 00005 // Copyright (C) 2008, 2009 Rafael Ostertag 00006 // 00007 // This file is part of YAPET. 00008 // 00009 // YAPET is free software: you can redistribute it and/or modify it under the 00010 // terms of the GNU General Public License as published by the Free Software 00011 // Foundation, either version 3 of the License, or (at your option) any later 00012 // version. 00013 // 00014 // YAPET is distributed in the hope that it will be useful, but WITHOUT ANY 00015 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00016 // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00017 // details. 00018 // 00019 // You should have received a copy of the GNU General Public License along with 00020 // YAPET. If not, see <http://www.gnu.org/licenses/>. 00021 // 00022 00023 #ifndef _SEARCHDIALOG_H 00024 #define _SEARCHDIALOG_H 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 #ifdef HAVE_STRING 00042 # include <string> 00043 #endif 00044 00045 #include <basewindow.h> 00046 #include <button.h> 00047 #include <inputwidget.h> 00048 00054 class SearchDialog : protected YAPETUI::BaseWindow { 00055 private: 00056 enum { 00057 HEIGHT = 6 00058 }; 00059 00060 WINDOW* window; 00061 YAPETUI::InputWidget* searchtermw; 00062 YAPETUI::Button* okbutton; 00063 YAPETUI::Button* cancelbutton; 00064 YAPETUI::secstring searchterm; 00065 00066 bool canceled; 00067 00068 inline SearchDialog(const SearchDialog&) {} 00069 inline const SearchDialog& operator=(const SearchDialog&) { 00070 return *this; } 00071 00072 inline int getWidth() const { return maxX() - 8; } 00073 inline int getHeight() const { return HEIGHT; } 00074 00075 inline int getStartX() const { return maxX()/2 - getWidth()/2; } 00076 inline int getStartY() const { return maxY()/2 - getHeight()/2; } 00077 00078 void createWindow() throw(YAPETUI::UIException); 00079 00080 public: 00081 SearchDialog() throw (YAPETUI::UIException); 00082 ~SearchDialog(); 00083 00084 void run() throw(YAPETUI::UIException); 00085 void resize() throw(YAPETUI::UIException); 00086 void refresh() throw(YAPETUI::UIException); 00087 00088 inline bool isCanceled() const { return canceled; } 00089 inline const char* getSearchTerm() const { 00090 return searchtermw->getText().c_str(); 00091 } 00092 }; 00093 00094 #endif // _SEARCHDIALOG_H