61FXIMPLEMENT(
GUIDialog_ChooserAbstract, FXMainWindow, GUIDialog_ChooserAbstractMap, ARRAYNUMBER(GUIDialog_ChooserAbstractMap))
70 myWindowsParent(windowsParent),
71 myMessageId(messageId),
72 myLocateByName(false),
73 myHaveFilteredSubstring(false) {
85 if (title.text() != std::string(
"Vehicle Chooser")) {
86 myTrackButton->disable();
87 myTrackButton->hide();
99 myCountLabel =
new FXLabel(layoutRight,
"placeholder",
nullptr, LAYOUT_BOTTOM | LAYOUT_FILL_X | JUSTIFY_LEFT);
100 myCaseSensitive =
new FXCheckButton(layoutRight,
TL(
"case-sensitive search"));
101 myCaseSensitive->setCheck(getApp()->reg().readIntEntry(
"LOCATOR",
"caseSensitive", 0) == 1);
102 myInstantCenter =
new FXCheckButton(layoutRight,
TL(
"auto-center"));
103 myInstantCenter->setCheck(getApp()->reg().readIntEntry(
"LOCATOR",
"autoCenter", 0) == 1);
106 myWindowsParent->getParent()->addChild(
this);
111 getApp()->reg().writeIntEntry(
"TL_TRACKER",
"x", getX());
118 getApp()->reg().writeIntEntry(
"LOCATOR",
"autoCenter",
myInstantCenter->getCheck());
119 getApp()->reg().writeIntEntry(
"LOCATOR",
"caseSensitive",
myCaseSensitive->getCheck());
131 FXMainWindow::show();
138 int selected =
myList->getCurrentItem();
149 int selected =
myList->getCurrentItem();
193 const int numItems =
myList->getNumItems();
195 if (!caseSensitive) {
198 for (
int i = 0; i < numItems; i++) {
199 FXString t2 =
myList->getItemText(i);
200 if (!caseSensitive) {
203 if (t2.find(t) >= 0) {
209 const int caseOpt = caseSensitive ? 0 : SEARCH_IGNORECASE;
213 if (
myList->getNumItems() > 0) {
221 myList->makeItemVisible(
id);
223 myList->setCurrentItem(
id,
true);
232 int current =
myList->getCurrentItem();
233 if (current >= 0 &&
myList->isItemSelected(current)) {
243 FXEvent*
event = (FXEvent*)ptr;
244 if (event->code == KEY_Return) {
246 if ((event->state & CONTROLMASK) != 0) {
250 }
else if (event->code == KEY_Left || (event->code == KEY_Up &&
myList->getCurrentItem() == 0)) {
262 std::vector<GUIGlID> selectedGlIDs;
263 const int numItems =
myList->getNumItems();
264 for (
int i = 0; i < numItems; i++) {
267 selectedGlIDs.push_back(glID);
278 std::vector<GUIGlID> selectedGlIDs;
279 const int numItems =
myList->getNumItems();
281 if (!caseSensitive) {
284 for (
int i = 0; i < numItems; i++) {
285 FXString t2 =
myList->getItemText(i);
286 if (!caseSensitive) {
289 if (t2.find(t) >= 0) {
291 selectedGlIDs.push_back(glID);
335 int i =
myList->getCurrentItem();
339 myList->setItemIcon(i,
nullptr);
353 const int numItems =
myList->getNumItems();
354 for (
int i = 0; i < numItems; i++) {
366 const int numItems =
myList->getNumItems();
367 for (
int i = 0; i < numItems; i++) {
369 myList->setItemIcon(i,
nullptr);
379 std::vector<std::pair<std::string, GUIGlID> > namesAndIDs;
381 const int numItems =
myList->getNumItems();
382 for (
int i = 0; i < numItems; i++) {
388 namesAndIDs.push_back(std::make_pair(name, glID));
393 std::sort(namesAndIDs.begin(), namesAndIDs.end());
394 std::vector<GUIGlID> selectedGlIDs;
395 for (
const auto& item : namesAndIDs) {
396 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) 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.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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 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
@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 / 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
virtual std::vector< GUIGlID > getObjectIDs(int messageId) const
GUIMainWindow * getParent()
Returns the main window.
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)
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.
const unsigned char flag[]