Changeset 3596:f226213a8036 in orange


Ignore:
Timestamp:
04/26/07 22:43:52 (7 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
bdc3f69a49b948e4a43e08635a7831607b2f5e80
Message:
  • added an if which checks whether the platform is "darwin"; if it's not, it doesn't change colors from long to int (or whatever these functions do)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/OrangeWidgets/ColorPalette.py

    r3560 r3596  
    2929# it sees the number as positive - so it cannot be stored as positive number in 31 bits) and sometimes 
    3030# it needs unsigned number and so uses long and does not want a signed int 
    31 def signedColor(long): 
    32     if type(long) == int: 
    33         return long 
    34     elif long > 0xFFFFFFFF: 
    35     long &= 0xFFFFFFFF 
     31 
     32import sys 
     33if sys.platform == "darwin": 
     34    def signedColor(long): 
     35        if type(long) == int: 
     36            return long 
     37        elif long > 0xFFFFFFFF: 
     38            long &= 0xFFFFFFFF 
     39         
     40        if long & 0x80000000: 
     41            return int(-((long ^ 0xFFFFFFFF) + 1)) 
     42        else: 
     43            return int(long) 
     44 
     45    def positiveColor(color): 
     46        if color < 0: 
     47            return (-color - 1) ^ 0xFFFFFFFF 
     48        else: 
     49            return color 
     50 
     51    def signedPalette(palette): 
     52        return [signedColor(color) for color in palette] 
     53 
     54else: 
     55    signedColor = positiveColor = signedPalette = lambda x:x 
    3656     
    37     if long & 0x80000000: 
    38         return int(-((long ^ 0xFFFFFFFF) + 1)) 
    39     else: 
    40         return int(long) 
    41  
    42 def positiveColor(color): 
    43     if color < 0: 
    44         return (-color - 1) ^ 0xFFFFFFFF 
    45     else: 
    46         return color 
    47  
    48 def signedPalette(palette): 
    49     return [signedColor(color) for color in palette] 
    50  
    5157class ColorPalette(QWidget): 
    5258    def __init__(self, parent, master, value, label = "Colors", additionalColors = None, callback = None): 
Note: See TracChangeset for help on using the changeset viewer.