colours.py revision 10259
11689SN/A# Copyright (c) 2013 ARM Limited 29783Sandreas.hansson@arm.com# All rights reserved 310239Sbinhpham@cs.rutgers.edu# 47598Sminkyu.jeong@arm.com# The license below extends only to copyright in the software and shall 57598Sminkyu.jeong@arm.com# not be construed as granting a license to any other intellectual 67598Sminkyu.jeong@arm.com# property including but not limited to intellectual property relating 77598Sminkyu.jeong@arm.com# to a hardware implementation of the functionality of the software 87598Sminkyu.jeong@arm.com# licensed hereunder. You may use the software subject to the license 97598Sminkyu.jeong@arm.com# terms below provided that you ensure that this notice is replicated 107598Sminkyu.jeong@arm.com# unmodified and in its entirety in all distributions of the software, 117598Sminkyu.jeong@arm.com# modified or unmodified, in source code or in binary form. 127598Sminkyu.jeong@arm.com# 137598Sminkyu.jeong@arm.com# Redistribution and use in source and binary forms, with or without 147598Sminkyu.jeong@arm.com# modification, are permitted provided that the following conditions are 152326SN/A# met: redistributions of source code must retain the above copyright 161689SN/A# notice, this list of conditions and the following disclaimer; 171689SN/A# redistributions in binary form must reproduce the above copyright 181689SN/A# notice, this list of conditions and the following disclaimer in the 191689SN/A# documentation and/or other materials provided with the distribution; 201689SN/A# neither the name of the copyright holders nor the names of its 211689SN/A# contributors may be used to endorse or promote products derived from 221689SN/A# this software without specific prior written permission. 231689SN/A# 241689SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 251689SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 261689SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 271689SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 281689SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 291689SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 301689SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 311689SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 321689SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 331689SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 341689SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 351689SN/A# 361689SN/A# Authors: Andrew Bardsley 371689SN/A 381689SN/Aimport gtk 391689SN/A 402665Ssaidi@eecs.umich.edu# All the miscellaneous colours used in the interface 412665Ssaidi@eecs.umich.eduunknownColour = gtk.gdk.color_parse('magenta') 421689SN/AblockedColour = gtk.gdk.color_parse('grey') 431689SN/AbubbleColour = gtk.gdk.color_parse('bisque') 449944Smatt.horsnell@ARM.comemptySlotColour = gtk.gdk.color_parse('grey90') 459944Smatt.horsnell@ARM.comreservedSlotColour = gtk.gdk.color_parse('cyan') 469944Smatt.horsnell@ARM.comerrorColour = gtk.gdk.color_parse('blue') 471060SN/AbackgroundColour = gtk.gdk.color_parse('white') 481060SN/AfaultColour = gtk.gdk.color_parse('dark cyan') 491689SN/AreadColour = gtk.gdk.color_parse('red') 501060SN/AwriteColour = gtk.gdk.color_parse('white') 511060SN/A 521060SN/Ablack = gtk.gdk.color_parse('black') 538230Snate@binkert.org 546658Snate@binkert.orgdef name_to_colour(name): 558887Sgeoffrey.blake@arm.com """Convert a colour name to a GdkColor""" 562292SN/A try: 571717SN/A ret = gtk.gdk.color_parse(name) 588229Snate@binkert.org except: 598232Snate@binkert.org ret = unknownColour 609444SAndreas.Sandberg@ARM.com return ret 618232Snate@binkert.org 629527SMatt.Horsnell@arm.comnumber_colour_code = map(name_to_colour, ['black', 'brown', 'red', 'orange', 635529Snate@binkert.org 'yellow', 'green', 'blue', 'violet', 'grey', 'white']) 641060SN/A 656221Snate@binkert.orgdef number_to_colour(num): 666221Snate@binkert.org """Convert the last decimal digit of an integer into a resistor 671681SN/A stripe colour""" 685529Snate@binkert.org return number_colour_code[num % 10] 692873Sktlim@umich.edu