1 /********************************************************************** 2 * 3 * FreeDoko a Doppelkopf-Game 4 * 5 * Copyright (C) 2001 – 2018 by Diether Knof and Borg Enders 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License as 9 * published by the Free Software Foundation; either version 2 of 10 * the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * You can find this license in the file 'gpl.txt'. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 21 * MA 02111-1307 USA 22 * 23 * Contact: 24 * Diether Knof dknof@posteo.de 25 * 26 **********************************************************************/ 27 28 #ifdef USE_UI_GTKMM 29 30 #pragma once 31 32 #include "base.h" 33 #include "../../party/rule.h" 34 35 #include "widgets/sticky_dialog.h" 36 #include "widgets/file_chooser_dialog_wrapper.h" 37 #include <gtkmm/notebook.h> 38 namespace Gtk { 39 class Label; 40 class Button; 41 class RadioButton; 42 class CheckButton; 43 class LabelSpinButton; 44 class Box; 45 class Notebook; 46 class Image; 47 } // namespace Gtk 48 49 class Rule; 50 51 namespace UI_GTKMM_NS { 52 53 /** 54 ** the rules dialog 55 ** 56 ** @todo use a treeview 57 **/ 58 class Rules : public Base, public Gtk::StickyDialog { 59 public: 60 explicit Rules(Base* parent); 61 ~Rules() override; 62 63 Rules() = delete; 64 Rules(Rules const&) = delete; 65 Rules& operator=(Rules const&) = delete; 66 67 // create a backup 68 void create_backup(); 69 // the backup 70 Rule const& backup() const; 71 72 // reset the rules 73 void reset(); 74 // create a menu with the rules to load from 75 void load(); 76 // load rules 77 void load_file(string filename); 78 // save rules 79 bool save(string filename); 80 81 // update the sensitivity 82 void sensitivity_update(); 83 // update a rule 84 void update(int type, bool update_sensitivity = true); 85 // a rule has been changed 86 void changed(int type); 87 88 // update all 89 void update_all(); 90 91 private: 92 // initialize the window 93 void init(); 94 95 // adjust the announcement times to the game with nines 96 void adjust_to_with_nines(); 97 // adjust the announcement times to the game without nines 98 void adjust_to_without_nines(); 99 100 Gtk::Box* add_group(string const& name, Gtk::Image* image = nullptr); 101 102 // a key was pressed 103 bool on_key_press_event(GdkEventKey* key) override; 104 105 // update the announcement text (because of knocking) 106 void update_announcement_text(); 107 108 public: 109 vector<Gtk::CheckButton*> type_bool; 110 vector<Gtk::LabelSpinButton*> type_unsigned; 111 std::map<Counting, Gtk::RadioButton*> counting; 112 113 private: 114 Gtk::Button* reset_button = nullptr; 115 116 Gtk::Button* load_button = nullptr; 117 Gtk::Button* save_button = nullptr; 118 unique_ptr<Gtk::FileChooserDialogWrapper> save_file_chooser; 119 120 Gtk::Notebook* group_notebook = nullptr; 121 122 private: 123 AutoDisconnector disconnector_; 124 125 std::unique_ptr<Rule> backup_; 126 // whether the info dialog changes for the rule 'with nines' <-> 'without nines' was shown 127 bool without_nines_info_shown = false; 128 }; // class Rules : public Base, public Gtk::StickyDialog 129 130 } // namespace UI_GTKMM_NS 131 132 #endif // #ifdef USE_UI_GTKMM 133