OpenXcom
1.0
Open-source clone of the original X-Com
|
List of Text's split into columns. More...
#include <TextList.h>
Public Member Functions | |
TextList (int width, int height, int x=0, int y=0) | |
Creates a text list with the specified size and position. More... | |
~TextList () | |
Cleans up the text list. 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... | |
int | getArrowsLeftEdge () |
Gets the arrowsLeftEdge. More... | |
int | getArrowsRightEdge () |
Gets the arrowsRightEdge. More... | |
void | unpress (State *state) |
Unpresses the surface. More... | |
void | setCellColor (size_t row, size_t column, Uint8 color) |
Sets the text color of a certain cell. More... | |
void | setRowColor (size_t row, Uint8 color) |
Sets the text color of a certain row. More... | |
std::wstring | getCellText (size_t row, size_t column) const |
Gets the text of a certain cell. More... | |
void | setCellText (size_t row, size_t column, const std::wstring &text) |
Sets the text of a certain cell. More... | |
int | getColumnX (size_t column) const |
Gets the X position of a certain column. More... | |
int | getRowY (size_t row) const |
Gets the Y position of a certain row. More... | |
size_t | getTexts () const |
Gets the amount of text in the list. More... | |
size_t | getRows () const |
Gets the amount of rows in the list. More... | |
size_t | getVisibleRows () const |
Gets the amount of visible rows in the list. More... | |
void | addRow (int cols,...) |
Adds a new row to the text list. More... | |
void | setColumns (int cols,...) |
Sets the columns in the text list. 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 | setHeight (int height) |
Sets the height of the surface. More... | |
void | setColor (Uint8 color) |
Sets the text color of the text list. More... | |
Uint8 | getColor () const |
Gets the text color of the text list. More... | |
void | setSecondaryColor (Uint8 color) |
Sets the secondary color of the text list. More... | |
Uint8 | getSecondaryColor () const |
Gets the secondary color of the text list. More... | |
void | setWordWrap (bool wrap) |
Sets the text list's wordwrap setting. More... | |
void | setHighContrast (bool contrast) |
Sets the text list's high contrast color setting. More... | |
void | setAlign (TextHAlign align, int col=-1) |
Sets the text horizontal alignment of the text list. More... | |
void | setDot (bool dot) |
Sets whether to separate columns with dots. More... | |
void | setSelectable (bool selectable) |
Sets whether the list is selectable. More... | |
void | setBig () |
Sets the text size to big. More... | |
void | setSmall () |
Sets the text size to small. More... | |
void | setCondensed (bool condensed) |
Sets whether to condense columns instead of a table like layout. More... | |
void | setBackground (Surface *bg) |
Sets the background for the selector. More... | |
int | getSelectedRow () const |
Gets the selected row in the list. More... | |
void | setMargin (int margin) |
Sets the margin of the text list. More... | |
int | getMargin () const |
Gets the margin of the text list. More... | |
void | setArrowColor (Uint8 color) |
Sets the arrow color of the text list. More... | |
void | setArrowColumn (int pos, ArrowOrientation type) |
Sets the arrow column of the text list. More... | |
void | onLeftArrowClick (ActionHandler handler) |
Hooks an action handler to a mouse click on the left arrows. More... | |
void | onLeftArrowPress (ActionHandler handler) |
Hooks an action handler to a mouse press over the left arrows. More... | |
void | onLeftArrowRelease (ActionHandler handler) |
Hooks an action handler to a mouse release over the left arrows. More... | |
void | onRightArrowClick (ActionHandler handler) |
Hooks an action handler to a mouse click on the right arrows. More... | |
void | onRightArrowPress (ActionHandler handler) |
Hooks an action handler to a mouse press over the right arrows. More... | |
void | onRightArrowRelease (ActionHandler handler) |
Hooks an action handler to a mouse release over the right arrows. More... | |
void | clearList () |
Clears the list. More... | |
void | scrollUp (bool toMax, bool scrollByWheel=false) |
Scrolls the list up. More... | |
void | scrollDown (bool toMax, bool scrollByWheel=false) |
Scrolls the list down. More... | |
void | setScrolling (bool scrolling, int scrollPos=4) |
Sets the list scrolling. More... | |
void | draw () |
Draws the text onto the text list. More... | |
void | blit (Surface *surface) |
Blits the text list onto another surface. More... | |
void | think () |
Thinks arrow buttons. More... | |
void | handle (Action *action, State *state) |
Handles arrow buttons. More... | |
void | mousePress (Action *action, State *state) |
Special handling for mouse presses. More... | |
void | mouseRelease (Action *action, State *state) |
Special handling for mouse releases. | |
void | mouseClick (Action *action, State *state) |
Special handling for mouse clicks. More... | |
void | mouseOver (Action *action, State *state) |
Special handling for mouse hovering. More... | |
void | mouseOut (Action *action, State *state) |
Special handling for mouse hovering out. More... | |
size_t | getScroll () |
get the scroll depth | |
void | scrollTo (size_t scroll) |
set the scroll depth | |
void | setComboBox (ComboBox *comboBox) |
Attaches this button to a combobox. More... | |
ComboBox * | getComboBox () const |
Check for a combobox. 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... | |
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 | mouseIn (Action *action, State *state) |
Processes a mouse hover in 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 | 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 () |
Clears the surface's contents. 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 | invert (Uint8 mid) |
Inverts the surface's colors. 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... | |
void | setVisible (bool visible) |
Sets the surface's visibility. 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... | |
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... | |
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 off, bool half=false, int newBaseColor=0) |
Specific blit function to blit battlescape terrain data in different shades in a fast way. More... | |
void | invalidate () |
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... | |
Additional Inherited Members | |
Protected Member Functions inherited from OpenXcom::InteractiveSurface | |
bool | isButtonPressed (Uint8 button=0) |
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 | |
void | resize (int width, int height) |
Recreates the surface with a new size. More... | |
List of Text's split into columns.
Contains a set of Text's that are automatically lined up by rows and columns, like a big table, making it easy to manage them together.
OpenXcom::TextList::TextList | ( | int | width, |
int | height, | ||
int | x = 0 , |
||
int | y = 0 |
||
) |
Creates a text list with the specified size and position.
Sets up a blank list with the specified size and position.
width | Width in pixels. |
height | Height in pixels. |
x | X position in pixels. |
y | Y position in pixels. |
OpenXcom::TextList::~TextList | ( | ) |
Cleans up the text list.
Deletes all the stuff contained in the list.
void OpenXcom::TextList::addRow | ( | int | cols, |
... | |||
) |
|
virtual |
Blits the text list onto another surface.
Blits the text list and selector.
surface | Pointer to surface to blit onto. |
Reimplemented from OpenXcom::Surface.
void OpenXcom::TextList::clearList | ( | ) |
Clears the list.
Removes all the rows currently stored in the list.
|
virtual |
Draws the text onto the text list.
Draws the text list and all the text contained within.
Reimplemented from OpenXcom::Surface.
int OpenXcom::TextList::getArrowsLeftEdge | ( | ) |
Gets the arrowsLeftEdge.
int OpenXcom::TextList::getArrowsRightEdge | ( | ) |
Gets the arrowsRightEdge.
std::wstring OpenXcom::TextList::getCellText | ( | size_t | row, |
size_t | column | ||
) | const |
Uint8 OpenXcom::TextList::getColor | ( | ) | const |
Gets the text color of the text list.
Returns the color of the text in the list.
int OpenXcom::TextList::getColumnX | ( | size_t | column | ) | const |
Gets the X position of a certain column.
Returns the X position of a specific text column in the list.
column | Column number. |
ComboBox * OpenXcom::TextList::getComboBox | ( | ) | const |
Check for a combobox.
Gets the combobox that this list is attached to, if any.
int OpenXcom::TextList::getMargin | ( | ) | const |
Gets the margin of the text list.
Returns the margin of the text in the list.
size_t OpenXcom::TextList::getRows | ( | ) | const |
Gets the amount of rows in the list.
Returns the amount of physical rows stored in the list.
int OpenXcom::TextList::getRowY | ( | size_t | row | ) | const |
Gets the Y position of a certain row.
Returns the Y position of a specific text row in the list.
row | Row number. |
Uint8 OpenXcom::TextList::getSecondaryColor | ( | ) | const |
Gets the secondary color of the text list.
Returns the secondary color of the text in the list.
int OpenXcom::TextList::getSelectedRow | ( | ) | const |
Gets the selected row in the list.
Returns the currently selected row if the text list is selectable.
size_t OpenXcom::TextList::getTexts | ( | ) | const |
Gets the amount of text in the list.
Returns the amount of text rows stored in the list.
size_t OpenXcom::TextList::getVisibleRows | ( | ) | const |
Gets the amount of visible rows in the list.
Returns the amount of visible rows stored in the list.
Handles arrow buttons.
Passes events to arrow buttons.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Initializes the resources for the text list.
Changes the resources for the text in the list and calculates the selector and visible amount of rows.
big | Pointer to large-size font. |
small | Pointer to small-size font. |
lang | Pointer to current language. |
Reimplemented from OpenXcom::Surface.
Special handling for mouse clicks.
Ignores any mouse clicks that aren't on a row.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Special handling for mouse hovering out.
Deselects the row.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Special handling for mouse hovering.
Selects the row the mouse is over.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
Special handling for mouse presses.
Ignores any mouse clicks that aren't on a row.
action | Pointer to an action. |
state | State that the action handlers belong to. |
Reimplemented from OpenXcom::InteractiveSurface.
void OpenXcom::TextList::onLeftArrowClick | ( | ActionHandler | handler | ) |
Hooks an action handler to a mouse click on the left arrows.
Sets a function to be called every time the left arrows are mouse clicked.
handler | Action handler. |
void OpenXcom::TextList::onLeftArrowPress | ( | ActionHandler | handler | ) |
Hooks an action handler to a mouse press over the left arrows.
Sets a function to be called every time the left arrows are mouse pressed.
handler | Action handler. |
void OpenXcom::TextList::onLeftArrowRelease | ( | ActionHandler | handler | ) |
Hooks an action handler to a mouse release over the left arrows.
Sets a function to be called every time the left arrows are mouse released.
handler | Action handler. |
void OpenXcom::TextList::onRightArrowClick | ( | ActionHandler | handler | ) |
Hooks an action handler to a mouse click on the right arrows.
Sets a function to be called every time the right arrows are mouse clicked.
handler | Action handler. |
void OpenXcom::TextList::onRightArrowPress | ( | ActionHandler | handler | ) |
Hooks an action handler to a mouse press over the right arrows.
Sets a function to be called every time the right arrows are mouse pressed.
handler | Action handler. |
void OpenXcom::TextList::onRightArrowRelease | ( | ActionHandler | handler | ) |
Hooks an action handler to a mouse release over the right arrows.
Sets a function to be called every time the right arrows are mouse released.
handler | Action handler. |
void OpenXcom::TextList::scrollDown | ( | bool | toMax, |
bool | scrollByWheel = false |
||
) |
Scrolls the list down.
Scrolls the text in the list down by one row or to the bottom.
toMax | If true then scrolls to the bottom of the list. false => one row down |
scrollByWheel | If true then use wheel scroll, otherwise scroll normally. |
void OpenXcom::TextList::scrollUp | ( | bool | toMax, |
bool | scrollByWheel = false |
||
) |
Scrolls the list up.
Scrolls the text in the list up by one row or to the top.
toMax | If true then scrolls to the top of the list. false => one row up |
scrollByWheel | If true then use wheel scroll, otherwise scroll normally. |
void OpenXcom::TextList::setAlign | ( | TextHAlign | align, |
int | col = -1 |
||
) |
Sets the text horizontal alignment of the text list.
Changes the horizontal alignment of the text in the list.
This doesn't change the alignment of existing text, just the alignment of text added from then on.
align | Horizontal alignment. |
col | the column to set the alignment for (defaults to -1, meaning "all") |
void OpenXcom::TextList::setArrowColor | ( | Uint8 | color | ) |
Sets the arrow color of the text list.
Changes the color of the arrow buttons in the list.
color | Color value. |
void OpenXcom::TextList::setArrowColumn | ( | int | pos, |
ArrowOrientation | type | ||
) |
Sets the arrow column of the text list.
Sets the position of the column of arrow buttons in the text list.
pos | X in pixels (-1 to disable). |
type | Arrow orientation type. |
void OpenXcom::TextList::setBackground | ( | Surface * | bg | ) |
Sets the background for the selector.
Changes the surface used to draw the background of the selector.
bg | New background. |
void OpenXcom::TextList::setBig | ( | ) |
Sets the text size to big.
Changes the text list to use the big-size font.
void OpenXcom::TextList::setCellColor | ( | size_t | row, |
size_t | column, | ||
Uint8 | color | ||
) |
void OpenXcom::TextList::setCellText | ( | size_t | row, |
size_t | column, | ||
const std::wstring & | text | ||
) |
void OpenXcom::TextList::setColor | ( | Uint8 | color | ) |
Sets the text color of the text list.
Changes the color of the text in the list.
This doesn't change the color of existing text, just the color of text added from then on.
color | Color value. |
void OpenXcom::TextList::setColumns | ( | int | cols, |
... | |||
) |
Sets the columns in the text list.
Changes the columns that the list contains.
While rows can be unlimited, columns need to be specified since they can have various widths for lining up the text.
cols | Number of columns. |
... | Width of each column. |
void OpenXcom::TextList::setComboBox | ( | ComboBox * | comboBox | ) |
Attaches this button to a combobox.
Hooks up the button to work as part of an existing combobox, updating the selection when it's pressed.
comboBox | Pointer to combobox. |
void OpenXcom::TextList::setCondensed | ( | bool | condensed | ) |
Sets whether to condense columns instead of a table like layout.
If enabled, the columns will match the text width.
Otherwise, they will have a fixed width.
condensed | True for condensed layout, False for table layout. |
void OpenXcom::TextList::setDot | ( | bool | dot | ) |
Sets whether to separate columns with dots.
If enabled, the text in different columns will be separated by dots.
Otherwise, it will only be separated by blank space.
dot | True for dots, False for spaces. |
|
virtual |
Sets the height of the surface.
Changes the height of the text list.
height | New height in pixels. |
Reimplemented from OpenXcom::Surface.
void OpenXcom::TextList::setHighContrast | ( | bool | contrast | ) |
Sets the text list's high contrast color setting.
Enables/disables high contrast color.
Mostly used for Battlescape text.
contrast | High contrast setting. |
void OpenXcom::TextList::setMargin | ( | int | margin | ) |
Sets the margin of the text list.
Changes the horizontal margin placed around the text.
margin | Margin in pixels. |
|
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.
colors | Pointer to the set of colors. |
firstcolor | Offset of the first color to replace. |
ncolors | Amount of colors to replace. |
Reimplemented from OpenXcom::Surface.
void OpenXcom::TextList::setRowColor | ( | size_t | row, |
Uint8 | color | ||
) |
Sets the text color of a certain row.
Changes the text color of a whole row in the list.
row | Row number. |
color | Text color. |
void OpenXcom::TextList::setScrolling | ( | bool | scrolling, |
int | scrollPos = 4 |
||
) |
Sets the list scrolling.
Changes whether the list can be scrolled.
scrolling | True to allow scrolling, false otherwise. |
scrollPos | Custom X position for the scroll buttons. |
void OpenXcom::TextList::setSecondaryColor | ( | Uint8 | color | ) |
Sets the secondary color of the text list.
Changes the secondary color of the text in the list.
color | Color value. |
void OpenXcom::TextList::setSelectable | ( | bool | selectable | ) |
Sets whether the list is selectable.
If enabled, the list will respond to player input, highlighting selected rows and receiving clicks.
selectable | Selectable setting. |
void OpenXcom::TextList::setSmall | ( | ) |
Sets the text size to small.
Changes the text list to use the small-size font.
void OpenXcom::TextList::setWordWrap | ( | bool | wrap | ) |
Sets the text list's wordwrap setting.
Enables/disables text wordwrapping.
When enabled, rows can take up multiple lines of the list, otherwise every row is restricted to one line.
wrap | Wordwrapping setting. |
|
virtual |
Sets the X position of the surface.
Changes the position of the surface in the X axis.
x | X position in pixels. |
Reimplemented from OpenXcom::Surface.
|
virtual |
Sets the Y position of the surface.
Changes the position of the surface in the Y axis.
y | Y position in pixels. |
Reimplemented from OpenXcom::Surface.
|
virtual |
|
virtual |
Unpresses the surface.
Unpresses all the arrow buttons.
state | Pointer to running state. |
Reimplemented from OpenXcom::InteractiveSurface.