OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | List of all members
OpenXcom::ComboBox Class Reference

Text button with a list dropdown when pressed. More...

#include <ComboBox.h>

Inheritance diagram for OpenXcom::ComboBox:
OpenXcom::InteractiveSurface OpenXcom::Surface

Public Member Functions

 ComboBox (State *state, int width, int height, int x=0, int y=0, bool popupAboveButton=false)
 Creates a combo box with the specified size and position. More...
 
 ~ComboBox ()
 Cleans up the combo box. More...
 
void setX (int x)
 Sets the X position of the surface. More...
 
void setY (int y)
 Sets the Y position of the surface. More...
 
void setPalette (SDL_Color *colors, int firstcolor=0, int ncolors=256)
 Sets the palette of the text list. More...
 
void initText (Font *big, Font *small, Language *lang)
 Initializes the resources for the text list. More...
 
void setBackground (Surface *bg)
 Sets the background surface. More...
 
void setColor (Uint8 color)
 Sets the border color. More...
 
Uint8 getColor () const
 Gets the border color. More...
 
void setHighContrast (bool contrast)
 Sets the high contrast color setting. More...
 
void setArrowColor (Uint8 color)
 Sets the arrow color of the text list. More...
 
size_t getSelected () const
 Gets the selected option in the list. More...
 
size_t getHoveredListIdx () const
 Gets the item that is currently hovered over in the popup list, or the current selected item if no item is hovered over.
 
void setText (const std::string &text)
 Sets the button text without changing the selected option. More...
 
void setSelected (size_t sel)
 Sets the selected option in the list. More...
 
void setOptions (const std::vector< std::string > &options, bool translate=false)
 Sets the list of options. More...
 
void blit (Surface *surface)
 Blits the combo box onto another surface. More...
 
void think ()
 Thinks arrow buttons. More...
 
void handle (Action *action, State *state)
 Handle arrow buttons. More...
 
void toggle (bool first=false)
 Toggles the combo box state. More...
 
void onChange (ActionHandler handler)
 Hooks an action handler to when the slider changes. More...
 
void onListMouseIn (ActionHandler handler)
 Hooks an action handler to moving the mouse in to the listbox when it is visible. More...
 
void onListMouseOut (ActionHandler handler)
 Hooks an action handler to moving the mouse out of the listbox when it is visible. More...
 
void onListMouseOver (ActionHandler handler)
 Hooks an action handler to moving the mouse over the listbox when it is visible. More...
 
- Public Member Functions inherited from OpenXcom::InteractiveSurface
 InteractiveSurface (int width, int height, int x=0, int y=0)
 Creates a new interactive surface with the specified size and position. More...
 
virtual ~InteractiveSurface ()
 Cleans up the interactive surface.
 
void setVisible (bool visible)
 Sets the surface's visibility. More...
 
virtual void setFocus (bool focus)
 Sets the focus of this surface. More...
 
bool isFocused () const
 Gets the focus of this surface. More...
 
virtual void unpress (State *state)
 Unpresses the surface. More...
 
void onMouseClick (ActionHandler handler, Uint8 button=SDL_BUTTON_LEFT)
 Hooks an action handler to a mouse click on the surface. More...
 
void onMousePress (ActionHandler handler, Uint8 button=0)
 Hooks an action handler to a mouse press over the surface. More...
 
void onMouseRelease (ActionHandler handler, Uint8 button=0)
 Hooks an action handler to a mouse release over the surface. More...
 
void onMouseIn (ActionHandler handler)
 Hooks an action handler to moving the mouse into the surface. More...
 
void onMouseOver (ActionHandler handler)
 Hooks an action handler to moving the mouse over the surface. More...
 
void onMouseOut (ActionHandler handler)
 Hooks an action handler to moving the mouse out of the surface. More...
 
void onKeyboardPress (ActionHandler handler, SDLKey key=SDLK_ANY)
 Hooks an action handler to pressing a key when the surface is focused. More...
 
void onKeyboardRelease (ActionHandler handler, SDLKey key=SDLK_ANY)
 Hooks an action handler to releasing a key when the surface is focused. More...
 
virtual void mousePress (Action *action, State *state)
 Processes a mouse button press event. More...
 
virtual void mouseRelease (Action *action, State *state)
 Processes a mouse button release event. More...
 
virtual void mouseClick (Action *action, State *state)
 Processes a mouse click event. More...
 
virtual void mouseIn (Action *action, State *state)
 Processes a mouse hover in event. More...
 
virtual void mouseOver (Action *action, State *state)
 Processes a mouse hover event. More...
 
virtual void mouseOut (Action *action, State *state)
 Processes a mouse hover out event. More...
 
virtual void keyboardPress (Action *action, State *state)
 Processes a keyboard key press event. More...
 
virtual void keyboardRelease (Action *action, State *state)
 Processes a keyboard key release event. More...
 
void setListButton ()
 Check this surface to see if it's a textlist button. More...
 
- Public Member Functions inherited from OpenXcom::Surface
 Surface (int width, int height, int x=0, int y=0, int bpp=8)
 Creates a new surface with the specified size and position. More...
 
 Surface (const Surface &other)
 Creates a new surface from an existing one. More...
 
virtual ~Surface ()
 Cleans up the surface. More...
 
void loadRaw (const std::vector< unsigned char > &bytes)
 Loads a raw pixel array. More...
 
void loadRaw (const std::vector< char > &bytes)
 Loads a raw pixel array. More...
 
void loadScr (const std::string &filename)
 Loads an X-Com SCR graphic. More...
 
void loadSpk (const std::string &filename)
 Loads an X-Com SPK graphic. More...
 
void loadBdy (const std::string &filename)
 Loads a TFTD BDY graphic. More...
 
void loadImage (const std::string &filename)
 Loads a general image file. More...
 
void clear (Uint32 color=0)
 Clears the surface's contents eith a specified colour. More...
 
void offset (int off, int min=-1, int max=-1, int mul=1)
 Offsets the surface's colors by a set amount. More...
 
void offsetBlock (int off, int blk=16, int mul=1)
 Offsets the surface's colors in a color block. More...
 
void invert (Uint8 mid)
 Inverts the surface's colors. More...
 
virtual void draw ()
 Draws the surface's graphic. More...
 
void copy (Surface *surface)
 Copies a portion of another surface into this one. More...
 
void drawRect (SDL_Rect *rect, Uint8 color)
 Draws a filled rectangle on the surface. More...
 
void drawRect (Sint16 x, Sint16 y, Sint16 w, Sint16 h, Uint8 color)
 Draws a filled rectangle on the surface. More...
 
void drawLine (Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint8 color)
 Draws a line on the surface. More...
 
void drawCircle (Sint16 x, Sint16 y, Sint16 r, Uint8 color)
 Draws a filled circle on the surface. More...
 
void drawPolygon (Sint16 *x, Sint16 *y, int n, Uint8 color)
 Draws a filled polygon on the surface. More...
 
void drawTexturedPolygon (Sint16 *x, Sint16 *y, int n, Surface *texture, int dx, int dy)
 Draws a textured polygon on the surface. More...
 
void drawString (Sint16 x, Sint16 y, const char *s, Uint8 color)
 Draws a string on the surface. More...
 
SDL_Color * getPalette () const
 Returns the surface's 8bpp palette. More...
 
int getX () const
 Returns the position of the surface in the X axis. More...
 
int getY () const
 Returns the position of the surface in the Y axis. More...
 
bool getVisible () const
 Gets the surface's visibility. More...
 
void resetCrop ()
 Resets the cropping rectangle for the surface. More...
 
SDL_Rect * getCrop ()
 Gets the cropping rectangle for the surface. More...
 
void setPixel (int x, int y, Uint8 pixel)
 Changes the color of a pixel in the surface, relative to the top-left corner of the surface. More...
 
void setPixelIterative (int *x, int *y, Uint8 pixel)
 Changes the color of a pixel in the surface and returns the next pixel position. More...
 
Uint8 getPixel (int x, int y) const
 Returns the color of a specified pixel in the surface. More...
 
Uint8 * getRaw (int x, int y) const
 Returns the pointer to a specified pixel in the surface. More...
 
SDL_Surface * getSurface () const
 Returns the internal SDL_Surface for SDL calls. More...
 
int getWidth () const
 Returns the width of the surface. More...
 
virtual void setWidth (int width)
 Sets the width of the surface. More...
 
int getHeight () const
 Returns the height of the surface. More...
 
virtual void setHeight (int height)
 Sets the height of the surface. More...
 
void setHidden (bool hidden)
 Sets the surface's special hidden flag. More...
 
void lock ()
 Locks the surface. More...
 
void unlock ()
 Unlocks the surface. More...
 
void blitNShade (Surface *surface, int x, int y, int shade, bool half=false, int newBaseColor=0)
 Specific blit function to blit battlescape terrain data in different shades in a fast way. More...
 
void blitNShade (Surface *surface, int x, int y, int shade, GraphSubset range)
 Specific blit function to blit battlescape terrain data in different shades in a fast way. More...
 
void invalidate (bool valid=true)
 Invalidate the surface: force it to be redrawn. More...
 
std::string getTooltip () const
 Gets the tooltip of the surface. More...
 
void setTooltip (const std::string &tooltip)
 Sets the tooltip of the surface. More...
 
virtual void setSecondaryColor (Uint8)
 Sets the secondary color of the surface.
 
virtual void setBorderColor (Uint8)
 Sets the border colour of the surface.
 
void setTFTDMode (bool mode)
 Sets this button to use a colour lookup table instead of inversion for its alternate form. More...
 
bool isTFTDMode () const
 checks if this is a TFTD mode surface. More...
 

Additional Inherited Members

- Protected Member Functions inherited from OpenXcom::InteractiveSurface
bool isButtonPressed (Uint8 button=0) const
 Is this mouse button pressed?
 
virtual bool isButtonHandled (Uint8 button=0)
 Is this mouse button event handled?
 
void setButtonPressed (Uint8 button, bool pressed)
 Set a mouse button's internal state.
 
- Protected Member Functions inherited from OpenXcom::Surface
template<typename T >
void rawCopy (const std::vector< T > &bytes)
 Copies raw pixels. More...
 
void resize (int width, int height)
 Resizes the surface. More...
 

Detailed Description

Text button with a list dropdown when pressed.

Allows selection from multiple available options.

Constructor & Destructor Documentation

◆ ComboBox()

OpenXcom::ComboBox::ComboBox ( State state,
int  width,
int  height,
int  x = 0,
int  y = 0,
bool  popupAboveButton = false 
)

Creates a combo box with the specified size and position.

Sets up a combobox with the specified size and position.

Parameters
statePointer to state the combobox belongs to.
widthWidth in pixels.
heightHeight in pixels.
xX position in pixels.
yY position in pixels.

◆ ~ComboBox()

OpenXcom::ComboBox::~ComboBox ( )

Cleans up the combo box.

Deletes all the stuff contained in the list.

Member Function Documentation

◆ blit()

void OpenXcom::ComboBox::blit ( Surface surface)
virtual

Blits the combo box onto another surface.

Blits the combo box components.

Parameters
surfacePointer to surface to blit onto.

Reimplemented from OpenXcom::Surface.

◆ getColor()

Uint8 OpenXcom::ComboBox::getColor ( ) const

Gets the border color.

Returns the color used to draw the combo box.

Returns
Color value.

◆ getSelected()

size_t OpenXcom::ComboBox::getSelected ( ) const

Gets the selected option in the list.

Returns the currently selected option.

Returns
Selected row.

◆ handle()

void OpenXcom::ComboBox::handle ( Action action,
State state 
)
virtual

Handle arrow buttons.

Passes events to internal components.

Parameters
actionPointer to an action.
stateState that the action handlers belong to.

Reimplemented from OpenXcom::InteractiveSurface.

◆ initText()

void OpenXcom::ComboBox::initText ( Font big,
Font small,
Language lang 
)
virtual

Initializes the resources for the text list.

Changes the resources for the text in the combo box.

Parameters
bigPointer to large-size font.
smallPointer to small-size font.
langPointer to current language.

Reimplemented from OpenXcom::Surface.

◆ onChange()

void OpenXcom::ComboBox::onChange ( ActionHandler  handler)

Hooks an action handler to when the slider changes.

Sets a function to be called every time the slider's value changes.

Parameters
handlerAction handler.

◆ onListMouseIn()

void OpenXcom::ComboBox::onListMouseIn ( ActionHandler  handler)

Hooks an action handler to moving the mouse in to the listbox when it is visible.

Sets a function to be called every time the mouse moves in to the listbox surface.

Parameters
handlerAction handler.

◆ onListMouseOut()

void OpenXcom::ComboBox::onListMouseOut ( ActionHandler  handler)

Hooks an action handler to moving the mouse out of the listbox when it is visible.

Sets a function to be called every time the mouse moves out of the listbox surface.

Parameters
handlerAction handler.

◆ onListMouseOver()

void OpenXcom::ComboBox::onListMouseOver ( ActionHandler  handler)

Hooks an action handler to moving the mouse over the listbox when it is visible.

Sets a function to be called every time the mouse moves over the listbox surface.

Parameters
handlerAction handler.

◆ setArrowColor()

void OpenXcom::ComboBox::setArrowColor ( Uint8  color)

Sets the arrow color of the text list.

Changes the color of the arrow buttons in the list.

Parameters
colorColor value.

◆ setBackground()

void OpenXcom::ComboBox::setBackground ( Surface bg)

Sets the background surface.

Changes the surface used to draw the background of the combo box.

Parameters
bgNew background.

◆ setColor()

void OpenXcom::ComboBox::setColor ( Uint8  color)
virtual

Sets the border color.

Changes the color used to draw the combo box.

Parameters
colorColor value.

Reimplemented from OpenXcom::Surface.

◆ setHighContrast()

void OpenXcom::ComboBox::setHighContrast ( bool  contrast)
virtual

Sets the high contrast color setting.

Enables/disables high contrast color.

Mostly used for Battlescape UI.

Parameters
contrastHigh contrast setting.

Reimplemented from OpenXcom::Surface.

◆ setOptions()

void OpenXcom::ComboBox::setOptions ( const std::vector< std::string > &  options,
bool  translate = false 
)

Sets the list of options.

Changes the list of available options to choose from.

Parameters
optionsList of strings.
translateTrue for a list of string IDs, false for a list of raw strings.

◆ setPalette()

void OpenXcom::ComboBox::setPalette ( SDL_Color *  colors,
int  firstcolor = 0,
int  ncolors = 256 
)
virtual

Sets the palette of the text list.

Replaces a certain amount of colors in the palette of all the text contained in the list.

Parameters
colorsPointer to the set of colors.
firstcolorOffset of the first color to replace.
ncolorsAmount of colors to replace.

Reimplemented from OpenXcom::Surface.

◆ setSelected()

void OpenXcom::ComboBox::setSelected ( size_t  sel)

Sets the selected option in the list.

Changes the currently selected option.

Parameters
selSelected row.

◆ setText()

void OpenXcom::ComboBox::setText ( const std::string &  text)

Sets the button text without changing the selected option.

sets the button text independent of the currently selected option.

Parameters
textthe text to display

◆ setX()

void OpenXcom::ComboBox::setX ( int  x)
virtual

Sets the X position of the surface.

Changes the position of the surface in the X axis.

Parameters
xX position in pixels.

Reimplemented from OpenXcom::Surface.

◆ setY()

void OpenXcom::ComboBox::setY ( int  y)
virtual

Sets the Y position of the surface.

Changes the position of the surface in the Y axis.

Parameters
yY position in pixels.

Reimplemented from OpenXcom::Surface.

◆ think()

void OpenXcom::ComboBox::think ( )
virtual

Thinks arrow buttons.

Passes ticks to arrow buttons.

Reimplemented from OpenXcom::Surface.

◆ toggle()

void OpenXcom::ComboBox::toggle ( bool  first = false)

Toggles the combo box state.

Opens/closes the combo box list.

Parameters
firstIs it the initialization toggle?

The documentation for this class was generated from the following files: