New Artwork
Adit Panchal <[email protected]>
| Newsgroups | gmane.comp.mobile.bitpim.devel |
|---|---|
| Message-ID | <[email protected]> |
I just finished my finals so I had a bit of time to complete the artwork that I had been working on. I implemented (as suggested by Roger) by overriding the wx.ArtProvider function. Attached is my diff to enable the artwork as well as a zip file (renamed to .zio) of the artwork. The artwork should go into the resources folder. Thanks, Adit
artwork.diff
(application/octet-stream, 9.5 KB)
cvs diff: Diffing .
Index: gui.py
===================================================================
RCS file: /cvsroot/bitpim/bitpim/gui.py,v
retrieving revision 1.165
diff -u -r1.165 gui.py
--- gui.py 3 Feb 2005 04:56:22 -0000 1.165
+++ gui.py 28 Feb 2005 02:36:17 -0000
@@ -263,12 +263,33 @@
def OnInit(self):
self.made=False
# Routine maintenance
wx.lib.colourdb.updateColourDB()
+
+ # Enables all image handlers for wxImage
+ wx.InitAllImageHandlers()
# Thread stuff
global mainthreadid
@@ -558,18 +579,26 @@
menuBar.Append(menu, "&Help");
### toolbar
+
+ # establish the custom art provider for custom icons
+ # this is a global setting, so no need to call it for each toolbar
+ wx.ArtProvider_PushProvider(guihelper.ArtProvider())
+
# self.tb=self.CreateToolBar(wx.TB_HORIZONTAL|wx.NO_BORDER|wx.TB_FLAT)
self.tb=self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_TEXT)
- #self.tb.SetToolBitmapSize(wx.Size(32,32))
+ # work around a bug in which the Mac toolbar icons are 4 pixels bigger
+ # in each dimension
+ if guihelper.IsMac():
+ self.tb.SetToolBitmapSize(wx.Size(27,27))
+ else:
+ self.tb.SetToolBitmapSize(wx.Size(32,32))
sz=self.tb.GetToolBitmapSize()
# work around a bug on Linux that returns random (large) numbers
if sz[0]<10 or sz[0]>100: sz=wx.Size(32,32)
# add and delete tools
- self.tb.AddLabelTool(guihelper.ID_EDITADDENTRY, "Add", wx.ArtProvider_GetBitmap(wx.ART_ADD_BOOKMARK, wx.ART_TOOLBAR, sz),
- shortHelp="Add", longHelp="Add an item")
- self.tb.AddLabelTool(guihelper.ID_EDITDELETEENTRY, "Delete", wx.ArtProvider_GetBitmap(wx.ART_DEL_BOOKMARK, wx.ART_TOOLBAR, sz),
- shortHelp="Delete", longHelp="Delete item")
+ self.tb.AddLabelTool(guihelper.ID_EDITADDENTRY, "Add", wx.ArtProvider_GetBitmap("ART_ADD_WALLPAPER", wx.ART_TOOLBAR, sz), shortHelp="Add", longHelp="Add an item")
+ self.tb.AddLabelTool(guihelper.ID_EDITDELETEENTRY, "Delete", wx.ArtProvider_GetBitmap("ART_DEL_WALLPAPER", wx.ART_TOOLBAR, sz), shortHelp="Delete", longHelp="Delete item")
# You have to make this call for the toolbar to draw itself properly
self.tb.Realize()
@@ -973,12 +1002,34 @@
text=self.nb.GetPageText(self.nb.GetSelection())
if text is not None:
self.config.Write("viewnotebookpage", text)
- # is ringers viewable?
+ # if we selected a tab that has editible properties
widget=self.nb.GetPage(self.nb.GetSelection())
if widget is self.ringerwidget or \
widget is self.wallpaperwidget or \
widget is self.phonewidget:
+ # enable the editible functions
enableedit=True
+ # wx.toolbar cannot replace the icon of the toolbar on the fly
+ # so we have to delete the tool and re-add it
+
+ # delete the toolbar buttons (so we can add them again)
+ self.tb.DeleteTool(guihelper.ID_EDITADDENTRY)
+ self.tb.DeleteTool(guihelper.ID_EDITDELETEENTRY)
+
+ sz=self.tb.GetToolBitmapSize()
+ # work around a bug on Linux that returns random (large) numbers
+ if sz[0]<10 or sz[0]>100: sz=wx.Size(32,32)
+
+ if widget is self.ringerwidget:
+ self.tb.AddLabelTool(guihelper.ID_EDITADDENTRY, "Add", wx.ArtProvider_GetBitmap("ART_ADD_RINGER", wx.ART_TOOLBAR, sz), shortHelp="Add Ringer", longHelp="Add Ringer")
+ self.tb.AddLabelTool(guihelper.ID_EDITDELETEENTRY, "Delete", wx.ArtProvider_GetBitmap("ART_DEL_RINGER", wx.ART_TOOLBAR, sz), shortHelp="Delete Ringer", longHelp="Delete Ringer")
+ elif widget is self.wallpaperwidget:
+ self.tb.AddLabelTool(guihelper.ID_EDITADDENTRY, "Add", wx.ArtProvider_GetBitmap("ART_ADD_WALLPAPER", wx.ART_TOOLBAR, sz), shortHelp="Add Wallpaper", longHelp="Add Wallpaper")
+ self.tb.AddLabelTool(guihelper.ID_EDITDELETEENTRY, "Delete", wx.ArtProvider_GetBitmap("ART_DEL_WALLPAPER", wx.ART_TOOLBAR, sz), shortHelp="Delete Wallpaper", longHelp="Delete Wallpaper")
+ elif widget is self.phonewidget:
+ self.tb.AddLabelTool(guihelper.ID_EDITADDENTRY, "Add", wx.ArtProvider_GetBitmap("ART_ADD_CONTACT", wx.ART_TOOLBAR, sz), shortHelp="Add Contact", longHelp="Add Contact")
+ self.tb.AddLabelTool(guihelper.ID_EDITDELETEENTRY, "Delete", wx.ArtProvider_GetBitmap("ART_DEL_CONTACT", wx.ART_TOOLBAR, sz), shortHelp="Delete Contact", longHelp="Delete Contact")
+ self.tb.Realize()
else: enableedit=False
# Toolbar
Index: guihelper.py
===================================================================
RCS file: /cvsroot/bitpim/bitpim/guihelper.py,v
retrieving revision 1.29
diff -u -r1.29 guihelper.py
--- guihelper.py 16 Jan 2005 10:23:27 -0000 1.29
+++ guihelper.py 28 Feb 2005 02:36:17 -0000
@@ -262,3 +262,51 @@
return cmd
return None
+class ArtProvider(wx.ArtProvider):
+ """ArtProvider manages the art for the application"""
+
+ def __init__(self):
+ """Constructor"""
+ wx.ArtProvider.__init__(self)
+
+ def CreateBitmap(self, artid, client, size):
+ """Loads a bitmap and returns it depending on the parameters
+ """
+ # create a null bitmap as default
+ bmp = wx.NullBitmap
+
+ # select the bitmap from the appropriate resource
+ if artid == "ART_ARROW_UP":
+ image = wx.Image(getresourcefile("arrow_up.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_ARROW_DOWN":
+ image = wx.Image(getresourcefile("arrow_down.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_ADD_FIELD":
+ image = wx.Image(getresourcefile("add_field.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_DELETE_FIELD":
+ image = wx.Image(getresourcefile("delete_field.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_ADD_CONTACT":
+ image = wx.Image(getresourcefile("add_contact.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_DEL_CONTACT":
+ image = wx.Image(getresourcefile("delete_contact.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_ADD_WALLPAPER":
+ image = wx.Image(getresourcefile("add_picture.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_DEL_WALLPAPER":
+ image = wx.Image(getresourcefile("delete_picture.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_ADD_RINGER":
+ image = wx.Image(getresourcefile("add_ringer.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ elif artid == "ART_DEL_RINGER":
+ image = wx.Image(getresourcefile("delete_ringer.png"), wx.BITMAP_TYPE_PNG)
+ bmp = image.ConvertToBitmap()
+ else:
+ print "error"
+ print size
+ return bmp
Index: phonebookentryeditor.py
===================================================================
RCS file: /cvsroot/bitpim/bitpim/phonebookentryeditor.py,v
retrieving revision 1.31
diff -u -r1.31 phonebookentryeditor.py
--- phonebookentryeditor.py 31 Jan 2005 07:09:21 -0000 1.31
+++ phonebookentryeditor.py 28 Feb 2005 02:36:20 -0000
@@ -14,6 +14,7 @@
import bphtml
import database
import wallpaper
+import guihelper
"""The dialog for editing a phonebook entry"""
@@ -987,12 +988,22 @@
self.data=factory.newdataobject(data)
vs=wx.BoxSizer(wx.VERTICAL)
tb=wx.ToolBar(self, 7, style=wx.TB_FLAT|wx.TB_HORIZONTAL|wx.TB_TEXT)
+
+ # work around a bug in which the mac toolbar icons are 4 pixels bigger
+ # in each dimension
+ if guihelper.IsMac():
+ tb.SetToolBitmapSize(wx.Size(27,27))
+ else:
+ tb.SetToolBitmapSize(wx.Size(32,32))
sz=tb.GetToolBitmapSize()
- tb.AddLabelTool(self.ID_UP, "Up", wx.ArtProvider_GetBitmap(wx.ART_GO_UP, wx.ART_TOOLBAR, sz))
- tb.AddLabelTool(self.ID_DOWN, "Down", wx.ArtProvider_GetBitmap(wx.ART_GO_DOWN, wx.ART_TOOLBAR, sz))
+ # work around a bug on Linux that returns random (large) numbers
+ if sz[0]<10 or sz[0]>100: sz=wx.Size(32,32)
+
+ tb.AddLabelTool(self.ID_UP, "Up", wx.ArtProvider_GetBitmap("ART_ARROW_UP", wx.ART_TOOLBAR, sz), shortHelp ="Move Field Up")
+ tb.AddLabelTool(self.ID_DOWN, "Down", wx.ArtProvider_GetBitmap("ART_ARROW_DOWN", wx.ART_TOOLBAR, sz), shortHelp ="Move Field Down")
tb.AddSeparator()
- tb.AddLabelTool(self.ID_ADD, "Add", wx.ArtProvider_GetBitmap(wx.ART_ADD_BOOKMARK, wx.ART_TOOLBAR, sz))
- tb.AddLabelTool(self.ID_DELETE, "Delete", wx.ArtProvider_GetBitmap(wx.ART_DEL_BOOKMARK, wx.ART_TOOLBAR, sz))
+ tb.AddLabelTool(self.ID_ADD, "Add", wx.ArtProvider_GetBitmap("ART_ADD_FIELD", wx.ART_TOOLBAR, sz), shortHelp ="Add Field")
+ tb.AddLabelTool(self.ID_DELETE, "Delete", wx.ArtProvider_GetBitmap("ART_DELETE_FIELD", wx.ART_TOOLBAR, sz), shortHelp ="Delete Field")
tb.Realize()
vs.Add(tb, 0, wx.EXPAND|wx.BOTTOM, 5)
artwork.zio
(application/octet-stream, 11.7 KB) - not displayed