Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _MESSAGEBOX_H
00024 #define _MESSAGEBOX_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"
00040
00041 #ifdef HAVE_STRING
00042 # include <string>
00043 #endif
00044
00045 #include "uiexception.h"
00046 #include "basewindow.h"
00047 #include "button.h"
00048
00049 namespace YAPET {
00050 namespace UI {
00060 class MessageBox : protected BaseWindow {
00061 private:
00062 enum {
00063 BASE_HEIGHT = 6,
00064 BASE_WIDTH = 4
00065 };
00066 WINDOW* window;
00067 Button* okbutton;
00068
00069 std::string title;
00070 std::string message;
00071
00072 void createWindow() throw (UIException);
00073
00074 protected:
00075 inline int getBaseHeight() const {
00076 return BASE_HEIGHT;
00077 }
00078
00079 inline int getWidth() const {
00080 return BASE_WIDTH + message.length();
00081 }
00082
00083 inline int getStartX() const {
00084 return maxX() / 2 - getWidth() / 2;
00085 }
00086
00087 inline int getStartY() const {
00088 return maxY() / 2 - BASE_HEIGHT / 2;
00089 }
00090
00091 inline int getOkButtonLength() const {
00092 if (okbutton == NULL) return -1;
00093
00094 return okbutton->getLength();
00095 }
00096
00097 public:
00098 MessageBox (std::string t, std::string m) throw (UIException);
00099 virtual ~MessageBox();
00100
00101 virtual int run() throw (UIException) ;
00102 virtual void resize() throw (UIException);
00103 virtual void refresh() throw (UIException);
00104 };
00105
00106 }
00107 }
00108 #endif // _MESSAGEBOX_H