FAQ
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
FAQ
This is the "official" wxWidgets C++ Users Forum FAQ.
This FAQ is user-editable - if you have a FAQ you think should be here, post a reply to this topic with the FAQ and corresponding answer.
You should read the main wxWidgets FAQ first; here we just try to cover issues not covered in the main FAQ. The main wxWidgets FAQ is located at
https://wxwidgets.org/docs/faq/
The wxWiki FAQ is also very useful
https://wiki.wxwidgets.org/WxFAQ
Last edited by DavidHart on Fri Jun 20, 2014 2:27 pm, edited 12 times in total.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
When will version XXX come out?
See the roadmap at https://wxwidgets.org/develop/roadmap/.
Yes, it's out of date usually
See the roadmap at https://wxwidgets.org/develop/roadmap/.
Yes, it's out of date usually
Last edited by Ryan Norton on Mon Sep 04, 2006 7:36 pm, edited 4 times in total.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Help!!! I'm new/stuck and need a tutorial - NOW!
- Official Hello World:https://docs.wxwidgets.org/trunk/overvi ... world.html
- The samples in the wxWidgets also provide extensive examples how parts of wxWidgets can be used
- There's a few tutorials on the wxWidgets website itself.
- There's tons of unofficial tutorials listed on the wxWiki.
- wxGuide by Otto Wyss: http://wxguide.sourceforge.net/index.html
Last edited by Ryan Norton on Mon Sep 04, 2006 7:37 pm, edited 3 times in total.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
What other resources are there for help/information?
- Mailing list archives at https://www.wxwidgets.org/support/mailing-lists/
- wxWiki : https://wiki.wxwidgets.org/
- #wxwidgets IRC channel
- wxWidgets docs also https://wxwidgets.org/docs/
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
I'm frustrated! I keep on getting stuff like Xlib: unexpected async reply (...) and other wierdness when I use threads on non-windows platforms!!!
You cannot use GUI functions/classes in secondary threads (INCLUDING wxBitmap!!!!)- you may only use them in the main thread. Windows supports this because it's the leader in this kind of thing - but the free X11 servers still don't support this. By GUI functions/classes I mean _anything_ that draws, creates windows, etc.. This includes even wxMessageBox and wxBitmap.
However, there is a possible workaround for this - simply put wxMutexGuiEnter() before any GUI stuff in a secondary thread and wxMutexGuiLeave() when you're done with the GUI stuff in the secondary thread. Note that this may or may not work all the time - people have reported problems with this.
You cannot use GUI functions/classes in secondary threads (INCLUDING wxBitmap!!!!)- you may only use them in the main thread. Windows supports this because it's the leader in this kind of thing - but the free X11 servers still don't support this. By GUI functions/classes I mean _anything_ that draws, creates windows, etc.. This includes even wxMessageBox and wxBitmap.
However, there is a possible workaround for this - simply put wxMutexGuiEnter() before any GUI stuff in a secondary thread and wxMutexGuiLeave() when you're done with the GUI stuff in the secondary thread. Note that this may or may not work all the time - people have reported problems with this.
Last edited by Ryan Norton on Thu Dec 08, 2005 7:05 am, edited 1 time in total.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
When the OpenGL/GLCanvas examples compile, I get an error to change wxUSE_GLCANVAS to 1, and then when I do so in setup.h I get a whole bunch of link errors!! (sebol)
Windows : You should make sure that you recompile the library with wxUSE_GLCANVAS in setup.h set to 1, also not forgetting to include the opengl32.lib and glu.lib libraries.
Linux/Unix : Do not edit setup.h manually, instead delete your build folder, and start a new one, with ../configure --with-opengl
Windows : You should make sure that you recompile the library with wxUSE_GLCANVAS in setup.h set to 1, also not forgetting to include the opengl32.lib and glu.lib libraries.
Linux/Unix : Do not edit setup.h manually, instead delete your build folder, and start a new one, with ../configure --with-opengl
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
What would be the wxWidget equivalent to the MFC VERIFY macro?
There is none, although wxCHECK comes close. Here's a better alternative:
There is none, although wxCHECK comes close. Here's a better alternative:
Code: Select all
#ifdef _DEBUG
#define wxVERIFY(cmd) \
wxASSERT((cmd))
#else
#define wxVERIFY(cmd) \
(cmd)
#endif
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Why can't I add a wxPanel or sizer to a wxButton when it is derived from wxWindow?
The jist of it is that most native APIs don't support this - and wxWidgets uses the native APIs underneath the hood.
To solve this, either subclass wxButton and take care of it yourself, or use wxUniversal - which only relies on the native API's drawing routines.
The jist of it is that most native APIs don't support this - and wxWidgets uses the native APIs underneath the hood.
To solve this, either subclass wxButton and take care of it yourself, or use wxUniversal - which only relies on the native API's drawing routines.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Help! I just updated CVS and I'm getting linker errors!!
Before reporting linker errors to the lists or sourceforge, make sure you do the following things:
Before reporting linker errors to the lists or sourceforge, make sure you do the following things:
- Rebuild the wxWidgets library
You can usually do this via a "make clean". Don't forget to run configure again afterwards - Make sure you update to get new files
Sounds self explanatory, but if you don't do a full cvs update you may miss files that were added - Rubuild any components that you use that use wxWidgets
For example, if you use Jorg's wxMultiTreeCtrl or similar, make sure to rebuild that also
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
I need to do XXX for my game with wxWidgets...
In general, wxWidgets is probably not the best choice for games, it definately won't help you win any size contests .
However, it does provide some things:
In general, wxWidgets is probably not the best choice for games, it definately won't help you win any size contests .
However, it does provide some things:
- wxWindow::WarpPointer is a fairly accurate and fast way of interacting with the mouse
- wxGetKeyState is a pretty fast way to get the state of a key - on mac its really fast
- wxGLCanvas and friends interact with opengl for decent graphics
- Allegro http://alleg.sf.net
Public domain game library. Lacks decent 3D API. Other than that has a very decent API and some of the best - if not the best - documentation, period. - SDL (Simple Directmedia Layer) http://libsdl.org
SDL is the de-facto media library for linux, and has decent support for other platforms. Under a LPGL with additional restriction(s). - OpenAL http://openal.org
Once maintained by the game company Loki, now maintained by Creative. OpenAL isn't really a game library unto itself, but provides pretty much the industry standard 3d sound. Somewhat annoying API - is simple, but there is a lot of unexpected behavior and platform-specific funnies to keep you busy.
Last edited by Ryan Norton on Fri Apr 22, 2005 9:28 pm, edited 1 time in total.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
No really, how do you make a custom event??
Use the following template and replace media etc. with whatever you want.
Use the following template and replace media etc. with whatever you want.
Code: Select all
//in .h
class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
{
public:
// ------------------------------------------------------------------------
// wxMediaEvent Constructor
//
// Normal constructor, much the same as wxNotifyEvent
// ------------------------------------------------------------------------
wxMediaEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
: wxNotifyEvent(commandType, id)
{ }
// ------------------------------------------------------------------------
// wxMediaEvent Copy Constructor
//
// Normal copy constructor, much the same as wxNotifyEvent
// ------------------------------------------------------------------------
wxMediaEvent(const wxMediaEvent &clone)
: wxNotifyEvent(clone)
{ }
// ------------------------------------------------------------------------
// wxMediaEvent::Clone
//
// Allocates a copy of this object.
// Required for wxEvtHandler::AddPendingEvent
// ------------------------------------------------------------------------
virtual wxEvent *Clone() const
{ return new wxMediaEvent(*this); }
// Put this class on wxWidget's RTTI table
DECLARE_DYNAMIC_CLASS(wxMediaEvent)
};
//Event ID to give to our events
#define wxMEDIA_FINISHED_ID 13000
#define wxMEDIA_STOP_ID 13001
//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
DECLARE_EVENT_TYPE(wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
DECLARE_EVENT_TYPE(wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
//Function type(s) our events need
typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
//Macro for usage with message maps
#define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
#define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
//in .cpp
IMPLEMENT_DYNAMIC_CLASS(wxMediaEvent, wxEvent);
DEFINE_EVENT_TYPE(wxEVT_MEDIA_FINISHED);
DEFINE_EVENT_TYPE(wxEVT_MEDIA_STOP);
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Does wxWidgets have any stuff for ActiveX??
There is a 3rd party add-on called wxActiveX that is a ActiveX container, but there are no known 3rd party add-ons for making ActiveX controls.
There is a 3rd party add-on called wxActiveX that is a ActiveX container, but there are no known 3rd party add-ons for making ActiveX controls.
- wxActiveX Website: http://sourceforge.net/projects/wxactivex
Last edited by Ryan Norton on Thu Dec 08, 2005 7:03 am, edited 1 time in total.
[Mostly retired moderator, still check in to clean up some stuff]
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
How do I open the application of a file extension?? How do I launch the default browser??
Just do something like:
In theory, launching the defualt browser is similar - just get whatever opens .htm(l) pages by default through the mime types manager. However, in practice you'll probably want to use the 2.6+ wxLaunchDefaultBrowser function.
Just do something like:
Code: Select all
wxFileType *ft =
wxTheMimeTypesManager->GetFileTypeFromExtension (suffix);
if (!ft) {
wxLogError("Impossible to determine the file type for extension %s.\n"
"Please edit your MIME types.", suffix);
return;
}
wxString cmd;
bool ok =
ft->GetOpenCommand (&cmd,
wxFileType::MessageParameters (afile.GetFullPath(),
_T("")));
delete ft;
if (ok)
wxExecute (cmd, wxEXEC_ASYNC);
Last edited by Ryan Norton on Tue Jan 23, 2007 8:23 am, edited 1 time in total.
[Mostly retired moderator, still check in to clean up some stuff]