20 #include "../Engine/InteractiveSurface.h" 39 static const int HORIZONTAL_MARGIN;
40 static const int VERTICAL_MARGIN;
41 static const int MAX_ITEMS;
42 static const int BUTTON_WIDTH;
43 static const int TEXT_HEIGHT;
50 ActionHandler _change;
56 bool _popupAboveButton;
59 void setDropdown(
int options);
62 ComboBox(
State *state,
int width,
int height,
int x = 0,
int y = 0,
bool popupAboveButton =
false);
70 void setPalette(SDL_Color *colors,
int firstcolor = 0,
int ncolors = 256);
89 void setText(
const std::string &text);
93 void setOptions(
const std::vector<std::string> &options,
bool translate =
false);
101 void toggle(
bool first =
false);
103 void onChange(ActionHandler handler);
void initText(Font *big, Font *small, Language *lang)
Initializes the resources for the text list.
Definition: ComboBox.cpp:147
void onListMouseOver(ActionHandler handler)
Hooks an action handler to moving the mouse over the listbox when it is visible.
Definition: ComboBox.cpp:447
void setY(int y)
Sets the Y position of the surface.
Definition: ComboBox.cpp:113
Container for all the information associated with a given user action, like mouse clicks...
Definition: Action.h:32
void setX(int x)
Sets the X position of the surface.
Definition: ComboBox.cpp:100
A game state that receives user input and reacts accordingly.
Definition: State.h:44
Box with a coloured border and custom background.
Definition: Window.h:40
void think()
Thinks arrow buttons.
Definition: ComboBox.cpp:381
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.
Definition: ComboBox.cpp:59
Surface that the user can interact with.
Definition: InteractiveSurface.h:37
void setSelected(size_t sel)
Sets the selected option in the list.
Definition: ComboBox.cpp:283
List of Text's split into columns.
Definition: TextList.h:40
size_t getHoveredListIdx() const
Gets the item that is currently hovered over in the popup list, or the current selected item if no it...
Definition: ComboBox.cpp:256
void toggle(bool first=false)
Toggles the combo box state.
Definition: ComboBox.cpp:394
void setPalette(SDL_Color *colors, int firstcolor=0, int ncolors=256)
Sets the palette of the text list.
Definition: ComboBox.cpp:132
void setArrowColor(Uint8 color)
Sets the arrow color of the text list.
Definition: ComboBox.cpp:242
Contains strings used throughout the game for localization.
Definition: Language.h:39
void setOptions(const std::vector< std::string > &options, bool translate=false)
Sets the list of options.
Definition: ComboBox.cpp:320
Text button with a list dropdown when pressed.
Definition: ComboBox.h:36
Takes care of loading and storing each character in a sprite font.
Definition: Font.h:46
Coloured button with a text label.
Definition: TextButton.h:38
Element that is blit (rendered) onto the screen.
Definition: Surface.h:38
size_t getSelected() const
Gets the selected option in the list.
Definition: ComboBox.cpp:251
void onChange(ActionHandler handler)
Hooks an action handler to when the slider changes.
Definition: ComboBox.cpp:420
Uint8 getColor() const
Gets the border color.
Definition: ComboBox.cpp:180
void onListMouseIn(ActionHandler handler)
Hooks an action handler to moving the mouse in to the listbox when it is visible. ...
Definition: ComboBox.cpp:429
void setHighContrast(bool contrast)
Sets the high contrast color setting.
Definition: ComboBox.cpp:231
void handle(Action *action, State *state)
Handle arrow buttons.
Definition: ComboBox.cpp:356
void onListMouseOut(ActionHandler handler)
Hooks an action handler to moving the mouse out of the listbox when it is visible.
Definition: ComboBox.cpp:438
void setText(const std::string &text)
Sets the button text without changing the selected option.
Definition: ComboBox.cpp:274
void setColor(Uint8 color)
Sets the border color.
Definition: ComboBox.cpp:167
void setBackground(Surface *bg)
Sets the background surface.
Definition: ComboBox.cpp:158
Definition: BaseInfoState.cpp:40
~ComboBox()
Cleans up the combo box.
Definition: ComboBox.cpp:88
void blit(Surface *surface)
Blits the combo box onto another surface.
Definition: ComboBox.cpp:338