]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/tests/test_gcText.py
   4 #---------------------------------------------------------------------- 
   7 class TestPanel(wx
.Panel
): 
   8     def __init__(self
, parent
): 
   9         wx
.Panel
.__init
__(self
, parent
, -1) 
  10         self
.Bind(wx
.EVT_PAINT
, self
.OnPaint
) 
  13     def OnPaint(self
, evt
): 
  16             gc 
= wx
.GraphicsContext
.Create(dc
) 
  17         except NotImplementedError: 
  18             dc
.DrawText("This build of wxPython does not support the wx.GraphicsContext " 
  23         font 
= wx
.SystemSettings
.GetFont(wx
.SYS_DEFAULT_GUI_FONT
) 
  24         font
.SetWeight(wx
.BOLD
) 
  28         self
.DrawText(gc
, 'normal') 
  33         self
.DrawText(gc
, 'scaled') 
  37         self
.DrawText(gc
, '\nnewline') 
  39     def DrawText(self
, gc
, txt
): 
  40         txt 
= "This is a test: " + txt
 
  41         w
,h
,d
,e 
= gc
.GetFullTextExtent(txt
) 
  44         gc
.DrawText(txt
, 0, 0) 
  46         pen 
= wx
.Pen("red", 1) 
  49         path 
= gc
.CreatePath()        
  50         path
.MoveToPoint(-1, -1) 
  51         self
.MakeCrosshair(path
) 
  54         path 
= gc
.CreatePath()        
  55         path
.MoveToPoint(w
+1, h
+1) 
  56         self
.MakeCrosshair(path
) 
  62     def MakeCrosshair(self
, path
): 
  63         x
, y 
= path
.GetCurrentPoint() 
  64         path
.MoveToPoint(x
-5, y
) 
  65         path
.AddLineToPoint(x
+5,y
) 
  66         path
.MoveToPoint(x
, y
-5) 
  67         path
.AddLineToPoint(x
, y
+5) 
  74 frm 
= wx
.Frame(None, title
="Testing GC Text")