Dialog Widgets Dialog widgets present information and collect input from the user: Dialogs are windows that are often displayed for a relatively short.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

L3:CSC © Dr. Basheer M. Nasef Lecture #3 By Dr. Basheer M. Nasef.
Container Widgets Container widgets can be used to combine other widgets into composite panels. Examples: – XmMessageBox – XmForm – XmBulletinBoard – XmRowColumn.
Using Motif with C++ X and Motif are written in C
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
CHAPTER 13 Object Oriented Programming. Objectives  Design class definitions  Implement data hiding and encapsulation  Use accessor and mutator methods.
Visual C++ Programming: Concepts and Projects Chapter 13A: Object-Oriented Programming (Concepts)
GUI and Swing, part 2 The illustrated edition. Scroll bars As we have previously seen, a JTextArea has a fixed size, but the amount of text that can be.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
© The McGraw-Hill Companies, 2006 Chapter 18 Advanced graphics programming.
1 Lab Session-XIV CSIT121 Spring 2002 b Namespaces b First Class Travel b Lab Exercise 14 (Demo) b Lab Exercise b Practice Problem.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Interaction Styles Interface Widgets. What are Interaction Styles?  A Collection of interface objects and associated techniques from which an interaction.
Chapter 3 - Introduction to Java Applets Outline 3.1Introduction 3.2Thinking About Objects 3.4A Simple Java Applet: Drawing a String 3.5Two More Simple.
Scope of Variables and Constants A Variable or Constant may exist and be Visible for an entire project, for only one form, or for only one procedure Therefore,
GUI For the 8-Puzzle A minimal layout: All background colors and fonts are specified in a resource file.
A Simple Motif Widget The basic steps involved in creating and displaying this or any other Motif widget are essentially the same. This is a shell widget.
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Graphics and Multimedia In visual Studio. Net (C#)
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
MrsBillinghurst. net A2 Computing A2 Computing Projects Game Animation in Pascal.
1 Interface Types & Polymorphism & introduction to graphics programming in Java.
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
Chapter 6 Understanding the Structure of an Application: Procedures, Modules, and Classes.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Mobile Computing Lecture#11 Adapters and Dialogs.
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Computer Science 112 Fundamentals of Programming II Graphics Programming.
Table Row Table Data ( Header & Data) Data Cell Padding TABLE.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
Tutorial 51 Programming Structures Sequence - program instructions are processed, one after another, in the order in which they appear in the program Selection.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
CS 151: Object-Oriented Design September 26 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
CSC1401 Classes - 1. Learning Goals Computing concepts Identifying objects and classes Declaring a class Declaring fields Default field values.
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
JavaScript, Fourth Edition
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Chapter 5 Classes and Methods II Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 13 How Long Can This Go On?
Intro to Loops 1.General Knowledge 2.Two Types of Loops 3.The WHILE loop 1.
HTML DOM Basharat Mahmood, Department of Computer Science, CIIT, Islamabad, Pakistan 1.
Calculator Program Explained by Arafa Hamed. First Designing The Interface Ask yourself how many places are there that will be used to input numbers?
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
Creating and Using Dialogs ● A dialog is a box that pops up and prompts the user for a value or informs them of something ● One way: directly create objects.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
Copyright © Curt Hill Common Dialogs Easily Obtaining File Names in DevC++ Windows Programs.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
5-1 GUIs and Events Rick Mercer. 5-2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces to respond.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Georgia Institute of Technology More on Creating Classes Barb Ericson Georgia Institute of Technology June 2006.
JLink Linking Mathematica with Java and the other way round…
GUI’s.
Topics Graphical User Interfaces Using the tkinter Module
PYGAME.
“Form Ever Follows Function” Louis Henri Sullivan
JOptionPane Dialogs javax.swing.JOptionPane is a class for creating dialog boxes. Has both static methods and instance methods for dialogs. Easy to create.
Variables and Arithmetic Operations
WEB PROGRAMMING JavaScript.
Topics Graphical User Interfaces Using the tkinter Module
Java Programming with BlueJ Objectives
More on Creating Classes
Presentation transcript:

Dialog Widgets Dialog widgets present information and collect input from the user: Dialogs are windows that are often displayed for a relatively short amount of time. The user is expected to dismiss them when they are no longer needed.

Dialog Classes  The basis of all dialogs is the TransientShell widget class provided by Xt  Motif provides an XmDialogShell widget class which is a subclass of TransientShell  Motif also provides an XmMessageBox class upon which several pre-defined dialog types are based  All dialogs have a modality, which controls screen input while they are displayed

Pre-Defined Motif Dialogs  The following kinds of dialogs are pre-defined by the XmMessageBox class:  Error  Warning  Information  Working  Question  They differ primarily in the type of icon presented

Example Widget shell, errord, infod, warnd, workd, questiond; XtAppContext app; XmString msg; ArgList args = new Arg[10]; Integer n = 0; XtSetArg(args[n], XmNdefaultPosition, FALSE); n++; XtSetArg(args[n], XmNheight, 100); n++; XtSetArg(args[n], XmNwidth, 100); n++; XtSetArg(args[n], XmNx, 400); n++; XtSetArg(args[n], XmNy, 400); n++; shell = XtAppInitialize ( &app, "Test", NULL, 0, &argc, argv, NULL, args, n ); XtRealizeWidget ( shell ); XtAppMainLoop ( app ); The following code creates a top-level shell to act as a parent for some example dialogs:

Shell Widget Display Height and width are 100 pixels. Upper left corner is at (400,400) in root window. Does not have any children yet.

Example Error Dialog errord = XmCreateErrorDialog(shell, "error", NULL, 0); msg = XmStringCreateLocalized("Bad input. Try again."); XtVaSetValues(errord, XmNmessageString, msg, NULL); XtManageChild(errord); XmCreateErrorDialog is a convenience function. errord is made a child of shell. Note use of variable arguments instead of an ArgList. XtManageChild will allow the dialog to appear when shell is realized.

Error Dialog Display

About the Error Dialog  Note the message icon  Note the default placement of the dialog at (0,0)  Note the default set of buttons

Example Warning Dialog warnd = XmCreateWarningDialog(shell, "warning", NULL, 0); msg = XmStringCreateLocalized( "Bad input. Using default value."); XtVaSetValues(warnd, XmNmessageString, msg, XmNdefaultPosition, FALSE, XmNx, 300, XmNy, 0, NULL); XtManageChild(warnd); The convenience function takes the same arguments. Note that the placement (300,0) is explicitly given. Still must set XmNdefaultPosition to FALSE.

Warning Dialog Display

About the Warning Dialog  The only difference is the icon  Both dialogs are children of the shell  If the shell is quit all windows disappear

Example Information Dialog infod = XmCreateInformationDialog(shell, "information", NULL, 0); msg = XmStringCreateLocalized( "Next we will get personal data."); XtVaSetValues(infod, XmNmessageString, msg, XmNdefaultPosition, FALSE, XmNx, 0, XmNy, 200, XmNokLabelString,XmStringCreateLocalized( "CONTINUE"), NULL); XtManageChild(infod); Note that the default label on the OK button is changed.

Information Dialog Display

Example Working Dialog workd = XmCreateWorkingDialog(shell, "working", NULL, 0); msg = XmStringCreateLocalized( "Processing... click Cancel to quit."); XtVaSetValues(workd, XmNmessageString, msg, XmNdefaultPosition, FALSE, XmNx, 350, XmNy, 200, XmNdefaultButtonType, XmDIALOG_CANCEL_BUTTON, NULL); XtManageChild(workd); Note that the Cancel button has been made the default button type.

Working Dialog Display

Example Question Dialog questiond = XmCreateQuestionDialog(shell, "question", NULL, 0); msg = XmStringCreateLocalized("Shall we proceed?"); XtVaSetValues(questiond, XmNmessageString, msg, XmNdefaultPosition, FALSE, XmNx, 0, XmNy, 400, XmNokLabelString, XmStringCreateLocalized("Yes"), XmNcancelLabelString, XmStringCreateLocalized("No"), NULL); XtManageChild(questiond); Note that both the Ok and Cancel button labels have been changed.

Question Dialog Display

Dialog Modality The previous examples use nonmodal dialogs. Even though the dialog box is visible, the user is not prevented from interacting with other windows on the desktop. There are 4 levels of modality:  Nonmodal  Primary application modal: input to the window that launched the dialog is locked out but not others  Full application modal: input to all windows in the application is locked out  Full system modal: input to all windows in all applications in the system is locked out

Setting Dialog Modality  Resource: XmNdialogStyle  Values:  XmDIALOG_MODELESS  XmDIALOG_PRIMARY_APPLICATION_MODAL  XmDIALOG_FULL_APPLICATION_MODAL  XmDIALOG_SYSTEM_MODAL

Modal Dialog Example questiond = XmCreateQuestionDialog(shell, "question", NULL, 0); msg = XmStringCreateLocalized("Shall we proceed?"); XtVaSetValues(questiond, XmNmessageString, msg, XmNdefaultPosition, FALSE, XmNx, 0, XmNy, 400, XmNokLabelString, XmStringCreateLocalized("Yes"), XmNcancelLabelString, XmStringCreateLocalized("No"), XmNdialogStyle, XmDIALOG_SYSTEM_MODAL, NULL); XtManageChild(questiond); The question dialog will now insist that it be answered before input to any other application is accepted.

Dialogs and Callbacks Recall the opening dialog for the Tic-Tac-Toe game: The program must deal (at least) with clicks on the OK and Cancel buttons.

Recall the Class Diagram Board canvas: Widget display: Display gc: GC Game state: CharArray count: Integer playerX: Player Dialog dialog: Widget Main shell: Widget app: XtAppContext board game board game startd endd summaryd * The start dialog startd is owned by the main program object.

Tic-Tac-Toe Main Program shell = XtAppInitialize ( &app, "TicTacToe", NULL, 0, &argc, argv, NULL, NULL, 0 ); XtVaSetValues(shell, XmNdefaultPosition, FALSE, XmNheight, 300, XmNwidth, 300, XmNx, 400, XmNy, 400, NULL); game = new GameInfo(); // Create a new game board = new BoardInfo(shell, game); // Create a board drawing area game->setBoard(board); // Tell game about board startd = new DialogInfo("start", shell, game); // Create dialog startd->manage("Computer plays first? (Cancel for NO)"); // expose dialog XtRealizeWidget ( shell ); XtAppMainLoop ( app );

Tic-Tac-Toe Main Program (cont'd)  startd is not a Motif object but a C++ DialogInfo object  The Motif start dialog is an attribute of the DialogInfo object  Multiple instances of DialogInfo will ultimately be made for the program, including:  game ending dialog endd  game summary dialog summaryd  The message to be carried by the dialog is given as a parameter to the manage method

Dialog Class Recall that a Dialog object has a Game attribute by association.

DialogInfo Class Definition class DialogInfo { private: Widget dialog; // the dialog widget Game game; // the game state public: DialogInfo(Text name, Widget parent, Game g); void manage(Text msg); // expose dialog with msg private: DECL_CALLBACK(startOk); // Computer plays first DECL_CALLBACK(startCancel); // User plays first };

DialogInfo Class Constructor DialogInfo::DialogInfo(Text name, Widget parent, Game g) { game = g; dialog = XmCreateQuestionDialog (parent, name, NULL, 0); XtVaSetValues (dialog, XmNdefaultPosition, FALSE, XmNx, 400, XmNy, 200, XmNdialogStyle, XmDIALOG_FULL_APPLICATION_MODAL, NULL); if (strcmp(name,"start")==0) { // creating the start dialog XtAddCallback (dialog, XmNokCallback, &DialogInfo::startOkCallback, (XtPointer) this); XtAddCallback (dialog, XmNcancelCallback, &DialogInfo::startCancelCallback, (XtPointer) this); }

DialogInfo Class Constructor (cont'd)  Callbacks are registered depending on the type of the dialog  Currently there is just one type (start)  The if statement could be extended to register other callbacks for other dialog types (end and summary)

Start Dialog Callbacks IMPL_CALLBACK(DialogInfo, startOk) { // Computer plays first game->init(COMPUTER); } IMPL_CALLBACK(DialogInfo, startCancel) { // User plays first game->init(USER); }

DialogInfo::manage Method void DialogInfo::manage(Text msg) { // expose dialog with message XmString xmstr = XmStringCreateLocalized(msg); XtVaSetValues (dialog, XmNmessageString, xmstr, NULL); XtManageChild(dialog); } startd->manage("Computer plays first? (Cancel for NO)"); Recall how the main program gets the start dialog to display: