GUIDialog_GLChosenEditor Class Reference

#include <GUIDialog_GLChosenEditor.h>

Inheritance diagram for GUIDialog_GLChosenEditor:

FXMainWindow

Detailed Description

Editor for the list of chosen objects.

See also:
GUIMainWindow

GUISelectedStorage

Definition at line 54 of file GUIDialog_GLChosenEditor.h.


Public Member Functions

 GUIDialog_GLChosenEditor (GUIMainWindow *parent, GUISelectedStorage *str) throw ()
 Constructor.
void rebuildList () throw ()
 Rebuilds the entire list.
 ~GUIDialog_GLChosenEditor () throw ()
 Destructor.
FOX-callbacks
long onCmdClear (FXObject *, FXSelector, void *)
 Called when the user presses the Clear-button.
long onCmdClose (FXObject *, FXSelector, void *)
 Called when the user presses the Close-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.
long onCmdSave (FXObject *, FXSelector, void *)
 Called when the user presses the Save-button.

Protected Member Functions

 GUIDialog_GLChosenEditor ()
 FOX needs this.

Private Attributes

FXList * myList
 The list that holds the ids.
GUIMainWindowmyParent
 The parent window.
GUISelectedStoragemyStorage
 The storage.

Constructor & Destructor Documentation

GUIDialog_GLChosenEditor::GUIDialog_GLChosenEditor ( GUIMainWindow parent,
GUISelectedStorage str 
) throw ()

Constructor.

Notifies both the parent and the storage about being initialised.

Parameters:
[in] parent The parent window
[in] str The storage of object selections to use

GUIDialog_GLChosenEditor::~GUIDialog_GLChosenEditor (  )  throw ()

Destructor.

Notifies both the parent and the storage about being destroyed.

Definition at line 120 of file GUIDialog_GLChosenEditor.cpp.

References myParent, myStorage, GUISelectedStorage::remove2Update(), and GUIMainWindow::removeChild().

00120                                                             {
00121     myStorage->remove2Update(this);
00122     myParent->removeChild(this);
00123 }

GUIDialog_GLChosenEditor::GUIDialog_GLChosenEditor (  )  [inline, protected]

FOX needs this.

Definition at line 142 of file GUIDialog_GLChosenEditor.h.

00142 { }


Member Function Documentation

long GUIDialog_GLChosenEditor::onCmdClear ( FXObject ,
FXSelector  ,
void *   
)

Called when the user presses the Clear-button.

Clear the internal list and calls GUISelectedStorage::clear. Repaints itself

Definition at line 204 of file GUIDialog_GLChosenEditor.cpp.

References GUISelectedStorage::clear(), gSelected, myList, myParent, and GUIMainWindow::updateChildren().

00204                                                                {
00205     myList->clearItems();
00206     gSelected.clear();
00207     myParent->updateChildren();
00208     return 1;
00209 }

long GUIDialog_GLChosenEditor::onCmdClose ( FXObject ,
FXSelector  ,
void *   
)

Called when the user presses the Close-button.

Closes itself.

Definition at line 214 of file GUIDialog_GLChosenEditor.cpp.

00214                                                                {
00215     close(true);
00216     return 1;
00217 }

long GUIDialog_GLChosenEditor::onCmdDeselect ( FXObject ,
FXSelector  ,
void *   
)

Called when the user presses the Deselect-button.

Determines which items were chosen and calls GUISelectedStorage::deselect for each.

Definition at line 182 of file GUIDialog_GLChosenEditor.cpp.

References GUISelectedStorage::deselect(), gSelected, myList, myParent, rebuildList(), and GUIMainWindow::updateChildren().

00182                                                                   {
00183     FXint no = myList->getNumItems();
00184     FXint i;
00185     std::vector<GLuint> selected;
00186     for (i=0; i<no; ++i) {
00187         if (myList->getItem(i)->isSelected()) {
00188             selected.push_back((GLuint)(FXuval) myList->getItem(i)->getData());
00189         }
00190     }
00191     // remove items from list
00192     for (i=0; i<(FXint) selected.size(); ++i) {
00193         gSelected.deselect(-1, selected[i]);
00194     }
00195     // rebuild list
00196     rebuildList();
00197     myParent->updateChildren();
00198     return 1;
00199 }

long GUIDialog_GLChosenEditor::onCmdLoad ( FXObject ,
FXSelector  ,
void *   
)

Called when the user presses the Load-button.

Opens a file dialog and forces the parent to load the list of selected objects when a file was chosen. Rebuilds the list, then, and redraws itself.

Todo:
Recheck loading/saving of selections

Definition at line 144 of file GUIDialog_GLChosenEditor.cpp.

References gCurrentFolder, GUIIconSubSys::getIcon(), ICON_EMPTY, GUIMainWindow::loadSelection(), myParent, and rebuildList().

00144                                                               {
00145     // get the new file name
00146     FXFileDialog opendialog(this,"Open List of Selected Items");
00147     opendialog.setIcon(GUIIconSubSys::getIcon(ICON_EMPTY));
00148     opendialog.setSelectMode(SELECTFILE_EXISTING);
00149     opendialog.setPatternList("*.txt");
00150     if (gCurrentFolder.length()!=0) {
00151         opendialog.setDirectory(gCurrentFolder);
00152     }
00153     if (opendialog.execute()) {
00154         gCurrentFolder = opendialog.getDirectory();
00155         std::string file = opendialog.getFilename().text();
00156         std::string msg;
00157         if (!myParent->loadSelection(file, msg)) {
00158             FXMessageBox::error(this, MBOX_OK, "Loading failed.", msg.c_str());
00159         }
00160         rebuildList();
00161     }
00162     return 1;
00163 }

long GUIDialog_GLChosenEditor::onCmdSave ( FXObject ,
FXSelector  ,
void *   
)

Called when the user presses the Save-button.

Opens a file dialog and forces the selection container to save the list of selected objects when a file was chosen.

If the saveing failed, a message window is shown.

Todo:
Recheck loading/saving of selections

Definition at line 167 of file GUIDialog_GLChosenEditor.cpp.

References gCurrentFolder, MFXUtils::getFilename2Write(), GUIIconSubSys::getIcon(), gSelected, ICON_EMPTY, and GUISelectedStorage::save().

00167                                                               {
00168     FXString file = MFXUtils::getFilename2Write(this, "Save List of selected Items", ".txt", GUIIconSubSys::getIcon(ICON_EMPTY), gCurrentFolder);
00169     if (file=="") {
00170         return 1;
00171     }
00172     try {
00173         gSelected.save(-1, file.text());
00174     } catch (IOError &e) {
00175         FXMessageBox::error(this, MBOX_OK, "Storing failed!", e.what());
00176     }
00177     return 1;
00178 }

void GUIDialog_GLChosenEditor::rebuildList (  )  throw ()

Rebuilds the entire list.

Definition at line 127 of file GUIDialog_GLChosenEditor.cpp.

References GUIGlObject::getFullName(), GUIGlObjectStorage::getObjectBlocking(), GUISelectedStorage::getSelected(), GUIGlObjectStorage::gIDStorage, gSelected, myList, and GUIGlObjectStorage::unblockObject().

Referenced by GUISelectedStorage::clear(), GUISelectedStorage::deselect(), onCmdDeselect(), onCmdLoad(), and GUISelectedStorage::select().

00127                                               {
00128     myList->clearItems();
00129     const std::vector<GLuint> &chosen = gSelected.getSelected();
00130     for (std::vector<GLuint>::const_iterator i=chosen.begin(); i!=chosen.end(); ++i) {
00131         GUIGlObject *object = GUIGlObjectStorage::gIDStorage.getObjectBlocking(*i);
00132         if (object!=0) {
00133             std::string name = object->getFullName();
00134             FXListItem *item = myList->getItem(myList->appendItem(name.c_str()));
00135             item->setData((void*) *i);
00136             GUIGlObjectStorage::gIDStorage.unblockObject(*i);
00137         }
00138     }
00139     update();
00140 }


Field Documentation

The list that holds the ids.

Definition at line 132 of file GUIDialog_GLChosenEditor.h.

Referenced by onCmdClear(), onCmdDeselect(), and rebuildList().

The parent window.

Definition at line 135 of file GUIDialog_GLChosenEditor.h.

Referenced by onCmdClear(), onCmdDeselect(), onCmdLoad(), and ~GUIDialog_GLChosenEditor().

The storage.

Definition at line 138 of file GUIDialog_GLChosenEditor.h.

Referenced by ~GUIDialog_GLChosenEditor().


The documentation for this class was generated from the following files:

Generated on Wed May 5 00:06:42 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6