Hi,
I've got a few questions:
Am I able to create a GUI application in wxWidgets without subclassing wxFrame/wxApp etc? This seems like a very restrictive, verbose, and annoying structure, but I can't find any resources that don't do it.
Can I start at my own main function rather than have wxWidgets steal that control away from me?
If I'm only using the GUI part of wxWidgets, do I need any instance of wxApp? I'd rather not have it.
GUI/App without subclassing Topic is solved
-
- In need of some credit
- Posts: 2
- Joined: Fri Apr 17, 2015 1:34 am
-
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
Re: GUI/App without subclassing
wxWidgets is really designed as an object oriented library. At the least, you'll need to subclass wxApp, but it is possible to avoid subclassing almost everything else, however, you will be fairly limited in what you can do. Really though, why are you trying to avoid object inheritance?Abraxe wrote:Am I able to create a GUI application in wxWidgets without subclassing wxFrame/wxApp etc? This seems like a very restrictive, verbose, and annoying structure, but I can't find any resources that don't do it.
Yes, using IMPLEMENT_APP_NO_MAIN(). It might looks something like this:Abraxe wrote:Can I start at my own main function rather than have wxWidgets steal that control away from me?
Code: Select all
IMPLEMENT_APP_NO_MAIN(MyApp);
int main(int argc, char* argv[])
{
wxEntryStart(argc, argv);
wxTheApp->CallOnInit();
wxTheApp->OnRun();
return 0;
}
It's absolutely required, even for console applications that don't use the GUI at all.Abraxe wrote:If I'm only using the GUI part of wxWidgets, do I need any instance of wxApp? I'd rather not have it.
-
- In need of some credit
- Posts: 2
- Joined: Fri Apr 17, 2015 1:34 am
Re: GUI/App without subclassing
Thanks a lot.
It's not that I'm trying to avoid inheritance, it's that I don't think it's really a good use of inheritance. The wxWidgets already handle children and the like without me subclassing it. It seems to be an unecessary indirection, and subclassing locks me in to whatever structure I define the class to be. I'm a very procedural style programmer and it just puts me off is all. I'm fine with it being there, I just didn't want to be forced in to it.
Having App is fine, it's just one item that I can live with.
I'll try that out though, thanks. I feel a bit better about it now.
It's not that I'm trying to avoid inheritance, it's that I don't think it's really a good use of inheritance. The wxWidgets already handle children and the like without me subclassing it. It seems to be an unecessary indirection, and subclassing locks me in to whatever structure I define the class to be. I'm a very procedural style programmer and it just puts me off is all. I'm fine with it being there, I just didn't want to be forced in to it.
Having App is fine, it's just one item that I can live with.
I'll try that out though, thanks. I feel a bit better about it now.
-
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
Re: GUI/App without subclassing
Probably worth noting that without subclassing controls, panels, windows, or other various components, the biggest drawback is the lack of static event tables. If you are a procedural programmer though, you probably would rather use dynamic event tables anyway. This works in 2.8 and older using Connect(), and even better in 3.0+ using Bind().
Almost all of the samples included with wxWidgets use static event tables though, so you'll have to figure out the equivalent Bind() call yourself most of the time if you plan to use the samples as guides. It's pretty strait forward once you get used to it though. Anything you can do with static event tables can be done with dynamic Bind() calls, there's no limitations there.
Almost all of the samples included with wxWidgets use static event tables though, so you'll have to figure out the equivalent Bind() call yourself most of the time if you plan to use the samples as guides. It's pretty strait forward once you get used to it though. Anything you can do with static event tables can be done with dynamic Bind() calls, there's no limitations there.