Main Page | Modules | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

GUI Class Reference

#include <gui.h>

List of all members.


Detailed Description

This class is able to build simple GUI's.

This class includes the ability to create a window in X, display an image stored in a buffer, and handle simple mouse and keyboard input.

Definition at line 40 of file gui.h.

Public Member Functions

 GUI ()
 Constructor.
 ~GUI ()
 Deconstructor.
int init ()
 Initializes SDL with given parameters.
int setDisplayMode (int mode)
 Sets the display mode.
void drawPixel (int x, int y, int r, int g, int b)
 Draws a pixel.
int drawFrame (struct Frame *frame, int x, int y)
 Draws a frame object.
int drawImage (struct Image *pic, int x, int y)
 Draws an Image object.
void drawLine (int x1, int y1, int x2, int y2, int r, int g, int b)
 Draws a line on the screen.
void setTitle (char *title, char *icon)
 Sets the title of a window.
void clearScreen (int r, int b, int g)
 Fills the screen with a color.
void toggleFullScreen ()
 Toggles full screen mode.
void showScreen ()
 Shows the screen.

Public Attributes

int displayFlags
 SDL flags to be passed to video mode.
int height
 Height of screen.
int width
 Width of screen.
int bpp
 Bits per pixel of screen mode.
SDL_Surface * screen
 SDL surface to hold the main display.


Constructor & Destructor Documentation

GUI::GUI  ) 
 

Constructor.

Initializes SDL and sets up default variables.

Definition at line 6 of file gui.cpp.

References displayFlags.

GUI::~GUI  ) 
 

Deconstructor.

Shuts down the SDL and makes sure all windows are closed and freed.

Definition at line 11 of file gui.cpp.


Member Function Documentation

void GUI::clearScreen int  r,
int  b,
int  g
 

Fills the screen with a color.

This method looks up the 32-bit color, given a set of red, green, and blue values. Then, it fills the screen with this color. Pass 0,0,0 as the red, green, and blue values to clear the screen with with black.

Parameters:
r - Red value to color screen.
g - Green value to color screen.
b - Blue value to color screen.

Definition at line 172 of file gui.cpp.

References screen.

int GUI::drawFrame struct Frame frame,
int  x,
int  y
 

Draws a frame object.

The frame class contains enough information about a captured image for it to be displayed on screen. The height and width of the frame are taken straight from the frame member varibles. It can be placed anywhere on screen.

Parameters:
frame* - Frame* instance to draw.
x - X coordinate to draw frame.
y - Y coordinate to draw frame.
Returns:
TRUE if successful, FALSE if error.
Todo:
Add error checking (always returns TRUE now), color depth check

Definition at line 139 of file gui.cpp.

References Frame::blueMask, Frame::buffer, drawPixel(), Frame::greenMask, height, Frame::masked, Frame::redMask, Frame::width, and width.

int GUI::drawImage struct Image pic,
int  x,
int  y
 

Draws an Image object.

This method extracts the SDL_Surface from the Image object and places it on the screen in a specified location.

Parameters:
pic - Image object containing the BMP to show.
x - X coordinate to draw image.
y - Y coordinate to draw image.
Returns:
int - TRUE if successful, FALSE if error.
Todo:
Add some sort of error checking (always returns TRUE)

Definition at line 158 of file gui.cpp.

References screen, and Image::surf.

void GUI::drawLine int  x1,
int  y1,
int  x2,
int  y2,
int  r,
int  g,
int  b
 

Draws a line on the screen.

This method uses a fast, integer based line drawing algorithm to display lines on screen.

Parameters:
x1 - Starting X coordinate of line.
y1 - Starting Y coordinate of line.
x2 - Ending X coordinate of line.
y2 - Ending Y coordinate of line.
r - Red value of line.
g - Green value of line.
b - Blue value of line.

Definition at line 194 of file gui.cpp.

References drawPixel(), Point2D::x, and Point2D::y.

void GUI::drawPixel int  x,
int  y,
int  r,
int  g,
int  b
 

Draws a pixel.

This method calculates the proper offset in the video buffer, creates the specified color, and draws it to the screen. It also makes sure to lock and unlock the screen if necessary.

Parameters:
x - X coordinate of pixel.
y - Y coordinate of pixel.
r - Red value of color.
g - Green value of color.
b - Blue value of color.
Todo:
Add support for palettized display modes.

Definition at line 115 of file gui.cpp.

References screen.

Referenced by drawFrame(), and drawLine().

int GUI::init  ) 
 

Initializes SDL with given parameters.

This method read the private class variables that can either be set directly or ignored. If ignored, the method will use default values established in the constructor.

Returns:
int - TRUE if successful, FALSE if error
Todo:
Have init try loading first with HW Double buffer, then SW

Definition at line 16 of file gui.cpp.

int GUI::setDisplayMode int  mode  ) 
 

Sets the display mode.

This method attempts to create an SDL surface of the specified type and change the display to that surface. The possible mode parameters are listed at the top of gui.h.

Parameters:
mode - The display mode to use. (See gui.h)
Returns:
int - TRUE if successful, FALSE if error

Definition at line 30 of file gui.cpp.

References bpp, displayFlags, height, screen, and width.

void GUI::setTitle char *  title,
char *  icon
 

Sets the title of a window.

This method is used to set the value of the caption that appears at the top of a regular window. The string is passed to the window manager, which takes care of rendering the text.

Parameters:
title - String for the name of the window.
icon - String for the name that appears in the icon box

Definition at line 167 of file gui.cpp.

void GUI::showScreen  ) 
 

Shows the screen.

This method flips the display buffer and the screen buffer so changes can be seen by the user. This is usually called after the program finished drawing an entire frame.

Definition at line 182 of file gui.cpp.

References screen.

void GUI::toggleFullScreen  ) 
 

Toggles full screen mode.

This method attempts to switch the display from windowed mode to fullscreen mode.

Definition at line 177 of file gui.cpp.

References screen.


The documentation for this class was generated from the following files:
Generated on Wed Aug 31 15:16:39 2005 for Chair by  doxygen 1.4.2