[GRASS-SVN] r65736 - grass/trunk/gui/wxpython/animation

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jul 20 23:53:41 PDT 2015


Author: annakrat
Date: 2015-07-20 23:53:41 -0700 (Mon, 20 Jul 2015)
New Revision: 65736

Modified:
   grass/trunk/gui/wxpython/animation/controller.py
   grass/trunk/gui/wxpython/animation/dialogs.py
   grass/trunk/gui/wxpython/animation/utils.py
Log:
wxGUI/animation: add text background/foreground in settings

Modified: grass/trunk/gui/wxpython/animation/controller.py
===================================================================
--- grass/trunk/gui/wxpython/animation/controller.py	2015-07-21 06:22:44 UTC (rev 65735)
+++ grass/trunk/gui/wxpython/animation/controller.py	2015-07-21 06:53:41 UTC (rev 65736)
@@ -495,6 +495,8 @@
         busy = wx.BusyInfo(message=_("Preparing export, please wait..."), parent=self.frame)
         wx.Yield()
         lastBitmaps = {}
+        fgcolor = UserSettings.Get(group='animation', key='font', subkey='fgcolor')
+        bgcolor = UserSettings.Get(group='animation', key='font', subkey='bgcolor')
         for frameIndex in range(frameCount):
             image = wx.EmptyImage(*size)
             image.Replace(0, 0, 0, 255, 255, 255)
@@ -547,10 +549,10 @@
                             text = _("%(start)s %(unit)s") % \
                                     {'start': timeLabel[0], 'unit': timeLabel[2]}
 
-                    decImage = RenderText(text, decoration['font']).ConvertToImage()
+                    decImage = RenderText(text, decoration['font'], bgcolor, fgcolor).ConvertToImage()
                 elif decoration['name'] == 'text':
                     text = decoration['text']
-                    decImage = RenderText(text, decoration['font']).ConvertToImage()
+                    decImage = RenderText(text, decoration['font'], bgcolor, fgcolor).ConvertToImage()
 
                 image.Paste(decImage, x, y)
 

Modified: grass/trunk/gui/wxpython/animation/dialogs.py
===================================================================
--- grass/trunk/gui/wxpython/animation/dialogs.py	2015-07-21 06:22:44 UTC (rev 65735)
+++ grass/trunk/gui/wxpython/animation/dialogs.py	2015-07-21 06:53:41 UTC (rev 65736)
@@ -1519,6 +1519,32 @@
 
         gridSizer.Add(item=nprocs, pos=(row, 1), flag=wx.ALIGN_RIGHT)
 
+        row += 1
+        gridSizer.Add(item=wx.StaticText(parent=panel,
+                                         label=_("Text foreground color:")),
+                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+        color = csel.ColourSelect(parent=panel,
+                                  colour=UserSettings.Get(group='animation',
+                                                          key='font', subkey='fgcolor'),
+                                  size=globalvar.DIALOG_COLOR_SIZE)
+        color.SetName('GetColour')
+        self.winId['animation:font:fgcolor'] = color.GetId()
+
+        gridSizer.Add(item=color, pos=(row, 1), flag=wx.ALIGN_RIGHT)
+
+        row += 1
+        gridSizer.Add(item=wx.StaticText(parent=panel,
+                                         label=_("Text background color:")),
+                      flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, pos=(row, 0))
+        color = csel.ColourSelect(parent=panel,
+                                  colour=UserSettings.Get(group='animation',
+                                                          key='font', subkey='bgcolor'),
+                                  size=globalvar.DIALOG_COLOR_SIZE)
+        color.SetName('GetColour')
+        self.winId['animation:font:bgcolor'] = color.GetId()
+
+        gridSizer.Add(item=color, pos=(row, 1), flag=wx.ALIGN_RIGHT)
+
         gridSizer.AddGrowableCol(1)
         sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=3)
         border.Add(item=sizer, proportion=0, flag=wx.ALL | wx.EXPAND, border=3)

Modified: grass/trunk/gui/wxpython/animation/utils.py
===================================================================
--- grass/trunk/gui/wxpython/animation/utils.py	2015-07-21 06:22:44 UTC (rev 65735)
+++ grass/trunk/gui/wxpython/animation/utils.py	2015-07-21 06:53:41 UTC (rev 65736)
@@ -240,19 +240,19 @@
     return {'width': width, 'height': height, 'x': x, 'y': y, 'scale': scale}
 
 
-def RenderText(text, font):
+def RenderText(text, font, bgcolor, fgcolor):
     """Renderes text with given font to bitmap."""
     dc = wx.MemoryDC()
     dc.SetFont(font)
     w, h = dc.GetTextExtent(text)
     bmp = wx.EmptyBitmap(w + 2, h + 2)
     dc.SelectObject(bmp)
-    dc.SetBrush(wx.TRANSPARENT_BRUSH)
-    dc.SetBackgroundMode(wx.TRANSPARENT)
+    dc.SetBackgroundMode(wx.SOLID)
+    dc.SetTextBackground(wx.Colour(*bgcolor))
+    dc.SetTextForeground(wx.Colour(*fgcolor))
     dc.Clear()
     dc.DrawText(text, 1, 1)
     dc.SelectObject(wx.NullBitmap)
-    bmp.SetMaskColour(wx.WHITE)
 
     return bmp
 



More information about the grass-commit mailing list