19 #ifndef OPENXCOM_INTERACTIVE_SURFACE_H
20 #define OPENXCOM_INTERACTIVE_SURFACE_H
30 typedef void (State::* ActionHandler)(Action*);
42 static const int NUM_BUTTONS = 7;
43 static const SDLKey SDLK_ANY;
44 Uint8 _buttonsPressed;
46 std::map<Uint8, ActionHandler> _click, _press, _release;
47 ActionHandler _in, _over, _out;
48 std::map<SDLKey, ActionHandler> _keyPress, _keyRelease;
49 bool _isHovered, _isFocused, _listButton;
73 void onMouseClick(ActionHandler handler, Uint8 button = SDL_BUTTON_LEFT);
75 void onMousePress(ActionHandler handler, Uint8 button = 0);
virtual void setFocus(bool focus)
Sets the focus of this surface.
Definition: InteractiveSurface.cpp:208
void onMouseRelease(ActionHandler handler, Uint8 button=0)
Hooks an action handler to a mouse release over the surface.
Definition: InteractiveSurface.cpp:444
void onMouseClick(ActionHandler handler, Uint8 button=SDL_BUTTON_LEFT)
Hooks an action handler to a mouse click on the surface.
Definition: InteractiveSurface.cpp:410
InteractiveSurface(int width, int height, int x=0, int y=0)
Creates a new interactive surface with the specified size and position.
Definition: InteractiveSurface.cpp:35
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:34
virtual bool isButtonHandled(Uint8 button=0)
Is this mouse button event handled?
Definition: InteractiveSurface.cpp:46
A game state that receives user input and reacts accordingly.
Definition: State.h:44
Surface that the user can interact with.
Definition: InteractiveSurface.h:39
virtual void mouseOver(Action *action, State *state)
Processes a mouse hover event.
Definition: InteractiveSurface.cpp:332
void onMouseIn(ActionHandler handler)
Hooks an action handler to moving the mouse into the surface.
Definition: InteractiveSurface.cpp:460
virtual void mouseIn(Action *action, State *state)
Processes a mouse hover in event.
Definition: InteractiveSurface.cpp:317
void setListButton()
Check this surface to see if it's a textlist button.
Definition: InteractiveSurface.cpp:520
virtual void handle(Action *action, State *state)
Processes any pending events.
Definition: InteractiveSurface.cpp:107
void setButtonPressed(Uint8 button, bool pressed)
Set a mouse button's internal state.
Definition: InteractiveSurface.cpp:72
void onKeyboardRelease(ActionHandler handler, SDLKey key=SDLK_ANY)
Hooks an action handler to releasing a key when the surface is focused.
Definition: InteractiveSurface.cpp:505
virtual void mouseOut(Action *action, State *state)
Processes a mouse hover out event.
Definition: InteractiveSurface.cpp:347
void onMouseOver(ActionHandler handler)
Hooks an action handler to moving the mouse over the surface.
Definition: InteractiveSurface.cpp:469
bool isButtonPressed(Uint8 button=0)
Is this mouse button pressed?
Definition: InteractiveSurface.cpp:60
void onMousePress(ActionHandler handler, Uint8 button=0)
Hooks an action handler to a mouse press over the surface.
Definition: InteractiveSurface.cpp:427
Element that is blit (rendered) onto the screen.
Definition: Surface.h:39
virtual void mouseClick(Action *action, State *state)
Processes a mouse click event.
Definition: InteractiveSurface.cpp:294
void onMouseOut(ActionHandler handler)
Hooks an action handler to moving the mouse out of the surface.
Definition: InteractiveSurface.cpp:478
void onKeyboardPress(ActionHandler handler, SDLKey key=SDLK_ANY)
Hooks an action handler to pressing a key when the surface is focused.
Definition: InteractiveSurface.cpp:488
virtual void mousePress(Action *action, State *state)
Processes a mouse button press event.
Definition: InteractiveSurface.cpp:248
virtual void keyboardRelease(Action *action, State *state)
Processes a keyboard key release event.
Definition: InteractiveSurface.cpp:387
bool isFocused() const
Gets the focus of this surface.
Definition: InteractiveSurface.cpp:218
virtual void mouseRelease(Action *action, State *state)
Processes a mouse button release event.
Definition: InteractiveSurface.cpp:271
virtual ~InteractiveSurface()
Cleans up the interactive surface.
Definition: InteractiveSurface.cpp:42
virtual void keyboardPress(Action *action, State *state)
Processes a keyboard key press event.
Definition: InteractiveSurface.cpp:362
void setVisible(bool visible)
Sets the surface's visibility.
Definition: InteractiveSurface.cpp:89
virtual void unpress(State *state)
Unpresses the surface.
Definition: InteractiveSurface.cpp:228