~ubuntu-branches/ubuntu/hardy/gnue-common/hardy

« back to all changes in this revision

Viewing changes to src/cursing/Control.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2005-03-09 11:06:31 UTC
  • Revision ID: james.westby@ubuntu.com-20050309110631-8gvvn39q7tjz1kj6
Tags: upstream-0.5.14
ImportĀ upstreamĀ versionĀ 0.5.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# This file is part of GNU Enterprise.
 
3
#
 
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.
 
8
#
 
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.
 
13
#
 
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.
 
18
#
 
19
# Copyright 2002-2005 Free Software Foundation
 
20
#
 
21
# FILE:
 
22
# Control.py
 
23
#
 
24
# DESCRIPTION:
 
25
#
 
26
# NOTES:
 
27
#
 
28
 
 
29
 
 
30
from constants import *
 
31
from GraphicObject import GraphicObject
 
32
 
 
33
class Control(GraphicObject):
 
34
  VISIBLE = True
 
35
  CANGETFOCUS=True
 
36
  FOCUS=False
 
37
  NAME=""
 
38
  Methods = {}
 
39
 
 
40
  def __init__(self, Parent, x, y, w=1, h=1, **properties):
 
41
    GraphicObject.__init__(self, Parent.SCREEN, **properties)
 
42
    self.SetColor('DIALOG','BACKGROUND')
 
43
    self.X = x
 
44
    self.Y = y
 
45
    self.H = h
 
46
    self.W = w
 
47
 
 
48
    self.PARENT = Parent
 
49
    self.Methods["CLICK"] = None
 
50
    self.Methods["PAINT"] = None
 
51
    self.Methods["GOTFOCUS"] = None
 
52
    self.Methods["LOSTFOCUS"] = None
 
53
    self.Methods["ACTION"] = None
 
54
 
 
55
    Parent.AddControl(self)
 
56
 
 
57
 
 
58
##  def DetermineAndSetColor(self, HasFocus):
 
59
##    if self.active:
 
60
##      if HasFocus :
 
61
##        self.SetColor(self.FOCUSCOLOR)
 
62
##      else:
 
63
##        self.SetColor(self.COLOR)
 
64
##    else:
 
65
##      pass
 
66
##      ##self.SetColor(4)
 
67
 
 
68
  def CreateProperty(self, Property, Value):
 
69
    self.__dict__[Property] = Value
 
70
 
 
71
  def SetMethod(self, MethodName, MethodValue):
 
72
    self.Methods[MethodName] = MethodValue
 
73
 
 
74
  def GetMethod(self, MethodName):
 
75
    if self.Methods.has_key(MethodName):
 
76
      return(self.Methods[MethodName])
 
77
    return None
 
78
 
 
79
  def Paint(self, v1,v2,v3):
 
80
    pass
 
81
 
 
82
  def ExecMethod(self, MethodName, Arg1, Arg2, Arg3):
 
83
    if not self.Methods.has_key(MethodName):
 
84
      return None
 
85
    if self.Methods[MethodName] == None:
 
86
      return None
 
87
    else:
 
88
      return self.Methods[MethodName](Arg1, Arg2, Arg3)
 
89
 
 
90
  def DeActivate(self, state):
 
91
    if self.active != state:
 
92
      self.active = state
 
93
      self.Paint(0,0,0)
 
94
      self.ExecMethod("REFRESH",None,None,None)
 
95
 
 
96
 
 
97
  def SetActiveState( self, state):
 
98
    self.DeActivate( state)
 
99
 
 
100
 
 
101
  def GetHeight(self):
 
102
    return self.H
 
103
 
 
104
  def GetWidth(self):
 
105
    return self.W
 
106
 
 
107