wxRuby Documentation Home

# Wx::StaticText

A static text control displays one or more lines of read-only text.

## Derived from

Control

Window

EvtHandler

Object

## Window styles

`ALIGN_LEFT` | Align the text to the left
`ALIGN_RIGHT` | Align the text to the right
`ALIGN_CENTRE` | Center the text (horizontally)
`ST_NO_AUTORESIZE` | By default, the control willadjust its size to exactly fit to the size of the text when set_label is called. If this style flag isgiven, the control will not change its size (this style is especially usefulwith controls which also have ALIGN_RIGHT or CENTER style because otherwisethey won’t make sense any longer after a call to SetLabel)

See also window styles overview.

## See also

StaticBitmap, StaticBox

## Methods

- StaticText.new
- StaticText#create
- StaticText#get_label
- StaticText#set_label
- StaticText#wrap

### StaticText.new

StaticText.new(%(arg-type)Window% parent, Integer id, String label, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = 0, String name = “staticText”)

Constructor, creating and showing a text control.

#### Parameters

- parent Parent window. Should not be NULL.
- id Control identifier. A value of -1 denotes a default value.
- label Text label.
- pos Window position.
- size Window size.
- style Window style. See StaticText.
- name Window name.

#### See also

StaticText#create

### StaticText#create

Boolean create(%(arg-type)Window% parent, Integer id, String label, Point pos = DEFAULT_POSITION, Size size = DEFAULT_SIZE, Integer style = 0, String name = “staticText”)

Creation function, for two-step construction. For details see StaticText.new.

### StaticText#get_label

String get_label()

Returns the contents of the control.

### StaticText#set_label

set_label(%(arg-type)String% label)

Sets the static text label and updates the controls size to exactly fit the
label unless the control has ST_NO_AUTORESIZE flag.

#### Parameters

- label The new label to set. It may contain newline characters.

### StaticText#wrap

wrap(%(arg-type)Integer% width)

This functions wraps the controls label so that each of its lines becomes at
most width pixels wide if possible (the lines are broken at words
boundaries so it might not be the case if words are too long). If width
is negative, no wrapping is done.

2.6.2

[This page automatically generated from the Textile source at 2023-06-09 00:45:33 +0000]