Debian Codegraph @

src/Gui/Window.h

raw
1 /***************************************************************************
2 * Copyright (c) 2004 Jürgen Riegel <[email protected]> *
3 * *
4 * This file is part of the FreeCAD CAx development system. *
5 * *
6 * This library is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Library General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU Library General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Library General Public *
17 * License along with this library; see the file COPYING.LIB. If not, *
18 * write to the Free Software Foundation, Inc., 59 Temple Place, *
19 * Suite 330, Boston, MA 02111-1307, USA *
20 * *
21 ***************************************************************************/
22
23
24 #ifndef GUI_WINDOW_H
25 #define GUI_WINDOW_H
26
27 #include <Base/Parameter.h>
28 #include <functional>
29
30 namespace Gui
31 {
32
33 /** Adapter class to the parameter of FreeCAD for all windows
34 * Retrieve the parameter group of the specific window by the windowname.
35 * @author Jürgen Riegel
36 */
37 class GuiExport WindowParameter: public ParameterGrp::ObserverType
38 {
39 public:
40 WindowParameter(const char* name);
41 ~WindowParameter() override;
42
43 void OnChange(Base::Subject<const char*>& rCaller, const char* sReason) override;
44
45 /// get the parameters
46 static ParameterGrp::handle getDefaultParameter();
47 /// return the parameter group of this window
48 ParameterGrp::handle getWindowParameter();
49
50 protected:
51 bool setGroupName(const char* name);
52 /// connect slot to ParameterManager signal
53 template<typename S, typename T>
54 void setSlotParamChanged(S slot, T* obsPtr);
55
56 private:
57 ParameterGrp::handle _handle;
58 boost::signals2::connection connParamChanged;
59 };
60
61
62 template<typename S, typename T>
63 inline void WindowParameter::setSlotParamChanged(S slot, T* obsPtr)
64 {
65 namespace bp = std::placeholders;
66 if (_handle->Manager()) {
67 connParamChanged = _handle->Manager()->signalParamChanged.connect(
68 std::bind(slot, obsPtr, bp::_1, bp::_2, bp::_3, bp::_4)
69 );
70 }
71 }
72
73 } // namespace Gui
74
75 #endif // GUI_WINDOW_H