Other odds and ends...
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,7 +29,7 @@ if wxPlatform == '__WXMSW__':
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class TestPanel(wxPanel):
|
||||
def __init__(self, parent):
|
||||
def __init__(self, parent, log):
|
||||
wxPanel.__init__(self, parent, -1)
|
||||
self.pdf = None
|
||||
|
||||
@@ -94,7 +94,7 @@ class TestPanel(wxPanel):
|
||||
|
||||
def runTest(frame, nb, log):
|
||||
if wxPlatform == '__WXMSW__':
|
||||
win = TestPanel(nb)
|
||||
win = TestPanel(nb, log)
|
||||
return win
|
||||
else:
|
||||
dlg = wxMessageDialog(frame, 'This demo only works on MSW.',
|
||||
@@ -117,6 +117,7 @@ if __name__ == '__main__':
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, event):
|
||||
|
||||
self.tp.pdf.Cleanup()
|
||||
self.Destroy()
|
||||
|
||||
|
@@ -37,6 +37,8 @@ class SimpleGrid(wxGrid):
|
||||
self.SetColLabelValue(1, "column")
|
||||
self.SetColLabelValue(2, "labels")
|
||||
|
||||
self.SetColLabelAlignment(wxALIGN_LEFT, wxALIGN_BOTTOM)
|
||||
|
||||
# test all the events
|
||||
EVT_GRID_CELL_LEFT_CLICK(self, self.OnCellLeftClick)
|
||||
EVT_GRID_CELL_RIGHT_CLICK(self, self.OnCellRightClick)
|
||||
|
@@ -91,6 +91,8 @@ class wxPythonDemo(wxFrame):
|
||||
self.otherWin = None
|
||||
EVT_IDLE(self, self.OnIdle)
|
||||
EVT_CLOSE(self, self.OnCloseWindow)
|
||||
EVT_ICONIZE(self, self.OnIconfiy)
|
||||
EVT_MAXIMIZE(self, self.OnMaximize)
|
||||
|
||||
self.Centre(wxBOTH)
|
||||
self.CreateStatusBar(1, wxST_SIZEGRIP)
|
||||
@@ -403,6 +405,19 @@ class wxPythonDemo(wxFrame):
|
||||
wxGetApp().ProcessIdle()
|
||||
|
||||
|
||||
#---------------------------------------------
|
||||
def OnIconfiy(self, evt):
|
||||
wxLogMessage("OnIconfiy")
|
||||
evt.Skip()
|
||||
|
||||
#---------------------------------------------
|
||||
def OnMaximize(self, evt):
|
||||
wxLogMessage("OnMaximize")
|
||||
evt.Skip()
|
||||
|
||||
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
@@ -41,6 +41,40 @@ class RoundedRectangleShape(wxRectangleShape):
|
||||
self.SetCornerRadius(-0.3)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
## class LabeledBitmapShape(wxBitmapShape):
|
||||
## def __init__(self, bmp, text):
|
||||
## wxBitmapShape.__init__(self)
|
||||
## self.SetBitmap(bmp)
|
||||
## self.region = r = wxShapeRegion()
|
||||
## r.SetPosition(0, 0) #bmp.GetHeight())
|
||||
## r.SetSize(bmp.GetWidth(), bmp.GetHeight())
|
||||
## r.SetText(text)
|
||||
## self.AddRegion(r)
|
||||
|
||||
## def OnMovePost(self, dc, x, y, old_x, old_y, display):
|
||||
## self.region.SetPosition(x, y)
|
||||
## self.base_OnMovePost(dc, x, y, old_x, old_y, display)
|
||||
|
||||
|
||||
## class LabeledBitmapShape(wxCompositeShape):
|
||||
## def __init__(self, canvas, bmp, text):
|
||||
## wxCompositeShape.__init__(self)
|
||||
## self.bs = wxBitmapShape()
|
||||
## self.bs.SetBitmap(bmp)
|
||||
## self.ts = wxTextShape()
|
||||
## self.ts.AddText(text)
|
||||
|
||||
## self.AddChild(self.bs)
|
||||
## self.AddChild(self.ts, self.bs)
|
||||
|
||||
## self.AddConstrainedShapes(gyCONSTRAINT_CENTRED_VERTICALLY, self, [self.bs, self.ts])
|
||||
## self.AddSimpleConstraint(gyCONSTRAINT_BELOW, self.bs, self.ts)
|
||||
## self.AddSimpleConstraint(gyCONSTRAINT_ALIGNED_TOP, self, self.bs)
|
||||
## self.AddSimpleConstraint(gyCONSTRAINT_ALIGNED_BOTTOM, self, self.ts)
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
class MyEvtHandler(wxShapeEvtHandler):
|
||||
@@ -49,7 +83,6 @@ class MyEvtHandler(wxShapeEvtHandler):
|
||||
self.log = log
|
||||
self.statbarFrame = frame
|
||||
|
||||
|
||||
def UpdateStatusBar(self, shape):
|
||||
x,y = shape.GetX(), shape.GetY()
|
||||
width, height = shape.GetBoundingBoxMax()
|
||||
@@ -126,6 +159,7 @@ class TestWindow(wxShapeCanvas):
|
||||
self.SetDiagram(self.diagram)
|
||||
self.diagram.SetCanvas(self)
|
||||
self.shapes = []
|
||||
self.save_gdi = []
|
||||
|
||||
rRectBrush = wxBrush(wxNamedColour("MEDIUM TURQUOISE"), wxSOLID)
|
||||
|
||||
@@ -134,6 +168,24 @@ class TestWindow(wxShapeCanvas):
|
||||
self.MyAddShape(DiamondShape(90, 90), 345, 235, wxPen(wxBLUE, 3, wxDOT), wxRED_BRUSH, "Polygon")
|
||||
self.MyAddShape(RoundedRectangleShape(95,70), 140, 255, wxPen(wxRED, 1), rRectBrush, "Rounded Rect")
|
||||
|
||||
bmp = wxBitmap('bitmaps/test2.bmp', wxBITMAP_TYPE_BMP)
|
||||
mask = wxMaskColour(bmp, wxBLUE)
|
||||
bmp.SetMask(mask)
|
||||
## s = LabeledBitmapShape(self, bmp, "Hello")
|
||||
## self.MyAddShape(s, 225, 150, None, None, None)
|
||||
## print s.Recompute()
|
||||
## s.CalculateSize()
|
||||
## print s.GetX(), s.GetY()
|
||||
## s.SetSize(225)
|
||||
## s.SetY(150)
|
||||
## s.SetSize(80, 80)
|
||||
## print s.GetX(), s.GetY()
|
||||
## #print s.GetSize()
|
||||
|
||||
s = wxBitmapShape()
|
||||
s.SetBitmap(bmp)
|
||||
self.MyAddShape(s, 225, 150, None, None, "Bitmap")
|
||||
|
||||
dc = wxClientDC(self)
|
||||
self.PrepareDC(dc)
|
||||
for x in range(len(self.shapes)):
|
||||
@@ -158,13 +210,13 @@ class TestWindow(wxShapeCanvas):
|
||||
|
||||
|
||||
def MyAddShape(self, shape, x, y, pen, brush, text):
|
||||
shape.SetDraggable(true)
|
||||
shape.SetDraggable(true, true)
|
||||
shape.SetCanvas(self)
|
||||
shape.SetX(x)
|
||||
shape.SetY(y)
|
||||
shape.SetPen(pen)
|
||||
shape.SetBrush(brush)
|
||||
shape.AddText(text)
|
||||
if pen: shape.SetPen(pen)
|
||||
if brush: shape.SetBrush(brush)
|
||||
if text: shape.AddText(text)
|
||||
#shape.SetShadowMode(SHADOW_RIGHT)
|
||||
self.diagram.AddShape(shape)
|
||||
shape.Show(true)
|
||||
@@ -177,6 +229,7 @@ class TestWindow(wxShapeCanvas):
|
||||
self.shapes.append(shape)
|
||||
|
||||
|
||||
|
||||
def __del__(self):
|
||||
for shape in self.diagram.GetShapeList():
|
||||
if shape.GetParent() == None:
|
||||
|
@@ -42,7 +42,6 @@ class MyCanvas(wxScrolledWindow):
|
||||
|
||||
def DoDrawing(self, dc):
|
||||
dc.BeginDrawing()
|
||||
#pen1 = wxPen(wxNamedColour('RED'))
|
||||
dc.SetPen(wxPen(wxNamedColour('RED')))
|
||||
dc.DrawRectangle(5, 5, 50, 50)
|
||||
|
||||
@@ -50,7 +49,6 @@ class MyCanvas(wxScrolledWindow):
|
||||
dc.SetPen(wxPen(wxNamedColour('BLUE'), 4))
|
||||
dc.DrawRectangle(15, 15, 50, 50)
|
||||
|
||||
#font = wxFont(14, wxSWISS, wxNORMAL, wxNORMAL)
|
||||
dc.SetFont(wxFont(14, wxSWISS, wxNORMAL, wxNORMAL))
|
||||
dc.SetTextForeground(wxColour(0xFF, 0x20, 0xFF))
|
||||
te = dc.GetTextExtent("Hello World")
|
||||
|
Reference in New Issue
Block a user