Changeset 4086 in orxonox.OLD for orxonox/trunk/src
- Timestamp:
- May 6, 2005, 4:51:48 PM (20 years ago)
- Location:
- orxonox/trunk/src/lib/gui/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/gui/gui/gui_keys.cc
r4085 r4086 43 43 44 44 this->keysFrame->fill(this->keysBox); 45 46 47 this->inputWindow = new Window("inputWindow"); 48 this->inputButton = new Button("test"); 49 #ifdef HAVE_GTK2 50 this->inputWindow->connectSignal("destroy", Widget::doNothingSignal); 51 this->inputWindow->connectSignal("delete_event", Widget::doNothingSignal); 52 #endif /* HAVE_GTK2 */ 53 this->inputWindow->fill(inputButton); 54 45 55 this->setMainWidget(keysFrame); 46 56 } … … 53 63 // nothing to do here. 54 64 } 65 66 67 Window* GuiKeys::inputWindow = NULL; 68 Button* GuiKeys::inputButton = NULL; 69 long GuiKeys::keySignal = 0; 70 55 71 56 72 /* PLAYER */ … … 93 109 this->openButton->connectSignal("button_press_event", this->pKeyWindow, Window::windowOpen); 94 110 #endif /* HAVE_GTK2 */ 95 96 this->inputWindow = new Window("inputWindow"); 97 98 this->inputButton = new Button("test"); 99 this->inputWindow->fill(inputButton); 100 #ifdef HAVE_GTK2 101 this->inputWindow->connectSignal("destroy", Widget::doNothingSignal); 102 this->inputWindow->connectSignal("delete_event", Widget::doNothingSignal); 103 #endif /* HAVE_GTK2 */ 104 111 } 112 113 /** 114 \returns the OpenButton of a Player 115 */ 116 Button* Player::getOpenButton(void) 117 { 118 return this->openButton; 119 } 120 121 /** 122 \brief sets a new Key(only output) 123 \param key the new Key. 124 */ 125 void Player::setkey(KEYS key) 126 { 127 PRINT(4)("setting up Key: %d\n", key); 105 128 } 106 129 … … 111 134 \returns A widget that has the Key-Box 112 135 */ 113 Widget* Player::addKey(KEYS key, char* name) 114 { 115 this->inputKey[key] = new InputKey; 116 this->inputKey[key]->pKeyBox = new Box(); 117 this->inputKey[key]->pKeyButton = new Button(name); 118 this->inputKey[key]->pKeyOLabel = new OptionLabel(name, name); 119 this->inputKey[key]->pKeyOLabel->saveability(); 120 121 #ifdef HAVE_GTK2 122 //inputKey[key]->pKeyButton->connectSignal("key_press_event", inputKey[key]->pKeyButton, key_cb); 123 this->inputKey[key]->pKeyButton->connectSignal("button_press_event", this->inputKey[key], inputWindowEvent); 124 #endif /* HAVE_GTK2 */ 125 this->inputKey[key]->pKeyBox->fill(this->inputKey[key]->pKeyButton); 126 this->inputKey[key]->pKeyBox->fill(this->inputKey[key]->pKeyOLabel); 127 return this->inputKey[key]->pKeyBox; 128 } 129 130 /** 131 \returns the OpenButton of a Player 132 */ 133 Button* Player::getOpenButton(void) 134 { 135 return this->openButton; 136 } 137 138 /** 139 \brief sets a new Key(only output) 140 \param key the new Key. 141 */ 142 void Player::setkey(KEYS key) 143 { 144 PRINT(4)("setting up Key: %d\n", key); 145 } 146 147 Window* Player::inputWindow = NULL; 148 Button* Player::inputButton = NULL; 149 long Player::keySignal = 0; 150 151 #ifdef HAVE_GTK2 152 gint Player::inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* inputKey) 153 { 154 inputButton->setTitle("press a Key"); 155 keySignal = inputButton->connectSignal("key_press_event", inputKey, key_cb); 156 inputWindow->open(); 136 Widget* addKey(KEYS key, char* name) 137 { 138 InputKey* inputKey = new InputKey; 139 inputKey->pKeyBox = new Box(); 140 inputKey->pKeyButton = new Button(name); 141 inputKey->pKeyOLabel = new OptionLabel(name, name); 142 inputKey->pKeyOLabel->saveability(); 143 144 #ifdef HAVE_GTK2 145 //inputKey->pKeyButton->connectSignal("key_press_event", inputKey->pKeyButton, key_cb); 146 inputKey->pKeyButton->connectSignal("button_press_event", inputKey, inputWindowEvent); 147 #endif /* HAVE_GTK2 */ 148 inputKey->pKeyBox->fill(inputKey->pKeyButton); 149 inputKey->pKeyBox->fill(inputKey->pKeyOLabel); 150 return inputKey->pKeyBox; 151 } 152 153 154 #ifdef HAVE_GTK2 155 gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* inputKey) 156 { 157 GuiKeys::inputButton->setTitle("press a Key"); 158 GuiKeys::keySignal = GuiKeys::inputButton->connectSignal("key_press_event", inputKey, key_cb); 159 GuiKeys::inputWindow->open(); 157 160 } 158 161 … … 164 167 \returns Nothing 165 168 */ 166 gint Player::key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey)169 gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey) 167 170 { 168 171 InputKey* inputkey =(InputKey*) inputKey; … … 336 339 337 340 inputkey->pKeyOLabel->setValue(title); 338 inputButton->disconnectSignal(keySignal);339 inputWindow->close();340 } 341 #endif /* HAVE_GTK2 */ 341 GuiKeys::inputButton->disconnectSignal(GuiKeys::keySignal); 342 GuiKeys::inputWindow->close(); 343 } 344 #endif /* HAVE_GTK2 */ -
orxonox/trunk/src/lib/gui/gui/gui_keys.h
r4056 r4086 20 20 enum KEYS {UP, DOWN, LEFT, RIGHT, SHOOT}; 21 21 22 //! One KeyOption has one InputKey 23 struct InputKey 24 { 25 Box* pKeyBox; //!< One Box that holds the Keys 26 Button* pKeyButton; //!< The Button for changing the Key. 27 OptionLabel* pKeyOLabel;//!< The Label for displaying the Key-setting. 28 }; 29 30 22 31 class Player; 23 32 //! Class that creates the Keys-Options. … … 34 43 GuiKeys(void); 35 44 ~GuiKeys(void); 45 46 static Window* inputWindow; //!< A Window that gets keyboard clicks. Static, because only one needed. 47 static Button* inputButton; //!< A Button that gets keyboard clicks. Static, because only one needed. 48 static long keySignal; //!< A keySignal that handles keyboard clicks. Static, because only one needed. 49 36 50 }; 37 51 … … 48 62 Button* closeButton; //!< The CloseButton for this key-settings. 49 63 Box* pKeysBox; //!< The Box that holds the Key-settings. 50 51 //! One KeyOption has one InputKey52 struct InputKey53 {54 Box* pKeyBox; //!< One Box that holds the Keys55 Button* pKeyButton; //!< The Button for changing the Key.56 OptionLabel* pKeyOLabel;//!< The Label for displaying the Key-setting.57 };58 64 59 InputKey* inputKey[10]; //!< Buttons-array. \todo make it dynamic.65 // InputKey* inputKey[10]; //!< Buttons-array. \todo make it dynamic. 60 66 61 static Window* inputWindow; //!< A Window that gets keyboard clicks. Static, because only one needed.62 static Button* inputButton; //!< A Button that gets keyboard clicks. Static, because only one needed.63 static long keySignal; //!< A keySignal that handles keyboard clicks. Static, because only one needed.64 67 public: 65 68 Player(char* player); 66 69 67 Widget* addKey(KEYS key, char* name);68 70 69 71 Button* getOpenButton(void); 70 72 71 #ifdef HAVE_GTK272 static gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget);73 static gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey);74 #endif /* HAVE_GTK2 */75 73 void setkey(KEYS key); 76 74 77 75 }; 78 76 77 Widget* addKey(KEYS key, char* name); 78 #ifdef HAVE_GTK2 79 gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget); 80 gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey); 81 #endif /* HAVE_GTK2 */ 79 82 80 83
Note: See TracChangeset
for help on using the changeset viewer.