Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
spotlight.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_UI_COMMON_COMPONENT_SPOTLIGHT_SPOTLIGHT_H__
22#define __ANTARES_UI_COMMON_COMPONENT_SPOTLIGHT_SPOTLIGHT_H__
23
24#include <yuni/yuni.h>
25#include "../panel.h"
26#include <vector>
27#include <yuni/core/event.h>
28#include <wx/bitmap.h>
29#include <wx/textctrl.h>
30#include <wx/combobox.h>
31#include <yuni/core/color/rgb.h>
33#include <memory>
35namespace Antares
37namespace Component
38{
39class Spotlight final : public Antares::Component::Panel, public Yuni::IEventObserver<Spotlight>
41public:
43 {
44 optNone = 0,
45 optResultsInAPopup = 1,
54 };
55 enum
56 {
58 defaultFlags = optResultsInAPopup | optGroups,
59 };
61// class SearchToken
62#include "searchtoken.h"
63// class IItem / Separator
64#include "iitem.h"
65#include "separator.h"
66#include "text.h"
67// class IProvider
68#include "provider.h"
69// class NullProvider
70#include "null-provider.h"
71
72public:
76 static void FrameShow(wxWindow* parent,
78 uint flags = optGroups,
79 uint width = 340);
80
84 static void FrameClose();
85
86public:
88
89
95 Spotlight(wxWindow* parent, uint flags = defaultFlags);
97 virtual ~Spotlight();
99
101
102
105 void search(const Yuni::String& text);
106
111 void search(const wxString& text);
112
116 void redoResearch();
117
123 void resetSearchInput();
125
131 void onMapLayerChanged(const wxString* text);
133
134 void onMapLayerAdded(const wxString* text);
135
136 void onMapLayerRemoved(const wxString* text);
137
138 void onMapLayerRenamed(const wxString* text);
139
141
142
143 IProvider::Ptr provider() const;
147
149
150
151 uint itemHeight() const;
153 void itemHeight(uint h);
155
156public:
158 Yuni::Event<void(const IItem::VectorPtr&, const SearchToken::VectorPtr&)> onUpdateItems;
159
163 void updateResults();
164
165protected:
169 void convertRawTextIntoSearchTokenVector(SearchToken::Vector& out, const Yuni::String& text);
170
171 void createComponents(Spotlight* parent, bool input, bool results);
172
174 void onInputUpdated(wxCommandEvent& evt);
175
176 void onComboUpdated(wxCommandEvent& evt);
177
179 void resizeParentWindow();
180
181protected:
183 uint pFlags;
185 IProvider::Ptr pDataProvider;
191 Yuni::String pLastResearch;
193 Yuni::Event<void(IProvider::Ptr)> pResetProvider;
195 wxComboBox* pLayerFilter;
197 wxTextCtrl* pEdit;
199 wxWindow* pListbox;
202
203 // data related to frame
207 wxWindow* pLayoutParent;
209 // When the mini frame is above the parent control, it should not be resized
210 // the frame can be resized if this variable is zero
213 // keeping the sizers for some hide/show Magic depending on the number of layers
214 wxBoxSizer* vz;
215 wxBoxSizer* hzCombo;
217}; // class Spotlight
219} // namespace Component
220} // namespace Antares
221
222#include "spotlight.hxx"
223#include "iitem.hxx"
225#endif // __ANTARES_UI_COMMON_COMPONENT_SPOTLIGHT_SPOTLIGHT_H__
Panel implementation.
Definition panel.h:36
std::shared_ptr< Vector > VectorPtr
Vector Ptr.
Definition spotlight.h:35
std::shared_ptr< IProvider > Ptr
ptr
Definition spotlight.h:34
std::vector< Ptr > Vector
Vector of search tokens.
Definition spotlight.h:34
std::shared_ptr< Vector > VectorPtr
Vector ptr.
Definition spotlight.h:36
Definition spotlight.h:40
void convertRawTextIntoSearchTokenVector(SearchToken::Vector &out, const Yuni::String &text)
Convert a raw text into a vector of tokens.
Definition spotlight.cpp:290
int pDisplayHandle
Display monitor handle.
Definition spotlight.h:205
wxWindow * pLayoutParent
Parent to consider for layout positioning when used from a frame.
Definition spotlight.h:207
void updateResults()
Update the GUI with the new results.
Definition spotlight.cpp:344
void onInputUpdated(wxCommandEvent &evt)
Event: the text input has been changed.
Definition spotlight.cpp:510
static void FrameClose()
Close any opened window.
Definition spotlight.cpp:657
IItem::VectorPtr pResults
Result set.
Definition spotlight.h:187
virtual ~Spotlight()
Destructor.
Definition spotlight.cpp:67
static void FrameShow(wxWindow *parent, IProvider::Ptr provider, uint flags=optGroups, uint width=340)
Display the spotlight in a frame.
Definition spotlight.cpp:553
Options
Definition spotlight.h:43
@ optBkgWhite
Use a white background instead of the default one.
Definition spotlight.h:53
@ optGroups
Display groups as well.
Definition spotlight.h:47
@ optAutoResizeParent
Try to automatically resize the parent window when according to the list.
Definition spotlight.h:49
@ optNoSearchInput
The search input will not be shown.
Definition spotlight.h:51
wxComboBox * pLayerFilter
ComboBox Filter.
Definition spotlight.h:195
Yuni::String pLastResearch
The last research.
Definition spotlight.h:191
@ defaultFlags
Default flags used by the constructor.
Definition spotlight.h:58
uint pFlags
Flags.
Definition spotlight.h:183
uint pItemHeight
Item height.
Definition spotlight.h:201
IProvider::Ptr provider() const
Get the provider.
Definition spotlight.hxx:36
Spotlight(wxWindow *parent, uint flags=defaultFlags)
Default constructor.
Definition spotlight.cpp:53
wxTextCtrl * pEdit
Text edit.
Definition spotlight.h:197
Yuni::Event< void(const IItem::VectorPtr &, const SearchToken::VectorPtr &)> onUpdateItems
Event: update items.
Definition spotlight.h:158
void resetSearchInput()
Reset the search input.
Definition spotlight.cpp:444
uint itemHeight() const
Get the item height.
Definition spotlight.hxx:61
Yuni::Event< void(IProvider::Ptr)> pResetProvider
Internal updater for the provider.
Definition spotlight.h:193
void redoResearch()
Redo the last search.
Definition spotlight.cpp:246
bool pAllowFrameResize
Previous height.
Definition spotlight.h:211
void resizeParentWindow()
Resize the parent window.
Definition spotlight.cpp:358
void search(const Yuni::String &text)
Update the component with a given search string.
void onMapLayerChanged(const wxString *text)
set the value of the search input
Definition spotlight.cpp:488
wxWindow * pListbox
The listbox.
Definition spotlight.h:199