CS 480    -    Program # 2    -    Due:  2/18/02

Assignment:
Write a C++ class definition (and all appropriate member function definitions for the class) that implements a sliding-bar control widget that returns a floating-point value.  Then use this class to implement a program that allows the user to change the Red, Green and Blue components of the color of a polygon that is drawn on the screen.  This will give the user a way to test various RGB color values interactively.
Sliding-Bar Class Definition:
Use the class definition of the PushButton class (seen in class) as a guide for creating a Sliding-Bar control widget class in C++.  Here are the data members and member functions that you should implement for this control:
Data Members: Member Functions:
Program:
Draw three sliding-bars on the screen, one for the Red component of the color of the Polygon to be drawn by your program, one for the Green component, and one for the Blue component.  Declare three global floating-point variables that will contain the starting red, green and blue color values -- be sure to initialize these variables with the same values passed into the constructor functions for the sliders of the same color.  Also, include three PushButton objects in your program:  a Button labelled "Triangle", a button labelled "Square" and a button labelled "Quit".

Initially, the screen should only show your buttons and sliders.  If the user clicks on the Triangle button, draw a triangle with randomly-determined vertices in the display window, using the colors that are indicated by the current values of the sliders.  If the user clicks on the Square button, draw a square with randomly-determined vertices in the display.  The program should exit if the Quit button is clicked.

Your mouse callback function should be able to handle a click on the buttons properly.  You will also need a motion callback function that will test to see if the motion event (a dragging of the mouse) happens on the knob of one of your sliding-bars.  If so, call the moveKnob function for the sliding-bar, use the return value of the moveKnob function to change the appropriate color component global variable, and redraw the sliding-bar (so that the knob position is updated on screen).
Notes:
Completing this assignment as specified above is worth 13 points (out of a possible 15).  In order to earn more points, add your own creative touches to the program.  Some suggestions might include:  coloring the screen background, buttons or other program features; more descriptive text on the screen (in a variety of fonts), other functionality for button or slider widget behavior, etc.  Be creative, and have fun!  This assignment is to be completed individually. Please submit a title page and printed source listing, and send a copy of your .CPP fil.e to CINDRICBB on or before the due date.