60 FXIMPLEMENT(
GUIDialog_GLChosenEditor, FXMainWindow, GUIDialog_GLChosenEditorMap, ARRAYNUMBER(GUIDialog_GLChosenEditorMap))
68 : FXMainWindow(parent->getApp(), "List of Selected Items", NULL, NULL, DECOR_ALL, 20, 20, 300, 300),
69 myParent(parent), myStorage(str) {
70 myStorage->add2Update(
this);
71 FXHorizontalFrame* hbox =
72 new FXHorizontalFrame(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0,
75 myList =
new FXList(hbox, 0, 0,
76 LAYOUT_FILL_X | LAYOUT_FILL_Y | LIST_MULTIPLESELECT);
79 FXVerticalFrame* layout =
new FXVerticalFrame(hbox, LAYOUT_TOP, 0, 0, 0, 0,
83 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
84 0, 0, 0, 0, 4, 4, 3, 3);
87 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
88 0, 0, 0, 0, 4, 4, 3, 3);
94 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
95 0, 0, 0, 0, 4, 4, 3, 3);
98 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
99 0, 0, 0, 0, 4, 4, 3, 3);
104 new FXButton(layout,
"Close\t\t", 0,
this,
MID_CANCEL,
105 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
106 0, 0, 0, 0, 4, 4, 3, 3);
108 myParent->addChild(
this);
122 for (std::set<GUIGlID>::const_iterator i = chosen.begin(); i != chosen.end(); ++i) {
126 FXListItem* item =
myList->getItem(
myList->appendItem(name.c_str()));
127 item->setData(
object);
137 FXMainWindow::update();
144 FXFileDialog opendialog(
this,
"Open List of Selected Items");
146 opendialog.setSelectMode(SELECTFILE_EXISTING);
147 opendialog.setPatternList(
"*.txt\nAll files (*)");
151 if (opendialog.execute()) {
153 std::string file = opendialog.getFilename().text();
156 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", msg.c_str());
173 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
181 FXint no =
myList->getNumItems();
183 std::vector<GUIGlID> selected;
184 for (i = 0; i < no; ++i) {
185 if (
myList->getItem(i)->isSelected()) {
186 selected.push_back(static_cast<GUIGlObject*>(
myList->getItem(i)->getData())->getGlID());
190 for (i = 0; i < (FXint) selected.size(); ++i) {
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
FXDEFMAP(GUIDialog_GLChosenEditor) GUIDialog_GLChosenEditorMap[]
void remove2Update()
Removes the dialog to be updated.
Editor for the list of chosen objects.
FXString gCurrentFolder
The folder used as last.
~GUIDialog_GLChosenEditor()
Destructor.
static FXString getFilename2Write(FXWindow *parent, const FXString &header, const FXString &extension, FXIcon *icon, FXString ¤tFolder)
Returns the file name to write.
long onCmdClear(FXObject *, FXSelector, void *)
Called when the user presses the Clear-button.
#define GUIDesignHorizontalSeparator
long onCmdDeselect(FXObject *, FXSelector, void *)
Called when the user presses the Deselect-button.
long onCmdLoad(FXObject *, FXSelector, void *)
Called when the user presses the Load-button.
void rebuildList()
Rebuilds the entire list.
static GUIGlObjectStorage gIDStorage
A single static instance of this class.
std::string load(const std::string &filename, GUIGlObjectType type=GLO_MAX)
Loads a selection list (optionally with restricted type)
void removeChild(FXMDIChild *child)
removes the given child window from the list
long onCmdClose(FXObject *, FXSelector, void *)
Called when the user presses the Close-button.
Storage for "selected" objects.
void deselect(GUIGlID id)
Deselects the object with the given id.
void clear()
Clears the list of selected objects.
void unblockObject(GUIGlID id)
Marks an object as unblocked.
const std::string & getFullName() const
long onCmdSave(FXObject *, FXSelector, void *)
Called when the user presses the Save-button.
GUIGlObject * getObjectBlocking(GUIGlID id)
Returns the object from the container locking it.
GUIMainWindow * myParent
The parent window.
GUISelectedStorage gSelected
A global holder of selected objects.
static FXIcon * getIcon(GUIIcon which)
returns a icon previously defined in the enum GUIIcon
GUISelectedStorage * myStorage
The storage.
void selectionUpdated()
called when selection is updated
FXList * myList
The list that holds the ids.
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.