Changeset 7866 in orxonox.OLD for branches/gui/src/lib
- Timestamp:
- May 26, 2006, 1:11:10 PM (19 years ago)
- Location:
- branches/gui/src/lib
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gui/src/lib/event/event_def.h
r5553 r7866 12 12 #include "SDL/SDL_keysym.h" 13 13 #endif 14 #include "stdincl.h"15 14 16 15 -
branches/gui/src/lib/event/event_handler.cc
r7756 r7866 171 171 unsubscribe(EventListener* el, elState state) function 172 172 */ 173 void EventHandler::unsubscribe( elState state, int eventType)173 void EventHandler::unsubscribe(EventListener* el, elState state, int eventType) 174 174 { 175 175 PRINTF(4)("Unsubscribing event type nr: %i\n", eventType); 176 176 if (state == ES_ALL) 177 177 for (unsigned int i = 0; i < ES_NUMBER; i++) 178 this->listeners[i][eventType].clear(); 179 else 180 this->listeners[state][eventType].clear(); 181 } 182 183 184 /** 185 * unsubscribe all events from a specific listener 178 { 179 std::vector<EventListener*>::iterator listener = 180 std::find(this->listeners[i][eventType].begin(), 181 this->listeners[i][eventType].end(), 182 el); 183 if (listener != this->listeners[i][eventType].end()) 184 this->listeners[i][eventType].erase(listener); 185 } 186 else 187 { 188 std::vector<EventListener*>::iterator listener = 189 std::find(this->listeners[state][eventType].begin(), 190 this->listeners[state][eventType].end(), 191 el); 192 if (listener != this->listeners[state][eventType].end()) 193 this->listeners[state][eventType].erase(listener); 194 } 195 } 196 197 198 /** 199 * @brief unsubscribe all events from a specific listener 186 200 * @param el: the listener that wants to unsubscribe itself 187 201 * @param state: the state in which the events shall be unsubscribed 188 189 */ 202 */ 190 203 void EventHandler::unsubscribe(EventListener* el, elState state) 191 204 { -
branches/gui/src/lib/event/event_handler.h
r7756 r7866 35 35 36 36 void subscribe(EventListener* el, elState state, int eventType); 37 void unsubscribe( elState state, int eventType);37 void unsubscribe(EventListener* el, elState state, int eventType); 38 38 void unsubscribe(EventListener* el, elState state = ES_ALL); 39 39 void flush(elState state); -
branches/gui/src/lib/event/event_listener.cc
r4866 r7866 23 23 24 24 /** 25 * standard constructor26 */25 * @brief standard constructor 26 */ 27 27 EventListener::EventListener () 28 28 { … … 32 32 33 33 /** 34 * standard deconstructor 35 */ 34 * @brief standard deconstructor 35 * 36 * Unsubscribes all Subscribed Events, of this EventListener. 37 */ 36 38 EventListener::~EventListener () 37 39 { … … 39 41 EventHandler::getInstance()->unsubscribe(this, ES_ALL); 40 42 } 43 44 bool EventListener::isEventSubscribed(elState state, int eventType) const 45 { 46 return EventHandler::getInstance()->isSubscribed(state, eventType); 47 } 48 49 50 /** 51 * @brief Subscribes an Events to this EventListener. 52 * @param state the state to subscribe to. 53 * @param eventType the Type of Event to subscribe. 54 */ 55 void EventListener::subscribeEvent(elState state, int eventType) 56 { 57 EventHandler::getInstance()->subscribe(this, state, eventType); 58 } 59 60 61 /** 62 * @brief Unubscribes an Event from this EventListener. 63 * @param state the state to unsubscribe from. 64 * @param eventType the Type of Event to unsubscribe. 65 */ 66 void EventListener::unsubscribeEvent(elState state, int eventType) 67 { 68 EventHandler::getInstance()->unsubscribe(this, state, eventType); 69 } 70 71 void EventListener::unsubscribeEvents(elState state) 72 { 73 EventHandler::getInstance()->unsubscribe(this, state); 74 } 75 -
branches/gui/src/lib/event/event_listener.h
r5291 r7866 9 9 #include "base_object.h" 10 10 #include "event.h" 11 #include "event_def.h" 11 12 12 13 //! A class for event listener … … 17 18 virtual ~EventListener(); 18 19 20 bool isEventSubscribed(elState state, int eventType) const; 21 22 void subscribeEvent(elState state, int eventType); 23 void unsubscribeEvent(elState state, int eventType); 24 void unsubscribeEvents(elState state = ES_ALL); 25 19 26 /** 20 * abstract function that processes events from the handler27 * @brief abstract function that processes events from the handler 21 28 * @param event: the event 22 29 */ 23 30 virtual void process(const Event &event) = 0; 31 24 32 }; 25 33 -
branches/gui/src/lib/gui/gl_gui/glgui_handler.cc
r7840 r7866 31 31 this->setClassID(CL_GLGUI_HANDLER, "GLGuiHandler"); 32 32 this->setName("GLGuiHandler"); 33 34 //this->subscribeEvent() 33 35 34 36 } -
branches/gui/src/lib/gui/gl_gui/glgui_widget.h
r7855 r7866 56 56 bool focusOverWidget(float x, float y); 57 57 58 // if something was clickt on the GUI-widget. 58 59 virtual void update() {}; 60 virtual void draw() const; 61 62 Material& backMaterial() { return this->backMat; }; 63 const Material& backMaterial() const { return this->backMat; }; 64 65 Material& frontMaterial() { return this->frontMat; }; 66 const Material& frontMaterial() const { return this->frontMat; }; 67 68 protected: 69 // if something was clickt on the GUI-widget. 59 70 virtual void clicked(const Event& event) {}; 60 71 virtual void released(const Event& event) {}; … … 65 76 virtual void destroyed() {}; 66 77 67 virtual void update() {};68 virtual void draw() const;69 78 70 Material& backMaterial() { return this->backMat; };71 Material& frontMaterial() { return this->frontMat; };72 73 protected:74 79 inline void startDraw() const { glPushMatrix(); glTranslatef(this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0); }; 75 80 inline void endDraw() const { glPopMatrix(); }; -
branches/gui/src/lib/shell/shell.cc
r7764 r7866 65 65 66 66 // EVENT-Handler subscription of '`' to all States. 67 EventHandler::getInstance()->subscribe(this,ES_ALL, SDLK_BACKQUOTE);68 EventHandler::getInstance()->subscribe(this,ES_ALL, SDLK_F12);69 EventHandler::getInstance()->subscribe(this,ES_SHELL, SDLK_PAGEUP);70 EventHandler::getInstance()->subscribe(this,ES_SHELL, SDLK_PAGEDOWN);71 EventHandler::getInstance()->subscribe(this,ES_SHELL, EV_VIDEO_RESIZE);67 this->subscribeEvent(ES_ALL, SDLK_BACKQUOTE); 68 this->subscribeEvent(ES_ALL, SDLK_F12); 69 this->subscribeEvent(ES_SHELL, SDLK_PAGEUP); 70 this->subscribeEvent(ES_SHELL, SDLK_PAGEDOWN); 71 this->subscribeEvent(ES_SHELL, EV_VIDEO_RESIZE); 72 72 73 73 // BUFFER -
branches/gui/src/lib/shell/shell_input.cc
r7858 r7866 20 20 #include "shell_command.h" 21 21 #include "shell_command_class.h" 22 #include "event_handler.h"23 22 24 23 #include "debug.h" … … 50 49 this->setRepeatDelay(.3, .05); 51 50 52 // subscribe all keyboard commands to ES_SEHLL 53 EventHandler* evh = EventHandler::getInstance(); 51 // subscribe all keyboard commands to ES_SHELL 54 52 for (int i = 1; i < SDLK_LAST; i++) 55 53 { 56 if (! evh->isSubscribed(ES_SHELL, i))57 evh->subscribe(this,ES_SHELL, i);54 if (!this->isEventSubscribed(ES_SHELL, i)) 55 this->subscribeEvent(ES_SHELL, i); 58 56 } 59 57 // unsubscribe unused TODO improve. 60 evh->unsubscribe(ES_SHELL, SDLK_BACKQUOTE);61 evh->unsubscribe(ES_SHELL, SDLK_F12);62 evh->unsubscribe(ES_SHELL, SDLK_PAGEUP);63 evh->unsubscribe(ES_SHELL, SDLK_PAGEDOWN);58 this->unsubscribeEvent(ES_SHELL, SDLK_BACKQUOTE); 59 this->unsubscribeEvent(ES_SHELL, SDLK_F12); 60 this->unsubscribeEvent(ES_SHELL, SDLK_PAGEUP); 61 this->unsubscribeEvent(ES_SHELL, SDLK_PAGEDOWN); 64 62 65 63 }
Note: See TracChangeset
for help on using the changeset viewer.