Slide 126
Slide 126 text
defmodule ChatApp.GUI do
# ..
.
defp build_gui(wx) do
window = :wxFrame.new(wx, -1, "Chat", size: {800, 600})
controls = :wxPanel.new(window)
chat = :wxTextCtrl.new(controls, 1, style: @multiline ||| @rich)
:wxTextCtrl.setEditable(chat, false)
bold = :wxNORMAL_FONT |> :wxe_util.get_const() |> :wxFont.new()
:wxFont.setWeight(bold, :wxe_util.get_const(:wxFONTWEIGHT_BOLD))
italic = :wxe_util.get_const(:wxITALIC_FONT)
c = "Commands:\n /listen PORT NAME\n /connect HOST PORT NAME\n /quit\n"
append_text_with_font(chat, c, italic)
form = :wxPanel.new(controls)
input = :wxTextCtrl.new(form, 2, style: @default)
button = :wxButton.new(form, 3, label: "Send")
%{
window: window
,
controls: controls
,
chat: chat
,
bold: bold
,
italic: italic
,
form: form
,
input: input
,
button: butto
n
}
end
end