Doc Index

Back
Main


Acknowledgements


I cannot take credit for the CMU Graphics package, it was mainly Geoff's work that made it possible for me to even consider doing this. I have mearly done work to help improve the work done by Geoff and others that have contributed as well. One of these things is to provide documentation on the package that does more than provide minimal reference documentation. That has been the main weakness of CMU, but this will rectify that problem. A word of caution however, is that this document does not actually apply to either v1.2 or v2.x, but v1.5. This documentation will be updated to handle later versions of 1.5 if there are any, but I believe development will move solely to v2.x once 1.5 is finished. This documentation will be replaced by v2.x documentation once v2 becomes stable enough to work with, and that development of the programming interface is 'frozen'. Thanks to Geoff Washburn and Mark Stehlik for bringing this package into existance, and outside CMU's boundaries.


Package Organization


The CMU package is organized into 2 major parts: the Window class, and a small group of classes designed to make using the Window class simpler. These can be organized as such:

Window -> Pane -> Font, Color & Palette

The Window class is the main class and is required to use CMU. Pane is a partial subclass of Window, while Font, Color & Palette are data classes designed to store complex data relating to certain attributes of the Window or Pane. This manual will describe the data classes, then go into depth on the Pane and Window classes and their behaviors.


Fonts, Colors & Palettes... Oh My!


One of the most annoying things I personally have had to deal with in Graphics programming is constantly setting a new color, font, etc. for every time I wanted to draw. This usually consisted of hunting down what font, size and style I needed and calling many functions to get it done. One must check the screen depth to see if the color can be handled, check to see if the font exists, etc. before they can even use it, and all they are doing is using a constant font too. These classes help solve that to an extent.

These data classes store a group of data that is associated with a specific setting. The organization should be slightly obvious: Color stores the RGB values for a color used on the screen, Palette stores the Color values for the Pen, Brush and Background as well as store the pen size, and Font stores the name, size and style of a font. They provide constructors to set the data when you first declare the object, operators to move and compare the objects, and member functions to adjust specific values of the object. I guess the best way to demonstrate this is to show an example:

// Ex 1 - Setting a Font, Color and Palette

void myFunction( Window &myWindow )
{
	// Black Pen & Brush on a White Background.
	Palette myPalette = Palette( BLACK, BLACK, WHITE );
	// Plain Helvetica, Size 12.
	Font myFont = Font( "Helvetica", 12, PLAIN ); 
	// Red
	Color myColor = Color( 255, 0, 0 );
	
	// Change the pen of the palette to red
	myPalette.SetPen( myColor );

	// Change the window's font to Helvetica.
	myWindow.SetFont( myFont );
	
	// Update the window's palette as well.
	myWindow.SetPalette( myPalette );

	// This does not actually take effect until we 
	//  call SetPalette() again.
	myPalette.SetBrush( myColor );
	
	// Update the palette yet again.
	myWindow.SetPalette( myPalette );
}
 

You don't need to worry about the calls made to myWindow, since we won't be discussing Windows and Panes until the next section. At the end of this section, there is a reference for what calls can be made to the members of the classes. A few notes about the classes as well:

If you use the Window class to set a Palette, Font or Color, and then change the color object's values, then the window is not automatically updated with the new values. If you modify a value, you will have to send the object back over to the window for the changes to take effect.

NOTE: Before 1.2.2 is finalized, this behavior may change and automatically update the window when you change something in the active palette. Unfortunately, this is doubtful because of wonderful things that the stack can mess you up with.

- Data Class Reference



Font Reference

MemberParametersFunction
FontFont &oRef Standard Copy Constructor
Font(string/char *) fontName
int fontSize
int fontStyle
Standard Constructor
Rename(string/char *) sFontName Sets a new name for the font.
Resizeint iFontSize Sets a new size for the font.
Restyleint iFontStyle Sets a new style for the font. Please see the Constants section of the manual for valid input for this function.
=
==
!=
Font &oRef Valid Operators


Color Reference

MemberParametersFunction
color(unsigned char/double) Red
(unsigned char/double) Green
(unsigned char/double) Blue
Standard Constructor
SetRed(unsigned char/double) Red Sets the red value for the color
SetGreen(unsigned char/double) Green Sets the green value for the color
SetBlue(unsigned char/double) Blue Sets the blue value for the color
=
==
!=
Color &oRef Valid Operators


Palette Reference

MemberParametersFunction
=
==
!=
Palette &oRef Valid Operators

Appendix



Font Styles

PLAINPlain Font, no modifications.
BOLDBold Font
ITALICItalic Font
UNDERLINEUnderlined Font
STRIKEOUTPC: Font with a line through it
Mac: Shadowed Font