00001 #ifndef ENTITYCLASSCHOOSER_H_ 00002 #define ENTITYCLASSCHOOSER_H_ 00003 00004 #include <gtk/gtk.h> 00005 00006 #include "radiant_i18n.h" 00007 #include "math/Vector3.h" 00008 00009 namespace ui 00010 { 00015 class EntityClassChooser 00016 { 00017 private: 00018 00019 // Main dialog window 00020 GtkWidget* _widget; 00021 00022 // Tree model holding the classnames 00023 GtkTreeStore* _treeStore; 00024 00025 // GtkTreeSelection holding the currently-selected classname 00026 GtkTreeSelection* _selection; 00027 00028 // Usage information textview 00029 GtkWidget* _usageTextView; 00030 00031 // Add button. Needs to be a member since we enable/disable it in the 00032 // selectionchanged callback. 00033 GtkWidget* _addButton; 00034 00035 // The 3D coordinates of the point where the entity must be created. 00036 Vector3 _lastPoint; 00037 00038 private: 00039 00040 /* Widget construction helpers */ 00041 GtkWidget* createTreeView (); 00042 GtkWidget* createUsagePanel (); 00043 GtkWidget* createButtonPanel (); 00044 00045 // Update the usage panel with information from the provided entityclass 00046 void updateUsageInfo (const std::string& eclass); 00047 00048 /* GTK callbacks */ 00049 00050 static void addEntity (EntityClassChooser*); 00051 00052 // Called when close button is clicked, ensure that window is hidden 00053 // not destroyed. 00054 static void callbackHide (GtkWidget*, GdkEvent*, EntityClassChooser*); 00055 00056 // Button callbacks 00057 static void callbackCancel (GtkWidget*, EntityClassChooser*); 00058 static void callbackAdd (GtkWidget*, EntityClassChooser*); 00059 00060 // Check when the selection changes, disable the add button if there 00061 // is nothing selected. 00062 static void callbackSelectionChanged (GtkWidget*, EntityClassChooser*); 00063 00064 // Callbacks for double clicks or button presses 00065 static gint callbackKeyPress (GtkWidget* widget, GdkEventKey* event, EntityClassChooser*); 00066 static gint callbackMouseButtonPress (GtkWidget *widget, GdkEventButton *event, EntityClassChooser*); 00067 00068 public: 00069 00071 EntityClassChooser (); 00072 00078 void show (const Vector3& point); 00079 00086 static void displayInstance (const Vector3& point); 00087 }; 00088 } 00089 00090 #endif /*ENTITYCLASSCHOOSER_H_*/ 00091