58 FXIMPLEMENT(
GUIDialog_ChooserAbstract, FXMainWindow, GUIDialog_ChooserAbstractMap, ARRAYNUMBER(GUIDialog_ChooserAbstractMap))
67 myWindowsParent(windowsParent),
68 myLocateByName(false),
69 myHaveFilteredSubstring(false) {
82 if (title.text() != std::string(
"Vehicle Chooser")) {
83 myTrackButton->disable();
84 myTrackButton->hide();
94 myWindowsParent->getParent()->addChild(
this);
115 FXMainWindow::show();
122 int selected =
myList->getCurrentItem();
133 int selected =
myList->getCurrentItem();
159 const int numItems =
myList->getNumItems();
161 for (
int i = 0; i < numItems; i++) {
162 if (
myList->getItemText(i).lower().find(t) >= 0) {
171 if (
myList->getNumItems() > 0) {
179 myList->makeItemVisible(
id);
181 myList->setCurrentItem(
id,
true);
190 int current =
myList->getCurrentItem();
191 if (current >= 0 &&
myList->isItemSelected(current)) {
201 FXEvent*
event = (FXEvent*)ptr;
202 switch (event->code) {
216 std::vector<GUIGlID> selectedGlIDs;
217 const int numItems =
myList->getNumItems();
218 for (
int i = 0; i < numItems; i++) {
221 selectedGlIDs.push_back(glID);
231 std::vector<GUIGlID> selectedGlIDs;
232 const int numItems =
myList->getNumItems();
234 for (
int i = 0; i < numItems; i++) {
235 if (
myList->getItemText(i).lower().find(t) >= 0) {
237 selectedGlIDs.push_back(glID);
280 int i =
myList->getCurrentItem();
284 myList->setItemIcon(i,
nullptr);
297 std::vector<std::pair<std::string, GUIGlID> > namesAndIDs;
299 const int numItems =
myList->getNumItems();
300 for (
int i = 0; i < numItems; i++) {
306 namesAndIDs.push_back(std::make_pair(name, glID));
311 std::sort(namesAndIDs.begin(), namesAndIDs.end());
312 std::vector<GUIGlID> selectedGlIDs;
313 for (
const auto& item : namesAndIDs) {
314 selectedGlIDs.push_back(item.second);
@ MID_CHOOSER_TRACK
Track object.
@ MID_CANCEL
Cancel-button pressed.
@ MID_CHOOSER_TEXT
Text entry.
@ MID_CHOOSEN_INVERT
Deselect selected items.
@ MID_CHOOSER_LIST
Object list.
@ MID_CHOOSEN_NAME
Deselect selected items.
@ MID_CHOOSER_FILTER_SUBSTR
Filter list by substring.
@ MID_CHOOSER_FILTER
Filter selected.
@ MID_CHOOSER_CENTER
Center object.
#define GUIDesignChooserTextField
design for Chooser TextField
#define GUIDesignChooserListSingle
design for Chooser List
#define GUIDesignChooserButtons
design for Chooser buttons
#define GUIDesignChooserLayoutLeft
design for Chooser Layout left
#define GUIDesignChooserLayoutRight
design for Chooser Layout right
#define GUIDesignHorizontalSeparator
#define GUIDesignChooserLayoutList
design for Chooser Layout list
#define GUIDesignAuxiliarFrame
design for auxiliar (Without borders) frames used to pack another frames extended in all directions
#define GUIDesignChooserDialog
FXDEFMAP(GUIDialog_ChooserAbstract) GUIDialog_ChooserAbstractMap[]
GUISelectedStorage gSelected
A global holder of selected objects.
bool myLocateByName
whether to locate by object name instead of id
FXButton * myCenterButton
The button that triggers centering on the select object.
long onCmdText(FXObject *, FXSelector, void *)
Callback: Selects to current item if enter is pressed.
long onCmdClose(FXObject *, FXSelector, void *)
Callback: The dialog shall be closed.
void refreshList(const std::vector< GUIGlID > &ids)
update the list with the given ids
long onCmdCenter(FXObject *, FXSelector, void *)
Callback: The selected item shall be centered within the calling view.
virtual ~GUIDialog_ChooserAbstract()
Destructor.
long onCmdFilter(FXObject *, FXSelector, void *)
Callback: Hides unselected items if pressed.
long onCmdFilterSubstr(FXObject *, FXSelector, void *)
Callback: Hides unmatched items if pressed.
void show()
sets the focus after the window is created to work-around bug in libfox
long onCmdTrack(FXObject *, FXSelector, void *)
Callback: The selected vehicle shall be tracked within the calling view.
long onCmdLocateByName(FXObject *, FXSelector, void *)
Callback: Toggle locator by name.
bool myHaveFilteredSubstring
whether the list was filter by substring
long onListKeyPress(FXObject *, FXSelector, void *)
Callback: Selects to current item if enter is pressed.
long onChgText(FXObject *, FXSelector, void *)
Callback: Something has been typed into the the field.
GUIGlChildWindow * myWindowsParent
window parent
std::set< GUIGlID > myIDs
myList contains (void) pointers to elements of myIDs instead of the more volatile pointers to GUIGlOb...
GUIGlObject * mySelected
The chosen id.
virtual void toggleSelection(int listIndex)
fox need this
FXButton * myTrackButton
The button that triggers tracking on the select vehicle.
virtual std::string getObjectName(GUIGlObject *o) const
@bbrief retrieve name for the given object
virtual void filterACs(const std::vector< GUIGlID > &GLIDs)
filter ACs (needed in NETEDIT)
FXTextField * myTextEntry
The text field.
long onCmdToggleSelection(FXObject *, FXSelector, void *)
Callback: Toggle selection status of current object.
GUIGlObject * getObject() const
Returns the chosen (selected) object.
FXList * myList
The list that holds the ids.
void setView(GUIGlID id)
Centers the view onto the given artifact.
virtual bool isSelected(GUIGlObject *o) const
true if the object is selected (may include extra logic besides calling gSelected)
GUISUMOAbstractView * getView() const
return GUISUMOAbstractView
GUIMainWindow * getParent()
Returns the main window.
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
virtual const std::string getOptionalName() const
Returns the name of the object (default "")
GUIGlObjectType getType() const
Returns the type of the object as coded in GUIGlObjectType.
GUIGlID getGlID() const
Returns the numerical id of the object.
A storage for of displayed objects via their numerical id.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
static FXIcon * getIcon(const GUIIcon which)
returns a icon previously defined in the enum GUIIcon
void removeChild(FXMainWindow *child)
removes the given child window from the list (FXMainWindow)
virtual void stopTrack()
stop track
virtual void startTrack(int)
star track
void toggleSelection(GUIGlID id)
Toggles selection of an object.
const unsigned char flag[]