Antares Simulator
Power System Simulator
gui.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_ACTION_GUI_HXX__
22 #define __ANTARES_TOOLBOX_ACTION_GUI_HXX__
23 
24 class wxDialog;
25 
26 namespace Antares::Private::Dispatcher
27 {
28 void FormShowModal(wxDialog* window);
29 
30 template<class FormT, class ParentT>
31 class JobShowForm: public Yuni::Job::IJob
32 {
33 public:
34  explicit JobShowForm(ParentT* parent):
35  pParent(parent)
36  {
37  }
38 
39  virtual ~JobShowForm()
40  {
41  }
42 
43 protected:
44  virtual void onExecute()
45  {
46  // An event will be triggered to avoid flickering
47  Antares::Dispatcher::GUI::ShowModal(new FormT(pParent));
48  }
49 
50 private:
51  ParentT* pParent;
52 };
53 
54 } // namespace Antares::Private::Dispatcher
55 
56 namespace Antares::Dispatcher::GUI
57 {
58 template<class FormT, class ParentT>
59 void CreateAndShowModal(ParentT* parent)
60 {
61  ::Antares::Dispatcher::GUI::Post(
62  (const Yuni::Job::IJob::Ptr&)new ::Antares::Private::Dispatcher::JobShowForm<FormT, ParentT>(
63  parent),
64  70);
65 }
66 
67 } // namespace Antares::Dispatcher::GUI
68 
69 #endif // __ANTARES_TOOLBOX_ACTION_GUI_HXX__