Changeset 3156 in orxonox.OLD for orxonox/trunk
- Timestamp:
- Dec 11, 2004, 10:45:18 PM (20 years ago)
- Location:
- orxonox/trunk/gui
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/gui/orxonox_gui.h
r3147 r3156 1 1 /*! 2 2 \file orxonox_gui.h 3 \brief C ontains all Widgets and the Creation of the Gui3 \brief Creation of the Gui 4 4 */ 5 5 -
orxonox/trunk/gui/orxonox_gui_gtk.cc
r3154 r3156 102 102 \brief Connect any signal to any given Sub-widget 103 103 */ 104 voidWidget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *))105 { 106 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL);104 gulong Widget::connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 105 { 106 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), NULL); 107 107 } 108 108 … … 110 110 \brief Connect a signal with additionally passing the whole Object 111 111 */ 112 voidWidget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *))113 { 114 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this);112 gulong Widget::connectSignal (char* event, gint (*signal)( GtkWidget*, Widget *)) 113 { 114 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), this); 115 115 } 116 116 … … 118 118 \brief Connect a signal with additionally passing a whole external Object 119 119 */ 120 voidWidget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *))121 { 122 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj);120 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)) 121 { 122 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 123 123 } 124 124 … … 126 126 \brief Connect a signal with additionally passing a whole external Object 127 127 */ 128 void Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)) 129 { 130 g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 128 gulong Widget::connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)) 129 { 130 return g_signal_connect (G_OBJECT (this->widget), event, G_CALLBACK (signal), extObj); 131 } 132 133 void Widget::disconnectSignal (gulong signalID) 134 { 135 g_signal_handler_disconnect (G_OBJECT (this->widget), signalID); 131 136 } 132 137 … … 374 379 { 375 380 static_cast<Window*>(window)->close(); 376 377 } 381 } 382 378 383 /** 379 384 * Quits the orxonox_GUI. … … 852 857 \brief Redraws the widget 853 858 Example: see void CheckButton::redraw () 854 859 */ 855 860 void Menu::redraw () 856 861 { 857 862 gtk_option_menu_set_history (GTK_OPTION_MENU (widget), value); 863 } 864 865 OptionLabel::OptionLabel(char* text) 866 { 867 init(); 868 setTitle(text); 869 } 870 871 void OptionLabel::init(void) 872 { 873 isOption = 4; 874 875 static_cast<Option*>(this)->init(); 876 877 widget = gtk_label_new (""); 878 } 879 880 void OptionLabel::setTitle(char* title) 881 { 882 gtk_label_set_text (GTK_LABEL (widget), title); 883 } 884 885 void OptionLabel::redraw(void) 886 { 887 858 888 } 859 889 … … 862 892 You migth consider adding Label::setTitle with this. 863 893 */ 864 Label:: 894 Label::Label () 865 895 { 866 896 this->init(); -
orxonox/trunk/gui/orxonox_gui_gtk.h
r3153 r3156 1 /*! 2 \file orxonox_gui_gtk.h 3 \brief Contains all th different Widgets. 4 */ 1 5 2 6 #ifndef _ORXONOX_GUI_GTK_H … … 34 38 enum option { containerType = -2, boxType = -1, nothingType = 0, boolType = 1, intType = 2}; 35 39 char* label; //!< The name of the Widget. Some do display it, Options need it to save; 36 void connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 37 void connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); 38 void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 39 void connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)); 40 gulong connectSignal (char* event, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 41 gulong connectSignal (char* event, gint (*signal)(GtkWidget*, Widget *)); 42 gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEvent*, void *)); 43 gulong connectSignal (char* event, void* extObj, gint (*signal)(GtkWidget*, GdkEventKey*, void *)); 44 void disconnectSignal (gulong signalID); 40 45 void show (); 41 46 void hide (); … … 178 183 char* flag_name_short; //!< like flag_name but shorter 179 184 int default_value; //!< A default value is good, for hiding a option if it is not needed. (hidden if value == default_value) 180 bool saveable; 185 bool saveable; //! Options can be Saved. 181 186 182 187 void setFlagName (char* flagname, int defaultvalue); … … 252 257 }; 253 258 259 //! A CharLabel is a simple Label, that holds a char*, and will be updated, if changed. 260 class OptionLabel : public Option 261 { 262 public: 263 OptionLabel(char* text); 264 void init(void); 265 266 void setTitle(char* title); 267 void redraw(); 268 }; 269 254 270 //! A label is a Widget, that displays a text 255 271 class Label : public Widget … … 264 280 }; 265 281 282 266 283 //gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data); 267 284 -
orxonox/trunk/gui/orxonox_gui_keys.cc
r3154 r3156 80 80 openButton->connectSignal("button_press_event", pKeyWindow, Window::windowOpen); 81 81 82 inputWindow = new Window("inputWindow"); 83 84 inputButton = new Button ("test"); 85 inputButton->connectSignal ("button_press_event", inputWindow, Window::windowClose); 86 inputWindow->fill (inputButton); 87 inputWindow->connectSignal("destroy", inputWindow, Window::windowClose); 88 inputWindow->connectSignal("delete_event", inputWindow, Window::windowClose); 89 82 90 } 83 91 84 92 Widget* Player::addKey (KEYS key, char* name) 85 93 { 86 pKeyBox[key] = new Box(); 87 pKeyLabel[key] = new Label (name); 88 pKeyButton[key] = new Button(name); 89 pKeyButton[key]->saveable = true; 94 inputKey[key] = new InputKey; 95 inputKey[key]->pKeyBox = new Box(); 96 inputKey[key]->pKeyButton = new Button(name); 97 inputKey[key]->pKeyOLabel = new OptionLabel (name); 98 inputKey[key]->pKeyOLabel->saveable = true; 90 99 91 pKeyButton[key]->connectSignal("key_press_event", pKeyButton[key], key_cb); 92 93 pKeyBox[key]->fill(pKeyLabel[key]); 94 pKeyBox[key]->fill(pKeyButton[key]); 95 return pKeyBox[key]; 100 //inputKey[key]->pKeyButton->connectSignal("key_press_event", inputKey[key]->pKeyButton, key_cb); 101 inputKey[key]->pKeyButton->connectSignal("button_press_event", inputKey[key], inputWindowEvent); 102 103 inputKey[key]->pKeyBox->fill(inputKey[key]->pKeyButton); 104 inputKey[key]->pKeyBox->fill(inputKey[key]->pKeyOLabel); 105 return inputKey[key]->pKeyBox; 96 106 } 97 107 … … 105 115 { 106 116 cout << "setting up Key: "<< key <<endl; 117 } 118 119 Window* Player::inputWindow = NULL; 120 Button* Player::inputButton = NULL; 121 long Player::keySignal = 0; 122 123 gint Player::inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* inputKey) 124 { 125 inputButton->setTitle("teste"); 126 keySignal = inputButton->connectSignal("key_press_event", inputKey, key_cb); 127 inputWindow->open(); 107 128 } 108 129 … … 114 135 \returns Nothing 115 136 */ 116 gint Player::key_cb(GtkWidget* w, GdkEventKey* event, void* widget) 117 { 118 Button* button = static_cast<Button*>(widget); 119 120 switch(event->keyval) { 121 case GDK_Up: 122 printf("Up arrow key!\n"); 123 button->setTitle("up"); 124 break; 125 case GDK_Down: 126 printf("Down arrow key!\n"); 127 button->setTitle("down"); 128 break; 129 case GDK_Left: 130 printf("Left arrow key!\n"); 131 button->setTitle("left"); 132 break; 133 case GDK_Right: 134 printf("Right arrow key!\n"); 135 button->setTitle("right"); 136 break; 137 138 case GDK_space: 139 printf("Space Pressed.\n"); 140 button->setTitle("space"); 141 break; 142 143 case 65293: 144 printf("Enter Pressed\n"); 145 button->setTitle("enter"); 146 break; 147 148 // Special Keys // 149 case GDK_Shift_L: 150 printf("Left Shift!\n"); 151 button->setTitle("l_shift"); 152 break; 153 case GDK_Shift_R: 154 printf("Right Shift!\n"); 155 button->setTitle("r_shift"); 156 break; 157 case GDK_Control_L: 158 printf("Left Control!\n"); 159 button->setTitle("l_ctrl"); 160 break; 161 case GDK_Control_R: 162 printf("Right Control!\n"); 163 button->setTitle("r_ctrl"); 164 break; 165 case GDK_Alt_L: 166 printf("Left Alt!\n"); 167 button->setTitle("l_alt"); 168 break; 169 case GDK_Alt_R: 170 printf("Rigth Alt!\n"); 171 button->setTitle("r_alt"); 172 break; 173 // FXX KEYS // 174 case GDK_F1: 175 printf("F1!\n"); 176 button->setTitle("f1"); 177 break; 178 case GDK_F2: 179 printf("F2!\n"); 180 button->setTitle("f2"); 181 break; 182 case GDK_F3: 183 printf("F3!\n"); 184 button->setTitle("f3"); 185 break; 186 case GDK_F4: 187 printf("F4!\n"); 188 button->setTitle("f4"); 189 break; 190 case GDK_F5: 191 printf("F5!\n"); 192 button->setTitle("f5"); 193 break; 194 case GDK_F6: 195 printf("F6!\n"); 196 button->setTitle("f6"); 197 break; 198 case GDK_F7: 199 printf("F7!\n"); 200 button->setTitle("f7"); 201 break; 202 case GDK_F8: 203 printf("F8!\n"); 204 button->setTitle("f8"); 205 break; 206 case GDK_F9: 207 printf("F9\n"); 208 button->setTitle("f9"); 209 break; 210 case GDK_F10: 211 printf("F10!\n"); 212 button->setTitle("f10"); 213 break; 214 case GDK_F11: 215 printf("F11!\n"); 216 button->setTitle("f11"); 217 break; 218 case GDK_F12: 219 printf("F12!\n"); 220 button->setTitle("f12"); 221 break; 222 223 224 default: 225 char* tmp; 226 sprintf(tmp, "%c", event->keyval); 227 printf ("other key %s \n", tmp); 228 button->setTitle(tmp); 229 break; 230 } 231 } 137 gint Player::key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey) 138 { 139 InputKey* inputkey = (InputKey*) inputKey; 140 char title [20]; 141 142 switch(event->keyval) 143 { 144 case GDK_Up: 145 printf("Up arrow key!\n"); 146 sprintf(title, "%s", "up"); 147 break; 148 case GDK_Down: 149 printf("Down arrow key!\n"); 150 sprintf(title, "%s", "down"); 151 break; 152 case GDK_Left: 153 printf("Left arrow key!\n"); 154 sprintf(title, "%s", "left"); 155 break; 156 case GDK_Right: 157 printf("Right arrow key!\n"); 158 sprintf(title, "%s", "right"); 159 break; 160 161 case GDK_space: 162 printf("Space Pressed.\n"); 163 sprintf(title, "%s", "space"); 164 break; 165 166 /* case GDK_escape: 167 printf("Esc Pressed.\n"); 168 sprintf(title, "%s", "esc"); 169 */ 170 case 65293: 171 printf("Enter Pressed\n"); 172 sprintf(title, "%s", "enter"); 173 break; 174 175 // Special Keys // 176 case GDK_Shift_L: 177 printf("Left Shift!\n"); 178 sprintf(title, "%s", "l_shift"); 179 break; 180 case GDK_Shift_R: 181 printf("Right Shift!\n"); 182 sprintf(title, "%s", "r_shift"); 183 break; 184 case GDK_Control_L: 185 printf("Left Control!\n"); 186 sprintf(title, "%s", "l_ctrl"); 187 break; 188 case GDK_Control_R: 189 printf("Right Control!\n"); 190 sprintf(title, "%s", "r_ctrl"); 191 break; 192 case GDK_Alt_L: 193 printf("Left Alt!\n"); 194 sprintf(title, "%s", "l_alt"); 195 break; 196 case GDK_Alt_R: 197 printf("Rigth Alt!\n"); 198 sprintf(title, "%s", "r_alt"); 199 break; 200 // FXX KEYS // 201 case GDK_F1: 202 printf("F1!\n"); 203 sprintf(title, "%s", "f1"); 204 break; 205 case GDK_F2: 206 printf("F2!\n"); 207 sprintf(title, "%s", "f2"); 208 break; 209 case GDK_F3: 210 printf("F3!\n"); 211 sprintf(title, "%s", "f3"); 212 break; 213 case GDK_F4: 214 printf("F4!\n"); 215 sprintf(title, "%s", "f4"); 216 break; 217 case GDK_F5: 218 printf("F5!\n"); 219 sprintf(title, "%s", "f5"); 220 break; 221 case GDK_F6: 222 printf("F6!\n"); 223 sprintf(title, "%s", "f6"); 224 break; 225 case GDK_F7: 226 printf("F7!\n"); 227 sprintf(title, "%s", "f7"); 228 break; 229 case GDK_F8: 230 printf("F8!\n"); 231 sprintf(title, "%s", "f8"); 232 break; 233 case GDK_F9: 234 printf("F9\n"); 235 sprintf(title, "%s", "f9"); 236 break; 237 case GDK_F10: 238 printf("F10!\n"); 239 sprintf(title, "%s", "f10"); 240 break; 241 case GDK_F11: 242 printf("F11!\n"); 243 sprintf(title, "%s", "f11"); 244 break; 245 case GDK_F12: 246 printf("F12!\n"); 247 sprintf(title, "%s", "f12"); 248 break; 249 250 251 default: 252 char* tmp; 253 sprintf(tmp, "%c", event->keyval); 254 printf ("other key %s \n", tmp); 255 sprintf(title, "%s", tmp); 256 break; 257 } 258 inputkey->pKeyOLabel->setTitle (title); 259 inputButton->disconnectSignal(keySignal); 260 inputWindow->close(); 261 } -
orxonox/trunk/gui/orxonox_gui_keys.h
r3154 r3156 43 43 Box* pKeysBox; 44 44 45 Box* pKeyBox[10]; 46 Button* pKeyButton[10]; 47 Label* pKeyLabel[10]; 45 struct InputKey 46 { 47 Box* pKeyBox; 48 Button* pKeyButton; 49 OptionLabel* pKeyOLabel; 50 }; 48 51 52 InputKey* inputKey[10]; 49 53 54 static Window* inputWindow; 55 static Button* inputButton; 56 static long keySignal; 50 57 public: 51 58 Player(char* player); … … 55 62 Button* getOpenButton(); 56 63 57 static gint key_cb(GtkWidget* w, GdkEventKey* event, void* widget); 64 static gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget); 65 static gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey); 58 66 void setkey(KEYS key); 59 67
Note: See TracChangeset
for help on using the changeset viewer.