62FXIMPLEMENT(
GUIDialog_ChooserAbstract, FXMainWindow, GUIDialog_ChooserAbstractMap, ARRAYNUMBER(GUIDialog_ChooserAbstractMap))
72 myWindowsParent(windowsParent),
73 myMessageId(messageId),
74 myLocateByName(false),
75 myHaveFilteredSubstring(false) {
87 if (title.text() != std::string(
TL(
"Vehicle Chooser"))) {
88 myTrackButton->disable();
89 myTrackButton->hide();
101 myCountLabel =
new FXLabel(layoutRight,
"placeholder",
nullptr, LAYOUT_BOTTOM | LAYOUT_FILL_X | JUSTIFY_LEFT);
102 myCaseSensitive =
new FXCheckButton(layoutRight,
TL(
"case-sensitive search"));
103 myCaseSensitive->setCheck(getApp()->reg().readIntEntry(
"LOCATOR",
"caseSensitive", 0) == 1);
104 myInstantCenter =
new FXCheckButton(layoutRight,
TL(
"auto-center"));
105 myInstantCenter->setCheck(getApp()->reg().readIntEntry(
"LOCATOR",
"autoCenter", 0) == 1);
108 myWindowsParent->getGUIMainWindowParent()->addChild(
this);
119 getApp()->reg().writeIntEntry(
"LOCATOR",
"autoCenter",
myInstantCenter->getCheck());
120 getApp()->reg().writeIntEntry(
"LOCATOR",
"caseSensitive",
myCaseSensitive->getCheck());
132 FXMainWindow::show();
139 int selected =
myList->getCurrentItem();
150 int selected =
myList->getCurrentItem();
194 const int numItems =
myList->getNumItems();
196 if (!caseSensitive) {
199 for (
int i = 0; i < numItems; i++) {
200 FXString t2 =
myList->getItemText(i);
201 if (!caseSensitive) {
204 if (t2.find(t) >= 0) {
210 const int caseOpt = caseSensitive ? 0 : SEARCH_IGNORECASE;
214 if (
myList->getNumItems() > 0) {
222 myList->makeItemVisible(
id);
224 myList->setCurrentItem(
id,
true);
233 int current =
myList->getCurrentItem();
234 if (current >= 0 &&
myList->isItemSelected(current)) {
244 FXEvent*
event = (FXEvent*)ptr;
245 if (event->code == KEY_Return) {
247 if ((event->state & CONTROLMASK) != 0) {
251 }
else if (event->code == KEY_Left || (event->code == KEY_Up &&
myList->getCurrentItem() == 0)) {
263 std::vector<GUIGlID> selectedGlIDs;
264 const int numItems =
myList->getNumItems();
265 for (
int i = 0; i < numItems; i++) {
267 if (
myList->getItemIcon(i) == flag) {
268 selectedGlIDs.push_back(glID);
279 std::vector<GUIGlID> selectedGlIDs;
280 const int numItems =
myList->getNumItems();
282 if (!caseSensitive) {
285 for (
int i = 0; i < numItems; i++) {
286 FXString t2 =
myList->getItemText(i);
287 if (!caseSensitive) {
290 if (t2.find(t) >= 0) {
292 selectedGlIDs.push_back(glID);
336 int i =
myList->getCurrentItem();
339 if (
myList->getItemIcon(i) == flag) {
340 myList->setItemIcon(i,
nullptr);
342 myList->setItemIcon(i, flag);
354 const int numItems =
myList->getNumItems();
355 for (
int i = 0; i < numItems; i++) {
357 myList->setItemIcon(i, flag);
367 const int numItems =
myList->getNumItems();
368 for (
int i = 0; i < numItems; i++) {
370 myList->setItemIcon(i,
nullptr);
380 std::vector<std::pair<std::string, GUIGlID> > namesAndIDs;
382 const int numItems =
myList->getNumItems();
383 for (
int i = 0; i < numItems; i++) {
389 namesAndIDs.push_back(std::make_pair(name, glID));
394 std::sort(namesAndIDs.begin(), namesAndIDs.end());
395 std::vector<GUIGlID> selectedGlIDs;
396 for (
const auto& item : namesAndIDs) {
397 selectedGlIDs.push_back(item.second);
@ MID_CHOOSER_TRACK
Track object.
@ MID_CANCEL
Cancel-button pressed.
@ MID_CHOOSER_TEXT
Text entry.
@ MID_UPDATE
Update-button pressed.
@ MID_CHOOSEN_INVERT
Deselect selected items.
@ MID_CHOOSEN_SELECT
select all items
@ MID_CHOOSER_LIST
Object list.
@ MID_CHOOSEN_NAME
Deselect selected items.
@ MID_CHOOSER_FILTER_SUBSTR
Filter list by substring.
@ MID_CHOOSEN_CLEAR
Clear set.
@ 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) frame extended in all directions
#define GUIDesignChooserDialog
FXDEFMAP(GUIDialog_ChooserAbstract) GUIDialog_ChooserAbstractMap[]
GUISelectedStorage gSelected
A global holder of selected objects.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
static FXButton * buildFXButton(FXComposite *p, const std::string &text, const std::string &tip, const std::string &help, FXIcon *ic, FXObject *tgt, FXSelector sel, FXuint opts=BUTTON_NORMAL, FXint x=0, FXint y=0, FXint w=0, FXint h=0, FXint pl=DEFAULT_PAD, FXint pr=DEFAULT_PAD, FXint pt=DEFAULT_PAD, FXint pb=DEFAULT_PAD)
build button
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.
FXCheckButton * myCaseSensitive
Whether search is case sensitive.
int myMessageId
the object type being chosen
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.
virtual void deselect(int listIndex)
unset selection (handled differently in netedit)
virtual void select(int listIndex)
set selection (handled differently in netedit)
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
FXLabel * myCountLabel
label for declaring list size
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 field.
GUIGlChildWindow * myWindowsParent
window parent
long onCmdUpdate(FXObject *, FXSelector, void *)
Callback: Update list.
std::set< GUIGlID > myIDs
myList contains (void) pointers to elements of myIDs instead of the more volatile pointers to GUIGlOb...
long onChgListSel(FXObject *, FXSelector, void *)
Callback: Current list item selection has changed.
GUIGlObject * mySelected
The chosen id.
long onCmdClearListSelection(FXObject *, FXSelector, void *)
long onCmdAddListSelection(FXObject *, FXSelector, void *)
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
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 / list.
FXCheckButton * myInstantCenter
Whether each change in the list should re-center the view.
long onChgList(FXObject *, FXSelector, void *)
Callback: Current list item has changed.
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 * getGUIMainWindowParent()
Returns the GUIMainWindow parent.
virtual std::vector< GUIGlID > getObjectIDs(int messageId) const
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.
GUIGlObject * getObjectBlocking(GUIGlID id) const
Returns the object from the container locking it.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
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)
Persists window position in the registry.
virtual void stopTrack()
stop track
virtual void startTrack(int)
star track
void toggleSelection(GUIGlID id)
Toggles selection of an object.
void select(GUIGlID id, bool update=true)
Adds the object with the given id.
void deselect(GUIGlID id)
Deselects the object with the given id.