47 #ifdef CHECK_MEMORY_LEAKS 49 #endif // CHECK_MEMORY_LEAKS 63 FXIMPLEMENT(
GUIDialog_GLChosenEditor, FXMainWindow, GUIDialog_GLChosenEditorMap, ARRAYNUMBER(GUIDialog_GLChosenEditorMap))
71 : FXMainWindow(parent->getApp(), "List of Selected Items", NULL, NULL, DECOR_ALL, 20, 20, 300, 300),
72 myParent(parent), myStorage(str) {
73 myStorage->add2Update(
this);
74 FXHorizontalFrame* hbox =
75 new FXHorizontalFrame(
this, LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0,
78 myList =
new FXList(hbox, 0, 0,
79 LAYOUT_FILL_X | LAYOUT_FILL_Y | LIST_MULTIPLESELECT);
82 FXVerticalFrame* layout =
new FXVerticalFrame(hbox, LAYOUT_TOP, 0, 0, 0, 0,
86 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
87 0, 0, 0, 0, 4, 4, 3, 3);
90 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
91 0, 0, 0, 0, 4, 4, 3, 3);
93 new FXHorizontalSeparator(layout, SEPARATOR_GROOVE | LAYOUT_FILL_X);
97 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
98 0, 0, 0, 0, 4, 4, 3, 3);
101 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
102 0, 0, 0, 0, 4, 4, 3, 3);
104 new FXHorizontalSeparator(layout, SEPARATOR_GROOVE | LAYOUT_FILL_X);
107 new FXButton(layout,
"Close\t\t", 0,
this,
MID_CANCEL,
108 ICON_BEFORE_TEXT | LAYOUT_FILL_X | FRAME_THICK | FRAME_RAISED,
109 0, 0, 0, 0, 4, 4, 3, 3);
111 myParent->addChild(
this);
125 for (std::set<GUIGlID>::const_iterator i = chosen.begin(); i != chosen.end(); ++i) {
129 FXListItem* item =
myList->getItem(
myList->appendItem(name.c_str()));
130 item->setData(
object);
140 FXMainWindow::update();
147 FXFileDialog opendialog(
this,
"Open List of Selected Items");
149 opendialog.setSelectMode(SELECTFILE_EXISTING);
150 opendialog.setPatternList(
"*.txt\nAll files (*)");
154 if (opendialog.execute()) {
156 std::string file = opendialog.getFilename().text();
159 FXMessageBox::error(
this, MBOX_OK,
"Errors while loading Selection",
"%s", msg.c_str());
176 FXMessageBox::error(
this, MBOX_OK,
"Storing failed!",
"%s", e.what());
184 FXint no =
myList->getNumItems();
186 std::vector<GUIGlID> selected;
187 for (i = 0; i < no; ++i) {
188 if (
myList->getItem(i)->isSelected()) {
189 selected.push_back(static_cast<GUIGlObject*>(
myList->getItem(i)->getData())->getGlID());
193 for (i = 0; i < (FXint) selected.size(); ++i) {
const std::set< GUIGlID > & getSelected() const
Returns the list 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.
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.
FXList * myList
The list that holds the ids.
void save(GUIGlObjectType type, const std::string &filename)
Saves a selection list.