[Commits] (john) * Part of Mimi's sidebar design
commits at osafoundation.org
commits at osafoundation.org
Wed Apr 20 18:16:29 PDT 2005
Commit by: john
Modified files:
chandler/parcels/osaf/views/main/parcel.xml 1.199 1.200
chandler/parcels/osaf/views/main/SideBar.py 1.42 1.43
chandler/parcels/osaf/views/main/Main.py 1.160 1.161
chandler/parcels/osaf/views/demo/parcel.xml 1.46 1.47
chandler/parcels/osaf/framework/blocks/detail/parcel.xml 1.72 1.73
chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py 1.35 1.36
chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py 1.76 1.77
chandler/parcels/osaf/framework/blocks/parcel.xml 1.159 1.160
chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py 1.41 1.42
chandler/parcels/osaf/framework/blocks/DrawingUtilities.py 1.1 1.2
chandler/parcels/osaf/framework/blocks/ControlBlocks.py 1.195 1.196
chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py 1.28 1.29
chandler/parcels/osaf/contentmodel/parcel.xml 1.100 1.101
chandler/application/images/MarkupBarTask.png 1.1 1.2
chandler/application/images/MarkupBarPrivate.png 1.1 1.2
chandler/application/images/MarkupBarMail.png 1.1 1.2
chandler/application/images/MarkupBarEvent.png 1.1 1.2
chandler/application/Application.py 1.320 1.321
Log message:
* Part of Mimi's sidebar design
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/parcel.xml.diff?r1=text&tr1=1.199&r2=text&tr2=1.200
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/SideBar.py.diff?r1=text&tr1=1.42&r2=text&tr2=1.43
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/main/Main.py.diff?r1=text&tr1=1.160&r2=text&tr2=1.161
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/views/demo/parcel.xml.diff?r1=text&tr1=1.46&r2=text&tr2=1.47
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/detail/parcel.xml.diff?r1=text&tr1=1.72&r2=text&tr2=1.73
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py.diff?r1=text&tr1=1.35&r2=text&tr2=1.36
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py.diff?r1=text&tr1=1.76&r2=text&tr2=1.77
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/parcel.xml.diff?r1=text&tr1=1.159&r2=text&tr2=1.160
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py.diff?r1=text&tr1=1.41&r2=text&tr2=1.42
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/DrawingUtilities.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/ControlBlocks.py.diff?r1=text&tr1=1.195&r2=text&tr2=1.196
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py.diff?r1=text&tr1=1.28&r2=text&tr2=1.29
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/contentmodel/parcel.xml.diff?r1=text&tr1=1.100&r2=text&tr2=1.101
http://cvs.osafoundation.org/index.cgi/chandler/application/images/MarkupBarTask.png.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/application/images/MarkupBarPrivate.png.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/application/images/MarkupBarMail.png.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/application/images/MarkupBarEvent.png.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/application/Application.py.diff?r1=text&tr1=1.320&r2=text&tr2=1.321
Index: chandler/application/Application.py
diff -u chandler/application/Application.py:1.320 chandler/application/Application.py:1.321
--- chandler/application/Application.py:1.320 Wed Apr 6 18:01:02 2005
+++ chandler/application/Application.py Wed Apr 20 18:16:26 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.320 $"
-__date__ = "$Date: 2005/04/07 01:01:02 $"
+__version__ = "$Revision: 1.321 $"
+__date__ = "$Date: 2005/04/21 01:16:26 $"
__copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -14,6 +14,7 @@
import VersionConflictError, MergeError
from crypto import Crypto
import logging as logging
+import cStringIO
logger = logging.getLogger('App')
logger.setLevel(logging.INFO)
@@ -22,7 +23,7 @@
import tools.timing
# Increment this constant whenever you change the schema:
-SCHEMA_VERSION = "6"
+SCHEMA_VERSION = "8"
"""
Event used to post callbacks on the UI thread
@@ -194,7 +195,7 @@
"""
splash = None
if not (__debug__ and application.Globals.options.nocatch):
- splashBitmap = self.GetImage ("splash")
+ splashBitmap = self.GetImage ("splash.png")
splash=StartupSplash(None, splashBitmap)
splash.Show()
wx.Yield() #let the splash screen render itself
@@ -417,7 +418,24 @@
self.PrintTree (window, indent + " ")
def GetImage (self, name):
- return wx.Image("application/images/" + name + ".png", wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+ """
+ Return None if image isn't found, otherwise loading an image
+ will log an error, puting up a dialog telling the user that some
+ file couldn't be found. The dialog is inappropriate for normal users.
+ Also look first for platform specific icons.
+ """
+ root, extension = os.path.splitext (name)
+ root = "application/images/" + root
+ try:
+ file = open(root + "-" + sys.platform + extension, "rb")
+ except IOError:
+ try:
+ file = open(root + extension, "rb")
+ except IOError:
+ return None
+ stream = cStringIO.StringIO (file.read())
+ return wx.BitmapFromImage (wx.ImageFromStream (stream))
+
def OnCommand(self, event):
"""
Index: chandler/parcels/osaf/views/main/Main.py
diff -u chandler/parcels/osaf/views/main/Main.py:1.160 chandler/parcels/osaf/views/main/Main.py:1.161
--- chandler/parcels/osaf/views/main/Main.py:1.160 Fri Apr 15 16:02:55 2005
+++ chandler/parcels/osaf/views/main/Main.py Wed Apr 20 18:16:20 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.160 $"
-__date__ = "$Date: 2005/04/15 23:02:55 $"
+__version__ = "$Revision: 1.161 $"
+__date__ = "$Date: 2005/04/21 01:16:20 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -254,13 +254,6 @@
if not inviteeContact in share.sharees:
share.sharees.append(inviteeContact)
- # change the name to include "Shared", but first record the
- # original name in case webdav publishing fails and we need to
- # restore it
- originalName = itemCollection.displayName
- if not itemCollection.displayName.endswith(_(" (Shared)")):
- itemCollection.displayName = _("%s (Shared)") % itemCollection.displayName
-
# Sync the collection with WebDAV
self.setStatusMessage (_("accessing WebDAV server"))
try:
@@ -275,9 +268,6 @@
application.dialogs.Util.ok(wx.GetApp().mainFrame,
"Error", msg)
- # An error occurred during webdav; restore the collection's name
- itemCollection.displayName = originalName
-
if isNewShare:
share.conduit.delete()
share.format.delete()
Index: chandler/parcels/osaf/framework/blocks/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/parcel.xml:1.159 chandler/parcels/osaf/framework/blocks/parcel.xml:1.160
--- chandler/parcels/osaf/framework/blocks/parcel.xml:1.159 Wed Apr 6 18:01:02 2005
+++ chandler/parcels/osaf/framework/blocks/parcel.xml Wed Apr 20 18:16:22 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.159 $ -->
-<!-- $Date: 2005/04/07 01:01:02 $ -->
+<!-- $Revision: 1.160 $ -->
+<!-- $Date: 2005/04/21 01:16:22 $ -->
<!-- Copyright (c) 2003-2005 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -1199,9 +1199,8 @@
<type itemref="String"/>
</Attribute>
- <Attribute itsName="selectedBitmap">
+ <Attribute itsName="disabledBitmap">
<type itemref="String"/>
- <initialValue type="String"/>
</Attribute>
<Enumeration itsName="toolbarItemKindEnumType">
@@ -1267,6 +1266,21 @@
<initialValue itemref="None"/>
</Attribute>
+ <!-- A dictionary of display names of items that don't show as Calendar Views -->
+ <Attribute itsName="dontShowCalendarForItemsWithName">
+ <type itemref="Boolean"/>
+ <cardinality>dict</cardinality>
+ </Attribute>
+
+ <!-- A dictionary mapping a name,kindpathComponent string to a new name.
+ It would be much nicer if the key could be a (name, kindItem) tuple, but
+ that's not possible with current parcel XML
+ -->
+ <Attribute itsName="nameAlternatives">
+ <type itemref="String"/>
+ <cardinality>dict</cardinality>
+ </Attribute>
+
<Cloud itsName="DefaultCloud">
<Endpoint itsName="filterKind">
<attribute value="filterKind"/>
Index: chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py
diff -u chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py:1.76 chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py:1.77
--- chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py:1.76 Wed Apr 20 16:29:18 2005
+++ chandler/parcels/osaf/framework/blocks/calendar/CalendarCanvas.py Wed Apr 20 18:16:22 2005
@@ -1,8 +1,8 @@
""" Canvas for calendaring blocks
"""
-__version__ = "$Revision: 1.76 $"
-__date__ = "$Date: 2005/04/20 23:29:18 $"
+__version__ = "$Revision: 1.77 $"
+__date__ = "$Date: 2005/04/21 01:16:22 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -855,8 +855,8 @@
#
# top row - left/right buttons, anchored to the right
- self.prevButton = CollectionCanvas.CanvasBitmapButton(self, "application/images/backarrow.png")
- self.nextButton = CollectionCanvas.CanvasBitmapButton(self, "application/images/forwardarrow.png")
+ self.prevButton = CollectionCanvas.CanvasBitmapButton(self, "backarrow.png")
+ self.nextButton = CollectionCanvas.CanvasBitmapButton(self, "forwardarrow.png")
self.Bind(wx.EVT_BUTTON, self.parent.OnPrev, self.prevButton)
self.Bind(wx.EVT_BUTTON, self.parent.OnNext, self.nextButton)
Index: chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py
diff -u chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py:1.41 chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py:1.42
--- chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py:1.41 Wed Mar 23 17:02:06 2005
+++ chandler/parcels/osaf/framework/blocks/DynamicContainerBlocks.py Wed Apr 20 18:16:22 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.41 $"
-__date__ = "$Date: 2005/03/24 01:02:06 $"
+__version__ = "$Revision: 1.42 $"
+__date__ = "$Date: 2005/04/21 01:16:22 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -8,7 +8,6 @@
import logging
import wx
from repository.item.Item import Item
-import sys
import os
@@ -830,17 +829,16 @@
Under construction
"""
def instantiateWidget (self):
- def getBitmapPath (path):
- """
- wxWidgets on Mac can only display ugly icons (e.g. one bit alpha) so
- we'll look up the ugly alternatives.
- """
- root, extension = os.path.splitext (path)
- platformAlternatePath = root + "-" + sys.platform + extension
- if os.path.isfile (platformAlternatePath):
- path = platformAlternatePath
- return path
-
+ def getBitmaps (self):
+ bitmap = wx.GetApp().GetImage (self.bitmap)
+ try:
+ disabledBitmapName = self.disabledBitmap
+ except AttributeError:
+ disabledBitmap = wx.NullBitmap
+ else:
+ disabledBitmap = wx.GetApp().GetImage (disabledBitmapName)
+ return bitmap, disabledBitmap
+
# can't instantiate ourself without a toolbar
try:
theToolbar = self.dynamicParent.widget
@@ -852,8 +850,8 @@
self.toolID = id
if (self.toolbarItemKind == 'Button' or
self.toolbarItemKind == 'Radio'):
- bitmap = wx.Image (getBitmapPath (self.bitmap),
- wx.BITMAP_TYPE_ANY).ConvertToBitmap()
+
+ bitmap, disabledBitmap = getBitmaps (self)
if self.toggle:
theKind = wx.ITEM_CHECK
elif self.toolbarItemKind == 'Radio':
@@ -864,7 +862,7 @@
tool = theToolbar.DoAddTool (id,
self.label,
bitmap,
- wx.NullBitmap,
+ disabledBitmap,
kind = theKind,
shortHelp=self.title,
longHelp=self.helpString)
@@ -874,12 +872,11 @@
theToolbar.AddSeparator()
elif self.toolbarItemKind == 'Check':
theKind = wx.ITEM_CHECK
- bitmap = wx.Image (getBitmapPath (self.bitmap),
- wx.BITMAP_TYPE_ANY).ConvertToBitmap()
+ bitmap, disabledBitmap = getBitmaps (self)
tool = theToolbar.DoAddTool (id,
self.label,
bitmap,
- wx.NullBitmap,
+ disabledBitmap,
kind = theKind,
shortHelp=self.title,
longHelp=self.helpString)
Index: chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py
diff -u chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py:1.28 chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py:1.29
--- chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py:1.28 Mon Mar 21 14:14:27 2005
+++ chandler/parcels/osaf/framework/attributeEditors/AttributeEditors.py Wed Apr 20 18:16:23 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.28 $"
-__date__ = "$Date: 2005/03/21 22:14:27 $"
+__version__ = "$Revision: 1.29 $"
+__date__ = "$Date: 2005/04/21 01:16:23 $"
__copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -11,6 +11,7 @@
import repository.item.ItemHandler as ItemHandler
import osaf.framework.blocks.Styles as Styles
import repository.query.Query as Query
+import osaf.framework.blocks.DrawingUtilities as DrawingUtilities
class IAttributeEditor (object):
""" CPIA Attribute Editor base class """
@@ -152,7 +153,7 @@
dc.SetBackgroundMode (wx.SOLID)
dc.SetPen (wx.TRANSPARENT_PEN)
- dc.DrawRectangle (rect.x, rect.y, rect.width, rect.height)
+ dc.DrawRectangleRect (rect)
"""
Draw the text in the box
@@ -162,25 +163,9 @@
rect.Inflate (-1, -1)
dc.SetClippingRect (rect)
- x = rect.x + 1
- y = rect.y + 1
-
- string = self.GetAttributeValue (item, attributeName)
- for line in str (string).split (os.linesep):
- dc.DrawText (line, x, y)
- lineWidth, lineHeight = dc.GetTextExtent (line)
- # If the text doesn't fit within the box we want to clip it and
- # put '...' at the end. This method may chop a character in half,
- # but is a lot faster than doing the proper calculation of where
- # to cut off the text. Eventually we will want a solution that
- # doesn't chop chars, but that will come along with multiline
- # wrapping and hopefully won't be done at the python level.
- if lineWidth > rect.width - 2:
- width, height = dc.GetTextExtent('...')
- x = rect.x+1 + rect.width-2 - width
- dc.DrawRectangle(x, rect.y+1, width+1, height)
- dc.DrawText('...', x, rect.y+1)
- y += lineHeight
+ DrawingUtilities.DrawWrappedText (dc,
+ self.GetAttributeValue (item, attributeName),
+ rect)
dc.DestroyClippingRegion()
def Create (self, parent, id):
@@ -393,7 +378,7 @@
dc.SetBackgroundMode (wx.SOLID)
dc.SetPen (wx.TRANSPARENT_PEN)
- dc.DrawRectangle (rect.x, rect.y, rect.width, rect.height)
+ dc.DrawRectangleRect (rect)
"""
Draw the text in the box
@@ -429,23 +414,11 @@
# if not selected there's no edit control, so we need to draw the value text.
if not isSelected:
- string = self.GetAttributeValue (item, attributeName)
- for line in str (string).split (os.linesep):
- dc.DrawText (line, x, y)
- lineWidth, lineHeight = dc.GetTextExtent (line)
- # If the text doesn't fit within the box we want to clip it and
- # put '...' at the end. This method may chop a character in half,
- # but is a lot faster than doing the proper calculation of where
- # to cut off the text. Eventually we will want a solution that
- # doesn't chop chars, but that will come along with multiline
- # wrapping and hopefully won't be done at the python level.
- if lineWidth > rect.width - 2:
- width, height = dc.GetTextExtent('...')
- x = rect.x+1 + rect.width-2 - width
- dc.DrawRectangle(x, rect.y+1, width+1, height)
- dc.DrawText('...', x, rect.y+1)
- y += lineHeight
- dc.DestroyClippingRegion()
+ textRectangle = wx.Rect (x, y, rect.GetRight() - x, rect.GetBottom() - y)
+ DrawingUtilities.DrawWrappedText (dc,
+ self.GetAttributeValue (item, attributeName),
+ textRectangle)
+ dc.DestroyClippingRegion()
def Create (self, parent, id):
parentRect = parent.GetRect()
@@ -643,25 +616,12 @@
def Draw (self, dc, rect, item, attributeName, isSelected):
dc.DrawRectangleRect(rect) # always draw the background
imageName = self.GetAttributeValue(item, attributeName)
- if imageName != '':
- image = wx.GetApp().GetImage(imageName)
- if image:
- offscreenBuffer = wx.MemoryDC()
- offscreenBuffer.SelectObject (image)
- dc.SetBackgroundMode (wx.SOLID)
-
- width, height = image.GetWidth(), image.GetHeight()
- if width > rect.width - 2:
- width = rect.width - 2
- if height > rect.height - 2:
- height = rect.height - 2
-
- dc.Blit (rect.x + 1, rect.y + 1,
- width, height,
- offscreenBuffer,
- 0, 0,
- wx.COPY,
- True)
+ image = wx.GetApp().GetImage(imageName)
+ if image is not None:
+ x = rect.GetLeft() + (rect.GetWidth() - image.GetWidth()) / 2
+ y = rect.GetTop() + (rect.GetHeight() - image.GetHeight()) / 2
+ dc.DrawBitmap (image, x, y, True)
+
class EnumAttributeEditor (IconAttributeEditor):
"""
Index: chandler/parcels/osaf/framework/blocks/DrawingUtilities.py
diff -u chandler/parcels/osaf/framework/blocks/DrawingUtilities.py:1.1 chandler/parcels/osaf/framework/blocks/DrawingUtilities.py:1.2
--- chandler/parcels/osaf/framework/blocks/DrawingUtilities.py:1.1 Thu Apr 14 14:05:04 2005
+++ chandler/parcels/osaf/framework/blocks/DrawingUtilities.py Wed Apr 20 18:16:22 2005
@@ -13,16 +13,6 @@
if grid.IsEnabled():
if isSelected:
background = grid.GetSelectionBackground()
- focus = wx.Window_FindFocus()
- """
- If we don't have the focus mix the background color with
- equal parts of white
- """
- if (focus is None or
- focus.GetParent() is not grid):
- background.Set ((background.Red() + 255) / 2,
- (background.Green() + 255) / 2,
- (background.Blue() + 255) / 2)
foreground = grid.GetSelectionForeground()
else:
background = attr.GetBackgroundColour()
@@ -36,6 +26,7 @@
dc.SetFont (attr.GetFont())
+
def DrawWrappedText (dc, string, rect):
x = rect.x + 1
y = rect.y + 1
Index: chandler/parcels/osaf/contentmodel/parcel.xml
diff -u chandler/parcels/osaf/contentmodel/parcel.xml:1.100 chandler/parcels/osaf/contentmodel/parcel.xml:1.101
--- chandler/parcels/osaf/contentmodel/parcel.xml:1.100 Fri Apr 15 15:42:11 2005
+++ chandler/parcels/osaf/contentmodel/parcel.xml Wed Apr 20 18:16:24 2005
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Parcel manifest for Pim Schema -->
-<!-- $Revision: 1.100 $ -->
-<!-- $Date: 2005/04/15 22:42:11 $ -->
+<!-- $Revision: 1.101 $ -->
+<!-- $Date: 2005/04/21 01:16:24 $ -->
<!-- Copyright (c) 2003-2004 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -325,7 +325,7 @@
<initialValue type="String">__adhoc__</initialValue>
</Attribute>
- <Attribute itsName="outOfTheBoxCollection">
+ <Attribute itsName="renameable">
<type itemref="Boolean"/>
</Attribute>
Index: chandler/parcels/osaf/views/demo/parcel.xml
diff -u chandler/parcels/osaf/views/demo/parcel.xml:1.46 chandler/parcels/osaf/views/demo/parcel.xml:1.47
--- chandler/parcels/osaf/views/demo/parcel.xml:1.46 Wed Mar 16 12:38:39 2005
+++ chandler/parcels/osaf/views/demo/parcel.xml Wed Apr 20 18:16:21 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.46 $ -->
-<!-- $Date: 2005/03/16 20:38:39 $ -->
+<!-- $Revision: 1.47 $ -->
+<!-- $Date: 2005/04/21 01:16:21 $ -->
<!-- Copyright (c) 2003-2004 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -193,7 +193,7 @@
<location>ApplicationBar</location>
<title>Block Demo</title>
<label>Cycle Tabs</label>
- <bitmap>application/images/forwardto.png</bitmap>
+ <bitmap>forwardto.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<helpString>Go to the next tab in block demo</helpString>
<event itemref="doc:CycleTabs"/>
@@ -278,7 +278,7 @@
<Button itsName="ImageButton">
<!-- Attributes -->
<buttonKind>Image</buttonKind>
- <icon>application/images/reply.png</icon>
+ <icon>reply.png</icon>
<size>60,40</size>
<minimumSize>60,40</minimumSize>
Index: chandler/parcels/osaf/views/main/parcel.xml
diff -u chandler/parcels/osaf/views/main/parcel.xml:1.199 chandler/parcels/osaf/views/main/parcel.xml:1.200
--- chandler/parcels/osaf/views/main/parcel.xml:1.199 Fri Apr 15 16:17:25 2005
+++ chandler/parcels/osaf/views/main/parcel.xml Wed Apr 20 18:16:20 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.199 $ -->
-<!-- $Date: 2005/04/15 23:17:25 $ -->
+<!-- $Revision: 1.200 $ -->
+<!-- $Date: 2005/04/21 01:16:20 $ -->
<!-- Copyright (c) 2003-2004 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -988,7 +988,7 @@
<blockName>ApplicationBarAllButton</blockName>
<title>All</title>
<label>All</label>
- <bitmap>application/images/ApplicationBarAll.png</bitmap>
+ <bitmap>ApplicationBarAll.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<event itemref="doc:ApplicationBarAll"/>
<helpString>No Filter</helpString>
@@ -1007,7 +1007,7 @@
<blockName>ApplicationBarMailButton</blockName>
<title>Messages</title>
<label>Mail</label>
- <bitmap>application/images/ApplicationBarMail.png</bitmap>
+ <bitmap>ApplicationBarMail.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<event itemref="doc:ApplicationBarMail"/>
<helpString>Mail Messages Filter</helpString>
@@ -1025,7 +1025,7 @@
<blockName>ApplicationBarTaskButton</blockName>
<title>Taskpad</title>
<label>Tasks</label>
- <bitmap>application/images/ApplicationBarTask.png</bitmap>
+ <bitmap>ApplicationBarTask.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<event itemref="doc:ApplicationBarTask"/>
<helpString>Tasks Filter</helpString>
@@ -1043,7 +1043,7 @@
<blockName>ApplicationBarEventButton</blockName>
<title>Calendar</title>
<label>Calendar</label>
- <bitmap>application/images/ApplicationBarEvent.png</bitmap>
+ <bitmap>ApplicationBarEvent.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<event itemref="doc:ApplicationBarEvent"/>
<helpString>Calendar Events Filter</helpString>
@@ -1066,7 +1066,7 @@
<blockName>ApplicationBarSyncButton</blockName>
<title>Sync</title>
<label>Sync All</label>
- <bitmap>application/images/ApplicationBarSync.png</bitmap>
+ <bitmap>ApplicationBarSync.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<helpString>Get new Mail and synchronize with other Chandler users</helpString>
<event itemref="doc:SyncAll"/>
@@ -1076,7 +1076,7 @@
<blockName>ApplicationBarNewButton</blockName>
<title>New</title>
<label>New</label>
- <bitmap>application/images/ApplicationBarNew.png</bitmap>
+ <bitmap>ApplicationBarNew.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<helpString>Create a new Item</helpString>
<event itemref="doc:NewNote"/>
@@ -1091,7 +1091,7 @@
<blockName>ApplicationBarSendButton</blockName>
<title>Send</title>
<label>Send</label>
- <bitmap>application/images/ApplicationBarSend.png</bitmap>
+ <bitmap>ApplicationBarSend.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<helpString>Send the selected Item</helpString>
<event itemref="events:SendShareItem"/>
@@ -1143,19 +1143,19 @@
<contentModel:ItemCollection itsName="allItemCollection">
<displayName>All</displayName>
- <outOfTheBoxCollection>True</outOfTheBoxCollection>
+ <renameable>False</renameable>
<_rule value="for i inevery '//parcels/osaf/contentmodel/Note' where True"/>
</contentModel:ItemCollection>
<contentModel:ItemCollection itsName="inItemCollection">
<displayName>In</displayName>
- <outOfTheBoxCollection>True</outOfTheBoxCollection>
+ <renameable>False</renameable>
<_rule value="for i inevery '//parcels/osaf/contentmodel/mail/MailMessageMixin' where i.isInbound == True"/>
</contentModel:ItemCollection>
<contentModel:ItemCollection itsName="outItemCollection">
<displayName>Out</displayName>
- <outOfTheBoxCollection>True</outOfTheBoxCollection>
+ <renameable>False</renameable>
<_rule value="for i inevery '//parcels/osaf/contentmodel/mail/MailMessageMixin' where i.isOutbound == True"/>
</contentModel:ItemCollection>
@@ -1246,7 +1246,7 @@
<Sidebar itsName="Sidebar">
<blockName>Sidebar</blockName>
<contents itemref="doc:sidebarItemCollection"/>
- <elementDelegate>osaf.views.main.SideBar.SidebarAttributeDelegate</elementDelegate>
+ <elementDelegate>osaf.views.main.SideBar.SidebarElementDelegate</elementDelegate>
<selectedItemToView itemref="doc:allItemCollection"/>
<columnHeadings></columnHeadings>
<columnData>displayName</columnData>
@@ -1259,6 +1259,12 @@
<core:Integer value="0"/>
</selection>
<border>0,0,4,0</border>
+ <dontShowCalendarForItemsWithName key="In filtered by Calendar Event Mixin Kind" value="True"></dontShowCalendarForItemsWithName>
+ <dontShowCalendarForItemsWithName key="Out filtered by Calendar Event Mixin Kind" value="True"></dontShowCalendarForItemsWithName>
+ <nameAlternatives key="All" value="All my Items"></nameAlternatives>
+ <nameAlternatives key="AllMailMessageMixin" value="All my Mail"></nameAlternatives>
+ <nameAlternatives key="AllCalendarEventMixin" value="All my Events"></nameAlternatives>
+ <nameAlternatives key="AllTaskMixin" value="All my Tasks"></nameAlternatives>
</Sidebar>
<calendar:MiniCalendar itsName="MiniCalendar">
@@ -1443,8 +1449,7 @@
<ToolbarItem itsName="ListViewButton">
<blockName>ListViewButton1</blockName>
<title>List View</title>
- <bitmap>application/images/list.png</bitmap>
- <selectedBitmap></selectedBitmap>
+ <bitmap>list.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<helpString>Display the view in list mode</helpString>
<event itemref="doc:ChangeLayout"/>
@@ -1453,8 +1458,7 @@
<ToolbarItem itsName="WeekViewButton">
<blockName>WeekViewButton1</blockName>
<title>Week View</title>
- <bitmap>application/images/week.png</bitmap>
- <selectedBitmap></selectedBitmap>
+ <bitmap>week.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<helpString>Display the view in week mode</helpString>
<event itemref="doc:ChangeLayout"/>
@@ -1463,8 +1467,7 @@
<ToolbarItem itsName="DayViewButton">
<blockName>DayViewButton1</blockName>
<title>Day View</title>
- <bitmap>application/images/day.png</bitmap>
- <selectedBitmap></selectedBitmap>
+ <bitmap>day.png</bitmap>
<toolbarItemKind>Radio</toolbarItemKind>
<helpString>Display the view in day mode</helpString>
<event itemref="doc:ChangeLayout"/>
Index: chandler/parcels/osaf/framework/blocks/detail/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.72 chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.73
--- chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.72 Tue Apr 19 11:26:17 2005
+++ chandler/parcels/osaf/framework/blocks/detail/parcel.xml Wed Apr 20 18:16:21 2005
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.72 $ -->
-<!-- $Date: 2005/04/19 18:26:17 $ -->
+<!-- $Revision: 1.73 $ -->
+<!-- $Date: 2005/04/21 01:16:21 $ -->
<!-- Copyright (c) 2003-2005 Open Source Applications Foundation -->
<!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
@@ -43,10 +43,6 @@
<fontSize>10</fontSize>
</CharacterStyle>
- <ColorStyle itsName="GrayBackground">
- <backgroundColor>204,204,204,204</backgroundColor>
- </ColorStyle>
-
<ColorStyle itsName="WhiteBackground">
<backgroundColor>255,255,255,0</backgroundColor>
</ColorStyle>
@@ -185,7 +181,7 @@
itemClass="osaf.framework.blocks.detail.Detail.MailMessageButton">
<blockName>MailMessageButton</blockName>
<title>Send as message</title>
- <bitmap>application/images/MarkupBarMail.png</bitmap>
+ <bitmap>MarkupBarMail.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<toggle>True</toggle>
<helpString>Send this item as a mail message</helpString>
@@ -196,7 +192,7 @@
itemClass="osaf.framework.blocks.detail.Detail.TaskStamp">
<blockName>TaskStamp</blockName>
<title>Put on Taskpad</title>
- <bitmap>application/images/MarkupBarTask.png</bitmap>
+ <bitmap>MarkupBarTask.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<toggle>True</toggle>
<helpString>Put this item onto the Taskpad</helpString>
@@ -207,7 +203,7 @@
itemClass="osaf.framework.blocks.detail.Detail.CalendarStamp">
<blockName>CalendarStamp</blockName>
<title>Put on Calendar</title>
- <bitmap>application/images/MarkupBarEvent.png</bitmap>
+ <bitmap>MarkupBarEvent.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<toggle>True</toggle>
<helpString>Put this item onto the Calendar</helpString>
@@ -223,7 +219,7 @@
itemClass="osaf.framework.blocks.detail.Detail.PrivateSwitchButton">
<blockName>PrivateSwitchButton</blockName>
<title>Never share this item</title>
- <bitmap>application/images/MarkupBarPrivate.png</bitmap>
+ <bitmap>MarkupBarPrivate.png</bitmap>
<toolbarItemKind>Button</toolbarItemKind>
<toggle>True</toggle>
<helpString>Never share this item</helpString>
Index: chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py
diff -u chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py:1.35 chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py:1.36
--- chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py:1.35 Fri Apr 15 16:05:47 2005
+++ chandler/parcels/osaf/framework/blocks/calendar/CollectionCanvas.py Wed Apr 20 18:16:22 2005
@@ -1,8 +1,8 @@
""" Canvas block for displaying item collections
"""
-__version__ = "$Revision: 1.35 $"
-__date__ = "$Date: 2005/04/15 23:05:47 $"
+__version__ = "$Revision: 1.36 $"
+__date__ = "$Date: 2005/04/21 01:16:22 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -144,17 +144,17 @@
a button with no border.
"""
- def __init__(self, parent, path):
+ def __init__(self, parent, name):
"""
@param parent: like all controls, requires a parent window
@type parent: wx.Window
- @param path: path to a png file
- @type path: string
+ @param name: name of an image file
+ @type name: string
"""
self.forcedBorder = GetPlatformBorder()
- bitmap = wx.Image(path, wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+ bitmap = wx.GetApp().GetImage (name)
super(CanvasBitmapButton, self).__init__(parent, -1,
bitmap, style=wx.NO_BORDER)
Index: chandler/parcels/osaf/views/main/SideBar.py
diff -u chandler/parcels/osaf/views/main/SideBar.py:1.42 chandler/parcels/osaf/views/main/SideBar.py:1.43
--- chandler/parcels/osaf/views/main/SideBar.py:1.42 Thu Mar 17 15:01:28 2005
+++ chandler/parcels/osaf/views/main/SideBar.py Wed Apr 20 18:16:20 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.42 $"
-__date__ = "$Date: 2005/03/17 23:01:28 $"
+__version__ = "$Revision: 1.43 $"
+__date__ = "$Date: 2005/04/21 01:16:20 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -8,21 +8,40 @@
import osaf.framework.blocks.Trunk as Trunk
import osaf.contentmodel.ItemCollection as ItemCollection
import wx
+import osaf.framework.blocks.DrawingUtilities as DrawingUtilities
+import os
-class SidebarAttributeDelegate (ControlBlocks.AttributeDelegate):
+def GetRenderEditorTextRect (rect):
+ image = wx.GetApp().GetImage ("SidebarAll.png")
+ width = image.GetWidth() + 2
+ return wx.Rect (rect.GetLeft() + width,
+ rect.GetTop(),
+ rect.GetWidth() - (2 * width),
+ rect.GetHeight())
+
+
+class SidebarElementDelegate (ControlBlocks.ListDelegate):
def ReadOnly (self, row, column):
"""
Second argument should be True if all cells have the first value
"""
(item, attribute) = self.GetElementValue (row, column)
try:
- readOnly = getattr (item, 'outOfTheBoxCollection')
+ readOnly = not item.renameable
except AttributeError:
readOnly = False
return readOnly, False
+ def GetElementType (self, row, column):
+ return "Item"
+
+ def GetElementValue (self, row, column):
+ return self.blockItem.contents [row], self.blockItem.columnData [column]
+
+
class wxSidebar(ControlBlocks.wxTable):
+
def OnRequestDrop(self, x, y):
self.dropRow = self.YToRow(y)
if self.dropRow == wx.NOT_FOUND:
@@ -64,29 +83,88 @@
self.SetCellBackgroundColour(row, 0, wx.WHITE)
# Just invalidate the changed rect
rect = self.CellToRect(row, 0)
+ rect.OffsetXY (self.GetRowLabelSize(), self.GetColLabelSize())
self.RefreshRect(rect)
self.Update()
-
+
+class SSSidebarRenderer (wx.grid.PyGridCellRenderer):
+ """
+ Super specialized Sidebar Renderer, is so specialized that it works in
+ only one context -- Mimi's Sidebar.
+ """
+ def Draw (self, grid, attr, dc, rect, row, col, isSelected):
+ DrawingUtilities.SetTextColorsAndFont (grid, attr, dc, isSelected)
+
+ dc.SetBackgroundMode (wx.SOLID)
+ dc.SetPen (wx.TRANSPARENT_PEN)
+
+ dc.DrawRectangleRect(rect)
+
+ dc.SetBackgroundMode (wx.TRANSPARENT)
+ item, attribute = grid.GetTable().GetValue (row, col)
+ name = getattr (item, attribute)
+
+ if isinstance (item, ItemCollection.ItemCollection):
+ if len (item) == 0:
+ dc.SetTextForeground (wx.SystemSettings.GetColour (wx.SYS_COLOUR_GRAYTEXT))
+
+ numberOfShares = len (item.shares)
+ if numberOfShares > 0:
+ sharer = item.shares.first().sharer
+ if numberOfShares == 1 and str(sharer.itsPath) == "//userdata/me":
+ imageName = "SidebarOut.png"
+ else:
+ imageName = "SidebarIn.png"
+ image = wx.GetApp().GetImage (imageName)
+ x = rect.GetRight() -image.GetWidth() - 1
+ y = rect.GetTop() + (rect.GetHeight() - image.GetHeight()) / 2
+ dc.DrawBitmap (image, x, y, True)
+
+ if not getattr (item, "renameable", True):
+ key = name
+ sidebar = grid.blockItem
+ if sidebar.filterKind is not None:
+ key += os.path.basename (unicode (sidebar.filterKind.itsPath))
+ try:
+ name = sidebar.nameAlternatives [key]
+ except KeyError:
+ imageSuffix = name
+ else:
+ imageSuffix = key
+ image = wx.GetApp().GetImage ("Sidebar" + imageSuffix + ".png")
+
+ if image is not None:
+ x = rect.GetLeft() + 1
+ y = rect.GetTop() + (rect.GetHeight() - image.GetHeight()) / 2
+ dc.DrawBitmap (image, x, y, True)
+
+ textRect = GetRenderEditorTextRect (rect)
+ textRect.Inflate (-1, -1)
+ dc.SetClippingRect (textRect)
+ DrawingUtilities.DrawWrappedText (dc, name, textRect)
+ dc.DestroyClippingRegion()
+
+
+class SSSidebarEditor (ControlBlocks.GridCellAttributeEditor):
+ """
+ Super specialized Sidebar Editor, is so specialized that it works in
+ only one context -- Mimi's Sidebar.
+ """
+
+ def SetSize(self, rect):
+ textRect = GetRenderEditorTextRect (rect)
+ self.control.SetRect (textRect);
+
+
class Sidebar (ControlBlocks.Table):
def instantiateWidget (self):
- return wxSidebar (self.parentBlock.widget, Block.Block.getWidgetID(self))
+ widget = wxSidebar (self.parentBlock.widget, Block.Block.getWidgetID(self))
+ widget.RegisterDataType ("Item", SSSidebarRenderer(), SSSidebarEditor("Item"))
+ return widget
- def onKindParameterizedEvent (self, event):
- # @@@ Temporary hack until we have persistence in the toolbar.
- # Whenever you get an event to select a kind of filter make sure that
- # the toolbar click state is in sync with the desired filter
- toolbar = Block.Block.findBlockByName('ApplicationBar')
- for childBlock in toolbar.dynamicChildren:
- try:
- childBlock.event
- except AttributeError:
- pass
- else:
- if childBlock.event == event:
- if not childBlock.widget.IsToggled():
- toolbar.widget.ToggleTool(childBlock.toolID, True)
-
+ def onKindParameterizedEvent (self, event):
self.filterKind = event.kindParameter
+ self.widget.Refresh()
self.postEventByName("SelectItemBroadcast", {'item':self.selectedItemToView})
def onRequestSelectSidebarItemEvent (self, event):
@@ -137,24 +215,17 @@
def _makeTrunkForCacheKey(self, keyItem):
if isinstance (keyItem, ItemCollection.ItemCollection):
sidebar = Block.Block.findBlockByName ("Sidebar")
- """
- This test is a temporary place holder for a better, more complicated solution
- to the problem if figuring out when to show the calendar view. We also use
- a single calendar view for all item collections and a separate table for
- each item collection.
- Bryan argued that the better solution shouldn't be implmented until we decide
- the UI is final since he thinks the UI is too confusing so will likely change
- """
- if (sidebar.filterKind is self.findPath ("//parcels/osaf/contentmodel/calendar/CalendarEventMixin") and
- keyItem.displayName != u"In filtered by Calendar Event Mixin Kind" and
- keyItem.displayName != u"Out filtered by Calendar Event Mixin Kind"):
- trunk = self.findPath (self.calendarTemplatePath)
- keyUUID = trunk.itsUUID
- try:
- trunk = self.keyUUIDToTrunk[keyUUID]
- except KeyError:
- trunk = self._copyItem(trunk, onlyIfReadOnly=True)
- self.keyUUIDToTrunk[keyUUID] = trunk
+ filterKind = sidebar.filterKind
+ if (filterKind is not None and
+ unicode (filterKind.itsPath) == "//parcels/osaf/contentmodel/calendar/CalendarEventMixin" and
+ keyItem.displayName not in sidebar.dontShowCalendarForItemsWithName):
+ trunk = self.findPath (self.calendarTemplatePath)
+ keyUUID = trunk.itsUUID
+ try:
+ trunk = self.keyUUIDToTrunk[keyUUID]
+ except KeyError:
+ trunk = self._copyItem(trunk, onlyIfReadOnly=True)
+ self.keyUUIDToTrunk[keyUUID] = trunk
else:
trunk = self.findPath (self.tableTemplatePath)
else:
Index: chandler/parcels/osaf/framework/blocks/ControlBlocks.py
diff -u chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.195 chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.196
--- chandler/parcels/osaf/framework/blocks/ControlBlocks.py:1.195 Thu Apr 7 12:51:51 2005
+++ chandler/parcels/osaf/framework/blocks/ControlBlocks.py Wed Apr 20 18:16:22 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.195 $"
-__date__ = "$Date: 2005/04/07 19:51:51 $"
+__version__ = "$Revision: 1.196 $"
+__date__ = "$Date: 2005/04/21 01:16:22 $"
__copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -19,6 +19,7 @@
from repository.schema.Types import DateTime
from repository.schema.Types import RelativeDateTime
import mx.DateTime
+import osaf.framework.blocks.DrawingUtilities as DrawingUtilities
class Button(RectangularChild):
def instantiateWidget(self):
@@ -31,9 +32,7 @@
wx.DefaultPosition,
(self.minimumSize.width, self.minimumSize.height))
elif self.buttonKind == "Image":
- image = wx.Image(self.icon,
- wx.BITMAP_TYPE_PNG)
- bitmap = image.ConvertToBitmap()
+ bitmap = wx.GetApp().GetImage (self.icon)
button = wx.BitmapButton (parentWidget,
id,
bitmap,
@@ -400,7 +399,7 @@
self.widget.GoToItem (self.selection)
-class wxTableData(wx.grid.PyGridTableBase):
+class wxTableData (wx.grid.PyGridTableBase):
def __init__(self, *arguments, **keywords):
super (wxTableData, self).__init__ (*arguments, **keywords)
self.defaultRWAttribute = wx.grid.GridCellAttr()
@@ -417,13 +416,13 @@
GetNumberCols before wiring up the view instance variable
"""
view = self.GetView()
- if view:
+ if view is not None:
return view.GetElementCount()
return 1
def GetNumberCols (self):
view = self.GetView()
- if view:
+ if view is not None:
return view.GetColumnCount()
return 1
@@ -449,7 +448,7 @@
def GetAttr (self, row, column, kind):
attribute = self.base_GetAttr (row, column, kind)
- if not attribute:
+ if attribute is None:
type = self.GetTypeName (row, column)
delegate = IAttributeEditor.GetAttributeEditorSingleton (type)
attribute = self.defaultROAttribute
@@ -493,22 +492,15 @@
of the scrollbar so the scroll bars won't show. Instead we should consider modifying
grid adding a new style for not showing scrollbars. Bug #2375
"""
- self.SetMargins(0-wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X),
- 0-wx.SystemSettings_GetMetric(wx.SYS_HSCROLL_Y))
+ self.SetMargins(-wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X),
+ -wx.SystemSettings_GetMetric(wx.SYS_HSCROLL_Y))
"""
Don't draw cursor outline on selected cells
"""
self.SetCellHighlightPenWidth (0)
self.SetCellHighlightROPenWidth (0)
-
- defaultName = "_default"
- self.SetDefaultRenderer (GridCellAttributeRenderer (defaultName))
- map = wx.GetApp().UIRepositoryView.findPath('//parcels/osaf/framework/attributeEditors/AttributeEditors')
- for key in map.editorString.keys():
- if key != defaultName:
- self.RegisterDataType (key,
- GridCellAttributeRenderer (key),
- GridCellAttributeEditor (key))
+ background = wx.SystemSettings.GetColour (wx.SYS_COLOUR_HIGHLIGHT)
+ self.SetLightSelectionBackground()
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColumnDrag)
@@ -517,6 +509,33 @@
self.Bind(wx.grid.EVT_GRID_CELL_BEGIN_DRAG, self.OnItemDrag)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick)
+ self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick)
+ self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick)
+ self.Bind(wx.EVT_SET_FOCUS, self.OnGainFocus)
+ self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
+
+ def OnGainFocus (self, event):
+ self.SetSelectionBackground (wx.SystemSettings.GetColour (wx.SYS_COLOUR_HIGHLIGHT))
+ self.InvalidateSelection ()
+
+ def OnLoseFocus (self, event):
+ self.SetLightSelectionBackground()
+ self.InvalidateSelection ()
+
+ def SetLightSelectionBackground (self):
+ background = wx.SystemSettings.GetColour (wx.SYS_COLOUR_HIGHLIGHT)
+ background.Set ((background.Red() + 255) / 2,
+ (background.Green() + 255) / 2,
+ (background.Blue() + 255) / 2)
+ self.SetSelectionBackground (background)
+
+ def InvalidateSelection (self):
+ for range in self.blockItem.selection:
+ dirtyRect = wx.Rect()
+ dirtyRect.SetTopLeft (self.CellToRect (range[0], 0).GetTopLeft())
+ dirtyRect.SetBottomRight (self.CellToRect (range[1], self.GetNumberCols() - 1).GetBottomRight())
+ dirtyRect.OffsetXY (self.GetRowLabelSize(), self.GetColLabelSize())
+ self.RefreshRect (dirtyRect)
def OnKeyDown(self, event):
"""
@@ -783,31 +802,12 @@
super (GridCellAttributeRenderer, self).__init__ ()
self.delegate = IAttributeEditor.GetAttributeEditorSingleton (type)
- def SetTextColorsAndFont (self, grid, attr, dc, isSelected):
- """
- Set the text foreground, text background, brush and font into the dc
- """
- if grid.IsEnabled():
- if isSelected:
- background = grid.GetSelectionBackground()
- foreground = grid.GetSelectionForeground()
- else:
- background = attr.GetBackgroundColour()
- foreground = attr.GetTextColour()
- else:
- background = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)
- foreground = wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)
- dc.SetTextBackground (background)
- dc.SetTextForeground (foreground)
- dc.SetBrush (wx.Brush (background, wx.SOLID))
-
- dc.SetFont (attr.GetFont())
def Draw (self, grid, attr, dc, rect, row, column, isSelected):
"""
Currently only handles left justified multiline text
"""
- self.SetTextColorsAndFont (grid, attr, dc, isSelected)
+ DrawingUtilities.SetTextColorsAndFont (grid, attr, dc, isSelected)
item, attributeName = grid.GetElementValue (row, column)
self.delegate.Draw (dc, rect, item, attributeName, isSelected)
@@ -865,48 +865,22 @@
return self.delegate.GetControlValue (self.control)
-class ImageRenderer (wx.grid.PyGridCellRenderer):
- def Draw (self, grid, attr, dc, rect, row, col, isSelected):
- imageName = grid.GetTable().GetValue (row, col)
- image = wx.GetApp().GetImage (imageName)
-
- if image:
- offscreenBuffer = wx.MemoryDC()
-
- offscreenBuffer.SelectObject (image)
-
- dc.SetBackgroundMode (wx.SOLID)
-
- if isSelected:
- dc.SetBrush (wx.Brush (grid.GetSelectionBackground(), wx.SOLID))
- dc.SetPen (wx.Pen (grid.GetSelectionBackground(), 1, wx.SOLID))
- else:
- dc.SetBrush (wx.Brush (attr.GetBackgroundColour(), wx.SOLID))
- dc.SetPen (wx.Pen (attr.GetBackgroundColour(), 1, wx.SOLID))
-
- dc.DrawRectangleRect(rect)
-
- width, height = image.GetWidth(), image.GetHeight()
-
- if width > rect.width - 2:
- width = rect.width - 2
-
- if height > rect.height - 2:
- height = rect.height - 2
-
- dc.Blit ((rect.x + 1, rect.y + 1),
- (width, height),
- offscreenBuffer,
- (0, 0),
- wx.COPY,
- True)
-
class Table (RectangularChild):
def __init__(self, *arguments, **keywords):
super (Table, self).__init__ (*arguments, **keywords)
def instantiateWidget (self):
- return wxTable (self.parentBlock.widget, Block.getWidgetID(self))
+ widget = wxTable (self.parentBlock.widget, Block.getWidgetID(self))
+ defaultName = "_default"
+ widget.SetDefaultRenderer (GridCellAttributeRenderer (defaultName))
+ map = wx.GetApp().UIRepositoryView.findPath('//parcels/osaf/framework/attributeEditors/AttributeEditors')
+ for key in map.editorString.keys():
+ if key != defaultName:
+ widget.RegisterDataType (key,
+ GridCellAttributeRenderer (key),
+ GridCellAttributeEditor (key))
+ return widget
+
def onSetContentsEvent (self, event):
item = event.arguments ['item']
More information about the Commits
mailing list