Xwindows. Xwindows: Windows. Windows Drawing Events Advanced Topics. Window Models Creating Windows in X X11 Architecture. Before Windowing Systems
|
|
- Griffin Myron Moore
- 6 years ago
- Views:
Transcription
1 Xwindows Windows Drawing Events Advanced Topics Xwindows: Windows Window Models Creating Windows in X X11 Architecture Before Windowing Systems 3
2 What's Under the Hood of a GUI Toolkit? Up until now, we ve been assuming: - Low-level events get to us, somehow (e.g., information about the keyboard, mouse, the need to paint, etc.) - We can create a window, somehow - We can paint on that window, somehow What is this mechanism that allows us to get this information, and to create and paint windows? And just as importantly, what is it that this mechanism is doing? That is, what is it abstracting away for our convenience? 4 Images: LG monitor CC BY-SA 2.0 by florisla; HP s rotatable display by HP; Vaio CC by Yoggy from Yokohama, Kanagawa, Japan; X61 public domain by Evan-Amos; mouse CC 5 BY-SA 3.0 by Darkone; TrackPoint CC by Inklein; keyboard public domain by the US Navy Abstracting Away the Hardware Our output displays can vary in dimensions, pixel density, number of colors that can be displayed We can get pointer input from a wide range of devices - Mouse - Stylus - Touch input We can get character input in a wide range of ways - Hardware keyboards - Soft keyboards As application developers, we d like to deal with all these different pieces of hardware as if they re the same thing 7
3 Base Window System The Base Window System (BWS) provides this layer of abstraction between the application programmer and the lowlevel hardware: - Display device(s) - Graphics cards - Pointing devices - Keyboard input 8 9 Base Window System Lowest level abstraction for windowing system Routines for creating, destroying, managing, and painting in windows Routes input to correct window Manages painting, so windows not painting in other windows area Ensures only one application changing frame buffer (video memory) at a time - one reason why single-threaded / non-thread-safe GUI architectures are popular 10
4 Base Window System Creates canvas abstraction for applications - Applications shielded from details of frame buffer, visibility of window, other application windows Provides basic graphics routines for drawing Each window has its own coordinate system - Each window always assumes its top-left is (0,0) - Simplifies painting/drawing - BWS transforms between coordinate systems 11 X (X11) Window System A base window system first developed in 1984 A standard for low-level graphical output and user input - A protocol to create windows, handle input, draw graphics, - Not a window manager (more on that later) - Does not specify style of user interface Free and cross-platform (os-, processor-, form factor-agnostic) Separate from operating system 12 Window Manager Layered on top of Base Window System Creates the look and feel of each window - Appearance (e.g., chrome ) and interaction for common window operations Provides interactive components for windows (menus, close box, resize capabilities) Manages things like window behavior, such as where windows appear when first created 14
5 Motif (Stacking) 15 DWM (tiling) 16 KDE (simple compositing) Screenshot 17 by CS Nev 349 Delap, - X Windows CC BY-SA 3.0
6 KWin (compositing) 18 Metisse (compositing) 19 Chapuis and Roussel, UIST Window Manager Application Window vs. Application Canvas - the window manager owns the window (including its controls) - the application owns the canvas window controls 20
7 BWS vs. Window Managers X separates Base Window System from Window Manager - Enables many alternative look and feels for windowing system (e.g., KDE, GNOME, fvwm ) - One of the keys to its lasting power: Can continue to grow by changing the Window Manager layer BWS and Window Manager are separate processes 21 BWS vs. Window Managers OSX, Microsoft Windows combine BWS and Window Manager Trade-offs in approaches? - Look and feel - Window management possibilities - Input possibilities 22 More on X11 23
8 X Windows Design Criteria (~1986) 1. implementable on a variety of displays 2. applications must be device independent 3. must be network transparent 4. support multiple, concurrent application displays 5. support many different applications 6. support output to overlapping windows ( even when partially obscured) 7. support a hierarchy of resizable windows ( an application can use many windows at once) 8. high-performance, high-quality text, 2-D graphics, imaging 9. system should be extensible 24 (from Scheifler & Gettys, 1986) X Client-Server Architecture Separate user interface and application: - the X Client handles all application logic - the X Server handles all display output and user input A server handles requests from multiple clients, processes data as requested, and returns the results to the clients X inverts conventional www server and client relationship (in www, web browser is the client, web site is the server ) 25 Why Client-Server? Goal was flexibility and economy - Many clients (perhaps on multiple machines), one display 26
9 Displays, Screens, Windows In X, a display may have multiple screens A display may have multiple windows A window may cross multiple screens 27 Using X Across the Network hostname:displaynumber.screennumber e.g. :0, :0.1, machine.cs.uwaterloo.ca:0.0, DISPLAY environment variable should be set to local display - printenv DISPLAY ssh X - X11 forwarding: when you run an X Client on a server, it uses your local machine as the X Server! 28 Xlib library to wrap low level X Window protocol - to avoid implementing message passing for every new program uses buffered input and output queues - need to flush them: XSync, XFlush Xlib functions: - connection operations: e.g. XOpenDisplay, XCloseDisplay, - connection operation requests: e.g. XCreateWindow, XCreateGC, - connection information requests: e.g. XGetWindowProperty, - local event queue operations: e.g. XNextEvent, XPeekEvent, - local data operations: e.g. XLookupKeysym, XParseGeometry, XSetRegion, XCreateImage, XSaveContext, Xlib data types: - e.g. Display, Window, GC, XSizeHints, XWhitePixel, XBlackPixel, etc. Xlib is not a window manager Xlib does not specify style of user interface or provide widgets 29
10 Structure of a Typical X Program 1. perform client initialization 2. connect to the X server 3. perform X related initialization 4. event loop: get next event from the X server handle the event: if the event was a quit message, exit the loop do any client-initiated work send drawing requests to the X server 5. close down the connection to the X server 6. perform client cleanup 30 null.min.cpp: creates and destroys a display #include <cstdlib> #include <iostream> #include <X11/Xlib.h> // main Xlib header Display* display; int main() { display = XOpenDisplay(""); // open using DISPLAY env var if (display == NULL) { std::cout << "error\n"; exit ( 1); else { std::cout << "success!\n"; XCloseDisplay(display); // close display 31 Makefiles You need makefiles for all assignments - (you can re-use the one in the code demos by setting NAME) - # super simple makefile # call it using 'make NAME=name_of_code_file_without_extension' # (assumes a.cpp extension) NAME = "null.min" "Compiling..." g++ o $(NAME) $(NAME).cpp L/usr/X11R6/lib lx11 lstdc++ run: "Running..."./$(NAME) 32
11 openwindow.min.cpp: Display a Window Display* display; Window window; // save the window id int main( int argc, char* argv[] ) { display = XOpenDisplay(""); // open display if (!display) exit ( 1); // couldn't open, so bail int screen = XDefaultScreen(display);// info about the display window = XCreateSimpleWindow( display, XDefaultRootWindow(display), // window's parent 10, 10, // location: x,y 400, 300, // size: width, height 2, // width of border XBlackPixel(display, screen), // foreground colour XWhitePixel(display, screen)); // background colour XMapRaised(display, window); // put window on screen XFlush(display); // flush the output buffer std::cout << "ENTER2exit"; std::cin.get(); // wait for input XCloseDisplay(display); 33 Code Review: openwindow.cpp Same Functions/Macros and procedures as min verson: - XOpenDisplay - XDefaultScreen - XWhitePixel, XBlackPixel - XCreateSimpleWindow - XSetStandardProperties - XMapRaised - XFlush Difference is cleaner coding practice, but longer code 34 X Windows: Drawing Drawing Models Drawing in X
12 Drawing X Windows manages multiple windows - where window is located, is it covered by another window, etc... - enables drawing using local coordinate system for window 37 Drawing Models Three different conceptual drawing models: Pixel SetPixel(x, y, colour) DrawImage(x, y, w, h, img) Stroke DrawLine(x1, y1, x2, y2, colour) DrawRect(x, y, w, h, colour) Region DrawLine(x1, y1, x2, y2, color, thick) DrawRect(x, y, w, h, colour, thick, fill) DrawText( A, x, y, colour) 38 Drawing Options for Stroke and Region Models e.g. drawline(x1,y1,x2,y2) - what colour? - how thick? - dashed or solid? - where are the end points and how should the ends overlap? - How to communicate all the options? Observation: most choices are the same for multiple calls to drawline 39
13 Graphics Context Gather all drawing options into a single structure and pass it to the drawing routines - In X, the GC structure All graphics environments use variation on this approach - Java: Graphics Object - OpenGL: Attribute State In X, the graphics context is stored on server - Switch between multiple saved contexts to reduce network traffic - But limited memory on server - There is a default context - The context is global to the application: need a policy 40 XGCValues (Xlib Graphics Context) typedef struct { int function; // how the source and destination are combined unsigned long plane_mask; // plane mask unsigned long foreground; // foreground pixel unsigned long background; // background pixel... int line_width; // line width (in pixels) int line_style; // LineSolid, LineDoubleDash, LineOnOffDash int cap_style; // CapButt, CapRound, CapProjecting int join_style; // JoinMiter, JoinRound, JoinBevel int fill_style; // FillSolid, FillTiled, FillStippled, int fill_rule; // EvenOddRule, WindingRule int arc_mode; // ArcChord, ArcPieSlice... Font font; // default font... XGCValues; 41 drawing.min.cpp int w = 300; int h = 300; XFlush(display); sleep(1); // let server get set up before sending // drawing demo with graphics context here... GC gc = XCreateGC(display, window, 0, 0); // graphics context XSetForeground(display, gc, XBlackPixel(display, screen)); XSetBackground(display, gc, XWhitePixel(display, screen)); XSetFillStyle(display, gc, FillSolid); XSetLineAttributes(display, gc, 3, // 3 is line width LineSolid, CapButt, JoinRound); // other line options // draw some things XDrawLine(display, window, gc, 10, 10, w 10, h 10); XFillRectangle(display, window, gc, 50, 50, w (2*50), h (2*50)); XSetForeground(display, gc, XWhitePixel(display, screen)); XDrawLine(display, window, gc, w 10, 10, 10, h 10); XFlush(display); 42
14 Code Review: drawing.cpp initx initializes three graphics contexts main changed to call several procedures to draw drawrectanglesincorners - get window attributes (eg width and height) - use of XDrawRectangle drawstuff - parameters say which GC and where to draw - use of XDrawLine, XDrawArc, XDrawRectangle, XFillRectangle Note: Minimize window and it vanishes - Need to redraw (need event to know when) 43 Painter s Algorithm The basic graphics primitives are primitive. To draw more complex shapes: - Draw back-to-front, layering the image - Called Painter s Algorithm 44 Painters Algorithm Analogy fast and with music: 45
15 Painting Advice Keep it simple - Clear the window and redraw everything each frame - Get fancier (eg. clipping, double buffering) only if you really need to for performance reasons Repaint when necessary -- but no oftener. Flush the buffer often enough -- but no oftener. - Unless you re debugging! 46 X Windows: Events Events and the Event Loop 47 Human vs. System User Interactive System perceive present seconds milliseconds or faster express translate 48
16 Events Defined 1. An observable occurrence, phenomenon, or an extraordinary occurrence. 2. A message to notify an application that something happened. Examples: Keyboard (key press, key release) Pointer Events (button press, button release, motion) Window crossing (mouse enters, leaves) Input focus (gained, lost) Window events (exposure, destroy, minimize) Timer events 49 Role of the X Server 1. Collect event information 2. Put relevant information in a known structure 3. Order the events by time 4. Decide which application/window should get event 5. Deliver the event Some events come from the user via the underlying hardware; some from the window manager. 50 Receiving Events In X, applications get the next event using: XNextEvent(Display* display, XEvent* evt) Gets and removes the next event in the queue. If empty, it blocks until another event arrives. Can avoid blocking by checking if events available using: XPending(Display* display) Query number of events in queue, never blocks. 51
17 Selecting Input Events to listen to Don t always need all of the events. (Why?) // Tell the window manager what input events you want. XSelectInput( xinfo.display, xinfo.window, ButtonPressMask KeyPressMask ExposureMask ButtonMotionMask ); Defined masks: NoEventMask, KeyPressMask, KeyReleaseMask, ButtonPressMask, ButtonReleaseMask, EnterWindowMask, LeaveWindowMask, PointerMotionMask, PointerMotionHintMask, Button1MotionMask, Button2MotionMask,..., ButtonMotionMask, KeymapStateMask, ExposureMask, VisibilityChangeMask,... See Event Structure: Union X uses a C union typedef union { int type; XKeyEvent xkey; XButtonEvent xbutton; XMotionEvent xmotion; // etc.... Each structure contains at least the following typedef struct { int type; unsigned long serial; // sequential # Bool send_event; // from SendEvent request? Display* display; // display event was read from Window window; // window which event is relative to X Event 53 Java Event Structure: Inheritance Java uses an inheritance hierarchy Each subclass contains additional information, as required (not shown) 54
18 eventloop.min.cpp window = XCreateSimpleWindow(display, XDefaultRootWindow(display), 10, 10, 300, 200, 2, foreground, background); XSelectInput(display, window, PointerMotionMask KeyPressMask); // select events XMapRaised(display, window); XFlush(display); XEvent event; // save the event here while( true ) { // event loop until 'exit' XNextEvent( display, &event ); // wait for next event switch( event.type ) { case MotionNotify: // mouse movement cout << event.xmotion.x << "," << event.xmotion.y << endl; break; case KeyPress: // any keypress exit(0); break; XCloseDisplay(display); 55 Responding to Events (blocking) while( true ) { XNextEvent(display, &event); // wait for next event switch(event.type) { case Expose: //... handle expose event... cout << event.xexpose.count << endl; break; case ButtonPress: //... handle button press event... cout << event.xbutton.x << endl; break; case MotionNotify: //... handle event... cout << event.xmotion.x << endl; break; repaint(... ); // call my repaint function 56 Code Review: eventloop.cpp XSelectInput XNextEvent eventloop KeyPress and XLookupString character vs. scan codes (Displayable, next slide) 57
19 Display List displayable base class /* * An abstract class representing displayable things. */ class Displayable { public: virtual void paint(xinfo &xinfo) = 0; ; 58 Displayable Text /* * Display some text */ class Text : public Displayable { public: virtual void paint(xinfo &xinfo) { XDrawImageString( xinfo.display, xinfo.window, xinfo.gc, this >x, this >y, this >s.c_str(), this >s.length() ); // constructor Text(int x, int y, string s):x(x), y(y), s(s) { ; 59 private: int x; int y; string s; (see also Displayable Polyline) Displaying the Display List of Displayables list<displayable*> dlist; // list of Displayables dlist.push_front(new Text(event.xbutton.x, event.xbutton.y, "x")); /* * Function to repaint a display list */ void repaint( list<displayable*> dlist, XInfo& xinfo) { list<displayable*>::const_iterator begin = dlist.begin(); list<displayable*>::const_iterator end = dlist.end(); 60 XClearWindow( xinfo.display, xinfo.window ); while( begin!= end ) { Displayable* d = *begin; d >paint(xinfo); begin++; XFlush( xinfo.display );
20 X Windows: Advanced Techiques Animation Double Buffering Clipping 61 Animation A simulation of movement created by displaying a series of pictures, or frames. Goals: - Move things around on the screen - Repaint times per second (frames-per-second, frame rate, or FPS ) - Make sure events are handled on a timely basis - Don t use more CPU than necessary - Easily understood code 62 Responding to Events (non-blocking) while( true ) { if (XPending(display) > 0) { // any events pending? XNextEvent(display, &event ); // yes, process them switch( event.type ) { // handle event cases here... handleanimation(xinfo); // update animation objects repaint(xinfo); // my repaint This doesn t block, but it doesn t work very well either 63
21 Keys to animation: managing time #include <sys/time.h> // get microseconds unsigned long now() { timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * tv.tv_usec; const int FPS = 30; // sleep for about 1/30 second usleep( /fps); 64 Code Review: animation.cpp New events used - EnterNotify (EnterWindowMask) - LeaveNotify (LeaveWindowMask) - ConfigureNotify (StructureNotifyMask)?!? // update width and height when window is resized void handleresize(xinfo &xinfo, XEvent &event) { XConfigureEvent xce = event.xconfigure; if (xce.width!= xinfo.width xce.height!= xinfo.height) { xinfo.width = xce.width; xinfo.height = xce.height; 65 Double Buffering Flickering: when an intermediate image is on the display - e.g.: Clear, then redraw strategies Solution: - Create an off screen image buffer - Draw to the buffer - Copy the buffer to the screen as quickly as possible (hopefully between refreshes) 66
22 Double Buffering // create off screen buffer xinfo.pixmap = XCreatePixmap(xinfo.display, xinfo.window, width, height, depth); // size and *depth* of pixmap // draw into the buffer // note that a window and a pixmap are drawables XFillRectangle(xinfo.display, xinfo.pixmap, xinfo.gc[0], 0, 0, width, height); // copy buffer to window XCopyArea(xinfo.display, xinfo.pixmap, xinfo.window, xinfo.gc[0], 0, 0, width, height, // pixmap region to copy 0, 0); // top left corner of pixmap in window XFlush( xinfo.display ); 67 Code Review: doublebuffer.cpp XFreePixmap to free buffer when size changes drawable types: Window and Pixmap Displayables need to be updated Resizing a window generates lots of flicker, even on some apps in the default X distribution. - has good suggestions, including disabling the background pixmap if it isn t needed (ie: you fill the entire window anyway) - XSetWindowBackgroundPixmap(xinfo.display, xinfo.window, None); 68 Clipping 69
23 Code Demo: clipping.cpp XSetClipMask XSetClipRectangles if (!is_clipping) XSetClipMask(display, gc, None); else XSetClipRectangles(display, gc, 0, 0, &clip_rect, 1, Unsorted); Also: - Pattern class to init and paint an object - Random helper function 70 Summary Basic X architecture (client, server, network) Windows: opening, disposing Drawing - Models (pixel, stroke, region) - graphics contexts - Painter s Algorithm; Display lists Events (structure, selecting, event loop, etc) Animation Double Buffering Clipping 71
Events. Events and the Event Loop Animation Double Buffering. 1.5 Events 1
Events Events and the Event Loop Animation Double Buffering 1.5 Events 1 Human vs. System User Interactive System perceive present seconds milliseconds or faster express translate 1.5 Events 2 Event Driven
More informationWindowing Systems. (using X Windows as case study) GUI Architecture Base Window System Window Manager. Windowing Systems 1
Windowing Systems (using X Windows as case study) GUI Architecture Base Window System Window Manager Windowing Systems 1 Windowing System Handles input device events - keyboard (text) and pointing (mouse/touchpage)
More informationGUI Basics and Windowing Systems. Using X Windows as a case study
GUI Basics and Windowing Systems Using X Windows as a case study 2 CS 349 - Syllabus Evolution of GUIs Xero Star (1981) Developed at Xerox PARC Not commercially successful. Apple Macintosh (1984) Inspired
More informationGUI Basics and Windowing Systems
GUI Basics and Windowing Systems Using X Windows as a case study 1 2 Evolution of GUIs Xero Star (1981) Developed at Xerox PARC Not commercially successful. Apple Macintosh (1984) Inspired by Xerox PARC
More informationGUI Basics and Windowing Systems. Using X Windows as a case study
GUI Basics and Windowing Systems Using X Windows as a case study 2 CS 349 - Syllabus Evolution of GUI Programming On early computers, everything was rolled by hand Re-inventing the wheel with every iteration
More informationXCreateGC, XCopyGC, XChangeGC, XGetGCValues, XFreeGC, XGContextFromGC, XGCValues create or free graphics contexts and graphics context structure
XCreateGC, XCopyGC, XChangeGC, XGetGCValues, XFreeGC, XGContextFromGC, XGCValues create or free graphics contexts and graphics context structure GC XCreateGC(display, d, valuemask, values) Drawable d;
More informationNotes on creating graphical output using X-11 graphics. Ubuntu Virtual Machine
Notes on creating graphical output using X-11 graphics Ubuntu Virtual Machine B. Wilkinson, Sept 4, 2014 Assignments and projects may require graphical output, which is especially relevant for problems
More informationEvent Dispatch. Review: Events
Event Dispatch 1 Review: Events Event: noun: a thing that happens, especially one of importance. Example: the media focused on events in Egypt Event: a structure used to notify an application of an event
More informationIndex. A Aim of book, 3 Approach options taken here, 1 toolkits, 1 Approaches to options selection, 56
References Champine GA (1991) MIT Project Athena: a model for distributed campus computing. Digital Press, Massachusetts, USA Gettys J, Scheifler RW (2002) Xlib - c language x interface: X consortium standard.
More informationC SCI The X Window System Stewart Weiss
The X Window System The X Window System is a networking and display protocol which provides windowing on bitmapped displays. X provides the basic framework for building GUI environments, such as drawing
More informationOperating systems. Lecture 15
Operating systems. Lecture 15 Michał Goliński 2019-01-22 Introduction Recall Architecture of Windows PowerShell Plan for today X Window System The X protocol Implementations Future Sample programs XCB
More informationAlgunas Funciones y Estructuras de Datos XWindow
Algunas Funciones y Estructuras de Datos XWindow Display *XOpenDisplay(display_name) char *display_name; char *ServerVendor(display) int XDisplayWidth(display,screen_number) int screen_number; int XDisplayHeight(display,screen_number)
More informationEvents. Dispatch, event-to-code binding. Review: Events Defined 1/17/2014. occurrence.
Events Dispatch, event-to-code binding Review: Events Defined 1. An observable occurrence, phenomenon, or an extraordinary occurrence. 2. A message to notify an application that something happened. Examples:
More informationEvent Dispatch. Dispatching events to windows and widgets.
Event Dispatch Dispatching events to windows and widgets. Review: Event Architecture 2 Event capture, processing and dispatch. Event Capture Hardware events (interrupts) Event Dispatch Software events
More informationWindows and Events. created originally by Brian Bailey
Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating
More informationCSC207H: Software Design Lecture 11
CSC207H: Software Design Lecture 11 Wael Aboelsaadat wael@cs.toronto.edu http://ccnet.utoronto.ca/20075/csc207h1y/ Office: BA 4261 Office hours: R 5-7 Acknowledgement: These slides are based on material
More informationInput (part 2: input models)
Input (part 2: input models) Dealing with diversity Saw lots of diversity in devices actual details of devices (e.g., device drivers) is a real pain how do we deal with the diversity? Need a model (abstraction)
More informationIT101. Graphical User Interface
IT101 Graphical User Interface Foundation Swing is a platform-independent set of Java classes used for user Graphical User Interface (GUI) programming. Abstract Window Toolkit (AWT) is an older Java GUI
More informationVolume One. Xlib Programming Manual
Volume One Xlib Programming Manual for Version 11 of the X Window System by Adrian Nye O'Reilly & Associates, Inc. -^ Table of Contents Page Preface About This Manual Summary of Contents How to Use This
More information+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.
+ Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create
More informationBackground Information About GTK+ and Related Libraries
Background Information About GTK+ and Related Libraries The X Window System The X Window System is a networking and display protocol which provides windowing on bitmapped displays. X provides the basic
More informationGraphical User Interface (GUI)
Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware
More informationCS 160: Interactive Programming
CS 160: Interactive Programming Professor John Canny 3/8/2006 1 Outline Callbacks and Delegates Multi-threaded programming Model-view controller 3/8/2006 2 Callbacks Your code Myclass data method1 method2
More informationLesson 34. Write down program of maze solver. Maze Solver
Lesson 34 Objectives: - Write down program of maze solver Maze Solver Function This program reads the representation of a maze from a text file, and finds a path through it. Programming Issues The first
More informationGraphical User Interface (GUI)
Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationLoad your files from the end of Lab A, since these will be your starting point.
Coursework Lab B It is extremely important that you finish lab A first, otherwise this lab session will probably not make sense to you. Lab B gives you a lot of the background and basics. The aim of the
More informationMIT-SHM The MIT Shared Memory Extension
MIT-SHM The MIT Shared Memory Extension How the shared memory extension works Jonathan Corbet Atmospheric Technology Division National Center for Atmospheric Research corbet@ncar.ucar.edu Formatted and
More informationOutput models Drawing Rasterization Color models
Output models Drawing Rasterization olor models Fall 2004 6.831 UI Design and Implementation 1 Fall 2004 6.831 UI Design and Implementation 2 omponents Graphical objects arranged in a tree with automatic
More informationComputer Graphics. Bing-Yu Chen National Taiwan University
Computer Graphics Bing-Yu Chen National Taiwan University Introduction to OpenGL General OpenGL Introduction An Example OpenGL Program Drawing with OpenGL Transformations Animation and Depth Buffering
More informationCS 376b Computer Vision
CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves
More informationEvent Binding. Different Approaches Global Hooks. 2.5 Event Binding 1
Event Binding Different Approaches Global Hooks 2.5 Event Binding 1 Event Dispatch vs. Event Binddling Event Dispatch phase addresses: - Which window receives an event? - Which widget processes it? Positional
More informationAnswers to Even- Numbered Exercises
Answers to Even- 6 Numbered Exercises from page 200 1. What is a window manager? Name two X Window System managers, and describe how they differ. 2. What happens when you position the mouse pointer in
More informationLomse library. Tutorial 1 for X11
This is meant to be an introduction to using Lomse in a X11 program. Before starting, ensure that you have installed the Lomse library. See the installation page for detailed instructions. In this first
More informationLab 4. Out: Friday, February 25th, 2005
CS034 Intro to Systems Programming Doeppner & Van Hentenryck Lab 4 Out: Friday, February 25th, 2005 What you ll learn. In this lab, you ll learn to use function pointers in a variety of applications. You
More informationPixelSurface a dynamic world of pixels for Unity
PixelSurface a dynamic world of pixels for Unity Oct 19, 2015 Joe Strout joe@luminaryapps.com Overview PixelSurface is a small class library for Unity that lets you manipulate 2D graphics on the level
More informationCSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010
CSE 374 Programming Concepts & Tools Hal Perkins Spring 2010 Lecture 19 Introduction ti to C++ C++ C++ is an enormous language: g All of C Classes and objects (kind of like Java, some crucial differences)
More informationCSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 19 Introduction to C++
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 19 Introduction to C++ C++ C++ is an enormous language: All of C Classes and objects (kind of like Java, some crucial differences) Many
More informationG51PRG: Introduction to Programming Second semester Applets and graphics
G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting
More information38.1 Tk_ConfigureWidget 337
1 Chapter 36 Introduction 323 36.1 What s in a widget? 324 36.2 Widgets are event-driven 325 36.3 Tk vs. Xlib 325 36.4 Square: an example widget 326 36.5 Design for re-usability 328 Chapter 37 Creating
More informationSome Notes on R Event Handling
Some Notes on R Event Handling Luke Tierney Statistics and Actuatial Science University of Iowa December 9, 2003 1 Some Things that Do Not Work Here is a non-exhaustive list of a few issues I know about.
More informationChapter 7 Applets. Answers
Chapter 7 Applets Answers 1. D The drawoval(x, y, width, height) method of graphics draws an empty oval within a bounding box, and accepts 4 int parameters. The x and y coordinates of the left/top point
More informationContents. Table of Contents. Table of Contents... iii Preface... xvii. Getting Started iii
Contents Discovering the Possibilities... iii Preface... xvii Preface to the First Edition xvii Preface to the Second Edition xviii Getting Started... 1 Chapter Overview 1 Philosophy Behind this Book 1
More informationSmoother Graphics Taking Control of Painting the Screen
It is very likely that by now you ve tried something that made your game run rather slow. Perhaps you tried to use an image with a transparent background, or had a gazillion objects moving on the window
More informationIntroduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts
Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationEvent Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. 2.4 Event Dispatch 1
Event Dispatch Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch 2.4 Event Dispatch 1 Event Architecture A pipeline: - Capture and Queue low-level hardware events - Dispatch
More informationDesigning Interactive Systems II
Designing Interactive Systems II Computer Science Graduate Program SS 2011 Prof. Dr. Jan Borchers Media Computing Group RWTH Aachen University http://hci.rwth-aachen.de/dis2 Jan Borchers 1 Review: WM,
More informationThere are, of course, many other possible solutions and, if done correctly, those received full credit.
Question 1. (20 points) STL. Complete the function ChangeWords below. This function has as inputs a vector of strings, and a map of key-value pairs. The function should return a new vector
More informationJava Programming Lecture 6
Java Programming Lecture 6 Alice E. Fischer Feb 15, 2013 Java Programming - L6... 1/32 Dialog Boxes Class Derivation The First Swing Programs: Snow and Moving The Second Swing Program: Smile Swing Components
More informationOpenGL Drawing Widgets and Related Functions
OpenGL Drawing Widgets and Related Functions Following is a list of the OpenGL widgets and widget-related functions, and the purpose of each. Select the item to receive more information. You may also go
More informationG52CPP C++ Programming Lecture 9
G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And
More informationAdobe Flash CS3 Reference Flash CS3 Application Window
Adobe Flash CS3 Reference Flash CS3 Application Window When you load up Flash CS3 and choose to create a new Flash document, the application window should look something like the screenshot below. Layers
More informationX Windows Version 11.5 A Concise Description
X Windows Version 11.5 A Concise Description Tim Love - CUED November 2, 1994 This document is an introduction to the X Windows system particularly from the point of view of a programmer in C. It does
More informationOutput in Window Systems and Toolkits
Output in Window Systems and Toolkits Recap Low-level graphical output models CRTs, LCDs, and other displays Colors (RGB, HSV) Raster operations (BitBlt) Lines, curves, path model Fonts Affine Transforms
More informationLecture 14: more class, C++ streams
CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 14:
More informationCS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1
P a g e 1 CS506 Web Programming and Development Solved Subjective Questions With Reference For Final Term Lecture No 1 Q1 Describe some Characteristics/Advantages of Java Language? (P#12, 13, 14) 1. Java
More informationIntroduction to C++ Systems Programming
Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions
More informationBuilding a Java First-Person Shooter
Building a Java First-Person Shooter Episode 2 [Last update: 4/30/2017] Objectives This episode adds the basic elements of our game loop to the program. In addition, it introduces the concept of threads.
More informationOutline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics
Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming
More informationChapter 6 Introduction to Defining Classes
Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of
More informationLecture 13: more class, C++ memory management
CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 13:
More informationCS 170 Java Programming 1. Week 9: Learning about Loops
CS 170 Java Programming 1 Week 9: Learning about Loops What s the Plan? Topic 1: A Little Review ACM GUI Apps, Buttons, Text and Events Topic 2: Learning about Loops Different kinds of loops Using loops
More informationCollaboration policies!
Tic is over! Collaboration policies! How was the signup process? Were they helpful? Would you rather have more TA hours instead? Design checks You can run demos! cs195n_demo tac2 zdavis cs195n_demo tic
More informationUI Software Organization
UI Software Organization The user interface From previous class: Generally want to think of the UI as only one component of the system Deals with the user Separate from the functional core (AKA, the app
More informationCS 270 Algorithms. Oliver Kullmann. Binary search. Lists. Background: Pointers. Trees. Implementing rooted trees. Tutorial
Week 7 General remarks Arrays, lists, pointers and 1 2 3 We conclude elementary data structures by discussing and implementing arrays, lists, and trees. Background information on pointers is provided (for
More informationSERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,
SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation
More informationCoursework Lab A. Open the coursework project
Coursework Lab A The aim of this lab session is for you to learn the basics of how the coursework framework works. In this first of two lab sessions you will learn about drawing backgrounds and handling
More informationA B C D CS105 03a Interaction
Interaction Function Definition Events Built-in Variables CS105 03a Interaction 1 Which image is drawn by this code? strokeweight(10); stroke(0, 255, 0); // green line(99, 0, 0, 99); stroke(200, 0, 200);
More informationRoad Map. Introduction to Java Applets Review applets that ship with JDK Make our own simple applets
Java Applets Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets Introduce inheritance Introduce the applet environment html needed for applets Reading:
More informationHow to draw and create shapes
Adobe Flash Professional Guide How to draw and create shapes You can add artwork to your Adobe Flash Professional documents in two ways: You can import images or draw original artwork in Flash by using
More informationCSE 303: Concepts and Tools for Software Development
CSE 303: Concepts and Tools for Software Development Hal Perkins Autumn 2008 Lecture 24 Introduction to C++ CSE303 Autumn 2008, Lecture 24 1 C++ C++ is an enormous language: All of C Classes and objects
More informationUnderstanding the implementation of SLS requires a little background on
Implementation of Advanced Display Technologies on HP-UX Workstations This article provides implementation and configuration information about the single logical screen (SLS) technology described in the
More informationKeynote 08 Basics Website:
Website: http://etc.usf.edu/te/ Keynote is Apple's presentation application. Keynote is installed as part of the iwork suite, which also includes the word processing program Pages and the spreadsheet program
More informationEvent Dispatch. Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch. Event Architecture. A pipeline: Event Capture
Event Dispatch Interactor Tree Lightweight vs. Heavyweight Positional Dispatch Focus Dispatch 2.4 Event Dispatch 1 Event Architecture A pipeline: - Capture and Queue low-level hardware events - Dispatch
More informationPointers and References
Steven Zeil October 2, 2013 Contents 1 References 2 2 Pointers 8 21 Working with Pointers 8 211 Memory and C++ Programs 11 212 Allocating Data 15 22 Pointers Can Be Dangerous 17 3 The Secret World of Pointers
More informationCSE au Midterm Exam Nov. 2, 2018 Sample Solution
Question 1. (16 points) Build tools and make. We re building a C++ software back-end prototype for a new food web site. So far, we ve got the following source files with the code for two main programs
More informationSeparate Compilation Model
Separate Compilation Model Recall: For a function call to compile, either the function s definition or declaration must appear previously in the same file. Goal: Compile only modules affected by recent
More informationQUIZ. What is wrong with this code that uses default arguments?
QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code
More informationCISC 1600 Lecture 2.2 Interactivity&animation in Processing
CISC 1600 Lecture 2.2 Interactivity&animation in Processing Topics: Interactivity: keyboard and mouse variables Interactivity: keyboard and mouse listeners Animation: vector graphics Animation: bitmap
More informationCSE 333 Final Exam June 6, 2017 Sample Solution
Question 1. (24 points) Some C and POSIX I/O programming. Given an int file descriptor returned by open(), write a C function ReadFile that reads the entire file designated by that file descriptor and
More informationBlock I Unit 2. Basic Constructs in Java. AOU Beirut Computer Science M301 Block I, unit 2 1
Block I Unit 2 Basic Constructs in Java M301 Block I, unit 2 1 Developing a Simple Java Program Objectives: Create a simple object using a constructor. Create and display a window frame. Paint a message
More informationWork with Shapes. Concepts CHAPTER. Concepts, page 3-1 Procedures, page 3-5
3 CHAPTER Revised: November 15, 2011 Concepts, page 3-1, page 3-5 Concepts The Shapes Tool is Versatile, page 3-2 Guidelines for Shapes, page 3-2 Visual Density Transparent, Translucent, or Opaque?, page
More informationTopic 9: Swing. Swing is a BIG library Goal: cover basics give you concepts & tools for learning more
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 5: Will be an open-ended Swing project. "Programming Contest"
More informationTopic 9: Swing. Why are we studying Swing? GUIs Up to now: line-by-line programs: computer displays text user types text. Outline. 1. Useful & fun!
Swing = Java's GUI library Topic 9: Swing Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Why are we studying Swing? 1. Useful & fun! 2. Good application of OOP techniques
More informationOverview. Applets. A Java GUI inside your browser! Important methods Drawing images Playing audio Getting input parameters Double buffering
Java Applets don't panic about frogs!
More informationSolving a 2D Maze. const int WIDTH = 10; const int HEIGHT = 10;
Solving a 2D Maze Let s use a 2D array to represent a maze. Let s start with a 10x10 array of char. The array of char can hold either X for a wall, for a blank, and E for the exit. Initially we can hard-code
More informationCE221 Programming in C++ Part 1 Introduction
CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab
More informationCS 4204 Computer Graphics
CS 4204 Computer Graphics GLUT (Continue) More Interactions Yong Cao Virginia Tech References: Interactive Computer Graphics, Fourth Edition, Ed Angle Orthographical Projection Synthetic camera model View
More informationIntroducing Motif. Motif User s Guide 1
Introducing Motif Motif is a software system that provides you with a great deal of control over the appearance of your computer s visual display. This introductory chapter provides information on the
More informationHow to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?
BASIC GAUGE CREATION The Video VBox setup software is capable of using many different image formats for gauge backgrounds, static images, or logos, including Bitmaps, JPEGs, or PNG s. When the software
More informationFramework. Set of cooperating classes/interfaces. Example: Swing package is framework for problem domain of GUI programming
Frameworks 1 Framework Set of cooperating classes/interfaces Structure essential mechanisms of a problem domain Programmer can extend framework classes, creating new functionality Example: Swing package
More informationCSE 333 Lecture smart pointers
CSE 333 Lecture 14 -- smart pointers Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington Administrivia New exercise out today, due Wednesday morning Exam Friday
More informationLinked List using a Sentinel
Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include
More informationAn applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a
CBOP3203 An applet is a program written in the Java programming language that can be included in an HTML page, much in the same way an image is included in a page. When you use a Java technology-enabled
More informationSoftware System Components 1 Graphics
Software System Components 1 Graphics Shan He LECTURE 3 Introduction to Java 2D Graphics (II) 1.1. Outline of Lecture Review of what we learned Rendering Shapes 1.2. Review of what we learned Last lecture,
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationModule 5 The Applet Class, Swings. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Module 5 The Applet Class, Swings OOC 4 th Sem, B Div 2017-18 Prof. Mouna M. Naravani The Applet Class Types of Applets (Abstract Window Toolkit) Offers richer and easy to use interface than AWT. An Applet
More informationArrays array array length fixed array fixed length array fixed size array Array elements and subscripting
Arrays Fortunately, structs are not the only aggregate data type in C++. An array is an aggregate data type that lets us access many variables of the same type through a single identifier. Consider the
More informationCPSC 427: Object-Oriented Programming
CPSC 427: Object-Oriented Programming Michael J. Fischer Lecture 10 October 1, 2018 CPSC 427, Lecture 10, October 1, 2018 1/20 Brackets Example (continued from lecture 8) Stack class Brackets class Main
More information