GUI Programming CS3283

25
GUI Programming CS3283 Hugh Anderson CS3283 - Hugh Anderson’s notes. Contact information Room S15 #06-12 Telephone 6874-6903 E-mail [email protected] CS3283 - Hugh Anderson’s notes. Page number: 1

Transcript of GUI Programming CS3283

Page 1: GUI Programming CS3283

GUI ProgrammingCS3283

Hugh Anderson

CS3283 - Hugh Anderson’s notes.

Contact information

Room S15 #06-12Telephone 6874-6903E-mail [email protected]

CS3283 - Hugh Anderson’s notes. Page number: 1

Page 2: GUI Programming CS3283

BAD and GOOD

CS3283 - Hugh Anderson’s notes. Page number: 2

GUI definition

The use of pictures rather than just words to representthe input and output of a program.

A program with a GUI runs under some windowingsystem.

Original idea from research at SRI by Doug Engelbart.

CS3283 - Hugh Anderson’s notes. Page number: 3

Page 3: GUI Programming CS3283

GUI

Icons, buttons, dialogue/dialog boxes, windows on thescreen.

User controls by moving a pointer on the screen andselecting objects.

Though Apple Computer would like to claim they in-vented the GUI with their Macintosh operating system,the concept originated in the early 1970s at Xerox’sPARC laboratory.

CS3283 - Hugh Anderson’s notes. Page number: 4

Official description of CS3283

This module aims to teach the nuts and bolts of GUIprogramming. At the end of the course, students willacquire practical knowledge in Windows programmingand techniques of programming interactive systems.Topics include Windows programming, Motif, Tcl/Tkprogramming.

CS3283 - Hugh Anderson’s notes. Page number: 5

Page 4: GUI Programming CS3283

And...

✔ Graphical visualization

CS3283 - Hugh Anderson’s notes. Page number: 6

My expectation

✔ Read supporting papers, and

✔ maintain an active interest in GUI design and implemen-tation.

CS3283 - Hugh Anderson’s notes. Page number: 7

Page 5: GUI Programming CS3283

Assessment

Assessment Weighting Grade

Assignments 35%

Ass1 Group 10

Ass2 Individual 20

Ass3 Individual 40

Ass4 Group 30

Tutorials 5%

Mid-term Closed book 10%

Final Exam Open Book 50%

Total marks 100%

CS3283 - Hugh Anderson’s notes. Page number: 8

Readings...

1. My textbook, and

1. The User Interface Concepts & Design, Lon Barfield,Addison-Wesley (1993)

2. The JFC Swing Tutorial - A Guide to ConstructingGUIs, Kathy Walrath & Mary Campione, Addison-Wesley(1999)

3. Tcl and the Tk Toolkit, John K. Ousterhout, Addison-Wesley (1994)

CS3283 - Hugh Anderson’s notes. Page number: 9

Page 6: GUI Programming CS3283

Coverage

� Fundamental GUI concepts (1 lecture)� Design and programming techniques (3 lectures)� Cross platform GUI development (6 lectures)� Visualization techniques (2 lectures)

Enjoy the course!

CS3283 - Hugh Anderson’s notes. Page number: 10

Chapter 1

Module 1 - GUI concepts

CS3283 - Hugh Anderson’s notes. Page number: 11

Page 7: GUI Programming CS3283

GUI concepts

✔ Early user interfaces text based - fixed event ordering.

✔ GUI provides for complex interaction, and

✔ GUI relies on shared concepts or metaphors.

GUI programming is about the conceptualization, designand implementation of that part of a software applicationwhich is concerned with user interaction.

CS3283 - Hugh Anderson’s notes. Page number: 12

How not to do GUI

CS3283 - Hugh Anderson’s notes. Page number: 13

Page 8: GUI Programming CS3283

Two points

1. Try out your applications before delivering them.

2. Ensure that error messages are precise, and indicate thenext step.

CS3283 - Hugh Anderson’s notes. Page number: 14

How not to do GUI

CS3283 - Hugh Anderson’s notes. Page number: 15

Page 9: GUI Programming CS3283

General rules of GUI

Effective GUIs owe more to effective psychology than toeffective programming.

✔ Not just icons - includes an abstract view

✔ No clash between views

CS3283 - Hugh Anderson’s notes. Page number: 16

EZ-link

Clash between

� User view: pay afterwards

� Bus co view: pay first

CS3283 - Hugh Anderson’s notes. Page number: 17

Page 10: GUI Programming CS3283

Key points

Another key point is that humans are not equipped to handlemultiple things at one time, and this leads us to try to keepinterfaces simple and uncluttered.

Humans are particularly good at navigating systems whichhave some analogy to things they know - for example theuse of the desktop metaphor is well established and workswell in most cultures. Icons are also useful, but shouldn’t beabused.

CS3283 - Hugh Anderson’s notes. Page number: 18

Summary

1. Ensure correlation between What-u-c and What-u-think

2. KISS

3. Analogy, metaphor and icons

Always remember to include the U in GUI.

CS3283 - Hugh Anderson’s notes. Page number: 19

Page 11: GUI Programming CS3283

Do’s and don’ts

� Do follow standards� Do be predictable and responsive� Do be flexible� Don’t forget the user� Don’t forget the machine/environment� Dont assume things

CS3283 - Hugh Anderson’s notes. Page number: 20

Types of applications

Not all applications benefit from a GUI - consider embeddedsystems

However, there are areas that do benefit from a GUI:

� Immersive applications

� Office and business applications

� Interactive control systems

CS3283 - Hugh Anderson’s notes. Page number: 21

Page 12: GUI Programming CS3283

And visualization ...

In addition, a newer application area involves the use of vi-sualization to examine large data sets:

� Data mining: - delving into some set of data.

CS3283 - Hugh Anderson’s notes. Page number: 22

And WAP, PDA ...

Finally, there is the use of GUI in WAP enabled devices andon PDAs.

This is a specialist topic, which will not be covered in thiscourse.

CS3283 - Hugh Anderson’s notes. Page number: 23

Page 13: GUI Programming CS3283

MAC platform

CS3283 - Hugh Anderson’s notes. Page number: 24

MAC platform

CS3283 - Hugh Anderson’s notes. Page number: 25

Page 14: GUI Programming CS3283

MAC platform

CS3283 - Hugh Anderson’s notes. Page number: 26

X

The X window system�

is a sophisticated and well devel-oped system which allows for multimedia software and hard-ware components to be distributed around a network.

✔ At its simplest level, it allows a program and its display tobe on different computers.

The system is called X, or the X window system. UNIX weenies insist that it is notcalled X-windows!

CS3283 - Hugh Anderson’s notes. Page number: 27

Page 15: GUI Programming CS3283

X architecture

The architectural view of X is a little peculiar. The designersview the display as central to the system, and the softwarerunning on the display is called the X-server:

Clients

X display (server)

CS3283 - Hugh Anderson’s notes. Page number: 28

Components of X

1. The X server

2. The X protocol

3. X clients

4. The Window manager(s)

5. The Display manager(s)

CS3283 - Hugh Anderson’s notes. Page number: 29

Page 16: GUI Programming CS3283

Display manager

CS3283 - Hugh Anderson’s notes. Page number: 30

Display manager

or

CS3283 - Hugh Anderson’s notes. Page number: 31

Page 17: GUI Programming CS3283

Window managers

or

CS3283 - Hugh Anderson’s notes. Page number: 32

Win32

✔ Win32 is the 32 bit successor of the Win16 API

✔ Win32 is a generic name for 4 (slightly) different APIs

✔ The Win32 API on Win95 is a subset of those on WinNT,so applications written for Win95 should be portable toWinNT.

CS3283 - Hugh Anderson’s notes. Page number: 33

Page 18: GUI Programming CS3283

Using Win32

✔ The normal way for you to access Win32 functions is byusing a precompiled library from a C program.

✔ C programmers include a set of header files, and appli-cations link at run time to the Win32 DLLs.

CS3283 - Hugh Anderson’s notes. Page number: 34

API for Win9X

Has three sections:

� KERNEL: - the low level kernel services in kernel32.dll.� GDI: - Graphics Device Interface - drawing and printing

in gdi32.dll.� USER: - User Interface controls, windows and messag-

ing services in user32.dll.

CS3283 - Hugh Anderson’s notes. Page number: 35

Page 19: GUI Programming CS3283

Non-native platforms

The following systems can be used to provide a consistentenvironment that is independant of the host operating sys-tems:

� Java/Swing� Web browser interfaces� Thin client systems

CS3283 - Hugh Anderson’s notes. Page number: 36

Java

Sun Microsystem’s development of Java has always beendone with portability issues in mind.

It is relatively easy to write a portable application - for deliv-ery either as an applet in a web page, or as a standaloneapplication.

The swing windowing toolkit is the Java API for GUI devel-opment.

CS3283 - Hugh Anderson’s notes. Page number: 37

Page 20: GUI Programming CS3283

Java app

CS3283 - Hugh Anderson’s notes. Page number: 38

Web browser interfaces

✔ The first web servers provided static pages of hypertextand images.

✔ Demand led to the specification of a standard for activepage generation - CGI

CS3283 - Hugh Anderson’s notes. Page number: 39

Page 21: GUI Programming CS3283

CGI

✔ CGI specifies how to pass arguments to a program on aserver as part of the HTTP request.

✔ The program might then look up a database before gen-erating some HTML to pass back to the browser.

✔ A CGI program can be any program which can acceptcommand line arguments

✔ Perl is a common choice for writing these programs.

CS3283 - Hugh Anderson’s notes. Page number: 40

Warning

✘ You should be aware that poorly constructed CGI scriptscan result in security problems for the server, and

✘ there is normally a process overhead for each scriptstarted.

CS3283 - Hugh Anderson’s notes. Page number: 41

Page 22: GUI Programming CS3283

Other web interfaces

1. Java applets, to allow processing at the browser,

2. PHP (a server-side, cross-platform, HTML-embeddedscripting language), or

3. ASP (a scripting environment for Microsoft Internet Infor-mation Server in which you can combine HTML, scriptsand reusable ActiveX server components).

CS3283 - Hugh Anderson’s notes. Page number: 42

Thin client systems

CS3283 - Hugh Anderson’s notes. Page number: 43

Page 23: GUI Programming CS3283

Widget sets

[possibly evoking “window gadget”] In graphical userinterfaces, a combination of a graphic symbol andsome program code to perform a specific function.E.g. a scroll-bar or button. Windowing systems usu-ally provide widget libraries (sets) containing com-monly used widgets drawn in a certain style and withconsistent behaviour.

When we use different widget sets, our applications have aslightly different look-and-feel.

CS3283 - Hugh Anderson’s notes. Page number: 44

Motif application

CS3283 - Hugh Anderson’s notes. Page number: 45

Page 24: GUI Programming CS3283

Athena application

CS3283 - Hugh Anderson’s notes. Page number: 46

Widgets as components

The ICS widget databook has a series of useful widgets toextend the basic Motif set, including ones for bar graphs andso on.

CS3283 - Hugh Anderson’s notes. Page number: 47

Page 25: GUI Programming CS3283

Summary of topics

In this module, we introduced the following topics:

� Rules of GUI� Types of applications� Windowing/GUI environments� Widgets

CS3283 - Hugh Anderson’s notes. Page number: 48