How are user interfaces developed from the ground up in low level languages like C or C++? We usually make GUIs using libraries or APIs. But I'm interested in understanding the fundamentals of how these libraries are implemented and how they create a Window from just coding only.
-
http://stackoverflow.com/questions/6399676/how-does-opengl-work-at-the-lowest-level you can read that answer. – Viet Nov 28 '15 at 04:23
2 Answers
There is a surprising amount of stuff to make a simple GUI control like a button work.
Quite a few years ago I was on a project developing a Pacemaker Programmer (custom computer) where we needed to write a GUI application but the OS we were using only had text-based output support. We purchased a product called the Zinc Application Framework that could do that for and since it was designed to work on anything, we had access to the source code (and I peeked).
There are simple thinks like you would not even think about. Like, what if the button is partially covered by another window. Then you have do the divide the button into both an visible and hidden region so you can display the correct part. Remember, a screen is only one set of pixels. Now, I am sure a graphics card or a library/protocal like direct-X might do that for you; but, it has to get done and you wanted to know the details.
Zinc was a very Object Oriented design so the part I described is part of the window drawing component that the button did not need to know about. Also, it used a lot of inheritance (written in C++) to build class upon class; so, the total functionality of a button was spread all over the place. Ex: A button and a check box are very similar except in the way they are displayed; so, the classes the realize them share the same base classes.
If you are really interested and are willing to spend the hours to understand it, there should be open-source Windowing/GUI code you could look at. X-Windows comes to mind. I wish I could show you the Zinc code because I am sure it was much simpler.

- 690
- 2
- 7
- 25
One of interesting readings on this topic i read was document of wayland http://wayland.freedesktop.org/docs/html/ch01.html. It explains on X Window System and wayland architecture. To begin with, may be interested.

- 2,408
- 27
- 27