GUI stands for a graphical user interface GUI
And so you get the acronym GUI and he's probably the predominant way we interact with computers today and with mobile phones
That's the term that sees these days in the 80s people tended to refer to them as wimps windows
Icons mice and pulldown menus or windows icons menus and pointers
Depending on which version of the acronym you went to well that pretty much just describes
The systems we get on computers today a GUI can refer to any sort of graphical user interface
for example
Your mobile phone doesn't have pointers on it and so on a 3d virtual reality interface is a graphical user interface
but if put doesn't have nice or pulldown menus involved
When it comes to writing GUI software things become
More interesting than writing sort of traditional command-line software or software
Where you're typing into the software and the reason is is that when you write a program of the traditional sort the command line sort
You have control as a programmer. I mean, let's think about that simple program. We looked at before and I shall just sketch it out
We have our main function and then we say printf and then we have some text hello world
Whatever it is and it prints out in that order now
Let's say we wanted to write a program that would ask you what your name is. And then ask you when your birthday is
So we could write the same cell phone
so we print out that and then we would say we want to read some text and because we're using
C we need space to read in the name
So we need a variable to store that in might be a long name and then we say we want to read in
we using the scanf function a
String in two names so we can read him today and then we can print out another message
Please enter your age your birthday
whatever it is you want and then you can say
read in that and you can specify that you want that to be an integer followed by slash followed by
Another integer followed by a slash followed by another integer don't like that
And so then you can read in that and you've got control
You know that when the user types here
They're typing in their name or should be typing in the name because of putting in keys there and when you're typing in here
They're typing in the date and you can check them
They've put the right things it if we were to do the same thing where the GUI
Then things get a little bit more interesting. So let's try and create one. I'm using Xcode
I'm using a Mac here because I have a Mac on my desk exactly the same would apply for Windows and Atari ST
A I'll click on it archimedes
Whatever is it you wanted to do it on so let's have a window and let's start building the same sort of thing
So we've got our window so we want some text. So let's put in a label that says name
And then we want to actually put in space for the person's type in their name
So we'd have a text field drop that in as well. We can line all that's it
We've now got space for that to do so and do the same again. They report birthday
and again, we'd have another text field so it isn't just
One summer so yeah, I mean at this point
we're not really what we are programming but we're declaring so what we want in the thing and we're defining it using a sort of
GUI thing which makes it nice and relatively straightforward to implement
And that's great but that
Only gets us as far as what peers in though that just saves typing lots and lots of boilerplate code
Which says add a text box at this position and so on and does that and gooeys are a great example of abstraction
We talked about again the other day in action because you can abstract lots of things
So all the code that's generating. These user interface is still there
I'm just not having to write it the computer can create it and loading the take data files and so on for me
so we've now got
Roughly the same sort of thing here and if we run the program now, you should hopefully pop up
and you program let's get rid of Xcode and
Eventually my program that's up and I can enter my name and I can enter my birthday
1/2/3 but whereas before if I was to write this program and that's write a command line version just to compare
Here I am going to
Print out, please
Enter your name
Support computer program so we need a variable to store that
We probably want one for the day
month and year
So we can then read in from that you want to read in the string and we'll put that into name
And we want to print out now enter
your birthday
Don't to print out a new line there either
Then we can read in
That as well so we read in the day the month and
The year
And then we can print out your birthday. Then we can print out those values again
so we've got two programs that allow us to enter our name and
Birthday, but if we run them they work in very very different ways
So let's just get a command line so we can run the command line one. So let's run this program
Just please enter your name Shaun enter your birthday
1/2/3
and
Yeah short vowel and it says your birthday is 1/2 accessory so we can write a program we can collect some data from the user
But our programs in control we could either we have to enter our name because it's after our name
We have to enter our birthday because it ssj4 our birthday if we go back to the gooey one
Then things are different because now we're in control because we've got the box
they're saying enter your name so we could enter our name and then our birthday or
We could enter our birthday first and then we can enter our name or we can start typing in our thing
they better put the birthday in and then
Better complete the birthday and type it in
and different things so
When we write a command line program or certainly simple command line programs the programs in control
It asks the user for input it gets that input for the user. It's asking for what particular type is and so on
When you get a GUI?
It changes you present the user with something. They will then fill it in in the order
They want or click the button and the order they do to do the task. And then you have to do whatever it is
At that point. So at this point we've put that values in
When it's finished
I'd probably have an OK button and add in so I'd have an OK button when that fires
We could run some code which occur close to values and put them together
So when we write a program to the GUI, they're working in a very different style
They have to be driven by what we call
Events things happening outside the program that they react to so the user clicks on a button
The user clicks the mouse user puts the mouse button back up. The user moves the mouse the windows move
You have to redraw the contents. How does that happens? When does that happen? All these things?
Have to be responded to by your program
So you're no longer saying ok do this then this then this and this you have to respond
To the events as they come as the programs running. So we've got a very different way of writing
Our program command-line programs can get like that
If you think about something the hair say like VY
You can press different keys and it does different things
so you press again because different things and
Do things at different times or you might have menu options and depending on what key it is you do different things in different orders
So you can't get to that point but by that point you becoming less of a command-line program and more
GUI like by the sounds of it in that kind of a command-line program where it's getting like a GUI
It's almost like you're writing the GUI
And yes, exactly
So you command line program you could write it to the point where it becomes more and more
Like a GUI effectively in you displaying that I mean the Debian Linux command line installs a building an example of this
Is that it looks?
More and more like a GUI drawn with text characters in a window rather than with lines and pixels
It's sort of where and how you respond to the input. So any write a computer program like this
Why do you call scanf for?
Input in basic or whatever it is. You using to read from the keyboard
You've said I want to read a series of things from the keyboard until
Something happens or get me a key that's been pressed and you know, that key is going to be pressed when you're writing a GUI
Any number of things could happen based on what's happening? It could be the someone's the window
So you need to redraw that bit of the screen. It could be that someone's clicked a button
So you have to respond to that button
it could be that another program is running and
Someone's dragged a file and dropped it onto yours and you have to respond to that so you have to respond to all these things
And you can't just assume your programs going to linearly follow each line of code one after the other
Of course, that's what's actually happening
The CPU is still doing that but it's actually jumping between the operating system in your code
Between the gooey libraries and things that are supported to implement your thing
Depending on what level it is to make the program run in different things. So what we'll do
over the next few computer files because we'll actually start to
Look at how we write GUI software. So we'll actually look at how we implement it and we started to look here
We've got a high level system cocoa on the Mac. There's equivalents WPF on
Windows and things and we can look at them and how they do it
They provide a very easy way to do things because I say I want
To text fields I can get the values from them and do things
But we'll also look at a lower level at some of the earlier Geary's cups like the original Macintosh
version or what happened on the Atari what happened on riscos and so on and
See how they work and then we'll start to look under the hood of what's going on and seeing how this program actually
Functions how we get to these things and how we implement the GUI
Image here into a set of pixels that are either black or white but which are compensating for the error and so again,
we'll give the appearance of
the original gray things
But if you were to zoom in on this you would say it's been found a hundred and eleven
Thousand times dyes engrave what that means is that in