#
# This file is part of GNU Enterprise.
#
# GNU Enterprise 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, or (at your option) any later version.
#
# GNU Enterprise 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 program; see the file COPYING. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
# Copyright 2002-2003 Free Software Foundation
#
# FILE:
# Control.py
#
# DESCRIPTION:
#
# NOTES:
#

#from gnue.common.apps import GDebug
from constants import *
from GraphicObject import GraphicObject

class Control(GraphicObject):
  def __init__(self, Parent, CName, **properties):
    apply (GraphicObject.__init__, (self, Parent.SCREEN),
       properties)
    self.NAME = CName
    self.SetColor('DIALOG','BACKGROUND')
    self.X = -1
    self.Y = -1
    self.VISIBLE = 1
    self.FOCUS = 0
    self.CANGETFOCUS = 1
    self.PARENT = Parent
    self.Methods = {}
    self.Methods["CLICK"] = None
    self.Methods["PAINT"] = None
    self.Methods["GOTFOCUS"] = None
    self.Methods["LOSTFOCUS"] = None
    self.Methods["ACTION"] = None

##  def DetermineAndSetColor(self, HasFocus):
##    if self.active:
##      if HasFocus :
##        self.SetColor(self.FOCUSCOLOR)
##      else:
##        self.SetColor(self.COLOR)
##    else:
##      pass
##      ##self.SetColor(4)

  def CreateProperty(self, Property, Value):
    self.__dict__[Property] = Value

  def SetMethod(self, MethodName, MethodValue):
    self.Methods[MethodName] = MethodValue

  def GetMethod(self, MethodName):
    if self.Methods.has_key(MethodName):
      return(self.Methods[MethodName])
    return None

  def Paint(self, v1,v2,v3):
    pass

  def ExecMethod(self, MethodName, Arg1, Arg2, Arg3):
    if not self.Methods.has_key(MethodName):
      return None
    if self.Methods[MethodName] == None:
      return None
    else:
      return self.Methods[MethodName](Arg1, Arg2, Arg3)

  def DeActivate(self, state):
    if self.active != state:
      self.active = state
      self.Paint(0,0,0)
      self.ExecMethod("REFRESH",None,None,None)


  def SetActiveState( self, state):
    self.DeActivate( state)


  def GetHeight(self):
    return self.H

  def GetWidth(self):
    return self.W


