Antares Simulator
Power System Simulator
notes.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_APPLICATION_WINDOWS_NOTES_H__
22 #define __ANTARES_APPLICATION_WINDOWS_NOTES_H__
23 
24 #include <ui/common/component/panel.h>
25 #include <wx/richtext/richtextctrl.h>
26 #include <wx/richtext/richtextstyles.h>
27 
28 namespace Antares::Window
29 {
33 class Notes final: public Antares::Component::Panel, public Yuni::IEventObserver<Notes>
34 {
35 public:
36  enum IDs
37  {
38  mnIDUserNotes = wxID_HIGHEST + 1,
39  };
40 
44  static Yuni::Event<void(Notes* sender)> OnChanged;
45 
46 public:
47  // \name Constructors & Destructor
49 
52  Notes(wxWindow* parent, uint margin = 18);
54  virtual ~Notes();
56 
60  void saveToStudy();
61 
65  void loadFromStudy();
66 
70  void connectToNotification();
71 
76 
77 private:
78  void onBold(void*);
79  void onItalic(void*);
80  void onUnderline(void*);
81 
82  void onAlignLeft(void*);
83  void onAlignRight(void*);
84  void onAlignCenter(void*);
85 
86  void onListBullet(void*);
87  void onListNumbered(void*);
88 
89  void onIndentIncrease(void*);
90  void onIndentDecrease(void*);
91 
92  void appendStyles();
93 
94  void onUserNotesCharacter(wxRichTextEvent& evt);
95  void onUserNotesStyleChanged(wxRichTextEvent& evt);
96 
97  void onNotesModified(Notes* sender);
98 
99  void notifyChanges();
100 
101  void onStudyClosed();
102 
110  bool initializeTemporaryFile();
111 
112 private:
114  wxRichTextCtrl* pRichEdit;
115  wxRichTextStyleSheet* pStyleSheet;
116  uint pLocalRevision;
117  uint pUpdatesToSkip;
118 
125  YString pTempFile;
126 
127  // Event Table
128  DECLARE_EVENT_TABLE()
129 
130 }; // class Notes
131 
132 } // namespace Antares::Window
133 
134 #endif // __ANTARES_APPLICATION_WINDOWS_NOTES_H__
Panel implementation.
Definition: panel.h:34
Save As Dialog
Definition: notes.h:34
void saveToStudy()
Save the comments to the study.
Definition: notes.cpp:408
Notes(wxWindow *parent, uint margin=18)
Constructor with a parent window and a study.
Definition: notes.cpp:58
static Yuni::Event< void(Notes *sender)> OnChanged
Event triggered when the user notes are changed.
Definition: notes.h:44
virtual ~Notes()
Destructor.
Definition: notes.cpp:164
void connectToNotification()
Connect to the notification of user notes updates.
Definition: notes.cpp:433
void loadFromStudy()
Load the comments from the study.
Definition: notes.cpp:444
void disconnectFromNotification()
Disconnect from the notifications of the user notes updates.
Definition: notes.cpp:439