/*
-Copyright (C) 1999-2006 Id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
-This file is part of GtkRadiant.
+ This file is part of GtkRadiant.
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ GtkRadiant is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ GtkRadiant is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-*/
+ You should have received a copy of the GNU General Public License
+ along with GtkRadiant; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
-#if !defined(INCLUDED_DIALOG_H)
+#if !defined( INCLUDED_DIALOG_H )
#define INCLUDED_DIALOG_H
#include <list>
+#include <uilib/uilib.h>
+#include "property.h"
+#include "generic/callback.h"
#include "gtkutil/dialog.h"
#include "generic/callback.h"
#include "string/string.h"
-template<typename Environment, typename FirstArgument, void(*func)(Environment&, FirstArgument)>
-class ReferenceCaller1;
-
-inline void BoolImport(bool& self, bool value)
+struct DLG_DATA
{
- self = value;
-}
-typedef ReferenceCaller1<bool, bool, BoolImport> BoolImportCaller;
+ virtual ~DLG_DATA() = default;
+ virtual void release() = 0;
+ virtual void importData() const = 0;
+ virtual void exportData() const = 0;
+};
-inline void BoolExport(bool& self, const BoolImportCallback& importCallback)
-{
- importCallback(self);
-}
-typedef ReferenceCaller1<bool, const BoolImportCallback&, BoolExport> BoolExportCaller;
+template<typename FirstArgument>
+class CallbackDialogData;
-inline void IntImport(int& self, int value)
-{
- self = value;
-}
-typedef ReferenceCaller1<int, int, IntImport> IntImportCaller;
+typedef std::list<DLG_DATA*> DialogDataList;
-inline void IntExport(int& self, const IntImportCallback& importCallback)
-{
- importCallback(self);
-}
-typedef ReferenceCaller1<int, const IntImportCallback&, IntExport> IntExportCaller;
+class Dialog {
+ ui::Window m_window;
+ DialogDataList m_data;
+public:
+ ModalDialog m_modal;
+ ui::Window m_parent;
+ Dialog();
-inline void SizeImport(std::size_t& self, std::size_t value)
-{
- self = value;
-}
-typedef ReferenceCaller1<std::size_t, std::size_t, SizeImport> SizeImportCaller;
+ virtual ~Dialog();
-inline void SizeExport(std::size_t& self, const SizeImportCallback& importCallback)
-{
- importCallback(self);
-}
-typedef ReferenceCaller1<std::size_t, const SizeImportCallback&, SizeExport> SizeExportCaller;
+/*!
+ start modal dialog box
+ you need to use AddModalButton to select eIDOK eIDCANCEL buttons
+ */
+ EMessageBoxReturn DoModal();
+ void EndModal(EMessageBoxReturn code);
-inline void FloatImport(float& self, float value)
-{
- self = value;
-}
-typedef ReferenceCaller1<float, float, FloatImport> FloatImportCaller;
+ virtual ui::Window BuildDialog() = 0;
-inline void FloatExport(float& self, const FloatImportCallback& importCallback)
-{
- importCallback(self);
-}
-typedef ReferenceCaller1<float, const FloatImportCallback&, FloatExport> FloatExportCaller;
+ virtual void exportData();
+ virtual void importData();
-inline void StringImport(CopiedString& self, const char* value)
-{
- self = value;
-}
-typedef ReferenceCaller1<CopiedString, const char*, StringImport> StringImportCaller;
-inline void StringExport(CopiedString& self, const StringImportCallback& importCallback)
-{
- importCallback(self.c_str());
-}
-typedef ReferenceCaller1<CopiedString, const StringImportCallback&, StringExport> StringExportCaller;
+ virtual void PreModal() {};
+ virtual void PostModal(EMessageBoxReturn code) {};
-struct DLG_DATA
-{
- virtual void release() = 0;
- virtual void importData() const = 0;
- virtual void exportData() const = 0;
-};
+ virtual void ShowDlg();
-typedef struct _GtkWindow GtkWindow;
-typedef struct _GtkToggleButton GtkToggleButton;
-typedef struct _GtkRadioButton GtkRadioButton;
-typedef struct _GtkSpinButton GtkSpinButton;
-typedef struct _GtkComboBox GtkComboBox;
-typedef struct _GtkEntry GtkEntry;
-typedef struct _GtkAdjustment GtkAdjustment;
+ virtual void HideDlg();
-template<typename FirstArgument>
-class CallbackDialogData;
+ void Create();
-typedef std::list<DLG_DATA*> DialogDataList;
+ void Destroy();
-class Dialog
-{
- GtkWindow* m_window;
- DialogDataList m_data;
-public:
- ModalDialog m_modal;
- GtkWindow* m_parent;
-
- Dialog();
- virtual ~Dialog();
-
- /*!
- start modal dialog box
- you need to use AddModalButton to select eIDOK eIDCANCEL buttons
- */
- EMessageBoxReturn DoModal();
- void EndModal (EMessageBoxReturn code);
- virtual GtkWindow* BuildDialog() = 0;
- virtual void exportData();
- virtual void importData();
- virtual void PreModal() { };
- virtual void PostModal (EMessageBoxReturn code) { };
- virtual void ShowDlg();
- virtual void HideDlg();
- void Create();
- void Destroy();
- GtkWindow* GetWidget()
- {
- return m_window;
- }
- const GtkWindow* GetWidget() const
- {
- return m_window;
- }
-
- GtkWidget* addCheckBox(GtkWidget* vbox, const char* name, const char* flag, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback);
- GtkWidget* addCheckBox(GtkWidget* vbox, const char* name, const char* flag, bool& data);
- void addCombo(GtkWidget* vbox, const char* name, StringArrayRange values, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void addCombo(GtkWidget* vbox, const char* name, int& data, StringArrayRange values);
- void addSlider(GtkWidget* vbox, const char* name, int& data, gboolean draw_value, const char* low, const char* high, double value, double lower, double upper, double step_increment, double page_increment, double page_size);
- void addRadio(GtkWidget* vbox, const char* name, StringArrayRange names, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void addRadio(GtkWidget* vbox, const char* name, int& data, StringArrayRange names);
- void addRadioIcons(GtkWidget* vbox, const char* name, StringArrayRange icons, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void addRadioIcons(GtkWidget* vbox, const char* name, int& data, StringArrayRange icons);
- GtkWidget* addEntry(GtkWidget* vbox, const char* name, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- GtkWidget* addEntry(GtkWidget* vbox, const char* name, int& data)
- {
- return addEntry(vbox, name, IntImportCaller(data), IntExportCaller(data));
- }
- GtkWidget* addEntry(GtkWidget* vbox, const char* name, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback);
- GtkWidget* addEntry(GtkWidget* vbox, const char* name, std::size_t& data)
- {
- return addEntry(vbox, name, SizeImportCaller(data), SizeExportCaller(data));
- }
- GtkWidget* addEntry(GtkWidget* vbox, const char* name, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
- GtkWidget* addEntry(GtkWidget* vbox, const char* name, float& data)
- {
- return addEntry(vbox, name, FloatImportCaller(data), FloatExportCaller(data));
- }
- GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, bool browse_directory, const StringImportCallback& importCallback, const StringExportCallback& exportCallback);
- GtkWidget* addPathEntry(GtkWidget* vbox, const char* name, CopiedString& data, bool directory);
- GtkWidget* addSpinner(GtkWidget* vbox, const char* name, int& data, double value, double lower, double upper);
- GtkWidget* addSpinner(GtkWidget* vbox, const char* name, double value, double lower, double upper, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- GtkWidget* addSpinner(GtkWidget* vbox, const char* name, double value, double lower, double upper, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
+ ui::Window GetWidget() {
+ return m_window;
+ }
+
+ const ui::Window GetWidget() const {
+ return m_window;
+ }
+
+ ui::VBox addSpacer(ui::VBox vbox, int size);
+
+ ui::Label addLabel(ui::VBox vbox, const char *name, const char *text);
+
+ ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, Property<bool> const &cb);
+
+ ui::CheckButton addCheckBox(ui::VBox vbox, const char *name, const char *flag, bool &data);
+
+ void addCombo(ui::VBox vbox, const char *name, StringArrayRange values, Property<int> const &cb);
+
+ void addCombo(ui::VBox vbox, const char *name, int &data, StringArrayRange values);
+
+ void addSlider(ui::VBox vbox, const char *name, int &data, gboolean draw_value, const char *low, const char *high,
+ double value, double lower, double upper, double step_increment, double page_increment);
+
+ void addRadio(ui::VBox vbox, const char *name, StringArrayRange names, Property<int> const &cb);
+
+ void addRadio(ui::VBox vbox, const char *name, int &data, StringArrayRange names);
+
+ void addRadioIcons(ui::VBox vbox, const char *name, StringArrayRange icons, Property<int> const &cb);
+
+ void addRadioIcons(ui::VBox vbox, const char *name, int &data, StringArrayRange icons);
+
+ ui::Widget addIntEntry(ui::VBox vbox, const char *name, Property<int> const &cb);
+
+ ui::Widget addEntry(ui::VBox vbox, const char *name, int &data) {
+ return addIntEntry(vbox, name, make_property(data));
+ }
+
+ ui::Widget addSizeEntry(ui::VBox vbox, const char *name, Property<std::size_t> const &cb);
+
+ ui::Widget addEntry(ui::VBox vbox, const char *name, std::size_t &data) {
+ return addSizeEntry(vbox, name, make_property(data));
+ }
+
+ ui::Widget addFloatEntry(ui::VBox vbox, const char *name, Property<float> const &cb);
+
+ ui::Widget addEntry(ui::VBox vbox, const char *name, float &data) {
+ return addFloatEntry(vbox, name, make_property(data));
+ }
+
+ ui::Widget addPathEntry(ui::VBox vbox, const char *name, bool browse_directory, Property<const char *> const &cb);
+
+ ui::Widget addPathEntry(ui::VBox vbox, const char *name, CopiedString &data, bool directory);
+
+ ui::SpinButton addSpinner(ui::VBox vbox, const char *name, int &data, double value, double lower, double upper);
+
+ ui::SpinButton
+ addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<int> const &cb);
+
+ ui::SpinButton
+ addSpinner(ui::VBox vbox, const char *name, double value, double lower, double upper, Property<float> const &cb);
protected:
- void AddBoolToggleData(GtkToggleButton& object, const BoolImportCallback& importCallback, const BoolExportCallback& exportCallback);
- void AddIntRadioData(GtkRadioButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void AddTextEntryData(GtkEntry& object, const StringImportCallback& importCallback, const StringExportCallback& exportCallback);
- void AddIntEntryData(GtkEntry& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void AddSizeEntryData(GtkEntry& object, const SizeImportCallback& importCallback, const SizeExportCallback& exportCallback);
- void AddFloatEntryData(GtkEntry& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
- void AddFloatSpinnerData(GtkSpinButton& object, const FloatImportCallback& importCallback, const FloatExportCallback& exportCallback);
- void AddIntSpinnerData(GtkSpinButton& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void AddIntAdjustmentData(GtkAdjustment& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
- void AddIntComboData(GtkComboBox& object, const IntImportCallback& importCallback, const IntExportCallback& exportCallback);
-
- void AddDialogData(GtkToggleButton& object, bool& data);
- void AddDialogData(GtkRadioButton& object, int& data);
- void AddDialogData(GtkEntry& object, CopiedString& data);
- void AddDialogData(GtkEntry& object, int& data);
- void AddDialogData(GtkEntry& object, std::size_t& data);
- void AddDialogData(GtkEntry& object, float& data);
- void AddDialogData(GtkSpinButton& object, float& data);
- void AddDialogData(GtkSpinButton& object, int& data);
- void AddDialogData(GtkAdjustment& object, int& data);
- void AddDialogData(GtkComboBox& object, int& data);
+ void AddBoolToggleData(ui::ToggleButton object, Property<bool> const &cb);
+
+ void AddIntRadioData(ui::RadioButton object, Property<int> const &cb);
+
+ void AddTextEntryData(ui::Entry object, Property<const char *> const &cb);
+
+ void AddIntEntryData(ui::Entry object, Property<int> const &cb);
+
+ void AddSizeEntryData(ui::Entry object, Property<std::size_t> const &cb);
+
+ void AddFloatEntryData(ui::Entry object, Property<float> const &cb);
+
+ void AddFloatSpinnerData(ui::SpinButton object, Property<float> const &cb);
+
+ void AddIntSpinnerData(ui::SpinButton object, Property<int> const &cb);
+
+ void AddIntAdjustmentData(ui::Adjustment object, Property<int> const &cb);
+
+ void AddIntComboData(ui::ComboBox object, Property<int> const &cb);
+
+ void AddDialogData(ui::ToggleButton object, bool &data);
+
+ void AddDialogData(ui::RadioButton object, int &data);
+
+ void AddDialogData(ui::Entry object, CopiedString &data);
+
+ void AddDialogData(ui::Entry object, int &data);
+
+ void AddDialogData(ui::Entry object, std::size_t &data);
+
+ void AddDialogData(ui::Entry object, float &data);
+
+ void AddDialogData(ui::SpinButton object, float &data);
+
+ void AddDialogData(ui::SpinButton object, int &data);
+
+ void AddDialogData(ui::Adjustment object, int &data);
+
+ void AddDialogData(ui::ComboBox object, int &data);
};
#endif