473,653 Members | 2,990 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A fun but difficult program

10 New Member
For this assignment you will write a function which takes as parameters the upper left corner of a button and a string representing the "label" of the button. The function will write the label to the screen with a rectangle drawn around it. The upper left hand corner of the rectangle will be the point sent to the function as a parameter. The declaration of the function is as follows:
//! \brief Draw a button in the drawing window at the specified
//! location with the specified label.
//! \param upper_left The upper left hand corner of the button.
//! \param label The text which appears inside the button.
//! \return Void.
void draw_button( const Point & upper_left, const std::string label );


You will then write a main ( ccc_win_main ) program which tests your function. The main function will set up the graphic window so the upper left hand corner is at the point ( 0, 0 ) and the lower right hand corner is at the point ( 100, 100 ). It will then prompt the user to click on a point in the window where they want the button to be drawn. After a point is entered by the user, the program will prompt the user to enter a string that should be the label of the button. You do not have to be able to handle multiple word strings, a single word is sufficient.

Once the position and label of the button have been obtained from the user, the screen should be cleared and the new button should be displayed in the graphic window by calling the draw_button function. Your program should continue prompting the user for a new location and a label for the button, and drawing the button in the graphic window until the user types "quit" as the button label.

When the user types "quit" as the button label, the program will draw the button with "quit" as its label and terminate. It is OK if the graphic window remains displayed on the computer screen.
Button Specification

When a Message object is displayed in the graphic window it is always the same size regardless of the coordinate system that has been set up with the cwin.coord( ... ) function. This makes it quite difficult to draw objects and text together in a way that is independent of the coordinate system being used. For this reason, amoung others, in every remaining assignment which uses the graphic window we will fix the graphic windows upper left hand corner at the point ( 0, 0 ) and its lower right hand corner at the point ( 100, 100 ).

Since we are permanently setting the size of the graphic window, we can define some constants which represent how wide and how tall a letter is when it is written in the graphic window. These constants are defined in the file global_const.h which is being provided to you. The constants defined in global_const.h that you will be interested in for this assignment are:

WINDOW_WIDTH
The width of the graphic window.
WINDOW_HEIGHT
The height of the graphic window.
UPPER_LEFT
The upper left coordinate of the graphic window.
LOWER_RIGHT
The lower right coordinate of the graphic window.
LETTER_WIDTH
The width of a letter in the graphic window.
LETTER_HEIGHT
The height of a letter in the graphic window.

To use these constants you simply need to sharp include "global_const.h " at the top of your file.

Since we know the width and height of an individial letter, we can draw the border of the button so that the label is completely contained within the border regardless of the length of the label. When the program draws the rectangle that is the border of the button, the rectangle should be a total of 1 LETTER_WIDTH wider than the label, and 1 LETTER_HEIGHTs higher than the label. The label should be centered in the rectangle. Placing the upper left hand conter of the label half a LETTER_WIDTH to the right, and a quarter of a LETTER_HEIGHT lower than the upper left hand corner of the border of the button centers the label quite nicely.

Assignment Framework
main.cpp
Use this file to implement the draw_button( ... ) function and your main function.
Makefile
Your makefile must use the options specified in the class coding standard. The first rule in the makefile shall have a target name of "all" and will compile the program with the default executable name of "a.out". Your makefile must also have a rule with a target name of "clean" which removes the executable and any backup files that were generated by your editor. You should always "make clean" before turning in your assignment.
global_const.h
Oct 17 '06 #1
0 1872

Sign in to post your reply or Sign up for a free account.

Similar topics

54
17390
by: Spammay Blockay | last post by:
I've been tasked with doing technical interviews at my company, and I have generally ask a range of OO, Java, and "good programming technique" concepts. However, one of my favorite exercises I give interviewees seems to trip them up all the time, and I wonder if I'm being too much of a hardass... it seems easy enough to ME, but these guys, when I get them up to the whiteboard, seem to get really confused. The exercise is this:
12
8212
by: Mike Dee | last post by:
A very very basic UTF-8 question that's driving me nuts: If I have this in the beginning of my Python script in Linux: #!/usr/bin/env python # -*- coding: UTF-8 -*- should I - or should I not - be able to use non-ASCII characters in strings and in Tk GUI button labels and GUI window titles and in raw_input data without Python returning wrong case in manipulated
5
1213
by: Nick Keighley | last post by:
Hi, In the beginning the code was:- BRUSHH new_brush = create_brush() BRUSHH old_brush = select_brush (new_brush) draw(...) select_brush (old_brush) destroy_brush (new_brush)
8
1683
by: shan | last post by:
I have tried writing a program which should 1)get a number from user 2)calculate the following for e.g if the input is 3 then 3 3 3 and the answer should be 19683. 3)similarly when the user entered 4 or 5 or any number it should give the rquired result.
7
1525
by: Manu | last post by:
Hi! All I was wondering what is the most difficult part of windows programming Is it Network Programming Etc..
0
1739
by: tom | last post by:
Hallo, I need help on MIDI file, and precisely about retrieving few note values (mainly the "Velocity" value, corrisponding to the intensity of a played note) while the MIDI is playing.
2
2277
by: Eniac | last post by:
*argh* ... *pull hairs* I've recently started developing from ASP to ASP.NET The switch was fairly smooth since i had done some VB.net before ... then came...FORMS! :) I find it astounding at how difficult it has become to control a form, something that was so dead easy in ASP.
4
1330
by: Laserson | last post by:
Hi all! I have a very difficult task for me and i can't so it. My task: I have created an application. But how to determine that it is not responding??? You can see it when windows add "Not Responding" to application title, but how to catch it from application? I hope you'll help...
6
2678
by: Jacob Rael | last post by:
Hello, I have a simple script to parse a text file (a visual basic program) and convert key parts to tcl. Since I am only working on specific sections and I need it quick, I decided not to learn/try a full blown parsing module. My simple script works well until it runs into functions that straddle multiple lines. For example: Call mass_write(&H0, &HF, &H4, &H0, &H5, &H0, &H6, &H0, &H7, &H0, &H8, &H0, _
0
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5620
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.