[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8300 - trunk/gnue-designer/src/forms/PagePainter
From: |
jcater |
Subject: |
[gnue] r8300 - trunk/gnue-designer/src/forms/PagePainter |
Date: |
Mon, 3 Apr 2006 18:23:00 -0500 (CDT) |
Author: jcater
Date: 2006-03-30 18:28:55 -0600 (Thu, 30 Mar 2006)
New Revision: 8300
Modified:
trunk/gnue-designer/src/forms/PagePainter/PagePainter.py
Log:
More work on pagepainter (BROKEN)
Modified: trunk/gnue-designer/src/forms/PagePainter/PagePainter.py
===================================================================
--- trunk/gnue-designer/src/forms/PagePainter/PagePainter.py 2006-03-31
00:28:05 UTC (rev 8299)
+++ trunk/gnue-designer/src/forms/PagePainter/PagePainter.py 2006-03-31
00:28:55 UTC (rev 8300)
@@ -37,7 +37,6 @@
# External Imports
#--------------------------------------------------------------------------
import wx
-import SimpleCanvas
xscale = 1
@@ -54,7 +53,7 @@
def init(self, object):
- canvas = self.canvas = MyCanvas(self)
+ canvas = self.canvas = DocumentCanvas(self)
self.document.app.ui.autoSizer(self, canvas)
self.object = object
@@ -71,7 +70,7 @@
})
# Determine text extents
- dc = wx.MemoryDC()
+ dc = wx.PaintDC(self)
dc.SetFont(wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT))
global xscale, yscale
@@ -118,19 +117,47 @@
pass
+
+# ===========================================================================
+# SimpleCanvas implementations
+# ===========================================================================
+#
+# These will be reorganized into a separate file once design is completed.
+#
+
import cPickle
from gnue.designer.uidrivers.wx.uihelpers import SimpleCanvas
+#--------------------------------------------------------------------------
+# MyObject
+#--------------------------------------------------------------------------
+selectionLineColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
+selectedObjectColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
+
+colorIndex = {}
+def buildColorIndex():
+ colorIndex['selectionframe'] =
wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
+ colorIndex['selectedframe'] =
wx.SystemSettings_GetColour(wx.SYS_COLOUR_HIGHLIGHT)
+ colorIndex['workspace'] =
wx.SystemSettings_GetColour(wx.SYS_COLOUR_APPWORKSPACE)
+ colorIndex['workspaceGrid'] = wx.Colour(240,240,240) # TODO: ???
+ colorIndex['panel'] = wx.SystemSettings_GetColour(wx.SYS_COLOUR_BACKGROUND)
+ colorIndex['text'] = wx.BLACK
+ colorIndex['widget'] = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWFRAME)
+
+
class MyObject(SimpleCanvas.wxSimpleDrawableObject):
def __init__(self, object, canvas):
self.__object = object
SimpleCanvas.wxSimpleDrawableObject.__init__(self, canvas)
+ if not colorIndex:
+ buildColorIndex()
+
+
def Draw(self, dc):
dc.BeginDrawing()
- dc.SetPen(wx.Pen(wx.BLACK))
- wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
+ dc.SetPen(wx.Pen(colorIndex['text']))
object = self.__object
x,y,w,h = self.bounds
dc.SetFont(wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT))
@@ -178,18 +205,102 @@
return False
-class MyCanvas(SimpleCanvas.wxSimpleCanvas):
+#==========================================================================
+# Canvas implementation
+#==========================================================================
+class DocumentCanvas(SimpleCanvas.wxSimpleCanvas):
+
+ # TODO: make this a preference setting or toolbar icon
+ showRuler = True
+ gridStyle = 1 (can be 0=None, 1 = dashed lines, 2=dots)
+
+ #------------------------------------------------------------------------
+ # To be subclassed
+ #------------------------------------------------------------------------
+
+ def DrawDocumentBorder(self, dc):
+ dc.BeginDrawing()
+ object = self._object
+ width =
+
+ #------------------------------------------------------------------------
+ # Not to be subclassed
+ #------------------------------------------------------------------------
+ def __init__(self, *args, **parms):
+ SimpleCanvas.wxSimpleCanvas(self, *args, **parms)
+
+ def Draw(self, dc):
+ # Draw the background grid
+ self.DrawGrid(dc)
+
+ # Draw the objects
+ SimpleCanvas.wxSimpleCanvas.Draw(self, dc)
+
+ # Draw any selection boxes
+ self.DrawSelectionBox(dc)
+
+ def DrawGrid(self, dc):
+ #
+ # Draw the grid
+ #
+ if self.gridStyle == 1:
+ SOLIDSPACING = 4
+ w, h = self.GetClientSizeTuple()
+ pen1 = wx.Pen(colorIndex['workspaceGrid'], 1, wx.SHORT_DASH)
+ pen2 = wx.Pen(colorIndex['workspaceGrid'], 1, wx.SOLID)
+ dc.SetPen(pen1)
+
+ # Draw vertical grid lines
+ switchToMainPen = False
+ for x in xrange(xscale,w,xscale):
+ if not x % SOLIDSPACING:
+ switchToMainPen = True
+ dc.SetPen(pen2)
+ dc.DrawLine(x,0,x,h-1)
+ if switchToMainPen:
+ dc.SetPen(pen1)
+
+
+ # Draw horizontal grid lines
+ switchToMainPen = False
+ for y in xrange(yscale, h, yscale):
+ if not y % SOLIDSPACING:
+ switchToMainPen = True
+ dc.SetPen(pen2)
+ dc.DrawLine(0, y, w, y)
+ if switchToMainPen:
+ dc.SetPen(pen1)
+
+ elif self.gridStyle == 2:
+ SOLIDSPACING = 4
+ w, h = self.GetClientSizeTuple()
+ pen1 = wx.Pen(colorIndex['workspaceGrid'], 1, wx.SOLID)
+ pen2 = wx.Pen(colorIndex['workspaceGrid'], 1, wx.SOLID)
+ dc.SetPen(pen1)
+
+
+ dc.SetPen(pen2)
+ for x in xrange(xscale,w,xscale):
+ for y in xrange(yscale, h, yscale):
+ dc.DrawPoint(x,y)
+
+ # Draw vertical grid lines
+ for x in xrange(xscale*SOLIDSPACING,w,xscale*SOLIDSPACING):
+ dc.DrawLine(x,0,x,h-1)
+
+
+ # Draw horizontal grid lines
+ for y in xrange(yscale*SOLIDSPACING, h, yscale*SOLIDSPACING):
+ dc.DrawLine(0, y, w, y)
+
+
def DrawBackground(self, dc):
+ dc.DrawDocumentBorder(dc)
dc.BeginDrawing()
dc.SetBackgroundMode(wx.TRANSPARENT)
dc.Clear()
+ dc.EndDrawing()
- # Draw the grid (TODO: make this settable)
- w, h = self.GetClientSizeTuple()
- dc.SetPen(wx.Pen(wx.Colour(240,240,240)))
- for x in range(0,w,xscale):
- dc.DrawLine(x,0,x,h-1)
- for y in range(0,h, yscale):
- dc.DrawLine(0,y,w,y)
- dc.EndDrawing()
+ def DrawSelectionBox(self, dc):
+ print "Draw da box, fewl"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8300 - trunk/gnue-designer/src/forms/PagePainter,
jcater <=