colours.py revision 10259
12623SN/A# Copyright (c) 2013 ARM Limited 22623SN/A# All rights reserved 32623SN/A# 42623SN/A# The license below extends only to copyright in the software and shall 52623SN/A# not be construed as granting a license to any other intellectual 62623SN/A# property including but not limited to intellectual property relating 72623SN/A# to a hardware implementation of the functionality of the software 82623SN/A# licensed hereunder. You may use the software subject to the license 92623SN/A# terms below provided that you ensure that this notice is replicated 102623SN/A# unmodified and in its entirety in all distributions of the software, 112623SN/A# modified or unmodified, in source code or in binary form. 122623SN/A# 132623SN/A# Redistribution and use in source and binary forms, with or without 142623SN/A# modification, are permitted provided that the following conditions are 152623SN/A# met: redistributions of source code must retain the above copyright 162623SN/A# notice, this list of conditions and the following disclaimer; 172623SN/A# redistributions in binary form must reproduce the above copyright 182623SN/A# notice, this list of conditions and the following disclaimer in the 192623SN/A# documentation and/or other materials provided with the distribution; 202623SN/A# neither the name of the copyright holders nor the names of its 212623SN/A# contributors may be used to endorse or promote products derived from 222623SN/A# this software without specific prior written permission. 232623SN/A# 242623SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 252623SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 262623SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 272665Ssaidi@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 282665Ssaidi@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 292623SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 302623SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 313170Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 328105Sgblack@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 332623SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 344040Ssaidi@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 356658Snate@binkert.org# 368229Snate@binkert.org# Authors: Andrew Bardsley 372623SN/A 388232Snate@binkert.orgimport gtk 398232Snate@binkert.org 403348Sbinkertn@umich.edu# All the miscellaneous colours used in the interface 413348Sbinkertn@umich.eduunknownColour = gtk.gdk.color_parse('magenta') 424762Snate@binkert.orgblockedColour = gtk.gdk.color_parse('grey') 437678Sgblack@eecs.umich.edububbleColour = gtk.gdk.color_parse('bisque') 442901Ssaidi@eecs.umich.eduemptySlotColour = gtk.gdk.color_parse('grey90') 452623SN/AreservedSlotColour = gtk.gdk.color_parse('cyan') 462623SN/AerrorColour = gtk.gdk.color_parse('blue') 472623SN/AbackgroundColour = gtk.gdk.color_parse('white') 482623SN/AfaultColour = gtk.gdk.color_parse('dark cyan') 492623SN/AreadColour = gtk.gdk.color_parse('red') 505606Snate@binkert.orgwriteColour = gtk.gdk.color_parse('white') 512623SN/A 522623SN/Ablack = gtk.gdk.color_parse('black') 532623SN/A 542623SN/Adef name_to_colour(name): 552623SN/A """Convert a colour name to a GdkColor""" 562623SN/A try: 572623SN/A ret = gtk.gdk.color_parse(name) 582623SN/A except: 592623SN/A ret = unknownColour 602623SN/A return ret 612623SN/A 625336Shines@cs.fsu.edunumber_colour_code = map(name_to_colour, ['black', 'brown', 'red', 'orange', 632623SN/A 'yellow', 'green', 'blue', 'violet', 'grey', 'white']) 644873Sstever@eecs.umich.edu 652623SN/Adef number_to_colour(num): 662623SN/A """Convert the last decimal digit of an integer into a resistor 672856Srdreslin@umich.edu stripe colour""" 686227Snate@binkert.org return number_colour_code[num % 10] 692856Srdreslin@umich.edu