48 #ifdef CHECK_MEMORY_LEAKS 50 #endif // CHECK_MEMORY_LEAKS 64 FXIMPLEMENT(
GUIDialog_GLChosenEditor, FXMainWindow, GUIDialog_GLChosenEditorMap, ARRAYNUMBER(GUIDialog_GLChosenEditorMap))
72 : FXMainWindow(parent->getApp(), "List of Selected Items", NULL, NULL, DECOR_ALL, 20, 20, 300, 300),
73 myParent(parent), myStorage(str) {
74 myStorage->add2Update(
this);
75 FXHorizontalFrame* hbox =
76 new FXHorizontalFrame(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0,
79 myList =
new FXList(hbox, 0, 0,
80 LAYOUT_FILL_X | LAYOUT_FILL_Y | LIST_MULTIPLESELECT);
83 FXVerticalFrame* layout =
new FXVerticalFrame(hbox, LAYOUT_TOP, 0, 0, 0, 0,
87 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
88 0, 0, 0, 0, 4, 4, 3, 3);
91 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
92 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);
102 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
103 0, 0, 0, 0, 4, 4, 3, 3);
108 new FXButton(layout,
"Close\t\t", 0,
this,
MID_CANCEL,
109 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
110 0, 0, 0, 0, 4, 4, 3, 3);
112 myParent->addChild(
this);
126 for (std::set<GUIGlID>::const_iterator i = chosen.begin(); i != chosen.end(); ++i) {
130 FXListItem* item =
myList->getItem(
myList->appendItem(name.c_str()));
131 item->setData(
object);
141 FXMainWindow::update();
148 FXFileDialog opendialog(
this,
"Open List of Selected Items");
150 opendialog.setSelectMode(SELECTFILE_EXISTING);
151 opendialog.setPatternList(
"*.txt\nAll files (*)");
155 if (opendialog.execute()) {
157 std::string file = opendialog.getFilename().text();
160 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", msg.c_str());
177 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
185 FXint no =
myList->getNumItems();
187 std::vector<GUIGlID> selected;
188 for (i = 0; i < no; ++i) {
189 if (
myList->getItem(i)->isSelected()) {
190 selected.push_back(static_cast<GUIGlObject*>(
myList->getItem(i)->getData())->getGlID());
194 for (i = 0; i < (FXint) selected.size(); ++i) {
FXDEFMAP(GUIDialog_GLChosenEditor) GUIDialog_GLChosenEditorMap[]
const std::string & getFullName() const
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.
const std::set< GUIGlID > & getSelected() const
Returns the set of ids of all selected objects.
#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.
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.