Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
mapnotebook.h
1/*
2** Copyright 2007-2024, 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_COMPONENT_MAPNOTEBOOK_H__
22#define __ANTARES_TOOLBOX_COMPONENT_MAPNOTEBOOK_H__
23
24#include "notebook.h"
25#include <wx/textctrl.h>
26#include <antares/logs/logs.h>
27namespace Antares
28{
29namespace Component
30{
34class MapNotebook : public Notebook, public Yuni::IEventObserver<MapNotebook>
35{
36 friend class MapTabs;
37
38public:
40
41
45 MapNotebook(wxWindow* parent, Notebook::Orientation orientation = orLeft);
47 {
48 destroyBoundEvents();
49 }
50
54 void onMapLayerChanged(const wxString* text);
55 bool remove(Page* page);
56
57public:
58 class TabTextCtrl : public wxTextCtrl
59 {
60 public:
61 TabTextCtrl(Tabs* parent, wxWindowID id, Page* pageToRename) :
62 wxTextCtrl((wxWindow*)parent,
63 id,
64 pageToRename->caption(),
65 wxPoint(pageToRename->pBoundingBox.x, pageToRename->pBoundingBox.y),
66 pageToRename->pBoundingBox.GetSize(),
67 wxTE_PROCESS_ENTER),
68 pPage(pageToRename),
69 pNotebook(&(parent->pNotebook))
70 {
71 SelectAll();
72 };
73 ~TabTextCtrl() = default;
74 void OnTextEnter(wxCommandEvent& evt);
75 void SetPage(Page* p)
76 {
77 if (p != nullptr)
78 {
79 pPage = p;
80 SetValue(pPage->caption());
81 Move(pPage->pBoundingBox.x, pPage->pBoundingBox.y);
82 SetSize(pPage->pBoundingBox.GetSize());
83 SelectAll();
84 Show();
85 }
86 else
87 Hide();
88 }
89
90 private:
91 Page* pPage;
92 Notebook* pNotebook;
93 };
94
95public:
96 class MapTabs : public Notebook::Tabs
97 {
98 friend class MapNotebook;
99
100 private:
101 class tabButton
102 {
103 public:
104 enum BtnType
105 {
106 btnLeft,
107 btnRight,
108 btnNone
109 };
110 tabButton(std::string imagePath,
111 MapTabs* parentFrame,
112 BtnType t = btnNone,
113 const char* hoverImagePath = nullptr);
114 ~tabButton();
115 void drawButton(wxDC& dc, int x, int y);
116 void onMouseUp(wxMouseEvent&);
117 void onMouseEnter();
118 void onMouseLeave();
119 void onClick(wxMouseEvent&, BtnType t);
120
121 BtnType type;
122 wxPoint coords;
123 wxBitmap* buttonImage = nullptr;
124 wxBitmap* hoverImage = nullptr;
125 wxRect* pBoundingBox = nullptr;
126 MapTabs* parentTabFrame = nullptr;
127 bool isVisible;
128 bool drawHover = false;
129 };
130
131 int sizingOffset;
132 int undrawnLeftTabs;
133 int remainingRightTabs;
134 tabButton* rightTabScroll;
135 tabButton* leftTabScroll;
136 tabButton* addPageButton;
137 TabTextCtrl* pTabNameCtrl;
138
139 public:
140 MapTabs(wxWindow* parent, Notebook& notebook);
141
142 ~MapTabs()
143 {
144 delete rightTabScroll;
145 delete leftTabScroll;
146 delete addPageButton;
147 }
148
149 void onDraw(wxPaintEvent&);
150 void drawOrientationTop(wxDC& dc);
152
153
157 void doSizing(wxDC& dc);
158
159 void drawItemTop(wxDC& dc, Page* page, int& pos, Notebook::Alignment align);
160 void onMouseUp(wxMouseEvent&);
161 void onMouseMove(wxMouseEvent&);
162 void onMouseLeave(wxMouseEvent&);
163
167 Yuni::Event<void(int&, int&)> onMouseMotion;
168
169 DECLARE_EVENT_TABLE()
170 };
171
172private:
173 wxRect closePageBoundingBox;
174
175public:
179 Yuni::Event<> onAddPage;
188 Yuni::Event<void(Page&)> onPageDelete;
189
190}; // class MapNotebook
191
192} // namespace Component
193} // namespace Antares
194#endif
Definition mapnotebook.h:97
void onMouseUp(wxMouseEvent &)
Click up.
Definition mapnotebook.cpp:440
Yuni::Event< void(int &, int &)> onMouseMotion
Event: adding a page.
Definition mapnotebook.h:167
void doSizing(wxDC &dc)
compute the offset and draw tab scrolling button if tabs don't fit in the window \
Definition mapnotebook.cpp:292
MapNotebook.
Definition mapnotebook.h:35
Yuni::Event< void(Page &)> onPageDelete
Event: Page deletion.
Definition mapnotebook.h:188
void onMapLayerChanged(const wxString *text)
remove a page by its name
Definition mapnotebook.cpp:86
Yuni::Event onAddPage
Event: adding a page.
Definition mapnotebook.h:179
MapNotebook(wxWindow *parent, Notebook::Orientation orientation=orLeft)
Default constructor.
Definition mapnotebook.cpp:49
Definition notebook.h:62
const wxString & caption() const
Get the caption of the page.
Definition notebook.hxx:38
Definition notebook.h:339
Notebook.
Definition notebook.h:38
Orientation orientation() const
Get the orientation of the notebook.
Definition notebook.hxx:113
virtual void onMouseLeave()
The mouse has leaved.
Definition panel.h:73