OpenXcom  1.0
Open-source clone of the original X-Com
BattlescapeButton.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * OpenXcom is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include "../Engine/InteractiveSurface.h"
21 
22 namespace OpenXcom
23 {
24 
25 enum InversionType {INVERT_NONE, INVERT_CLICK, INVERT_TOGGLE};
26 
35 {
36 protected:
37  Uint8 _color;
38  BattlescapeButton **_group;
39  bool _inverted;
40  InversionType _toggleMode;
41  Surface *_altSurface;
42 public:
44  BattlescapeButton(int width, int height, int x = 0, int y = 0);
46  virtual ~BattlescapeButton();
48  void setColor(Uint8 color);
50  Uint8 getColor() const;
52  void setGroup(BattlescapeButton **group);
54  void mousePress(Action *action, State *state);
56  void mouseRelease(Action *action, State *state);
58  void toggle(bool invert);
60  void allowToggleInversion();
62  void allowClickInversion();
64  void initSurfaces();
66  void blit(Surface *surface);
68  void setX(int x);
70  void setY(int y);
71 
72 };
73 
74 }
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void setY(int y)
Alters both versions of the button&#39;s Y pos.
Definition: BattlescapeButton.cpp:230
void allowClickInversion()
Allows this button to be toggled on when clicked, and off when released.
Definition: BattlescapeButton.cpp:135
A game state that receives user input and reacts accordingly.
Definition: State.h:44
void setColor(Uint8 color)
Sets the image button&#39;s color.
Definition: BattlescapeButton.cpp:48
BattlescapeButton(int width, int height, int x=0, int y=0)
Creates a new image button with the specified size and position.
Definition: BattlescapeButton.cpp:32
Surface that the user can interact with.
Definition: InteractiveSurface.h:37
void toggle(bool invert)
Invert a button explicitly either ON or OFF.
Definition: BattlescapeButton.cpp:116
void setX(int x)
Alters both versions of the button&#39;s X pos.
Definition: BattlescapeButton.cpp:217
Uint8 getColor() const
Gets the image button&#39;s color.
Definition: BattlescapeButton.cpp:57
virtual ~BattlescapeButton()
Cleans up the image button.
Definition: BattlescapeButton.cpp:39
void blit(Surface *surface)
Blits this surface onto another one.
Definition: BattlescapeButton.cpp:201
void mousePress(Action *action, State *state)
Special handling for mouse presses.
Definition: BattlescapeButton.cpp:80
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
void allowToggleInversion()
Allows this button to be toggled on/off with a click.
Definition: BattlescapeButton.cpp:127
void initSurfaces()
Sets up the "pressed" surface.
Definition: BattlescapeButton.cpp:146
void invert(Uint8 mid)
Inverts the surface&#39;s colors.
Definition: Surface.cpp:592
void mouseRelease(Action *action, State *state)
Special handling for mouse releases.
Definition: BattlescapeButton.cpp:103
void setGroup(BattlescapeButton **group)
Sets the image button&#39;s group.
Definition: BattlescapeButton.cpp:67
Regular image that works like a button.
Definition: BattlescapeButton.h:34
Definition: BaseInfoState.cpp:40