Antares Simulator
Power System Simulator
create.hxx
1 /*
2  * Copyright 2007-2025, RTE (https://www.rte-france.com)
3  * See AUTHORS.txt
4  * SPDX-License-Identifier: MPL-2.0
5  * This file is part of Antares-Simulator,
6  * Adequacy and Performance assessment for interconnected energy networks.
7  *
8  * Antares_Simulator is free software: you can redistribute it and/or modify
9  * it under the terms of the Mozilla Public Licence 2.0 as published by
10  * the Mozilla Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Antares_Simulator is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * Mozilla Public Licence 2.0 for more details.
17  *
18  * You should have received a copy of the Mozilla Public Licence 2.0
19  * along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20  */
21 #ifndef __ANTARES_TOOLBOX_CREATE_HXX__
22 #define __ANTARES_TOOLBOX_CREATE_HXX__
23 
24 #include <yuni/core/bind.h>
25 
26 namespace Antares::Private::Component
27 {
28 class CustomWxButton: public wxButton
29 {
30 public:
34  CustomWxButton(wxWindow* parent, const wxString& title);
35 
37  virtual ~CustomWxButton()
38  {
39  }
40 
41 public:
43  Yuni::Bind<void()> onUserClick;
44 
45 private:
46  void evtOnUserClick(wxCommandEvent&);
47 
48 }; // class CustomWxButton
49 
50 } // namespace Antares::Private::Component
51 
52 namespace Antares::Component
53 {
54 template<class T, class StringT, class UserDataT>
55 wxButton* CreateButton(wxWindow* parent,
56  const StringT& caption,
57  T* object,
58  void (T::*method)(UserDataT),
59  UserDataT userdata)
60 {
61  // type alias
63  // Title of the button
64  wxString title;
65  title << wxT(" ") << caption << wxT(" ");
66 
67  // Creation
68  auto* button = new ButtonType(parent, title);
69 
70  // Event
71  if (object)
72  {
73  using MemberType = void (T::*)(UserDataT);
74  button->onUserClick.bind(const_cast<T*>(object),
75  reinterpret_cast<MemberType>(method),
76  userdata);
77  }
78  return button;
79 }
80 
81 } // namespace Antares::Component
82 
83 #endif // __ANTARES_TOOLBOX_CREATE_HXX__
virtual ~CustomWxButton()
Destructor.
Definition: create.hxx:37
CustomWxButton(wxWindow *parent, const wxString &title)
Constructor.
Definition: create.cpp:30