61 FXIMPLEMENT(
GUIDialog_GLObjChooser, FXMainWindow, GUIDialog_GLObjChooserMap, ARRAYNUMBER(GUIDialog_GLObjChooserMap))
70 const FXString& title,
71 const std::vector<
GUIGlID>& ids,
73 FXMainWindow(parent->getApp(), title, icon, NULL, DECOR_ALL, 20, 20, 300, 300),
75 FXHorizontalFrame* hbox =
new FXHorizontalFrame(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0, 0, 0, 0, 0);
77 FXVerticalFrame* layout1 =
new FXVerticalFrame(hbox, LAYOUT_FILL_X | LAYOUT_FILL_Y | LAYOUT_TOP, 0, 0, 0, 0, 4, 4, 4, 4);
78 myTextEntry =
new FXTextField(layout1, 0,
this,
MID_CHOOSER_TEXT, LAYOUT_FILL_X | FRAME_THICK | FRAME_SUNKEN);
79 FXVerticalFrame* style1 =
new FXVerticalFrame(layout1, LAYOUT_FILL_X | LAYOUT_FILL_Y | LAYOUT_TOP | FRAME_THICK | FRAME_SUNKEN, 0, 0, 0, 0, 0, 0, 0, 0);
80 myList =
new FXList(style1,
this,
MID_CHOOSER_LIST, LAYOUT_FILL_X | LAYOUT_FILL_Y | LIST_SINGLESELECT | FRAME_SUNKEN | FRAME_THICK);
81 for (std::vector<GUIGlID>::const_iterator i = ids.begin(); i != ids.end(); ++i) {
87 bool selected = myParent->isSelected(o);
90 myList->appendItem(name.c_str(), icon, (
void*) & (*myIDs.find(o->
getGlID())));
91 glStorage.unblockObject(*i);
94 FXVerticalFrame* layout =
new FXVerticalFrame(hbox, LAYOUT_TOP, 0, 0, 0, 0, 4, 4, 4, 4);
96 this,
MID_CHOOSER_CENTER, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
97 0, 0, 0, 0, 4, 4, 4, 4);
100 this,
MID_CHOOSER_FILTER, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
101 0, 0, 0, 0, 4, 4, 4, 4);
103 this,
MID_CHOOSEN_INVERT, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
104 0, 0, 0, 0, 4, 4, 4, 4);
107 this,
MID_CANCEL, ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
108 0, 0, 0, 0, 4, 4, 4, 4);
110 myParent->getParent()->addChild(
this);
121 FXMainWindow::show();
128 int selected =
myList->getCurrentItem();
147 if (
myList->getNumItems() > 0) {
154 myList->makeItemVisible(
id);
156 myList->setCurrentItem(
id,
true);
164 int current =
myList->getCurrentItem();
165 if (current >= 0 &&
myList->isItemSelected(current)) {
175 FXEvent*
event = (FXEvent*)ptr;
176 switch (event->code) {
190 std::vector<GUIGlID> selectedGlIDs;
191 std::vector<FXString> selectedMicrosimIDs;
192 const int numItems =
myList->getNumItems();
193 for (
int i = 0; i < numItems; i++) {
196 selectedGlIDs.push_back(glID);
197 selectedMicrosimIDs.push_back(
myList->getItemText(i));
201 const int numSelected = (
const int)selectedGlIDs.size();
202 for (
int i = 0; i < numSelected; i++) {
203 myList->appendItem(selectedMicrosimIDs[i], flag, (
void*) & (*
myIDs.find(selectedGlIDs[i])));
212 int i =
myList->getCurrentItem();
217 myList->setItemIcon(i, 0);
219 myList->setItemIcon(i, flag);
void show()
sets the focus after the window is created to work-around bug in libfox
GUISUMOAbstractView * getView() const
long onCmdFilter(FXObject *, FXSelector, void *)
Callback: Hides unselected items if pressed.
void toggleSelection(GUIGlID id)
Toggles selection of an object.
~GUIDialog_GLObjChooser()
Destructor.
long onCmdCenter(FXObject *, FXSelector, void *)
Callback: The selected item shall be centered within the calling view.
FXDEFMAP(GUIDialog_GLObjChooser) GUIDialog_GLObjChooserMap[]
long onCmdText(FXObject *, FXSelector, void *)
Callback: Selects to current item if enter is pressed.
long onCmdToggleSelection(FXObject *, FXSelector, void *)
Callback: Toggle selection status of current object.
const unsigned char flag[]
#define GUIDesignHorizontalSeparator
GUIMainWindow * getParent()
Returns the main window.
FXList * myList
The list that holds the ids.
GUIGlChildWindow * myParent
The parent window.
void removeChild(FXMDIChild *child)
removes the given child window from the list
virtual const std::string & getMicrosimID() const
Returns the id of the object as known to microsim.
A storage for of displayed objects via their numerical id.
long onCmdClose(FXObject *, FXSelector, void *)
Callback: The dialog shall be closed.
void setView(GUIGlID id)
Centers the view onto the given artifact.
GUIGlID getGlID() const
Returns the numerical id of the object.
FXButton * myCenterButton
The button that triggers centering on the select object.
std::set< GUIGlID > myIDs
myList contains (void) pointers to elements of myIDs instead of the more
long onListKeyPress(FXObject *, FXSelector, void *)
Callback: Selects to current item if enter is pressed.
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
FXTextField * myTextEntry
The text field.
long onChgText(FXObject *, FXSelector, void *)
Callback: Something has been typed into the the field.