How can I make GUI Framework in C++?

A good start would be to learn an existing GUI framework. wxWidgets (Cross-Platform GUI Library) and Qt (Qt Project) are both cross-platform GUI frameworks that are worth learning from (of these two, wx is simpler but much less capable). The major operating systems also have their own proprietary frameworks. Windows has the Win32 API, the MFC API, and parts of .Net (plus some new thing for the tablets which I haven't played with yet). OS X has Cocoa. Linux has X-Windows, and a bunch of stuff that boils down to adding goop on top of X-Windows. I'm also a fan of Unity (Unity – Game Engine), which has a GUI library that is very simple (you just write a render method) and surprisingly expressive.

Next, you need to decide which layers you're interested in writing. Do you want to build your own graphics sub-system entirely from scratch? You might want to look into writing your own operating system. Do you want to use an existing graphics subsystem, and build your GUI on top of that? You should look into 2-d rendering libraries, like the native tools in your OS or something like SDL (Simple DirectMedia Layer – Homepage). You can also write a 2d or 3d GUI on top of an existing library, like OpenGL (NeHe Productions – Everything OpenGL) or DirectX (DirectX Software Development Kit). SDL or DirectX will also handle input from peripheral devices (mouse, keyboard, joystick, …) for you; if you're using OpenGL, you will need to find some other library to help with this. You might use glut (GLUT – The OpenGL Utility Toolkit), which is easy but a bit limited, or you might use SDL + OpenGL if you still want the 3d support.

Once you've got graphics and I/O, things are wide open. Will your GUI work as an event-pump, and your users write code by filling out event handlers? Qt is like this. Or will you leave the main execution loop in your user's hands, and your GUI is just a bunch of utility methods? Unity is like this. Or will you have the user implement both the event pump and the event handlers? The raw Win32 API works this way.

I could talk a little about the inheritance structure that's usually used for a GUI, but that's not the only way to do it. Read up on Qt if you want to see a beautiful implementation (or MFC if you want to see a hideous implementation). Really, I think you'll have more fun just by experimenting.

Answer by Adam Helps:

A good start would be to learn an existing GUI framework. wxWidgets (Cross-Platform GUI Library) and Qt (Qt Project) are both cross-platform GUI frameworks that are worth learning from (of these two, wx is simpler but much less capable). The major operating systems also have their own proprietary frameworks. Windows has the Win32 API, the MFC API, and parts of .Net (plus some new thing for the tablets which I haven't played with yet). OS X has Cocoa. Linux has X-Windows, and a bunch of stuff that boils down to adding goop on top of X-Windows. I'm also a fan of Unity (Unity – Game Engine), which has a GUI library that is very simple (you just write a render method) and surprisingly expressive.

Next, you need to decide which layers you're interested in writing. Do you want to build your own graphics sub-system entirely from scratch? You might want to look into writing your own operating system. Do you want to use an existing graphics subsystem, and build your GUI on top of that? You should look into 2-d rendering libraries, like the native tools in your OS or something like SDL (Simple DirectMedia Layer – Homepage). You can also write a 2d or 3d GUI on top of an existing library, like OpenGL (NeHe Productions – Everything OpenGL) or DirectX (DirectX Software Development Kit). SDL or DirectX will also handle input from peripheral devices (mouse, keyboard, joystick, …) for you; if you're using OpenGL, you will need to find some other library to help with this. You might use glut (GLUT – The OpenGL Utility Toolkit), which is easy but a bit limited, or you might use SDL + OpenGL if you still want the 3d support.

Once you've got graphics and I/O, things are wide open. Will your GUI work as an event-pump, and your users write code by filling out event handlers? Qt is like this. Or will you leave the main execution loop in your user's hands, and your GUI is just a bunch of utility methods? Unity is like this. Or will you have the user implement both the event pump and the event handlers? The raw Win32 API works this way.

I could talk a little about the inheritance structure that's usually used for a GUI, but that's not the only way to do it. Read up on Qt if you want to see a beautiful implementation (or MFC if you want to see a hideous implementation). Really, I think you'll have more fun just by experimenting.

How can I make GUI Framework in C++?

Advertisements

Leave a comment

Filed under Life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s