Countdown Alarm Clock. GUI Programming with wxhaskell. Widgets used. UI Creation Code. Wei Tan <wlta543@cse.unsw.edu.au>



Similar documents
Building GUIs in Haskell

DNNCentric Custom Form Creator. User Manual

INTRODUCTION TO ATRIUM... 2 SYSTEM REQUIREMENTS... 2 TECHNICAL DETAILS... 2 LOGGING INTO ATRIUM... 3 SETTINGS... 4 NAVIGATION PANEL...

INTRODUCTION TO DESKTOP PUBLISHING

Creating forms in Microsoft Access 2007

Unified Monitoring Portal Online Help Dashboard Designer

KIVY - A Framework for Natural User Interfaces

Basic Excel Handbook

The Microsoft Access 2007 Screen

Microsoft Office PowerPoint Creating a new presentation from a design template. Creating a new presentation from a design template

Working with the new enudge responsive styles

Instructions for Formatting MLA Style Papers in Microsoft Word 2010

Guide to SAS/AF Applications Development

Microsoft Publisher 2010 What s New!

Debugging JavaScript and CSS Using Firebug. Harman Goei CSCI 571 1/27/13

How to create labels using a Microsoft Access data file?

Mobile Web Design with HTML5, CSS3, JavaScript and JQuery Mobile Training BSP-2256 Length: 5 days Price: $ 2,895.00

Rapid Application Development with GNOME and Python

DIRECTIONS FOR SETTING UP LABELS FOR MARCO S INSERT STOCK IN WORD PERFECT, MS WORD AND ACCESS

Ulf Hermann. October 8, 2014 / Qt Developer Days The Qt Company. Using The QML Profiler. Ulf Hermann. Why? What? How To. Examples.

How to create a Flash banner advert in DrawPlus X2

Using Adobe Dreamweaver CS4 (10.0)

5.1 Features Denver CO 80202

Microsoft Office 2010 Publisher

Interactive Highway Safety Design Model (IHSDM) Running IHSDM Software Manual

Form Builder Manual. A brief overview of your website s Form Builder with screenshots.

MicroStrategy Analytics Express User Guide

MS Word 2007 practical notes

SalesPad for Dynamics GP Dashboard Designer and Viewer

Specialized Android APP Development Program with Java (SAADPJ) Duration 2 months

Microsoft Access GUI Building

Visual Basic. murach's TRAINING & REFERENCE

Create PDF invoice in Windows Forms application. Written by Apitron Documentation Team

Instructions for Formatting APA Style Papers in Microsoft Word 2010

Sitecore Dashboard User Guide

WEB DESIGN BASICS WITH ADOBE MUSE Cordei Clottey, IT-Trainer

Introduction to Microsoft PowerPoint

Dashcode User Guide. (Retired Document)

Making an online form in Serif WebPlus

caqtdm Tutorial Jim Stevens APS Controls Group October 9, 2014

Advanced Word for Windows

Mensch-Maschine-Interaktion 1. Chapter 8 (June 21st, 2012, 9am-12pm): Implementing Interactive Systems

Publisher 2010 Cheat Sheet

The Technology Behind a Graphical User Interface for an Equational Reasoning Assistant

Create a Poster Using Publisher

Creating Web Pages with HTML Simplified. 3rd Edition

ANDROID INTRODUCTION TO ANDROID

Tutorial : Getting Started with Movicon 11 Cod. DOCS 11 TUT-E Build 1010

Entering the example employee satisfaction survey in Survey Crafter Professional s Survey Designer window

CREATING FORMAL REPORT. using MICROSOFT WORD. and EXCEL

Polynomial Neural Network Discovery Client User Guide

Tutorial 2: Using Excel in Data Analysis

Building Applications With DUIM

Introduction to Microsoft Word 2008

Business Objects Version 5 : Introduction

Spreadsheet. Parts of a Spreadsheet. Entry Bar

DataPA OpenAnalytics End User Training

CHAPTER 6: SEARCHING AN ONLINE DATABASE

Designing a poster. Big is important. Poster is seldom linear, more like a MindMap. The subjects belonging together are located close to each other.

Create and Print Your Own Greeting Cards

Database Forms and Reports Tutorial

ios App for Mobile Website! Documentation!

Microsoft Word 2010 Prepared by Computing Services at the Eastman School of Music July 2010

8 CREATING FORM WITH FORM WIZARD AND FORM DESIGNER

Lesson 07: MS ACCESS - Handout. Introduction to database (30 mins)

INDUSTRIAL AUTOMATION Interactive Graphical SCADA System INSIGHT AND OVERVIEW. IGSS Online Training. Exercise 8: Creating Templates

KB COPY CENTRE. RM 2300 JCMB The King s Buildings West Mains Road Edinburgh EH9 3JZ. Telephone:

CaptainCasa. CaptainCasa Enterprise Client. CaptainCasa Enterprise Client. Feature Overview

Creating Basic Reports with the SAP Query Tool

Engineering Problem Solving and Excel. EGN 1006 Introduction to Engineering

TakeMySelfie ios App Documentation

ECDL. European Computer Driving Licence. Spreadsheet Software BCS ITQ Level 2. Syllabus Version 5.0

Publisher 2007: Part 2 Advanced Features. Grouped Objects in Publisher:

Shipment Label Header Guide

To Begin Customize Office

6. If you want to enter specific formats, click the Format Tab to auto format the information that is entered into the field.

Creating an Access Database. To start an Access Database, you should first go into Access and then select file, new.

GUIDELINES FOR PREPARING POSTERS USING POWERPOINT PRESENTATION SOFTWARE

Avigilon Control Center Web Client User Guide

Information Exchange Network (IEN) System Operator Training Day 3

San Joaquin County Office of Education Career & Technical Education Web Design ~ Course Outline CBEDS#: 4601

Excel 2003 A Beginners Guide

Expanded contents. Section 1. Chapter 2. The essence off ASP.NET web programming. An introduction to ASP.NET web programming

Sample Table. Columns. Column 1 Column 2 Column 3 Row 1 Cell 1 Cell 2 Cell 3 Row 2 Cell 4 Cell 5 Cell 6 Row 3 Cell 7 Cell 8 Cell 9.

Introduction to ROOT and data analysis

PDF Web Form. Projects 1

Welcome! Nice to see you.

Excel 2007 Basic knowledge

Excel 2007 A Beginners Guide

Lecture 1 Introduction to Android

STC: Descriptive Statistics in Excel Running Descriptive and Correlational Analysis in Excel 2013

ECDL / ICDL Spreadsheets Syllabus Version 5.0

GCSE Database Projects in Access

CAPITAL V8. Capital Business Software Tutorial Series. Introduction to Capital Business Manager V8 User Interface 1.2

Transcription:

Countdown Alarm Clock GUI Programming with wxhaskell Wei Tan <wlta543@cse.unsw.edu.au> Widgets used UI Creation Code Frame Menu StaticText -- create main window & container for widgets f <- frame [text := Countdown Watch, clientsize := sz 300 200] panel <- panel f [] -- create menu timermenu <- menupane [text := &Timer ] tstart <- menuitem timermenu [text := &Start ] quit <- menuquit timermenu [help := Quit ] -- labels timelabel <- statictext panel [text := Time:, fontweight := WeightBold] Panel SpinCtrl Button -- spin control sec <- spinctrl panel 0 59 [outersize := sz 35 20] 1

UI Creation Code (cont d) -- start/cancel button startbtn <- button panel [text := Start ] set startbtn <- [on command := setalarm f startbtn hr min sec] -- layout set f [layout := column 1 $ [hfill $ hrule 1 -- ruler to separate menu from panel,fill $ container panel $ margin 10 $ column 10 [hfill $ row 1 -- current time [widget timelabel, glue, widget timestatic],,hfill $ row 1 -- set alarm interval spinctrl s [widget intvlabel, glue, widget hr, label :,.,floatbottomright $ widget startbtn]]] -- start button What is wxhaskell and what s so good about it? Haskell binding for wxwidgets wxwidgets is a cross-platform GUI library written in C++. Mature, extensive, actively being developed. supports 75% of wxwidgets functionality wxhaskell is a medium-level library it offers simple functional bindings + higher level abstraction (really neat) Why use wxhaskell? Rapid prototyping Commercial applications Multi-platform support, native look-and-feel Integrate with existing Haskell code Because we can Tour of wxhaskell Packages Controls Types & Inheritance Events Attributes and Properties Layout Miscellaneous Db, Timer, Var, OpenGL 2

wxhaskell Packages Graphics.UI.WXCore Lower level interface to wxwidgets library Almost one-to-one mapping between C++ and Haskell Graphics.UI.WX Built on top of WXCore Provides nice functional abstraction (attributes, layout combinators, etc.) p <- panel [] Controls txt <- textentry p AlignLeft [text := your name here ] cb <- combobox p true [ NSW, ACT, VIC, WA ] [] rd <- radiobox p Horizontal [ one, two ] [on select := logselection] Other widgets: Gauge, Choice, ListBox, Slider, TreeCtrl, SplitterWindow, Toolbar Types & Inheritance Encodes inheritance relationship between different widget types using ADT Object (Ptr) -... - Window - Frame - Control - Button - RadioBox Button a === Ptr (... (CWindow (CControl (CButton a)))...) Attributes I We can control various attributes of widgets, e.g. caption, colour, font, size, etc. But what attributes can I use on which widget? Attributes are organized into Haskell classes Types of widgets instantiate appropriate classes Inherit instance definitions from parent types 3

Attributes II Type Frame a = Window (CFrame a) Frame a instantiates HasImage, Form, Closable, and everything that Window instantiates Window a instantiates Textual,Literate,Dimensions,... The HasImage class defines the image attribute, Textual class defines the text attribute. So, we can: f <- frame [] set f [text := Window Title, image := /some/image.ico ] Events Organized into Haskell classes (like Attr) A widget that instantiates an event class means it can receive events of that class. Event handlers can be defined by turning it into an attribute using the on function: paint :: (Paint w) => Event w (DC () -> Rect -> IO ()) Window is an instance of Paint, so we can define our own paint routine for all window types (including buttons and text boxes). set f [on paint := drawobjects] Attributes and Properties Attributes are turned in Properties with (:=) Prop (Button a) Prop (Button a) / \ / \ set btn [text := Stop, on command := dosomething] Attr String Event IO () (Button a) (Button a) String (IO ()) set :: forall w. w -> [Prop w] -> IO () (:=) :: forall w a. Attr w a -> a -> Prop w on :: forall a w. Event w a -> Attr w a Layout Manages the positioning and sizing of widgets within a container widget wxhaskell uses layout combinators which allows a more declarative style of specifying layout The return type of a layout combinator is always Layout It may take other arguments, often another Layout Allows precise control of behavior when window is resized (or to prevent resizing) Types of layout combinators: layouts (widgets, containers, glue, spacers) and transformers (stretch, expand, margin, alignment) 4

Layout examples set f [layout := column 1 $ [hfill $ hrule 1 -- ruler to separate menu from panel,fill $ container panel $ margin 10 $ column 10 [hfill $ row 1 -- current time [widget timelabel, glue, widget timestatic],,hfill $ row 1 -- set alarm interval spinctrl s [widget intvlabel, glue, widget hr, label :,.,floatbottomright $ widget startbtn]]] -- start button HPView Assignment: Heap Profile Viewer for GHC profiling output. Similar to hp2ps utility, but interactive. Draws a lot of lines so the mathematical model of Haskell helps. Screenshot Round up wxhaskell is great! script-like GUI creation, speeds up development no need to declare variables in IO monad, types deduced automatically (no need to keep track of intermediate objects) uniform interface for getting/setting properties closure for passing vars to event handlers, no special handling of void * data! HPView screenshot at Milestone2 5