View Single Post
Old 03-18-2003, 04:49 PM   #1 (permalink)
Zenogear11
Registered User
 
Zenogear11's Avatar
 
Join Date: Mar 2003
Location: Pittsburgh
Posts: 45
Zenogear11 is on a distinguished road
Send a message via ICQ to Zenogear11 Send a message via AIM to Zenogear11
Lightbulb My first post, I need help

My first post...Hi! I am writing a calculator (only programming for 6 weeks now) and I need some help. I know all my code is in main, and thats a bad thing, but ill organize it later. Code:
Code:
#include <iostream.h>
#include <CMUgraphics.h>



int main()
{
	//****************
	// Variables    **
	int sizebutx = 35;
	int counter2 = 0;
	int counter = 0;
	int sizebuty = 35;
	int spacebutx = 17;
	int spacebuty = 34;
	int calcx1 = 20;
	int calcy1 = 20;
	int calcx2 = 300;
	int calcy2 = 500;
	int buttonx1 = (calcx1+spacebutx);
	int buttony1 = (calcy2-spacebuty);
	int buttonx2 = (calcx1+spacebutx+sizebutx);
	int buttony2 = (calcy2-spacebuty-sizebuty);
	//*******************
	window testWindow(650,500,0,0);
	testWindow.SetPen(RED);
	testWindow.SetBrush(BLUE);
	testWindow.DrawRectangle(calcx1,calcy1,calcx2,calcy2,FILLED);
	
	testWindow.SetPen(GREEN);
	testWindow.SetBrush(RED);
	do
	{
		//Draws Columns
		counter2++;

	do
	{
		//Draws Rows
		
	testWindow.DrawRectangle(buttonx1,buttony1,buttonx2,buttony2,FILLED);
	buttonx1 = buttonx1+sizebutx+spacebutx;
	buttonx2 = buttonx2+sizebutx+spacebutx;
	
		counter++;
	}
	while (counter < 5);
		buttony1 = buttony1-sizebuty-spacebuty;
		buttony2 = buttony2-spacebuty-sizebuty;
		buttonx1 = (calcx1+spacebutx);
		buttonx2 = (calcx1+spacebutx+sizebutx);
		counter = 0;
	}
	while (counter2 < 5);
	testWindow.SetFont(20,BOLD,SCRIPT);
	testWindow.SetPen(YELLOW);
	testWindow.DrawString(50,165,"1");
	testWindow.DrawString(100,165,"2");
	testWindow.DrawString(150,165,"3");
	

	return 0;
}
CMU graphics is what im using to draw the calculator and the guide for it can be found
Here

I need to know how to make my calculator buttons clickable, and display the number they represent in a graphics box (after I draw all of them).

Thank you for your help in advance.
Zenogear11 is offline   Reply With Quote