Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4086 in orxonox.OLD


Ignore:
Timestamp:
May 6, 2005, 4:51:48 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: keySelector is now extern from Player

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  
    4343
    4444  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
    4555  this->setMainWidget(keysFrame);
    4656}
     
    5363  // nothing to do here.
    5464}
     65
     66
     67Window* GuiKeys::inputWindow = NULL;
     68Button* GuiKeys::inputButton = NULL;
     69long GuiKeys::keySignal = 0;
     70
    5571
    5672/* PLAYER */
     
    93109  this->openButton->connectSignal("button_press_event", this->pKeyWindow, Window::windowOpen);
    94110#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*/
     116Button* 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*/
     125void Player::setkey(KEYS key)
     126{
     127  PRINT(4)("setting up Key: %d\n", key);
    105128}
    106129
     
    111134   \returns A widget that has the Key-Box
    112135*/
    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();
     136Widget* 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
     155gint 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();
    157160}
    158161 
     
    164167   \returns Nothing
    165168*/
    166 gint Player::key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey)
     169gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey)
    167170{
    168171  InputKey* inputkey =(InputKey*) inputKey;
     
    336339
    337340  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  
    2020enum KEYS {UP, DOWN, LEFT, RIGHT, SHOOT};
    2121
     22//! One KeyOption has one InputKey
     23struct 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
    2231class Player;
    2332//! Class that creates the Keys-Options.
     
    3443  GuiKeys(void);
    3544  ~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
    3650};
    3751
     
    4862  Button* closeButton;    //!< The CloseButton for this key-settings.
    4963  Box* pKeysBox;          //!< The Box that holds the Key-settings.
    50  
    51   //! One KeyOption has one InputKey
    52   struct InputKey
    53   {
    54     Box* pKeyBox;           //!< One Box that holds the Keys
    55     Button* pKeyButton;     //!< The Button for changing the Key.
    56     OptionLabel* pKeyOLabel;//!< The Label for displaying the Key-setting.
    57   };
    5864
    59   InputKey* inputKey[10];     //!< Buttons-array. \todo make it dynamic.
     65  //  InputKey* inputKey[10];     //!< Buttons-array. \todo make it dynamic.
    6066
    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.
    6467 public:
    6568  Player(char* player);
    6669
    67   Widget* addKey(KEYS key, char* name);
    6870
    6971  Button* getOpenButton(void);
    7072
    71 #ifdef HAVE_GTK2
    72   static gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget);
    73   static gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey);
    74 #endif /* HAVE_GTK2 */
    7573  void setkey(KEYS key);
    7674 
    7775};
    7876
     77Widget* addKey(KEYS key, char* name);
     78#ifdef HAVE_GTK2
     79gint inputWindowEvent(GtkWidget* w, GdkEventKey* event, void* widget);
     80gint key_cb(GtkWidget* w, GdkEventKey* event, void* inputKey);
     81#endif /* HAVE_GTK2 */
    7982
    8083
Note: See TracChangeset for help on using the changeset viewer.