Antares Simulator
Power System Simulator
action-panel.h
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_EXT_SOURCE_ACTION_PANEL_H__
22 #define __ANTARES_TOOLBOX_EXT_SOURCE_ACTION_PANEL_H__
23 
24 #include <action/action.h>
25 #include <wx/menu.h>
26 #include <wx/menuitem.h>
27 #include <ui/common/component/panel.h>
28 
29 namespace Antares::Private::Window
30 {
32 {
33 public:
35  using Vector = std::vector<ActionPanel*>;
36 
37  enum
38  {
40  itemHeight = 20,
41  };
42 
43  static void DrawBackgroundWithoutItems(wxWindow& obj, wxDC& dc, const wxRect& rect);
44 
45 public:
47 
48 
51  ActionPanel(wxWindow* parent,
52  ActionPanel* parentPanel,
53  const Antares::Action::Context::Ptr& context,
54  const Antares::Action::IAction::Ptr& action);
56  virtual ~ActionPanel();
58 
59  void expand();
60 
61  void collapse();
62 
63  void onDraw(wxPaintEvent&);
64 
65  void update();
66 
67  void forceUpdate();
68 
69  virtual void SetFocus();
70 
71 private:
72  void onEnter(wxMouseEvent&);
73  void onLeave(wxMouseEvent&);
74  void onMouseDown(wxMouseEvent&);
75  void onMouseDownCollapseExpand();
76  void onMouseDownBehaviorSelect(wxWindow* obj);
77  void drawArrows(wxDC& dc, const wxRect& rect);
78 
79  void prepareAll(bool force = false);
80 
81  void relayoutAllParents();
82  void computeTotalChildrenCount();
83 
84  void onBehaviorMerge(wxCommandEvent&);
85  void onBehaviorOverwrite(wxCommandEvent&);
86  void onBehaviorSkip(wxCommandEvent&);
87 
88 public:
89  ActionPanel* pParent;
90  Antares::Action::Context::Ptr pContext;
92  bool pCollapsed;
93  bool pBold;
94  wxColour pBackgroundColor;
95  wxColour pBackgroundColorLight;
96  wxColour pStateColor[Antares::Action::stMax];
97  wxColour pLineColor;
98  uint pDepthSpace;
99  wxString pText;
100  wxString pBehaviorText;
101  wxString pStateText;
102  wxString pComments;
103  bool pHasChildren;
104  bool pCanDoSomething;
105  bool phasCreatedChildren;
106  static ActionPanel* SelectedItem;
107 
108  bool pDisabled;
109  wxMenu* pPopupMenu;
110 
111  Antares::Action::State pState;
112  Antares::Action::Behavior pBehavior;
113 
114  Vector pChildren;
117 
118  // Event table
119  DECLARE_EVENT_TABLE()
120 
121 }; // class ActionPanel
122 
123 } // namespace Antares::Private::Window
124 
125 #endif // __ANTARES_TOOLBOX_EXT_SOURCE_ACTION_PANEL_H__
AncestorType::Ptr Ptr
The most suitable smart ptr for the class.
Definition: action.h:41
Panel implementation.
Definition: panel.h:34
Definition: action-panel.h:32
ActionPanel(wxWindow *parent, ActionPanel *parentPanel, const Antares::Action::Context::Ptr &context, const Antares::Action::IAction::Ptr &action)
Default constructor.
Definition: action-panel.cpp:53
uint pTotalChildrenCount
The total of all children for all sub-nodes.
Definition: action-panel.h:116
@ itemHeight
Optimal height for a single item.
Definition: action-panel.h:40
std::vector< ActionPanel * > Vector
Array.
Definition: action-panel.h:35
virtual ~ActionPanel()
Destructor.
Definition: action-panel.cpp:108