62FXIMPLEMENT(
GUIDialog_ChooserAbstract, FXMainWindow, GUIDialog_ChooserAbstractMap, ARRAYNUMBER(GUIDialog_ChooserAbstractMap))
70#pragma warning(disable: 4355)
73 FXIcon* icon,
const FXString& title,
const std::vector<GUIGlID>& ids,
GUIGlObjectStorage& ) :
76 myWindowsParent(windowsParent),
77 myMessageId(messageId),
78 myLocateByName(false),
79 myHaveFilteredSubstring(false) {
91 if (title.text() != std::string(
TL(
"Vehicle Chooser"))) {
105 myCountLabel =
new FXLabel(layoutRight,
"placeholder",
nullptr, LAYOUT_BOTTOM | LAYOUT_FILL_X | JUSTIFY_LEFT);
107 myCaseSensitive->setCheck(getApp()->reg().readIntEntry(
"LOCATOR",
"caseSensitive", 0) == 1);
109 myInstantCenter->setCheck(getApp()->reg().readIntEntry(
"LOCATOR",
"autoCenter", 0) == 1);
126 getApp()->reg().writeIntEntry(
"LOCATOR",
"autoCenter",
myInstantCenter->getCheck());
127 getApp()->reg().writeIntEntry(
"LOCATOR",
"caseSensitive",
myCaseSensitive->getCheck());
139 FXMainWindow::show();
146 int selected =
myList->getCurrentItem();
157 int selected =
myList->getCurrentItem();
201 const int numItems =
myList->getNumItems();
203 if (!caseSensitive) {
206 for (
int i = 0; i < numItems; i++) {
207 FXString t2 =
myList->getItemText(i);
208 if (!caseSensitive) {
211 if (t2.find(t) >= 0) {
217 const int caseOpt = caseSensitive ? 0 : SEARCH_IGNORECASE;
221 if (
myList->getNumItems() > 0) {
229 myList->makeItemVisible(
id);
231 myList->setCurrentItem(
id,
true);
240 int current =
myList->getCurrentItem();
241 if (current >= 0 &&
myList->isItemSelected(current)) {
251 FXEvent*
event = (FXEvent*)ptr;
252 if (event->code == KEY_Return) {
254 if ((event->state & CONTROLMASK) != 0) {
258 }
else if (event->code == KEY_Left || (event->code == KEY_Up &&
myList->getCurrentItem() == 0)) {
261 }
else if (event->code == KEY_Escape) {
265 return FXMainWindow::onKeyPress(o, sel, ptr);
272 std::vector<GUIGlID> selectedGlIDs;
273 const int numItems =
myList->getNumItems();
274 for (
int i = 0; i < numItems; i++) {
276 if (
myList->getItemIcon(i) == flag) {
277 selectedGlIDs.push_back(glID);
288 std::vector<GUIGlID> selectedGlIDs;
289 const int numItems =
myList->getNumItems();
291 if (!caseSensitive) {
294 for (
int i = 0; i < numItems; i++) {
295 FXString t2 =
myList->getItemText(i);
296 if (!caseSensitive) {
299 if (t2.find(t) >= 0) {
301 selectedGlIDs.push_back(glID);
345 int i =
myList->getCurrentItem();
348 if (
myList->getItemIcon(i) == flag) {
349 myList->setItemIcon(i,
nullptr);
351 myList->setItemIcon(i, flag);
363 const int numItems =
myList->getNumItems();
364 for (
int i = 0; i < numItems; i++) {
366 myList->setItemIcon(i, flag);
376 const int numItems =
myList->getNumItems();
377 for (
int i = 0; i < numItems; i++) {
379 myList->setItemIcon(i,
nullptr);
389 std::vector<std::pair<std::string, GUIGlID> > namesAndIDs;
391 const int numItems =
myList->getNumItems();
392 for (
int i = 0; i < numItems; i++) {
398 namesAndIDs.push_back(std::make_pair(name, glID));
403 std::sort(namesAndIDs.begin(), namesAndIDs.end());
404 std::vector<GUIGlID> selectedGlIDs;
405 for (
const auto& item : namesAndIDs) {
406 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.
long onKeyPress(FXObject *o, FXSelector sel, void *data)
keyboard functions
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 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
GUIDialog_ChooserAbstract(GUIGlChildWindow *windowsParent, int messageId, FXIcon *icon, const FXString &title, const std::vector< GUIGlID > &ids, GUIGlObjectStorage &glStorage)
Constructor.
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)
void addChild(FXMainWindow *child)
Adds a further child window to 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.