Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are GUI's really made?

My question is
Gui libraries like Qt and lets say for Windows operating systems how do they create all those graphical user interfaces(windows etc).

Does each operating system gives API's or something else to do so?If yes, then how operating systems draw all those windows and things.Do they (operating systems) "control" the screen and then draw each pixel one by one to achieve their goal the GUI?

I would like an answer that explains things at the lowest level possible but well i don't demand someone to write me everything that happens( even if i would like to) because i know many things are behind all these.So for this reason comments with links or suggested books which explain with details
on what is happening under the hood would be appreciated.

like image 792
Lan Pac Avatar asked Nov 13 '22 03:11

Lan Pac


1 Answers

Stackoverflow answers are not supposed to use links, comments can but not answers.

Each operating system and gui library is different, but, yes in some way, shape, or form they do actually draw every one of the pixels. It is often quite organized and many peformance solutions are used, optimized routines that can update a rectangle or some chunk of a screen, sometimes hardware gets involved (these days a lot of the time the hardware or basically gpus get involved the cpu asks the gpu to draw something then the gpus are busy placing all the pixels).

You would likely for example want to create some sort of font rendering function that is given the font, the string to display, the font size, and perhaps a clipping window to not go outside, or perhaps a function that with the font, size and string returns the number of pixels then you can adjust the string to fit and wrap (look around this web page for example, drag the window wider and narrower and watch what web text does).

Definitely some sort of image drawing routines with the ability to stretch or fit the drawing to the rectangle defined.

The fun stuff, games, etc has improved so rapidly over time that it is hard to go back to a simple line draw and area fill routine, etc. But also along with the technology the games brought simple things like web pages benefit...Again look around.

There are many open source programs and libraries you should just wander around the source code and see what you see.

like image 94
old_timer Avatar answered Nov 15 '22 12:11

old_timer