diff --git a/CHANGES.rst b/CHANGES.rst
index 72dba5ce..fccaf9bd 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -161,6 +161,9 @@ Changes in this release include the following:
* Fix drawing of ticks in wx.lib.agw.speedmeter when there are negative bounds
values. (#1013)
+* wxWidgets for Mac includes the wxJoystick class now, also update the demo.
+ (#997)
+
diff --git a/demo/Joystick.py b/demo/Joystick.py
index e5ff4b5a..2c3758b5 100644
--- a/demo/Joystick.py
+++ b/demo/Joystick.py
@@ -2,7 +2,7 @@
#----------------------------------------------------------------------------
# Name: Joystick.py
-# Purpose: Demonstrate use of wx.Joystick
+# Purpose: Demonstrate use of wx.adv.Joystick
#
# Author: Jeff Grimmett (grimmtoo@softhome.net), adapted from original
# .wdr-derived demo
@@ -17,9 +17,6 @@ import math
import wx
import wx.adv
-haveJoystick = True
-if wx.Platform == "__WXMAC__":
- haveJoystick = False
#----------------------------------------------------------------------------
@@ -136,7 +133,8 @@ class JoyGauge(wx.Panel):
# Now to draw it.
dc.SetPen(wx.Pen(wx.RED, 2))
- dc.CrossHair(x, y)
+ dc.DrawLine(x, 0, x, h)
+ dc.DrawLine(0, y, w, y)
def Update(self):
@@ -626,9 +624,10 @@ class AxisBar(wx.Gauge):
self.SetBackgroundColour('light blue')
self.SetForegroundColour('orange')
- # Capture paint events for purpose of updating
- # the displayed value.
- self.Bind(wx.EVT_PAINT, self.onPaint)
+ # NOTE: See comment below
+ # # Capture paint events for purpose of updating
+ # # the displayed value.
+ # self.Bind(wx.EVT_PAINT, self.onPaint)
def Update(self, value, rawvalue):
# Updates the gauge itself, sets the raw value for
@@ -647,15 +646,24 @@ class AxisBar(wx.Gauge):
# Clear out the gauge
dc.Clear()
- # and then carry out business as usual
- wx.Gauge.OnPaint(self, evt)
+
+ # NOTE: in Classic we exposed wxWindow::OnPaint for MSW, so the default
+ # paint behavior can be triggered and then we can draw on top of
+ # that after the native OnPaint is done. For Phoenix, I chose to
+ # not do this any more, so this breaks. Not sure this is really
+ # needed for this demo, but if so then we'll nede to find another
+ # way to do this. In the meantime, this is commented out, and the
+ # Paint event will also not be captured at all.
+
+ # # and then carry out business as usual
+ # wx.Gauge.OnPaint(self, evt)
# This is the size available to us.
w, h = dc.GetSize()
# This is what we will overlay on the gauge.
# It reflects the actual value received from the
- # wx.Joystick.
+ # wx.adv.Joystick.
txt = str(self.rawvalue)
# Copy the default font, make it bold.
@@ -820,7 +828,7 @@ class Axis(wx.Panel):
class AxisPanel(wx.Panel):
#
# Contained herein is a panel that offers a graphical display
- # of the levels for all axes supported by wx.Joystick. If
+ # of the levels for all axes supported by wx.adv.Joystick. If
# your system doesn't have a particular axis, it will be
# 'dummied' for transparent use.
#
@@ -945,17 +953,25 @@ class JoystickDemoPanel(wx.Panel):
def ShutdownDemo(self):
if self.stick:
self.stick.ReleaseCapture()
+ self.stick.Destroy()
self.stick = None
#----------------------------------------------------------------------------
def runTest(frame, nb, log):
- if haveJoystick:
- win = JoystickDemoPanel(nb, log)
- return win
- else:
+ if not wx.adv.USE_JOYSTICK:
from wx.lib.msgpanel import MessagePanel
win = MessagePanel(nb, 'wx.Joystick is not available on this platform.',
+ 'Sorry', wx.ICON_WARNING)
+ return win
+
+ elif wx.adv.Joystick.GetNumberJoysticks() != 0:
+ win = JoystickDemoPanel(nb, log)
+ return win
+
+ else:
+ from wx.lib.msgpanel import MessagePanel
+ win = MessagePanel(nb, 'No joysticks are found on this system.',
'Sorry', wx.ICON_WARNING)
return win
@@ -965,13 +981,13 @@ def runTest(frame, nb, log):
overview = """\
-wx.Joystick
-This demo illustrates the use of the wx.Joystick class, which is an interface to
+wx.adv.Joystick
+This demo illustrates the use of the wx.adv.Joystick class, which is an interface to
one or more joysticks attached to your system.
The data that can be retrieved from the joystick comes in four basic flavors.
All of these are illustrated in the demo. In fact, this demo illustrates everything
-you can get from the wx.Joystick control.
+you can get from the wx.adv.Joystick control.
- Static information such as Manufacturer ID and model name,
@@ -1036,7 +1052,7 @@ versus a four-way hat.
Caveats
-The wx.Joystick control is in many ways incomplete at the C++ library level, but it is
+The wx.adv.Joystick control is in many ways incomplete at the C++ library level, but it is
not insurmountable. In short, while the joystick interface can be event-driven,
the wx.JoystickEvent class lacks event binders for all event types. Thus, you cannot
rely on wx.JoystickEvents to tell you when something has changed, necessarilly.
diff --git a/demo/run.py b/demo/run.py
index fbf5cbd2..1142e9c5 100755
--- a/demo/run.py
+++ b/demo/run.py
@@ -55,7 +55,7 @@ class RunDemoApp(wx.App, wx.lib.mixins.inspection.InspectionMixin):
self.SetAssertMode(assertMode)
self.InitInspection() # for the InspectionMixin base class
- frame = wx.Frame(None, -1, "RunDemo: " + self.name, pos=(50,50), size=(200,100),
+ frame = wx.Frame(None, -1, "RunDemo: " + self.name, size=(200,100),
style=wx.DEFAULT_FRAME_STYLE, name="run a sample")
frame.CreateStatusBar()
diff --git a/docs/sphinx/itemToModuleMap.json b/docs/sphinx/itemToModuleMap.json
index 16155faf..d0b3434a 100644
--- a/docs/sphinx/itemToModuleMap.json
+++ b/docs/sphinx/itemToModuleMap.json
@@ -6517,6 +6517,7 @@
"USER_ATTENTION_INFO":"wx.",
"USE_ACCESSIBILITY":"wx.",
"USE_GLCANVAS":"wx.glcanvas.",
+"USE_JOYSTICK":"wx.adv.",
"USE_MEDIACTRL":"wx.media.",
"USE_WEBVIEW":"wx.html2.",
"Uint16":"wx.",
diff --git a/etg/joystick.py b/etg/joystick.py
index 37eb6183..8508ceda 100644
--- a/etg/joystick.py
+++ b/etg/joystick.py
@@ -9,6 +9,7 @@
import etgtools
import etgtools.tweaker_tools as tools
+from etgtools import MethodDef
PACKAGE = "wx"
MODULE = "_adv"
@@ -31,71 +32,15 @@ def run():
# Tweak the parsed meta objects in the module object as needed for
# customizing the generated code and docstrings.
- module.addHeaderCode("""\
- #if !wxUSE_JOYSTICK && !defined(__WXMSW__)
- // A C++ stub class for wxJoystick for platforms that don't have it.
- class wxJoystick : public wxObject {
- public:
- wxJoystick(int joystick = wxJOYSTICK1) {
- wxPyErr_SetString(PyExc_NotImplementedError,
- "wxJoystick is not available on this platform.");
- }
- wxPoint GetPosition() const { return wxPoint(-1,-1); }
- int GetPosition(unsigned axis) const { return -1; }
- int GetZPosition() const { return -1; }
- int GetButtonState() const { return -1; }
- int GetButtonState(unsigned button) const { return -1; }
- int GetPOVPosition() const { return -1; }
- int GetPOVCTSPosition() const { return -1; }
- int GetRudderPosition() const { return -1; }
- int GetUPosition() const { return -1; }
- int GetVPosition() const { return -1; }
- int GetMovementThreshold() const { return -1; }
- void SetMovementThreshold(int threshold) {}
-
- bool IsOk(void) const { return false; }
- static int GetNumberJoysticks() { return -1; }
- int GetManufacturerId() const { return -1; }
- int GetProductId() const { return -1; }
- wxString GetProductName() const { return wxEmptyString; }
- int GetXMin() const { return -1; }
- int GetYMin() const { return -1; }
- int GetZMin() const { return -1; }
- int GetXMax() const { return -1; }
- int GetYMax() const { return -1; }
- int GetZMax() const { return -1; }
- int GetNumberButtons() const { return -1; }
- int GetNumberAxes() const { return -1; }
- int GetMaxButtons() const { return -1; }
- int GetMaxAxes() const { return -1; }
- int GetPollingMin() const { return -1; }
- int GetPollingMax() const { return -1; }
- int GetRudderMin() const { return -1; }
- int GetRudderMax() const { return -1; }
- int GetUMin() const { return -1; }
- int GetUMax() const { return -1; }
- int GetVMin() const { return -1; }
- int GetVMax() const { return -1; }
-
- bool HasRudder() const { return false; }
- bool HasZ() const { return false; }
- bool HasU() const { return false; }
- bool HasV() const { return false; }
- bool HasPOV() const { return false; }
- bool HasPOV4Dir() const { return false; }
- bool HasPOVCTS() const { return false; }
-
- bool SetCapture(wxWindow* win, int pollingFreq = 0) { return false; }
- bool ReleaseCapture() { return false; }
- };
- #endif
- """)
-
-
c = module.find('wxJoystick')
assert isinstance(c, etgtools.ClassDef)
c.mustHaveApp()
+ c.addItem(MethodDef(name='GetMaxButtons', type='int', isConst=True))
+ c.addItem(MethodDef(name='GetMaxAxes', type='int', isConst=True))
+
+ tools.generateStubs('wxUSE_JOYSTICK', module)
+
#-----------------------------------------------------------------
tools.doCommonTweaks(module)