WxWidgets?

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
primem0ver
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jun 19, 2019 12:18 am

WxWidgets?

Post by primem0ver »

I am working on a rather large, modular project that will involve a large number of "plugins". I am currently using Qt but Qt relies on private classes which make custom memory management difficult. I have come across WxWidgets in a number of places as I research C++ based GUI alternatives and I may switch. However, there are some very specific requirements, the first of which is the ability to use my own libraries for ALL memory management (using my own custom pointer and reference template classes).

Second, the plugins can supply a number of different features to the main interface, including UI components whose appearance, features, and functionality are defined using text (XML and possibly other formats) and optionally code. I have heard that WxWidgets employees a few different ways to manage UI events and calling delegates. However, I must be able to dynamically designate a C++ function (delegate/event handler) using text (defined in the XML for example). Qt allows me to do this. Is there a way to do this in WxWidgets?

Qt also supplies multimedia functionality, network socket functionality (using TCP/IP AND UDP), and XML parsing functionality and lots of other general functionality which are a fundamental part of my project. Some of these appear to be part of WxWidgets and some do not. I am particularly interested in things WxWidgets does not have functionality for that Qt does (excluding 3D stuff). Is there a quick guide to help me make a decision?

Finally, platform targets include: Windows 7-10 (possibly XP as well), MacOS, Linux, and Tablet OS's that support C++ based applications.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WxWidgets?

Post by doublemax »

first of which is the ability to use my own libraries for ALL memory management (using my own custom pointer and reference template classes).
There is nothing built in wxWidgets for this. You could provide custom "new" and "delete" operator through #define(s) like it's done for debugging memory leaks. But i don't know if that's sufficient for you.
I have heard that WxWidgets employees a few different ways to manage UI events and calling delegates. However, I must be able to dynamically designate a C++ function (delegate/event handler) using text (defined in the XML for example). Qt allows me to do this. Is there a way to do this in WxWidgets?
Not out of the box. It sounds like you could parse a text file yourself and use dynamic event binding to do the same, but i'd need to see an example to tell if it's possible.
I am particularly interested in things WxWidgets does not have functionality for that Qt does (excluding 3D stuff). Is there a quick guide to help me make a decision?
I don't know Qt well enough, so i can't tell what's missing in wxWidgets. But you can always mix other libraries with wxWidgets, too. E.g. it's quite common to use libcurl or boost together with wxWidgets.

BTW:This is a user forum. For more in-depth questions you can also try the wx-users Google group where you can talk to the core wxWidgets developers. https://groups.google.com/forum/#!forum/wx-users
Use the source, Luke!
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: WxWidgets?

Post by PB »

primem0ver wrote: Wed Jun 19, 2019 12:51 am Second, the plugins can supply a number of different features to the main interface, including UI components whose appearance, features, and functionality are defined using text (XML and possibly other formats) and optionally code. I have heard that WxWidgets employees a few different ways to manage UI events and calling delegates. However, I must be able to dynamically designate a C++ function (delegate/event handler) using text (defined in the XML for example). Qt allows me to do this. Is there a way to do this in WxWidgets?
I do not think wxWidgets would be a good fit for this.

BTW, wxWidgets (mostly) uses the native controls of the platform so the possibilities of customizing their appearance can be severely limited.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: WxWidgets?

Post by ONEEYEMAN »

Hi,
It is possible to write some XML parser and then dynamically bind an event to the GUI element based on the parsed object.

In regards to point 1 - nothing prevents you from using your own library (or any 3rd party library for that matter) with wxWidgets. As PB said - boost and cURL are good examples.

In addition to the first sentence - you can dynamically customize the UI with either inside the code or using the XRC system (read its documentation).

In regards to point #3 - all the stuff you mentioned (socket - TCP/IP and UDP), multimedia and 3D (OpenGL) are supported in wxWidgets. It would be nice to know what other functions you are looking for specifically.

All platform you mentioned are supported. What OS will be running on the Tablet? As long as its not Android you will be able to run wxWidgets based application on it.

Thank you.
primem0ver
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jun 19, 2019 12:18 am

Re: WxWidgets?

Post by primem0ver »

Although @PB misunderstood my post, his response directly contradicts something I was told by the person who specifically recommended wxWidgets for my project. He said that WxWidgets does support custom widgets with a custom appearance (similar to "User Control" in .NET). Is this not true?

When I said that UI appearance is partly customized by plugins from XML, I meant something like what is in the example below.

To give specific examples of what I am trying to accomplish, here is a specific use case that should give an idea of what I need in terms of UI flexibility based on XML. The example below is taken from one of the plugins and has been modified to make contents more generic and self-descriptive. The specific purpose of relevant XML tags is given below but this is probably important from the start: an "Action" represents a button that can be placed on a menu or toolbar. The controls themselves are not customized in the "custom control" sense by XML (though that can be done using a code library in the plugin). Instead, the XML simply alters the appearance of common controls (such as the button that is represented by the "Action" element).

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<Actions>
	<Action>
		<Name>GENERIC_PLACEMENT_ACTION</Name>
		<ActionClass>PlacementCursor</ActionClass>
		<Text>Place Some Object</Text>
		<Icon>SOME_OBJECT_ICON</Icon>
		<StateSet>NONE</StateSet>
		<DefaultState>false</DefaultState>
		<DefaultVisualStyle>IconOnly</DefaultVisualStyle>
		<HandlerType>Generic</HandlerType>
		<ChoiceGroupID>NONE</ChoiceGroupID>
		<UniqueCallID>NONE</UniqueCallID>
		<TrackingName>newObject</TrackingName>
		<Cursor>SOME_OBJECT_CURSOR</Cursor>
	</Action>
	<Action>
		<Name>SPECIFIC_ACTION_WITH_CALLBACK</Name>
		<ActionClass>Trigger</ActionClass>
		<Text>Do Something</Text>
		<Icon>SOME_TRIGGER_ICON</Icon>
		<StateSet>NONE</StateSet>
		<DefaultState>false</DefaultState>
		<DefaultVisualStyle>IconText</DefaultVisualStyle>
		<HandlerType>Unique</HandlerType>
		<ChoiceGroupID>NONE</ChoiceGroupID>
		<UniqueCallID>onTriggerCallback</UniqueCallID>
		<TrackingName>triggerMode1</TrackingName>
		<Cursor>NONE</Cursor>
	</Action>
	<Action>
		<Name>SOME_LOGICAL_ACTION_GROUP_1</Name>
		<ActionClass>Choice</ActionClass>
		<Text>Option 1</Text>
		<Icon>NONE</Icon>
		<StateSet>#BULLET</StateSet>
		<DefaultState>false</DefaultState>
		<DefaultVisualStyle>IconOnly</DefaultVisualStyle>
		<HandlerType>Unique</HandlerType>
		<ChoiceGroupID>GROUP_OF_CHOICES</ChoiceGroupID>
		<UniqueCallID>onChangeChoice</UniqueCallID>
		<TrackingName>option1</TrackingName>
		<Cursor>NONE</Cursor>
	</Action>
	<Action>
		<Name>SOME_LOGICAL_ACTION_GROUP_2</Name>
		<ActionClass>Choice</ActionClass>
		<Text>Option 2</Text>
		<Icon>NONE</Icon>
		<StateSet>#BULLET</StateSet>
		<DefaultState>false</DefaultState>
		<DefaultVisualStyle>IconOnly</DefaultVisualStyle>
		<HandlerType>Unique</HandlerType>
		<ChoiceGroupID>GROUP_OF_CHOICES</ChoiceGroupID>
		<UniqueCallID>onChangeChoice</UniqueCallID>
		<TrackingName>option2</TrackingName>
		<Cursor>NONE</Cursor>
	</Action>
</Actions>
Most of the tags above are either self-explanatory or unnecesary for our discussion. Exceptions are:

StateSet: This represents a set of values/states (text and/or images) that can be toggled between (an example would be "online" and "offline" in a messenger app.). The specific state that the action represents is defined in the TrackingName tag. Custom state sets provided by a plugin author are defined in XML There are also "generic" state sets provided by the application (A '#' in front of a state set name indicates it is a generic/application provided state set).

DefaultState: This is either true or false (for "checked" and "unchecked" buttons) or the default member of the StateSet that the Action button should be set to.

HandlerType: This is the type of handler that is to be called when the button is pressed. There is a specific, generic, application provided handler that is called for specific ActionClass types.

UniqueCallID: This tag holds the name of the plugin author provided function that should be called when the action button is pressed. This is why I need to be able to designate a callback function by string from XML (which is possible in Qt if I use a Qt slot as a callback).
Last edited by primem0ver on Thu Jun 20, 2019 5:25 am, edited 3 times in total.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: WxWidgets?

Post by ONEEYEMAN »

Hi,
This looks a lot like an XRC system.
Read the documentation about it.

Now remember wxWidgets is using native set of controls, therefore I doubt you will be able to create something on the menubar, but you can use some ownerdrawn menu items. Again check the docs of what kind of controls you will be able to put on the menu.

Thank you.
primem0ver
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jun 19, 2019 12:18 am

Re: WxWidgets?

Post by primem0ver »

ONEEYEMAN wrote: Thu Jun 20, 2019 3:11 am This looks a lot like an XRC system.
Read the documentation about it.
Essentially it is. Except that it is specific to my application, its functionality, and the resources it uses; and it has specifications and rules that go way beyond the UI itself. In addition, eventually, there will probably be more than one format (in addition to XML) that can accomplish the same thing (such as a script language).
ONEEYEMAN wrote: Thu Jun 20, 2019 3:11 am Now remember wxWidgets is using native set of controls, therefore I doubt you will be able to create something on the menubar,
I think you mistook "menu" to mean "menu bar". A menu has buttons on it. I am not adding "actions" to the menu bar; rather a (drop down) menu.

The most important question for me is can I link the SPECIFIC_ACTION_WITH_CALLBACK button to call a C++ class method "onTriggerCallback" specified by the XML when it is clicked.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: WxWidgets?

Post by evstevemd »

primem0ver wrote: Wed Jun 19, 2019 12:51 am Second, the plugins can supply a number of different features to the main interface, including UI components whose appearance, features, and functionality are defined using text (XML and possibly other formats) and optionally code.
1. Check wxXRC
2. On Plugins check this thread
primem0ver wrote: Wed Jun 19, 2019 12:51 am Qt also supplies multimedia functionality, network socket functionality (using TCP/IP AND UDP), and XML parsing functionality and lots of other general functionality which are a fundamental part of my project. Some of these appear to be part of WxWidgets and some do not. I am particularly interested in things WxWidgets does not have functionality for that Qt does (excluding 3D stuff). Is there a quick guide to help me make a decision?
wxWidgets have a lot of what QT have but done differently. For example Phonon is a standalome Multimedia framework but wx wraps platform multimedia framework. And some of the functionalities aren't there or were removed. For example support for databases was removed and so wx no longer have SQL support. However, a lot of tools exists and excel for that purpose
primem0ver wrote: Wed Jun 19, 2019 12:51 amFinally, platform targets include: Windows 7-10 (possibly XP as well), MacOS, Linux, and Tablet OS's that support C++ based applications.
With exception of tablet (used to be supported back then before MS messed things up), all others are well supported!
Last edited by evstevemd on Thu Jun 20, 2019 10:22 am, edited 1 time in total.
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WxWidgets?

Post by doublemax »

He said that WxWidgets does support custom widgets with a custom appearance (similar to "User Control" in .NET). Is this not true?
No. Like PB said, wxWidgets uses native controls where ever possible and there is no built-in way to skin them. You can of course create custom controls with custom drawing, but this usually means that you also have to reimplement the control's logic.
The most important question for me is can I link the SPECIFIC_ACTION_WITH_CALLBACK button to call a C++ class method "onTriggerCallback" specified by the XML when it is clicked.
Ar runtime you can Bind an event handler (for a specific event type) to a gui element. You can read the documentation about it here: https://docs.wxwidgets.org/trunk/classw ... 7d63de3b62

This might also be useful: https://docs.wxwidgets.org/trunk/overvi ... vents_bind
Use the source, Luke!
primem0ver
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jun 19, 2019 12:18 am

Re: WxWidgets?

Post by primem0ver »

evstevemd wrote: Thu Jun 20, 2019 6:28 am 1. Check wxXRC
You might want to read the last 2-3 posts before yours (I have already checked out wxXRC). While wxXRC loosely fulfills a similar purpose, the nature of what I am doing is different enough that I cannot use wxXRC.
evstevemd wrote: Thu Jun 20, 2019 6:28 am 2. On Plugins check this thread
I took a brief look at the first page of your link. I am not sure what your point is in sharing that with me. You quoted the first part of a paragraph in the OP. While I mention plugins, my question has nothing to do with writing plugins. I am pretty familiar with the basic idea of plugin design and how it works. Please read the last part of that paragraph to understand what I am really asking (which question hasn't really been answered yet):
primem0ver wrote: Wed Jun 19, 2019 12:51 am I have heard that WxWidgets employees a few different ways to manage UI events and calling delegates. However, I must be able to dynamically designate a C++ function (delegate/event handler) using text (defined in the XML for example). Qt allows me to do this. Is there a way to do this in WxWidgets?
Regarding the last part of your post:
evstevemd wrote: Thu Jun 20, 2019 6:28 am With exception of tablet (used to be supported back then before MS messed things up), all others are well supported!
I am not sure what you mean. I need to be able to export to any tablet OS that can support code compiled from C++. I assume that means at least both iOS and Windows. I want to export to Android too but I am not sure that the Android API and/or the language support for Android includes C++ applications since android is entirely based on Java (though I imagine C++ can be compiled into the instruction set used by the processors that android tablets use).

EDIT: IT looks like @doublemax may have posted an answer just as I was finishing this post up.
primem0ver
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Jun 19, 2019 12:18 am

Re: WxWidgets?

Post by primem0ver »

doublemax wrote: Thu Jun 20, 2019 7:02 am No. Like PB said, wxWidgets uses native controls where ever possible and there is no built-in way to skin them. You can of course create custom controls with custom drawing, but this usually means that you also have to reimplement the control's logic.
Does wxWidgets give us an interface to OS based drawing functions such as GDI/GDI+(Windows)? I am not sure what else you could mean by "reimplementing" control logic. Can you give me an example of something that would need to be reimplemented?
doublemax wrote: Thu Jun 20, 2019 7:02 am Ar runtime you can Bind an event handler (for a specific event type) to a gui element. You can read the documentation about it here: https://docs.wxwidgets.org/trunk/classw ... 7d63de3b62

This might also be useful: https://docs.wxwidgets.org/trunk/overvi ... vents_bind
I checked these out. There doesn't appear to be a way to bind a function using a string with the function name. This is possible in Qt out of the box and would be helpful to be able to do this. I suppose I could use a string keyed hashtable with function pointers that are meant to be plugin callbacks...
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WxWidgets?

Post by doublemax »

I need to be able to export to any tablet OS that can support code compiled from C++. I assume that means at least both iOS and Windows. I want to export to Android too but I am not sure that the Android API and/or the language support for Android includes C++ applications since android is entirely based on Java (though I imagine C++ can be compiled into the instruction set used by the processors that android tablets use).
wx can not create app for iOS, Android or Windows mobile. There were some attempts to create ports for iOS and Android, but both were abandoned in early stages.
Does wxWidgets give us an interface to OS based drawing functions such as GDI/GDI+(Windows)?
Yes. wxDC and wxGraphicsContext. For OpenGL there is wxGLCanvas.
I am not sure what else you could mean by "reimplementing" control logic. Can you give me an example of something that would need to be reimplemented?
Let's suppose you need a complex control like a calendar control, but you don't like how it looks. Then can't just provide new graphics and style information, you'd have to rewrite the whole thing including drawing the control, reacting to user input, date calculations etc. Sometimes generic implementations of complex controls exist which can be used a starting point, but not always. That has to be determined on a case-by-case basis.
There doesn't appear to be a way to bind a function using a string with the function name. This is possible in Qt out of the box and would be helpful to be able to do this.
Yes, wx can't do this out of the box, you'd need to implement that yourself.
Use the source, Luke!
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: WxWidgets?

Post by iwbnwif »

There doesn't appear to be a way to bind a function using a string with the function name. This is possible in Qt out of the box and would be helpful to be able to do this.
Not available in wxWidgets as Doublemax says, however it is readily available in Ponder.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Post Reply