mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 19:10:09 +01:00
Add overlay classes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
1
TODO.txt
1
TODO.txt
@@ -127,7 +127,6 @@ other dev stuff
|
||||
* axbase (ActiveX. Need to figure out best ways to do MSW-only items...)
|
||||
* check that all items in _functions.i and _misc.i have been wrapped
|
||||
* joystick
|
||||
* overlay
|
||||
* PseudoDC
|
||||
|
||||
* Add wxCHMHelpController (MSW-only)
|
||||
|
||||
@@ -84,6 +84,7 @@ INCLUDES = [ # core
|
||||
'dcsvg',
|
||||
'graphics',
|
||||
'imaglist',
|
||||
'overlay',
|
||||
|
||||
# more core
|
||||
'accel',
|
||||
|
||||
52
etg/overlay.py
Normal file
52
etg/overlay.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#---------------------------------------------------------------------------
|
||||
# Name: etg/overlay.py
|
||||
# Author: Robin Dunn
|
||||
#
|
||||
# Created: 18-May-2012
|
||||
# Copyright: (c) 2012 by Total Control Software
|
||||
# License: wxWindows License
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
import etgtools
|
||||
import etgtools.tweaker_tools as tools
|
||||
|
||||
PACKAGE = "wx"
|
||||
MODULE = "_core"
|
||||
NAME = "overlay" # Base name of the file to generate to for this script
|
||||
DOCSTRING = ""
|
||||
|
||||
# The classes and/or the basename of the Doxygen XML files to be processed by
|
||||
# this script.
|
||||
ITEMS = [ "wxOverlay",
|
||||
"wxDCOverlay",
|
||||
]
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
def run():
|
||||
# Parse the XML file(s) building a collection of Extractor objects
|
||||
module = etgtools.ModuleDef(PACKAGE, MODULE, NAME, DOCSTRING)
|
||||
etgtools.parseDoxyXML(module, ITEMS)
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
# Tweak the parsed meta objects in the module object as needed for
|
||||
# customizing the generated code and docstrings.
|
||||
|
||||
c = module.find('wxOverlay')
|
||||
assert isinstance(c, etgtools.ClassDef)
|
||||
c.addPrivateCopyCtor()
|
||||
|
||||
|
||||
c = module.find('wxDCOverlay')
|
||||
c.addPrivateCopyCtor()
|
||||
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
tools.doCommonTweaks(module)
|
||||
tools.runGenerators(module)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
if __name__ == '__main__':
|
||||
run()
|
||||
|
||||
88
samples/overlay/overlay.py
Normal file
88
samples/overlay/overlay.py
Normal file
@@ -0,0 +1,88 @@
|
||||
"""
|
||||
A simple sample of using a wx.Overlay to draw a rubberband effect
|
||||
"""
|
||||
|
||||
import wx
|
||||
print wx.version()
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, *args, **kw):
|
||||
wx.Panel.__init__(self, *args, **kw)
|
||||
|
||||
self.Bind(wx.EVT_PAINT, self.OnPaint)
|
||||
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
|
||||
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
|
||||
self.Bind(wx.EVT_MOTION, self.OnMouseMove)
|
||||
|
||||
self.startPos = None
|
||||
self.overlay = wx.Overlay()
|
||||
|
||||
wx.TextCtrl(self, pos=(140,20))
|
||||
|
||||
|
||||
def OnPaint(self, evt):
|
||||
# Just some simple stuff to paint in the window for an example
|
||||
dc = wx.PaintDC(self)
|
||||
dc.SetBackground(wx.Brush("sky blue"))
|
||||
dc.Clear()
|
||||
dc.DrawLabel("Drag the mouse across this window to see \n"
|
||||
"a rubber-band effect using wx.Overlay",
|
||||
(140, 50, -1, -1))
|
||||
|
||||
coords = ((40,40),(200,220),(210,120),(120,300))
|
||||
dc = wx.GCDC(dc)
|
||||
dc.SetPen(wx.Pen("red", 2))
|
||||
dc.SetBrush(wx.CYAN_BRUSH)
|
||||
dc.DrawPolygon(coords)
|
||||
|
||||
|
||||
def OnLeftDown(self, evt):
|
||||
# Capture the mouse and save the starting position for the
|
||||
# rubber-band
|
||||
self.CaptureMouse()
|
||||
self.startPos = evt.GetPosition()
|
||||
|
||||
|
||||
def OnMouseMove(self, evt):
|
||||
if evt.Dragging() and evt.LeftIsDown():
|
||||
rect = wx.Rect(topLeft=self.startPos, bottomRight=evt.GetPosition())
|
||||
|
||||
# Draw the rubber-band rectangle using an overlay so it
|
||||
# will manage keeping the rectangle and the former window
|
||||
# contents separate.
|
||||
dc = wx.ClientDC(self)
|
||||
odc = wx.DCOverlay(self.overlay, dc)
|
||||
odc.Clear()
|
||||
|
||||
# Mac's DC is already the same as a GCDC, and it causes
|
||||
# problems with the overlay if we try to use an actual
|
||||
# wx.GCDC so don't try it.
|
||||
if 'wxMac' not in wx.PlatformInfo:
|
||||
dc = wx.GCDC(dc)
|
||||
|
||||
dc.SetPen(wx.Pen("black", 2))
|
||||
dc.SetBrush(wx.Brush(wx.Colour(0xC0, 0xC0, 0xC0, 0x80)))
|
||||
dc.DrawRectangle(rect)
|
||||
|
||||
|
||||
def OnLeftUp(self, evt):
|
||||
if self.HasCapture():
|
||||
self.ReleaseMouse()
|
||||
self.startPos = None
|
||||
|
||||
# When the mouse is released we reset the overlay and it
|
||||
# restores the former content to the window.
|
||||
dc = wx.ClientDC(self)
|
||||
odc = wx.DCOverlay(self.overlay, dc)
|
||||
odc.Clear()
|
||||
del odc
|
||||
self.overlay.Reset()
|
||||
|
||||
|
||||
|
||||
app = wx.App(redirect=False)
|
||||
frm = wx.Frame(None, title="wx.Overlay Test", size=(450,450))
|
||||
#frm.SetDoubleBuffered(True)
|
||||
pnl = TestPanel(frm)
|
||||
frm.Show()
|
||||
app.MainLoop()
|
||||
16
unittests/test_overlay.py
Normal file
16
unittests/test_overlay.py
Normal file
@@ -0,0 +1,16 @@
|
||||
import imp_unittest, unittest
|
||||
import wtc
|
||||
import wx
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
class overlay_Tests(wtc.WidgetTestCase):
|
||||
|
||||
# TODO: Remove this test and add real ones.
|
||||
def test_overlay1(self):
|
||||
self.fail("Unit tests for overlay not implemented yet.")
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user