GUI For the 8-Puzzle A minimal layout: All background colors and fonts are specified in a resource file.

Slides:



Advertisements
Similar presentations
KompoZer. This is what KompoZer will look like with a blank document open. As you can see, there are a lot of icons for beginning users. But don't be.
Advertisements

Container Widgets Container widgets can be used to combine other widgets into composite panels. Examples: – XmMessageBox – XmForm – XmBulletinBoard – XmRowColumn.
Intro to Microsoft PowerPoint 2010 Public Computer Center, Moore Memorial Library, Greene, NY.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Computational Methods for Management and Economics Carla Gomes Module 4 Displaying and Solving LP Models on a Spreadsheet.
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
Table of Contents Solving Linear Systems of Equations - Graphing Method Recall that to solve the linear system of equations in two variables... we need.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Lab 8 Solver In VBA ► Review – Solver Add-in In Excel ► Solver Add-in In VBA.
Programming a GUI Hanan sedaghat pisheh. For calling GUI, we need a function with no inputs or outputs First We create a m.file m file has the same name.
Chapter 8: Writing Graphical User Interfaces
Creating a PowerPoint Presentation
OOD Case Study (For parallel treatment, see Chapter 2 of the text)
Chapter 12: Using Controls. Examining the IDE’s Automatically Generated Code A new Windows Forms project has been started and given the name FormWithALabelAndAButton.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 12 Advanced GUIs and Graphics.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
FLTK Tutorial.
Visual Basic .NET BASICS
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
CREATING A POWERPOINT PRESENTATION. Planning a presentation Create a presentation Rearrange and delete text and slides Add animations Add transitions.
Python Programming Graphical User Interfaces Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
Applications Development
Present by Wu Kun-Tse Simplifying Preference Pages with Field Editors.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
How the Session Works Outline Practical on arrival Talk 1 Reflect on practical Clarify concepts Practical exercises at your own pace Talk 2: Further concepts.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
CSE 331 Software Design & Implementation Hal Perkins Autumn 2012 Event-Driven Programming 1.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
MS Word 2010 Tutorial Prepared by: Mr. R. De Vera ii.
© 2010 Pearson Education, Inc. | Publishing as Prentice Hall.1 Computer Literacy for IC 3 Unit 2: Using Productivity Software Chapter 8: Giving Meaning.
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,
How to use By Lauren Fowler. Adding Attachments Attachments are pictures, videos and files that you have on your computer. You can add these to.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Dialog Widgets Dialog widgets present information and collect input from the user: Dialogs are windows that are often displayed for a relatively short.
Aquarium Lab Series Developed by Alyce BradyAlyce Brady of Kalamazoo CollegeKalamazoo College.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Second Model: “Model2”. What You Will Learn  How to build a simple layout  How to connect ports for routing flowitems  How to detail and enter data.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Text Reader And Typer Project By: Brandon Smith. What it does ● First, a picture containing text is used as an input. ● The program scans it for distinct.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Visual Basic.NET BASICS Lesson 9 Nested If Statements and Radio Buttons.
Setting up Solver Add-in for Excel
Visual Basic .NET BASICS
Topics Graphical User Interfaces Using the tkinter Module
Event Loops and GUI Intro2CS – weeks
Human Computer Interaction Lecture 07 The Interaction
Microsoft Visual Basic 2005 BASICS
Chapter 8: Writing Graphical User Interfaces
3.01 Apply Controls Associated With Visual Studio Form
Solving Linear Systems of Equations - Graphing Method
3.01 Apply Controls Associated With Visual Studio Form
Chapter 13: Advanced GUIs and Graphics
Graphical User Interfaces -- Introduction
Advanced Menuing, Introduction to Picking
GTK + Programming.
CSCE 489- Problem Solving Programming Strategies Spring 2018
Topics Graphical User Interfaces Using the tkinter Module
Know Your Charts Unit 3 Excel.
Advanced GUIs and Graphics
Animation Translation.
Applied Statistical and Optimization Models
Presentation transcript:

GUI For the 8-Puzzle A minimal layout: All background colors and fonts are specified in a resource file.

How It Was Laid Out ● Tiles are xmDrawnButton s: – Have drawing areas on their face – Appearance of “pushing in” is disabled by default ● Tile container is an xmBulletinBoard ● Options are xmPushButton s ● Option container is a vertical xmRowColumn ● Move count is an xmLabel ● Everything is contained in an xmForm

Parallel Representations Keep two "parallel" representations: 1 Internal representation that you have already created 2 Visual representation that mirrors the internal one This requires that the two representations be kept "in step". It also requires you to think about what the GUI needs from the other classes.

Class Relationships ProblemSolverQueue ActionListActionItemPriorityQueueFrontQueue RearQueue State MaxPriorityQueueMinPriorityQueue Interface Since the Solver knows about everything, associate the GUI with the Solver:

Previous Top-Level Program int main(...) {... Problem p = new PuzzleProblemInfo(...); MinPriorityQueue q = new MinPriorityQueueInfo(qsize); Solver s = new SolverInfo(p, q); s->solve(); }

New Top-Level Program int main(...) {... Problem p = new PuzzleProblemInfo(...); MinPriorityQueue q = new MinPriorityQueueInfo(qsize); Solver s = new SolverInfo(p, q); Interface i = new InterfaceInfo(s); } The InterfaceInfo constructor can create the widgets and callbacks, realize the widgets, and enter the main loop.

Determining Which Tile is Clicked ● Recall that every callback provides the widget w as its first argument ● Use XtVaGetValues to retrieve the widget's resource values: – XtVaGetValues(, {,,}* NULL) – XtVaGetValues(w, XmNx, &x, XmNy, &y, NULL) – x and y must be of type Position, which is a built-in X window system type that behaves like an Integer or int ● Now (x,y) is the pixel location of the clicked widget ● Use (x,y) to translate to the internal representation of the board and check if it is adjacent to the space

Moving the Tile ● Once you've determined the tile and the direction it is to move: – Compute a new target (x,y) location for the widget – Set the new location resources using XtVaSetValues ● To simulate slow tile motion, move the widget one pixel at a time within a loop – If motion still seems too fast, add a waiting loop, within the outer loop, that does nothing but count to some appropriate number

Handling a Solve Request ● Since the InterfaceInfo object contains a SolverInfo object, the Solve button callback can directly solve the current puzzle ● Since the solution is only a (reversed) list of items, you need to process the list Determine which tile moved between each pair of states. Tell that widget to move itself (can reuse tile motion code).