1 00:00:00,000 --> 00:00:00,420 2 00:00:00,420 --> 00:00:02,830 >> DAVID MALAN: Let's write a program with a graphical user interface, 3 00:00:02,830 --> 00:00:04,210 otherwise known as a GUI. 4 00:00:04,210 --> 00:00:07,450 And for this, we'll use Stanford's portable library, which comes with 5 00:00:07,450 --> 00:00:08,970 some header files of its own. 6 00:00:08,970 --> 00:00:10,330 Let's dive in. 7 00:00:10,330 --> 00:00:15,180 >> First, I'm going to include a file called gwindow.h. 8 00:00:15,180 --> 00:00:18,230 And notice, first that I'm using quotes instead of angle brackets 9 00:00:18,230 --> 00:00:20,880 because this header file happens to be in a sub directory 10 00:00:20,880 --> 00:00:22,510 of my current directory. 11 00:00:22,510 --> 00:00:26,760 Next, let's declare main as usual, int, main, void. 12 00:00:26,760 --> 00:00:30,590 And now let's proceed to instantiate, so to speak, that is create a 13 00:00:30,590 --> 00:00:31,720 graphical window. 14 00:00:31,720 --> 00:00:35,260 Otherwise known as a gwindow, as follows-- 15 00:00:35,260 --> 00:00:40,250 Gwindow window equals new gwindow. 16 00:00:40,250 --> 00:00:43,170 >> And now I need to specify the width and the height of this window. 17 00:00:43,170 --> 00:00:45,610 I'm going to go with something somewhat arbitrary, but somewhat 18 00:00:45,610 --> 00:00:48,340 small, so that it fits within the appliances window. 19 00:00:48,340 --> 00:00:52,710 Specifically, 320 by 240 pixels. 20 00:00:52,710 --> 00:00:56,510 Recall then, that a pixel is one of those dots on your screen. 21 00:00:56,510 --> 00:01:00,270 Next, let's go ahead and do not much of anything at all and simply pause 22 00:01:00,270 --> 00:01:01,950 for 500 milliseconds. 23 00:01:01,950 --> 00:01:04,349 Calling a function called pause that also is in the 24 00:01:04,349 --> 00:01:05,720 Stanford portable library. 25 00:01:05,720 --> 00:01:09,830 >> Finally, after those five seconds, let's go ahead and close the gwindow, 26 00:01:09,830 --> 00:01:11,260 as follows. 27 00:01:11,260 --> 00:01:14,330 And then let's return zero signifying that we're all done. 28 00:01:14,330 --> 00:01:15,930 >> So what is this program done? 29 00:01:15,930 --> 00:01:19,330 Well, in a moment we should see, when we run in, that it opens a window 30 00:01:19,330 --> 00:01:22,680 that's 320 pixels wide by 240 pixels wide. 31 00:01:22,680 --> 00:01:25,130 That window just lingers there for five seconds and then 32 00:01:25,130 --> 00:01:27,440 it should go away. 33 00:01:27,440 --> 00:01:32,290 Make window, dot, slash, window. 34 00:01:32,290 --> 00:01:35,240 And there's our window, on the top left hand corner of my screen. 35 00:01:35,240 --> 00:01:38,720 And in just a few seconds it's gone. 36 00:01:38,720 --> 00:01:39,970