Re: A new GUI/Widget Toolkit?
- Posted by ryanj Feb 04, 2022
- 1013 views
Hello all,
Does anyone have idea on where to start to make a GUI/Widget toolkit from scratch? I'd like to write it in C, so that I could then make a wrapper for it in Euphoria. I've briefly looked over source code for IUP and FLTK, but it looks it has to be built on top of something. Like the Windows API or Xlib(For Linux/Unix). Something that would have common controls to start, like a window, buttons, menus, menu-items, check-boxes and radio buttons. I've seen some GUIs built on top of SDL, so that could be one way. I of course want it to be cross-platform.
*Cough* Redy *Cough* LOL
But seriously, that's exactly what I did with Redy, except it's pure euphoria. I wrapped all the basic win32 api to create windows, handle events, and draw to bitmaps. Eventually, I added more advanced features like clipboard functions. It took me years, and it's still not finished. But, I learned so much from it. I gained a good understanding of the foundational win32 api. Those concepts can be carried over to linux. I haven't had time to port Redy to linux yet, but I basically understand how it could be done. I also learned a ton about optimization! The first few versions of Redy were horribly slow, but the version that RedyCode is built upon is amazingly fast, except for a few odd things here and there. I also learned a ton about important programming concepts, such as object-oriented and reactive programming. Even though Euphoria doesn't technically have those features, I was able to structure my code in a way that followed those concepts. And I also learned a lot of things that I could have done better, and would like to improve, but it would require a lot of rework.
I would suggest looking up the API documentation for windows and/or linux for creating windows, handling events, and drawing graphics. All the general API stuff. Ignore the controls/widget libraries, just look at the raw graphics stuff, and learn how to handle mouse/keyboard events, and draw/load/save bitmaps in memory, and how to manipulate windows and draw to them. It will take a lot of planning and good structure to define your own widget classes and how they interact with each other, as objects in a tree, with parent/child relationships. It's a lot of work, but it's definitely doable and is a great learning experience!