GG
AdamDlg.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and OpenGL.
3  Copyright (C) 2003-2008 T. Zachary Laine
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public License
7  as published by the Free Software Foundation; either version 2.1
8  of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18  02111-1307 USA
19 
20  If you do not wish to comply with the terms of the LGPL please
21  contact the author as other terms are available for a fee.
22 
23  Zach Laine
24  whatwasthataddress@gmail.com */
25 
33 #ifndef _AdamDlg_h_
34 #define _AdamDlg_h_
35 
36 #include <GG/AdamGlue.h>
37 
38 #include <GG/adobe/adam.hpp>
39 #include <GG/adobe/dictionary.hpp>
40 #include <GG/adobe/dictionary.hpp>
41 #include <GG/adobe/future/widgets/headers/virtual_machine_extension.hpp>
42 
43 #include <boost/function.hpp>
44 #include <boost/filesystem/path.hpp>
45 
46 
47 namespace GG {
48 
49 class Wnd;
50 
54 {
57 
63 
67 };
68 
71 {
78  adobe::dictionary_t m_property_state;
79 
86  adobe::dictionary_t m_result_values;
87 
91  adobe::name_t m_terminating_action;
92 };
93 
103 typedef boost::function <bool (adobe::name_t, const adobe::any_regular_t&)> AdamDialogActionCallback;
104 
107 {
108 public:
145  AdamModalDialog(const std::string& sheet_definition,
146  const adobe::dictionary_t& input,
147  const adobe::dictionary_t& previous_property_state,
148  AdamDialogDisplayOption display_option,
149  GG::Wnd* dlg,
150  AdamDialogActionCallback callback,
151  boost::filesystem::path working_directory);
152 
156  bool NeedUI() const;
157 
159  template <
160  class AdamValueType,
161  class GGValueType,
162  class ControlType
163  >
164  void BindCell(ControlType& control, adobe::name_t cell);
165 
168 
171  boost::signal<void (adobe::name_t, const adobe::any_regular_t&)> DialogActionSignal;
172 
173 private:
174  void LatchCallback(adobe::name_t action, const adobe::any_regular_t& value);
175  void MonitorPropertyState(const adobe::dictionary_t& property_state);
176  void MonitorInvariants(bool valid);
177 
178  adobe::dictionary_t m_input;
179  adobe::dictionary_t m_previous_property_state;
180  AdamDialogDisplayOption m_display_option;
181  AdamDialogActionCallback m_callback;
182  boost::filesystem::path m_working_directory;
183  adobe::sheet_t m_sheet;
184  adobe::vm_lookup_t m_vm_lookup;
185  bool m_need_ui;
186  AdamDialogResult m_result;
187  adobe::dictionary_t m_contributing;
188  GG::Wnd* m_dlg;
189 
190  std::vector<boost::shared_ptr<AdamCellGlueBase> > m_cells;
191 };
192 
193 // implementations
194 
195 template <
196  class AdamValueType,
197  class GGValueType,
198  class ControlType
199 >
200 void AdamModalDialog::BindCell(ControlType& control, adobe::name_t cell)
201 {
202  m_cells.push_back(
203  boost::shared_ptr<AdamCellGlueBase>(
204  new AdamCellGlue<ControlType, AdamValueType, GGValueType>(
205  control, m_sheet, cell
206  )
207  )
208  );
209 }
210 
211 }
212 
213 #endif