1 /* 2 Copyright (C) 1999-2006 Id Software, Inc. and contributors. 3 For a list of contributors, see the accompanying CONTRIBUTORS file. 4 5 This file is part of GtkRadiant. 6 7 GtkRadiant is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 GtkRadiant 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 17 You should have received a copy of the GNU General Public License 18 along with GtkRadiant; if not, write to the Free Software 19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #if !defined(INCLUDED_PREFERENCES_H) 23 #define INCLUDED_PREFERENCES_H 24 25 #include "../dialog.h" 26 #include "preferencesystem.h" 27 28 class PrefPage : public PreferencesPage 29 { 30 Dialog& m_dialog; 31 GtkWidget* m_vbox; 32 public: PrefPage(Dialog & dialog,GtkWidget * vbox)33 PrefPage (Dialog& dialog, GtkWidget* vbox) : 34 m_dialog(dialog), m_vbox(vbox) 35 { 36 } 37 /* greebo: This adds a checkbox and connects it to an XMLRegistry key. 38 * @returns: the pointer to the created GtkWidget */ appendCheckBox(const std::string & name,const std::string & flag,const std::string & registryKey)39 GtkWidget* appendCheckBox (const std::string& name, const std::string& flag, const std::string& registryKey) 40 { 41 return m_dialog.addCheckBox(m_vbox, name, flag, registryKey); 42 } 43 44 /* greebo: Appends an entry field with <name> as caption which is connected to the given registryKey 45 */ appendEntry(const std::string & name,const std::string & registryKey)46 GtkWidget* appendEntry(const std::string& name, const std::string& registryKey) { 47 return m_dialog.addEntry(m_vbox, name, registryKey); 48 } 49 appendTextureEntry(const std::string & name,const std::string & registryKey)50 GtkWidget* appendTextureEntry(const std::string& name, const std::string& registryKey) { 51 return m_dialog.addTextureEntry(m_vbox, name, registryKey); 52 } 53 54 /* greebo: greebo: This adds a horizontal slider to the internally referenced VBox and connects 55 * it to the given registryKey. */ appendSlider(const std::string & name,const std::string & registryKey,bool draw_value,double value,double lower,double upper,double step_increment,double page_increment,double page_size)56 void appendSlider (const std::string& name, const std::string& registryKey, bool draw_value, double value, 57 double lower, double upper, double step_increment, double page_increment, double page_size) 58 { 59 m_dialog.addSlider(m_vbox, name, registryKey, draw_value, value, lower, upper, step_increment, 60 page_increment, page_size); 61 } 62 63 /* greebo: Use this to add a dropdown selection box with the given list of strings as captions. The value 64 * stored in the registryKey is used to determine the currently selected combobox item */ appendCombo(const std::string & name,const std::string & registryKey,const ComboBoxValueList & valueList)65 void appendCombo(const std::string& name, const std::string& registryKey, const ComboBoxValueList& valueList) 66 { 67 m_dialog.addCombo(m_vbox, name, registryKey, valueList); 68 } 69 70 // greebo: Adds a PathEntry to choose files or directories (depending on the given boolean) appendPathEntry(const std::string & name,const std::string & registryKey,bool browseDirectories)71 GtkWidget* appendPathEntry(const std::string& name, const std::string& registryKey, bool browseDirectories) { 72 return m_dialog.addPathEntry(m_vbox, name, registryKey, browseDirectories); 73 } 74 75 /* greebo: Appends an entry field with spinner buttons which retrieves its value from the given 76 * RegistryKey. The lower and upper values have to be passed as well. 77 */ appendSpinner(const std::string & name,const std::string & registryKey,double lower,double upper,int fraction)78 GtkWidget* appendSpinner(const std::string& name, const std::string& registryKey, 79 double lower, double upper, int fraction) { 80 return m_dialog.addSpinner(m_vbox, name, registryKey, lower, upper, fraction); 81 } 82 }; 83 84 class PreferenceTreeGroup; 85 86 class PrefsDlg: public Dialog 87 { 88 typedef std::list<PreferenceConstructor*> PreferenceConstructorList; 89 // The list of all the constructors that have to be called on dialog construction 90 PreferenceConstructorList _constructors; 91 92 public: 93 94 GtkWidget *m_notebook; 95 ~PrefsDlg()96 virtual ~PrefsDlg () 97 { 98 } 99 100 /*! Utility function for swapping notebook pages for tree list selections */ 101 void showPrefPage (GtkWidget* prefpage); 102 103 // Add the given preference constructor to the internal list 104 void addConstructor(PreferenceConstructor* constructor); 105 106 protected: 107 108 /*! Dialog API */ 109 GtkWindow* BuildDialog (); 110 void PostModal (EMessageBoxReturn code); 111 112 private: 113 // greebo: calls the constructors to add the preference elements 114 void callConstructors(PreferenceTreeGroup& preferenceGroup); 115 }; 116 117 extern PrefsDlg g_Preferences; 118 119 typedef struct _GtkWindow GtkWindow; 120 void PreferencesDialog_constructWindow (GtkWindow* main_window); 121 void PreferencesDialog_destroyWindow (); 122 123 void PreferencesDialog_showDialog (); 124 125 #endif 126