59 FXIMPLEMENT(
GUIDialog_GLChosenEditor, FXMainWindow, GUIDialog_GLChosenEditorMap, ARRAYNUMBER(GUIDialog_GLChosenEditorMap))
67 : FXMainWindow(parent->getApp(), "List of Selected Items", NULL, NULL, DECOR_ALL, 20, 20, 300, 300),
68 myParent(parent), myStorage(str) {
69 myStorage->add2Update(
this);
70 FXHorizontalFrame* hbox =
71 new FXHorizontalFrame(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0,
74 myList =
new FXList(hbox, 0, 0,
75 LAYOUT_FILL_X | LAYOUT_FILL_Y | LIST_MULTIPLESELECT);
78 FXVerticalFrame* layout =
new FXVerticalFrame(hbox, LAYOUT_TOP, 0, 0, 0, 0,
82 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
83 0, 0, 0, 0, 4, 4, 3, 3);
86 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
87 0, 0, 0, 0, 4, 4, 3, 3);
93 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
94 0, 0, 0, 0, 4, 4, 3, 3);
97 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
98 0, 0, 0, 0, 4, 4, 3, 3);
103 new FXButton(layout,
"Close\t\t", 0,
this,
MID_CANCEL,
104 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
105 0, 0, 0, 0, 4, 4, 3, 3);
107 myParent->addChild(
this);
121 for (std::set<GUIGlID>::const_iterator i = chosen.begin(); i != chosen.end(); ++i) {
125 FXListItem* item =
myList->getItem(
myList->appendItem(name.c_str()));
126 item->setData(
object);
136 FXMainWindow::update();
143 FXFileDialog opendialog(
this,
"Open List of Selected Items");
145 opendialog.setSelectMode(SELECTFILE_EXISTING);
146 opendialog.setPatternList(
"*.txt\nAll files (*)");
150 if (opendialog.execute()) {
152 std::string file = opendialog.getFilename().text();
155 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", msg.c_str());
172 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
180 FXint no =
myList->getNumItems();
182 std::vector<GUIGlID> selected;
183 for (i = 0; i < no; ++i) {
184 if (
myList->getItem(i)->isSelected()) {
185 selected.push_back(static_cast<GUIGlObject*>(
myList->getItem(i)->getData())->getGlID());
189 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.