Pārlūkot izejas kodu

wxGUI/core: use gray always, sync purple with lib/gis/color_str.c although it is probably wrong

before: depending on dict ordering gray or grey was used, (un)checking Transparent in GUI caused switching from gray to grey
purple: accoring to Wikipedia it is different from violet and was correctly defined in the GUI before but this was not the same as in library

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@61255 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 10 gadi atpakaļ
vecāks
revīzija
a497f47c07
1 mainītis faili ar 15 papildinājumiem un 7 dzēšanām
  1. 15 7
      gui/wxpython/core/utils.py

+ 15 - 7
gui/wxpython/core/utils.py

@@ -945,28 +945,36 @@ def SetAddOnPath(addonPath = None, key = 'PATH'):
     # update path
     if addonPath not in os.environ['PATH']:
         os.environ['PATH'] = addonPath + os.pathsep + os.environ['PATH']
-    
-# From lib/gis/col_str.c, except purple which is mentioned
-# there but not given RGB values
+
+
+# predefined colors and their names
+# must be in sync with lib/gis/color_str.c
 str2rgb = {'aqua': (100, 128, 255),
            'black': (0, 0, 0),
            'blue': (0, 0, 255),
            'brown': (180, 77, 25),
            'cyan': (0, 255, 255),
            'gray': (128, 128, 128),
-           'green': (0, 255, 0),
            'grey': (128, 128, 128),
+           'green': (0, 255, 0),
            'indigo': (0, 128, 255),
            'magenta': (255, 0, 255),
            'orange': (255, 128, 0),
-           'purple': (128, 0, 128),
            'red': (255, 0, 0),
            'violet': (128, 0, 255),
+           'purple': (128, 0, 255),
            'white': (255, 255, 255),
            'yellow': (255, 255, 0)}
 rgb2str = {}
-for (s,r) in str2rgb.items():
-    rgb2str[ r ] = s
+for (s, r) in str2rgb.items():
+    rgb2str[r] = s
+# ensure that gray value has 'gray' string and not 'grey'
+rgb2str[str2rgb['gray']] = 'gray'
+# purple is defined as nickname for violet in lib/gis
+# (although Wikipedia says that purple is (128, 0, 128))
+# we will prefer the defined color, not nickname
+rgb2str[str2rgb['violet']] = 'violet'
+
 
 def color_resolve(color):
     if len(color) > 0 and color[0] in "0123456789":