1 // -*- mode: c++ -*- 2 // 3 // This file is part of libyacurs. 4 // Copyright (C) 2013 Rafael Ostertag 5 // 6 // This program is free software: you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License as 8 // published by the Free Software Foundation, either version 3 of the 9 // License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, but 12 // WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 // General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program. If not, see 18 // <http://www.gnu.org/licenses/>. 19 // 20 // 21 // $Id$ 22 23 #ifndef DIALOG_H 24 #define DIALOG_H 1 25 26 #include <string> 27 28 #include "button.h" 29 #include "hpack.h" 30 #include "hrule.h" 31 #include "spacer.h" 32 #include "vpack.h" 33 #include "window.h" 34 #include "yacurstypes.h" 35 36 namespace YACURS { 37 namespace INTERNAL { 38 class HotKeyEsc; 39 } 40 41 class Dialog : public Window { 42 private: 43 VPack* _vpack; 44 HPack* _hpack; 45 Button* _byes; 46 Button* _bok; 47 Spacer* _ok_spacer; 48 Button* _bcancel; 49 Button* _bno; 50 HRule* _hrule; 51 DIALOG_STATE _dstate; 52 DIALOG_TYPE _dialog_type; 53 DIALOG_SIZE _dialog_size; 54 55 std::string _title; 56 57 protected: 58 const Button* const ok_button() const; 59 60 const Button* const cancel_button() const; 61 62 const Button* const yes_button() const; 63 64 const Button* const no_button() const; 65 66 void dialog_state(DIALOG_STATE st); 67 68 /** 69 * Add a button to the button pack. 70 * 71 * @param b button to be added. 72 */ 73 void add_button(Button* b); 74 75 /** 76 * Add a spacer to the button pack. 77 * 78 * @param s spacer to add to the button pack. 79 */ 80 void add_button(Spacer* s); 81 82 virtual void button_press_handler(Event& e); 83 84 /** 85 * Called on OK button press. 86 * 87 * Will be called on OK button press. 88 * To be implemented by user if needed. 89 */ 90 virtual void on_ok_button(); 91 92 /** 93 * Called on Yes button press. 94 * 95 * Will be called on Yes button press. 96 * To be implemented by user if needed. 97 */ 98 virtual void on_yes_button(); 99 100 /** 101 * Called on Cancel button press. 102 * 103 * Will be called on Cancel button press. 104 * To be implemented by user if needed. 105 */ 106 virtual void on_cancel_button(); 107 108 /** 109 * Called on No button press. 110 * 111 * Will be called on No button press. 112 * To be implemented by user if needed. 113 */ 114 virtual void on_no_button(); 115 116 public: 117 Dialog(const std::string& title, DIALOG_TYPE dialogType = OKCANCEL, 118 DIALOG_SIZE dialogSize = AUTOMATIC); 119 // Not supported 120 Dialog(const Dialog&)=delete; 121 Dialog& operator=(const Dialog&)=delete; 122 Dialog(Dialog&&) = delete; 123 Dialog& operator=(Dialog&&) = delete; 124 virtual ~Dialog(); 125 DIALOG_STATE dialog_state() const; 126 DIALOG_TYPE dialog_type() const; 127 128 void title(const std::string& title); 129 130 std::string title() const; 131 132 /** 133 * Add widget 134 * 135 * Add widget to front of vpack. 136 * 137 * @param widgetBase widget to be added. 138 */ 139 void widget(WidgetBase* widgetBase); 140 141 // Those are from Realizable 142 void refresh(bool immediate); 143 144 // Does nothing, everything handled in parent. 145 // void resize(const Area& _a); 146 void realize(); 147 148 void unrealize(); 149 150 friend class INTERNAL::HotKeyEsc; 151 }; 152 } // namespace YACURS 153 154 #endif // DIALOG_H 155