00001 // -*- c++ -*- 00002 // 00003 // $Id: searchdialog.h 3342 2010-09-17 18:32:00Z java $ 00004 // 00005 // Copyright (C) 2008-2010 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 YAPET::UI::BaseWindow { 00055 private: 00056 enum { 00057 HEIGHT = 6 00058 }; 00059 00060 WINDOW* window; 00061 YAPET::UI::InputWidget* searchtermw; 00062 YAPET::UI::Button* okbutton; 00063 YAPET::UI::Button* cancelbutton; 00064 YAPET::UI::secstring searchterm; 00065 00066 bool canceled; 00067 00068 inline SearchDialog (const SearchDialog&) {} 00069 inline const SearchDialog& operator= (const SearchDialog&) { 00070 return *this; 00071 } 00072 00073 inline int getWidth() const { 00074 return maxX() - 8; 00075 } 00076 inline int getHeight() const { 00077 return HEIGHT; 00078 } 00079 00080 inline int getStartX() const { 00081 return maxX() / 2 - getWidth() / 2; 00082 } 00083 inline int getStartY() const { 00084 return maxY() / 2 - getHeight() / 2; 00085 } 00086 00087 void createWindow() throw (YAPET::UI::UIException); 00088 00089 public: 00090 SearchDialog() throw (YAPET::UI::UIException); 00091 ~SearchDialog(); 00092 00093 void run() throw (YAPET::UI::UIException); 00094 void resize() throw (YAPET::UI::UIException); 00095 void refresh() throw (YAPET::UI::UIException); 00096 00097 inline bool isCanceled() const { 00098 return canceled; 00099 } 00100 inline const char* getSearchTerm() const { 00101 return searchtermw->getText().c_str(); 00102 } 00103 }; 00104 00105 #endif // _SEARCHDIALOG_H
1.7.1