# `Cauldron2D.Wx.Text`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d_wx/lib/cauldron_2d/wx/text.ex#L1)

A wx panel that draws text items on a dark canvas and hands its keys to its owner —
the screens a game puts around its worlds, drawn as a game draws them rather than
built from widgets.

    text = Cauldron2D.Wx.Text.new(frame, owner: self(), backdrop: &MyGame.Wx.stars/3)
    Cauldron2D.Wx.Text.show(text, [{{:centre, 640}, 200, "DOTS", {127, 214, 255}, :title}, {60, 300, "Enter  play", {228, 231, 243}, :big}])

An item is `{x, y, text, colour, size}` — `x` a left edge in pixels or `{:centre, x}`,
`colour` an RGB triple, `size` one of `:small`, `:normal`, `:big`, `:title` — with an
optional sixth element, an action: a click on the item's text sends the owner
`{:cauldron_wx_text, :action, action}`. The owner also receives
`{:cauldron_wx_text, :key, code}` for every key that goes down (wx key codes) and
`{:cauldron_wx_text, :char, char}` for every character typed, and draws by calling
`show/2` again.

Options: `:owner` (default the caller); `:backdrop`, a function of the DC, the width
and the height that draws behind the text, after the canvas is cleared to
`:background` (default `{5, 6, 15}`); `:fonts` — points for `:small`, `:normal`,
`:big`, `:title` (default 12, 15, 20, 48).

# `item`

```elixir
@type item() ::
  {integer() | {:centre, integer()}, integer(), String.t(),
   {byte(), byte(), byte()}, :small | :normal | :big | :title}
  | tuple()
```

# `focus`

```elixir
@spec focus(term()) :: :ok
```

Give the panel the keyboard.

# `new`

```elixir
@spec new(term(), keyword()) :: term()
```

The panel under `parent`.

# `show`

```elixir
@spec show(term(), [item()]) :: :ok
```

Draw these items from now on.

# `size`

```elixir
@spec size(term()) :: {pos_integer(), pos_integer()}
```

The canvas's size in pixels.

# `window`

```elixir
@spec window(term()) :: term()
```

The panel's wx window.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
