/
bounding_box.h
115 lines (88 loc) · 3.22 KB
/
bounding_box.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#ifndef K3DSDK_NGUI_BOUNDING_BOX_H
#define K3DSDK_NGUI_BOUNDING_BOX_H
// K-3D
// Copyright (c) 1995-2005, Timothy M. Shead
//
// Contact: tshead@k-3d.com
//
// This program 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.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** \file
\author Tim Shead (tshead@k-3d.com)
*/
#include <k3dsdk/signal_system.h>
#include <k3dsdk/bounding_box3.h>
#include <gtkmm/table.h>
#include <memory>
// Forward declarations
namespace Gtk { class Button; }
namespace k3d { class ihint; }
namespace k3d { class iproperty; }
namespace k3d { class istate_recorder; }
namespace k3d
{
namespace ngui
{
namespace bounding_box
{
/////////////////////////////////////////////////////////////////////////////
// idata_proxy
/// Abstract interface for an object that proxies a data source for a bounding_box control (i.e. the "model" in model-view-controller)
class idata_proxy
{
public:
virtual ~idata_proxy() {}
/// Called to return the underlying data value
virtual const k3d::bounding_box3 value() = 0;
/// Called to set a new data value
virtual void set_value(const k3d::bounding_box3& Value) = 0;
/// Signal emitted if the underlying data changes
typedef sigc::signal<void, k3d::ihint*> changed_signal_t;
/// Signal emitted if the underlying data changes
virtual changed_signal_t& changed_signal() = 0;
/// Stores an optional state recorder for recording undo/redo data
k3d::istate_recorder* const state_recorder;
/// Stores an optional message for labelling undo/redo state changes
const Glib::ustring change_message;
protected:
idata_proxy(k3d::istate_recorder* const StateRecorder, const Glib::ustring& ChangeMessage) :
state_recorder(StateRecorder),
change_message(ChangeMessage)
{
}
private:
idata_proxy(const idata_proxy& RHS);
idata_proxy& operator=(const idata_proxy& RHS);
};
/////////////////////////////////////////////////////////////////////////////
// control
/// Provides a UI for modifying the bounding_box of an object
class control :
public Gtk::Table
{
typedef Gtk::Table base;
public:
control(std::unique_ptr<idata_proxy> Data);
private:
/// Stores a reference to the underlying data object
std::unique_ptr<idata_proxy> m_data;
};
/////////////////////////////////////////////////////////////////////////////
// proxy
/// Convenience factory function for creating k3d::spin_button::idata_proxy objects, specialized for k3d::iproperty
std::unique_ptr<idata_proxy> proxy(k3d::iproperty& Data, k3d::istate_recorder* const StateRecorder = 0, const Glib::ustring& ChangeMessage = Glib::ustring());
} // namespace bounding_box
} // namespace ngui
} // namespace k3d
#endif // !K3DSDK_NGUI_BOUNDING_BOX_H