GUIs and Color Here's a first crack at an 8-puzzle widget:

Slides:



Advertisements
Similar presentations
RAPTOR Syntax and Semantics By Lt Col Schorsch
Advertisements

Programming Languages and Paradigms The C Programming Language.
1 RTL Example: Video Compression – Sum of Absolute Differences Video is a series of frames (e.g., 30 per second) Most frames similar to previous frame.
Container Widgets Container widgets can be used to combine other widgets into composite panels. Examples: – XmMessageBox – XmForm – XmBulletinBoard – XmRowColumn.
Pointers Typedef Pointer Arithmetic Pointers and Arrays.
Using Motif with C++ X and Motif are written in C
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
Chapter 5 - Arrays CSC 200 Matt Kayala 2/27/06. Learning Objectives  Introduction to Arrays  Declaring and referencing arrays  For-loops and arrays.
Chapter 8 Arrays and Strings
CSCI/CMPE 4341 Topic: Programming in Python Chapter 3: Control Structures (Part 1) – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
Eleven colors and rasters. Color objects Meta represents colors with color objects You can create a color by saying: [color r g b] r: amount of red (0-255)
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.
Color How X handles color. Widget use of color n Widgets that use color have u XmNforeground u XmNbackground u XmNborderColor (since default border width.
Random Stuff Colors Sizes CSS Shortcuts. Learning Objectives By the end of this lecture, you should be able to: – Identify the 3 most common ways in which.
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.
Basics of a Computer Graphics System Introduction to Computer Graphics CSE 470/598 Arizona State University Dianne Hansford.
Welcome Topic: Pixels A.M.Meshkatur Rahman Class: vii Roll: 07.
Java: Chapter 1 Computer Systems Computer Programming II.
Data Type string #include // C++ String class string str1, str2; // Default constructor cin >> str1 >> str2; cout
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
Chapter 2 Getting Started: Drawing Figures. The Framebuffer Lecture 2 Fri, Aug 29, 2003.
Field Trip #26 Create a Find a Word Puzzle in Java By Keith Lynn.
The trkNavigator plugin 22/10/ CERN - DataBase meeting Simone Paoletti INFN - Sez. Firenze.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 5 Working with Images Starting Out with Games & Graphics in.
Chapter 8 Arrays and Strings
References types and Value types With a very brief introduction to struct and enum Reference types and Value types1.
Week 7. Lecture 2 Functions, Arrays, PHP&MySQL. Function with More than one argument and a return statement For a function to return a value, the return.
Using the JImageViewer classes. JImageViewer classes JImageViewer class JImageViewer class ImagePanel class ImagePanel class Image class Image class.
Georgia Institute of Technology Movies part 5 Barb Ericson Georgia Institute of Technology April 2006.
Building X Window GUIs with Motif The X Window System: Architecture Applications Sample code Review function (as time permits) … Introduce what it’s like.
Canvas and Graphics CS 21a. 9/26/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved L17: Canvas.
CS112 Scientific Computation Department of Computer Science Wellesley College Numb3rs Number and image types.
CSC1401 Classes - 1. Learning Goals Computing concepts Identifying objects and classes Declaring a class Declaring fields Default field values.
CHAPTER 7 arrays I NTRODUCTION T O C OMPUTER P ROGRAMMING (CSC425)
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
Computer Science 111 Fundamentals of Programming I Introduction to Digital Image Processing.
NestedLoops-Mod7-part31 Two-Dimensional Arrays and Nested Loops – part 3 Bugs in the garden Originally by Barb Ericson Georgia Institute of Technology.
© Copyright 2012 by Pearson Education, Inc. All Rights Reserved. Chapter 9 GUI Programming Using Tkinter 1.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
12/5/2015 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
ENUMERATED DATATYPES. USER DEFINED DATA TYPES  Data Type Defined By Programmer  Allows Use Of More Complex Data  Typically Defined Globally So Variables.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Beam Penetration & Shadow Mask Method
Color Web Design Professor Frank. Color Displays Based on cathode ray tubes (CRTs) or back- lighted flat-screen Monitors transmit light - displays use.
Copyright 2010 by Pearson Education Building Java Programs Chapter 10, 11 Lecture 22: 143 Preview optional reading: 10.1,
Slide 1 Chapter 5 Arrays. Slide 2 Learning Objectives  Introduction to Arrays  Declaring and referencing arrays  For-loops and arrays  Arrays in memory.
Chapter 5 Arrays. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 5-2 Learning Objectives  Introduction to Arrays  Declaring and referencing.
CSC 143A 1 CSC 143 Introduction to C++ [Appendix A]
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Program Organization Sequential Execution: One line done after the other Conditional Execution: If a test is true, one section is done, otherwise another.
CERN, 16/9/2003 S. Paoletti: trkNavigator 1 trkNavigator: A Java client for the Tracker DB 16/9/ CERN - mod. Prod meeting Simone Paoletti INFN -
Dialog Widgets Dialog widgets present information and collect input from the user: Dialogs are windows that are often displayed for a relatively short.
2/16/2016 EEC492/693/793 - iPhone Application Development 1 EEC-693/793 Applied Computer Vision with Depth Cameras Lecture 4 Wenbing Zhao
Characters and Strings
Copyright © Curt Hill Further Picture Manipulation Considering position.
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
TOPIC 8 MORE ON WHILE LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Chapter 5 Arrays Copyright © 2016 Pearson, Inc. All rights reserved.
Review 1.
Reading Netpbm Images.
User Interface Software Look under the hood
Chapter 13 Sights and Sounds.
12.4 p 471 a) double[] number = {1.05, 2.05, 3.05, 4.05, 5.05};
What Color is it?.
Hank Childs, University of Oregon
Non-numeric Data Representation
Tkinter Tkinter is a GUI (graphical user interface) widget set for Python. The Tkinter module (“ToolKit interface”) is the standard Python interface to.
Arrays Introduction to Arrays Reading for this Lecture:
Random Stuff Colors Sizes CSS Shortcuts.
Presentation transcript:

GUIs and Color Here's a first crack at an 8-puzzle widget:

How It Was Produced  A BulletinBoard container widget bb of 500 x 500 pixels was created. Resources:  XmNheight (500)  XmNwidth (500)  XmNshadowThickness (5 pixels)  Nine PushButton widgets were created as children of bb inside of a doubly nested loop:  XmNheight (100)  XmNwidth (100)

How It Was Produced (cont'd)  To make the buttons appear to pop out of the screen, use resources:  XmNshadowType (XmSHADOW_OUT)  XmNshadowThickness (5)  To make the tiles white, use resource XmNbackground (see later slide)  To display the tile number:  convert it to a string  convert the string to a Motif compound string (recall XmStringCreateLocalized)  give the compound string as value to the resource XmNlabelString

Changing the XmNbackground Resource Suppose you want your 8-puzzle board to look like this:

About Colors  The XmNbackground resource requires a value of type Pixel  A Pixel is a special kind of integer, one that is a valid index into a Colormap  A Colormap is an array of colors; most displays provide a hardware colormap  To specify a new background color, the programmer must know:  the symbolic name of the desired color, and  how to set the XmNbackground resource to the Pixel value associated with that color

Role of the Colormap R G B.. R = Red G = Green B = Blue Frame Buffer Pixel Value Colormap blue

Color Database (Human Readable) ! $XConsortium: rgb.txt,v /02/20 18:39:36 rws Exp $ snow ghost white GhostWhite white smoke WhiteSmoke gainsboro floral white FloralWhite old lace OldLace linen antique white AntiqueWhite papaya whip PapayaWhip blanched almond... [ about 720 more ]... Directory: /usr/X/lib File: rgb.txt The numbers stand for the intensity of the red, green, and blue components of the color

Setting Color Programmatically  The desired bulletin board and push button background colors are DarkRed and PowderBlue  To find their indexes into the colormap (pixels) a programmer can use: XAllocNamedColor(Display *display, Colormap cmap, char *name, XColor *color, XColor *exact) This requires knowing how to retrieve displays, screens, and colormaps.

Getting A Pixel By Color Name Pixel GetPixelByName (Widget w, char* colorname) { Display *dpy = XtDisplay( w ); int scr = DefaultScreen (dpy); Colormap cmap = DefaultColormap (dpy, scr); XColor color, ignore; If (XAllocNamedColor (dpy,cmap,colorname,&color,&ignore)) return color.pixel; else { XtWarning ("Couldn't allocate color" ); return BlackPixel (dpy, scr); { } Now use GetPixelByName(bb,"DarkRed") paired with resource XmNbackground when creating bb.

Using GetPixelByName Widget bb = XtVaCreateManagedWidget ( "puzzle", xmBulletinBoardWidgetClass, form, Nheight, 3*TILE_SIZE+2*BB_SHADOW, XmNwidth, 3*TILE_SIZE+2*BB_SHADOW, XmNmarginHeight, 0, XmNmarginWidth, 0, XmNshadowThickness, BB_SHADOW, XmNshadowType, XmSHADOW_IN, XmNbackground, GetPixelByName(bb, ``DarkRed''), NULL ); Use the same approach to make the color of the tile pushbuttons “PowderBlue”.

Disadvantages of Setting Color Programmatically  GetPixelByName is not defined in either Xt or Xm; you have to write it  Anytime you want to change the background color you have to recompile the program  A better way is to use the Resource Manager