# GLINT graphical package management
# Copyright (C) 1995 Red Hat, Inc
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

from Tkinter import *

# This isn't a real widget. Note it doesn't descend from anything and needs
# a canvas to exist

class Icon:

    def toggleSelect(self):
	if (self.selected):
	    self.unselect()
	else:
	    self.select()

    def selectCallback(self, selected, data):
	if (selected):
	    self.select()
	else:
	    self.unselect()

    def __init__(self, Canvas, Item):
	self.canvas = Canvas
	self.id = Item
	self.selected = 0

class BackIcon(Icon):

    def select(self):
	self.canvas.itemconfig(self.backid, { 'fill' : 'red' } )
	self.selected = 1

    def unselect(self):
	self.canvas.itemconfig(self.backid, { 'fill' : self.canvas['back'] } )
	self.selected = 0

    def __init__(self, Canvas, Item, Backdrop):
	Icon.__init__(self, Canvas, Item)
	self.backid = Backdrop

