Gui Help

Hello c++ Gods,

For some odd reason when I try to display the text in the canvas, it'll omit the second portion of the text( i.e Fox Trot = will only show Fox, instead of Fox Trot ).

The code is below; any help will be much appreciated; Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <Simple_window.h> // A plain window with the "Next" button
#include <Graph.h>  // A header with access to our graphics library facilities

using namespace Graph_lib; // Our graphics facilities are in Graph_lib
using namespace std;

int main()
{
    Point t1(100,100);  // top-left corner of window    
    Simple_window win(t1,600,400,"Canvas");  
    // screen coordinate tl for top-left corner
    // window size(600*400)
    // title: Canvas

    string user_name;

    cout << "Please input your full name: ";
    cin >> user_name;

    Text t(Point(150,150), user_name);  // location of where user_name
					// will be displayd in the window
    t.set_font(Graph_lib::Font::times_bold);
    t.set_font_size(20);

    win.set_label("Project 1a"); 
    win.attach(t);  // attach the cin of the user to the window win
    win.wait_for_button();  // give control to the display window
}
cin >> user_name;

This will take input as far as the first white space. Look up getline.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <Simple_window.h> // A plain window with the "Next" button
#include <Graph.h>  // A header with access to our graphics library facilities

using namespace Graph_lib; // Our graphics facilities are in Graph_lib
using namespace std;

int main()
{
    Point t1(100,100);  // top-left corner of window    
    Simple_window win(t1,600,400,"Canvas");  
    // screen coordinate tl for top-left corner
    // window size(600*400)
    // title: Canvas

    string user_name;

    cout << "What is your name? ";
    getline(cin,user_name);

    Text t(Point(150,150), user_name);  // location of where user_name
					// will be displayd in the
					// window
    cout << "Click the ""Next"" button to quit\n";
    t.set_font(Graph_lib::Font::times_bold);
    t.set_font_size(20);

    win.set_label("Project 1a"); 
    win.attach(t);  // attach the cin of the user to the window win
    win.wait_for_button();  // give control to the display window
}


It worked-- thanks a lot!
Hello c++ Gods


HAHAHAHAA! WOW! You really trust us?
Topic archived. No new replies allowed.