WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform...

19
wxErlang Mats-Ola Persson

Transcript of WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform...

Page 1: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

wxErlangMats-Ola Persson

Page 2: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

wxErlang

•GUI library for Erlang

•write GUI applications

•cross platform

•cross platform look and feel

Page 3: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Example

• A “stupid” tic-tac-toe application

• No intelligent behavior is implemented

• Just the (good) looks

Page 4: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Creating a window

create_window() ->wx:start(), % initialize wxErlang

% create a frame (window) with no parentFrame = wx:frame(?NULL, ?wxID_ANY, “Hello World!”),

wx:show(Frame). % make the frame visible

Page 5: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Creating a window

• Not very exciting: an empty window

Page 6: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Event-driven programming

•Things “react” to mouse clicks, mouse movements, etc.

•Event-handlers, callback functions

Page 7: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Events

create_window() ->wx:start(),Frame = wx:frame(?NULL, ?wxID_ANY, “Hello World!”),

% event-handler that reacts to close clickswx:connect(Frame, ?wxEVT_CLOSE_WINDOW,

fun(_,_) -> wx:quit() end),

wx:show(Frame).

Page 8: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Layouts

•Platform independent layouts

•Sizers

•No fixed sized widgets, etc.

•Arbitrary complex layouts

•Let’s add the buttons!

Page 9: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Sizers

create_grid(Frame) -> Grid = wx:grid_sizer(3), % a grid sizer with 3 cols create_buttons(Grid, Frame, 9), % create 9 buttons Grid.create_buttons(_, _, 0) -> ok;create_buttons(Grid, Frame, N) -> Button = wx:button(Frame, N), %a button without label

wx:add(Grid, Button), % add button to the sizer create_buttons(Grid, Frame, N - 1).

Page 10: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

The result

• A “shell” of a tic-tac-toe application

Page 11: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

wxEtop

• Port of the old “etop”

• New features

• context menues

• view running code

• ...

Page 12: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

From the programmers point

of view•wxErlang is verbose - like most GUI

libraries

•Trial-and-error - like most GUI libraries

•Interface designers

•XRCed, DialogBlocks, etc.

Page 13: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Design decisions•Binding to the C++ GUI library

wxWidgets

•Get a lot for free

•“free” features from wxWidgets

•reduced maintenance work

•wxErlang interface resembles wxWidgets C++ interface

•free documentation(!)

Page 14: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Translation scheme

•Easy

•Functions

•Multiple return values => tuples

•...

•Constants

Page 15: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Translation scheme

•Not as easy

•Classes

•Overloading and overriding functions

•Type system

Page 16: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Safety

•Checks arguments

•Types

•Primitive values

•Objects

•Sanity

Page 17: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Implementational details

•Most of the code is generated from wxWidgets headers

•Implemented as a “port program”

•Has a lot of bugs

Page 18: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Wrap up

•Current status - a prototyp

•wxEtop

•Perhaps 10% implemented

•Future

Page 19: WxErlang Mats-Ola Persson. wxErlang GUI library for Erlang write GUI applications cross platform cross platform look and feel.

Questions?