Ras Bodik CS 164 (Fall 2004) 1 A Small GUI Language.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

Chapter 3 – Web Design Tables & Page Layout
Event Driven Programming and GUIs Part 3 CS221 – 4/15/09.
9/27/2006Prof. Hilfinger, Lecture 141 Syntax-Directed Translation Lecture 14 (adapted from slides by R. Bodik)
1 Programming for Engineers in Python Autumn Lecture 5: Object Oriented Programming.
Tutorial 6 & 7 Symbol Table
Prof. Bodik CS 164 Lecture 11 Introduction to Programming Languages and Compilers CS164 3:30-5:00 TT 10 Evans.
Chapter 3 Program translation1 Chapt. 3 Language Translation Syntax and Semantics Translation phases Formal translation models.
 2008 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Cs164 Prof. Bodik, Fall Symbol Tables and Static Checks Lecture 14.
Creating Web Page Forms
CSC 8310 Programming Languages Meeting 2 September 2/3, 2014.
Graphical User Interfaces in Haskell Koen Lindström Claessen.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
Chapter 5 Java Script And Forms JavaScript, Third Edition.
ACM/JETT Workshop - August 4-5, ExceptionHandling and User Interfaces (Event Delegation, Inner classes) using Swing.
Prof. Bodik CS 164 Lecture 51 Building a Parser I CS164 3:30-5:00 TT 10 Evans.
Using the API. Learning Objectives By the end of this lecture, you should be able to: – Identify what is meant by an ‘API’ – Know how to look up functions.
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Object Oriented Analysis & Design & UML (Unified Modeling Language)1 Part V: Design The Design Workflow Design Classes Refining Analysis Relationships.
Designing Interface Components. Components Navigation components - the user uses these components to give instructions. Input – Components that are used.
GUI Widgets Jeff Offutt SWE 432 Design and Implementation of Software for the Web.
1 Semantic Analysis Aaron Bloomfield CS 415 Fall 2005.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Object Oriented Programming with C++/ Session 6 / 1 of 44 Multiple Inheritance and Polymorphism Session 6.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
Chapter 13. Procedural programming vs OOP  Procedural programming focuses on accomplishing tasks (“verbs” are important).  Object-oriented programming.
XHTML 1.1  Derived from Standard Generalized Markup Language (SGML) of ISO  XHTML concerned primary with content rather than presentation and style 
Windows and frames and the anchor tag. Frames Independent, scrollable portions of a Web browser window, with each frame capable of containing its own.
Table Row Table Data ( Header & Data) Data Cell Padding TABLE.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Ch 3-4: GUI Basics Java Software Solutions Foundations of Program Design Sixth Edition by Lewis & Loftus Coming up: GUI Components.
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Computing Science 1P Lecture 17: Friday 23 rd February Simon Gay Department of Computing Science University of Glasgow 2006/07.
COP4020 Programming Languages Names, Scopes, and Bindings Prof. Xin Yuan.
BA Team: Product Ownership, Analysis, and Solution Design BA Bi-Weekly Mini-meeting May 19, Acceptance Criteria Defining Success one Story.
C++ and Ubuntu Linux Review and Practice CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
Topic #1: Introduction EE 456 – Compiling Techniques Prof. Carl Sable Fall 2003.
Chapter 4 Introduction to Classes, Objects, Methods and strings
Forms Collecting Data CSS Class 5. Forms Create a form Add text box Add labels Add check boxes and radio buttons Build a drop-down list Group drop-down.
Oct 021 Outline What is a widget? Buttons Combo boxes Text components Message boxes.
CSE 413 Languages & Implementation Hal Perkins Autumn 2012 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
Methods Methods are how we implement actions – actions that objects can do, or actions that can be done to objects. In Alice, we have methods such as move,
Java Software Solutions Lewis and Loftus Chapter 9 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Enhanced Class Design -- Introduction.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 10 – C: the heap and manual memory management.
HTML Forms.
Graphical User Interfaces Tonga Institute of Higher Education.
Word Create a basic TOC. Course contents Overview: table of contents basics Lesson 1: About tables of contents Lesson 2: Format your table of contents.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
1 UMBC CMSC 104, Section Fall 2002 Functions, Part 1 of 3 Topics Top-down Design The Function Concept Using Predefined Functions Programmer-Defined.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
ANDROID LAYOUTS AND WIDGETS. Slide 2 Introduction Parts of the Android screen Sizing widgets and fonts Layouts and their characteristics Buttons, checkboxes.
LECTURE 10 Semantic Analysis. REVIEW So far, we’ve covered the following: Compilation methods: compilation vs. interpretation. The overall compilation.
3 Introduction to Classes and Objects.
Learning to Program D is for Digital.
“Form Ever Follows Function” Louis Henri Sullivan
Introduction to Parsing (adapted from CS 164 at Berkeley)
Objectives Design a form Create a form Create text fields
CS 536 / Fall 2017 Introduction to programming languages and compilers
Tkinter GUIs Computer Science and Software Engineering
Syntax-Directed Translation
Packages and Interfaces
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)
Topics Graphical User Interfaces Using the tkinter Module
Presentation transcript:

Ras Bodik CS 164 (Fall 2004) 1 A Small GUI Language

Ras Bodik CS 164 (Fall 2004) 2 Administrivia PA5: –due Thu Dec 9 –if you’ve ran out of late days, you can still submit late, with a penalty of 10%/day –submit not later than Sunday Dec 12 PA6: –due Monday, Dec 13 –your test cases may be selected as benchmarks to declare the winner –winner to be declared at the final exam

Ras Bodik CS 164 (Fall 2004) 3 Lecture Outline Follow-up to Dave’s lecture –a do-it-yourself language for GUI programming –design and implementation –from Fall 2003 final exam (design was given) –see the exam for more details on this language HKN Course Survey –with a few curious questions from me

Ras Bodik CS 164 (Fall 2004) 4 The problem Problem: –we have a GUI library –happy with its functionality –but client programs are too tedious to write –clients contain repetitive code  opportunity! Solution: –design a small language –a declarative language (state what, not how) –a simple, convenient layer over a complicated library –client programs will be concise, easy to develop

Ras Bodik CS 164 (Fall 2004) 5 What is GUI programming? 1.creating windows, menus 2.linking them to actions in client code our example language will take care of only the first

Ras Bodik CS 164 (Fall 2004) 6 A hypothetical GUI library Key elements: –widgets label (text) dialog box (for entering strings) button (such as Cancel) selection button (select zero or more options) radio buttons (select exactly one of multiple options) –windows contain widgets and (nested) windows content organized in rows an optional window title

Ras Bodik CS 164 (Fall 2004) 7 An example window Two windows nested in their parent window. The left window contains selection buttons; the right window contains radio buttons. three widgets: a text, a dialog box, and a button. Top-level window.

Ras Bodik CS 164 (Fall 2004) 8 Client code for the example window // the constructor's argument is always the parent window; Window top = new Window(null); // top-level window is parentless top.setTitle(``Find''); // The first row of the top-level window Text t = new Text(top); t.setPosition(0,0); // sets position within the parent window, given as x,y coord. // position is relative to top left corner of parent window // values are in percent of the parent size t.setLabel("Find what:"); Dialog d = new Dialog(top); d.setPosition(20,0); d.setWidth(18*someConstant); // there are 18 dashes in Button f = new Button(top); f.setType(REGULAR_BUTTON); f.setPosition(80,0); f.setLabel("Find Next"); // Second row of the top level window // Left nested window Window w1 = new Window(top); w1.setPosition(0,50); Selection s1 = new Selection(w1); s1.setPosition(0,0); s1.setLabel("Match whole word only"); Selection s2 = new Selection(w1); s2.setPosition(0,50); s2.setLabel("Match case"); s2.setSelected(true); // this selection is checked // Right nested window Window w2 = new Window(top); w2.setPosition(45,50); w2.setTitle("Direction"); w2.setFramed(true); Button r1 = new Button(w2); r1.setType(RADIO); r1.setPosition(0,0); r1.setLabel("Up"); Button r2 = new Button(w2); r2.setType(RADIO); r2.setPosition(50,0); r2.setLabel("Down"); r2.setSelected(true); // this button is checked // The very last element Button c = new Button(top); c.setType(REGULAR_BUTTON); c.setPosition(80,50); c.setLabel("Cancel"); // Finally, draw the entire window (it draws its subwindows, // too, of course) top.draw();

Ras Bodik CS 164 (Fall 2004) 9 The client code in detail (1) Create top-level window –the constructor's argument is always the parent window –top-level window is parentless (null argument) Window top = new Window(null); –set title: null argument means window has no title top.setTitle(“Find”);

Ras Bodik CS 164 (Fall 2004) 10 The client code in detail (2) Now create the first widget (the text label) Text t = new Text(top); t.setLabel("Find what:"); –set position within the parent window, given as x,y coord (in percent of the parent size) –position is relative to top left corner of parent window t.setPosition(0,0); The second widet (the dialog box)) Dialog d = new Dialog(top); d.setPosition(20,0); –set dialog box width (in percent of the parent width) d.setWidth(50);

Ras Bodik CS 164 (Fall 2004) 11 The client code in detail (3) Similarly, create the third widget (the Find button) Button f = new Button(top); f.setLabel("Find Next"); f.setType(REGULAR_BUTTON); f.setPosition(80,0);

Ras Bodik CS 164 (Fall 2004) 12 The client code in detail (4) Create the left nested window Window w1 = new Window(top); w1.setPosition(0,50); Create the selection buttons within the nested window Selection s1 = new Selection(w1); s1.setPosition(0,0); s1.setLabel("Match whole word only"); Selection s2 = new Selection(w1); s2.setPosition(0,50); s2.setLabel("Match case"); –this selection button is initially checked s2.setSelected(true);

Ras Bodik CS 164 (Fall 2004) 13 The client code in detail (5) Create the right nested window Window w2 = new Window(top); w2.setPosition(45,50); w2.setTitle("Direction"); w2.setFramed(true); Create the selection buttons within the nested window Button r1 = new Button(w2); r1.setType(RADIO); r1.setPosition(0,0); r1.setLabel("Up"); Button r2 = new Button(w2); r2.setType(RADIO); r2.setPosition(50,0); r2.setLabel("Down"); –this radio button is initially checked r2.setSelected(true);

Ras Bodik CS 164 (Fall 2004) 14 The client code in detail (6) The last widget Button c = new Button(top); c.setType(REGULAR_BUTTON); c.setPosition(80,50); c.setLabel("Cancel"); Finally, draw the top-level window (will draw its sub-windows, too) top.draw();

Ras Bodik CS 164 (Fall 2004) 15 Designing a higher-level language (1) What level of abstraction do we want? One painfully low-level detail: –the GUI code had to specify coordinates –can we avoid specifying these coordinates? idea: organize widgets into rows, specified by the programmer have the compiler for our small language compute coordinates for us less flexibility (cannot fine tune positions) but faster programming Another low-level detail we’d alike to avoid –specifying parents of windows –windows (nearly) always nested, so let’s use nested scoping to convey parenthood

Ras Bodik CS 164 (Fall 2004) 16 Rows: a concept in our new language Two windows nested in their parent window. Each nested window contains two elements; the left window has two rows, the right window has one. first row of the top-level window; contains three elements: a text, a dialog box, and a button.

Ras Bodik CS 164 (Fall 2004) 17 Designing a higher-level language (2) Why is client code so verbose? –a separate method call to set each attribute good software engineering, but painfully slow coding –idea: use compact mnemonic encoding [“Find”]button with label “Find” o “Up”radio button with label “Up” O “Up”radio button with label “Up”, initially selected dialog box with length 3 “units” (there are 3 dashes)

Ras Bodik CS 164 (Fall 2004) 18 Same window in our small language window "Find" { "Find what:" ["Find next"], window "" { x "Match whole word only", X "Match case" } window framed "Direction" { o "Up" O "Down" } ["Cancel"] } comma starts a new row

Ras Bodik CS 164 (Fall 2004) 19 Implementation We’re done with the language design –not really, we only conveyed key idea, with an example –in practice, must define language fully (unambiguously document semantics of each language feature) –focus of an entire course on programming languages Still, let’s proceed to implementation –the focus of the final exam’s question

Ras Bodik CS 164 (Fall 2004) 20 Implementation exam questions (1) lexical specification of the small language: –identify lexical elements, and their attributes (if any) syntactic analysis: –write a context-free grammar for the language AST –what AST nodes do you need? what attributes do they have? –draw an AST for the example program –syntax directed translation for creating the AST

Ras Bodik CS 164 (Fall 2004) 21 Implementation exam questions (2) Implement an interpreter –assume a visitor for your AST –can do it in multiple passes compute coordinates invoke the library methods Implement a compiler –rather trivial once you have an interpreter –recall PA2 (interpreter vs. compiler) one created the NFA the other emitted the code that creates the NFA –compiler created by emitting parts of interpreter code