2
# This file is part of GNU Enterprise.
4
# GNU Enterprise is free software; you can redistribute it
5
# and/or modify it under the terms of the GNU General Public
6
# License as published by the Free Software Foundation; either
7
# version 2, or (at your option) any later version.
9
# GNU Enterprise is distributed in the hope that it will be
10
# useful, but WITHOUT ANY WARRANTY; without even the implied
11
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
# PURPOSE. See the GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public
15
# License along with program; see the file COPYING. If not,
16
# write to the Free Software Foundation, Inc., 59 Temple Place
17
# - Suite 330, Boston, MA 02111-1307, USA.
19
# Copyright 2002-2005 Free Software Foundation
32
from constants import *
36
GraphicObject is the base class for Container: the full screen
37
container, as well as for Control: the base class for all of the on-
40
GraphicObject maintains a private dictionary of properties and is used
41
heavily throughout to modify appearance and behaviour. GraphicObject
42
methods are mostly concerned with managing data in the _Properties dict.
45
_InheritedProperties=[ "LOLIGHT_COLOR", "HILIGHT_COLOR" ]
48
def __init__( self, sioScreen, **properties):
49
self.__dict__.update(properties)
50
self.SCREEN = sioScreen
52
self.SetColor( colorLow,colorHi)
53
self.PRIOR_COLOR = colorLow
57
def GetProperty(self, pptyName):
58
return self.__dict__[pptyName]
61
def SetProperty(self, pptyName, pptyVal):
62
self.__dict__[pptyName] = pptyVal
65
def HasProperty(self, pptyName):
66
"Equally well named pptyExists(x)"
67
return self.__dict__.has_key(pptyName)
70
def IsPropertyInherited( self, pptyName):
71
"True if arguement is an inherited property, false otherwise."
72
return pptyName in self._InheritedProperties
75
def InheritProperties(self, fromObj):
77
A beefy method. InheritProperties uses each element in the private
78
list, _InheritedProperties, verifies that each member exists in
79
'fromObj' and that it DOESN'T exist in self before adding to self.
81
for pptyName in self._InheritedProperties:
82
if fromObj.HasProperty(pptyName) and not self.HasProperty(pptyName):
83
self.SetProperty(pptyName, fromObj.GetProperty(pptyName))
86
# various (of how much) utility methods
89
def Verify( self, arg1, arg2, arg3):
93
def SetColor( self, color, focusColor=None):
95
if type(color) == type(""):
96
color = self.SCREEN.colors.__dict__['C_%s' % color]
97
if focusColor == None:
99
elif type(focusColor) == type(""):
100
focusColor = self.SCREEN.colors.__dict__['C_%s' % focusColor]
103
self.FOCUSCOLOR = focusColor
109
self._SetLight("LOLIGHT_COLOR", Screen.SetColor, Screen.LoLight)
115
self._SetLight("HILIGHT_COLOR", Screen.SetColor, Screen.HiLight)
121
def _SetLight(self, PropertyName, Setter, DefaultSetter):
123
if curses.has_colors():
124
Setter(self.__dict__[PropertyName])
126
except (KeyError, AttributeError):