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

« back to all changes in this revision

Viewing changes to src/cursing/FocusedLabel.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
# FocusedLabel.py
 
23
#
 
24
# DESCRIPTION:
 
25
#
 
26
# NOTES:
 
27
#
 
28
 
 
29
 
 
30
from constants import *
 
31
from Label import Label
 
32
 
 
33
class FocusedLabel(Label):
 
34
  """
 
35
    Like a normal label but this can be receive Get/Lost focus and
 
36
    Action messages.  What is this used for?  Items like dropdown menus
 
37
    and the like.
 
38
  """
 
39
  def __init__(self, Parent, LabelName, Y, X, Caption, **properties):
 
40
    Label.__init__(self, Parent, LabelName, Y, X, Caption, **properties)
 
41
    self.CANGETFOCUS = 1
 
42
    self.SetMethod("SYSRUN", self.Run)
 
43
    self.SetMethod("SYSPAINT", self.Paint)
 
44
    self.SetMethod("SYSGOTFOCUS", self.GotFocus)
 
45
    self.SetMethod("SYSLOSTFOCUS", self.LostFocus)
 
46
    self.SetMethod("CLICK", None)
 
47
 
 
48
  def Run(self, v1, v2, v3):
 
49
    Container = self.PARENT.Screen()
 
50
    if v1 :
 
51
      self.ExecMethod("CLICK", self, None, None)
 
52
      if self.HasProperty("EXITFORM"):
 
53
        if self.EXITFORM:
 
54
          return 1
 
55
    while 1:
 
56
      global BACKWARDS
 
57
      ch = Container.GetChar()
 
58
      if self.PARENT.BreakOrder(ch) :
 
59
        return
 
60
      if ch in (Container.TokDownArrow, Container.TokNextField, Container.TokUpArrow):
 
61
        BACKWARDS = 0
 
62
        if ch == Container.TokUpArrow:
 
63
          BACKWARDS = 1
 
64
        return
 
65
      elif ch == Container.TokActivate:
 
66
        self.ExecMethod("CLICK", self, None, None)
 
67
        if self.HasProperty("EXITFORM"):
 
68
          if self.EXITFORM:
 
69
            return 1
 
70
        self.ExecMethod("SYSGOTFOCUS", None, None, None)
 
71
 
 
72
  def Paint(self, HasFocus, v2, v3):
 
73
    gDebug(0,'Workin it')
 
74
    Container = self.PARENT.Screen()
 
75
    if self.active:
 
76
      if HasFocus :
 
77
        color = self.FOCUSCOLOR
 
78
      else:
 
79
        color = self.COLOR
 
80
    else:
 
81
      color = self.COLOR
 
82
    Y = self.Y
 
83
    X = self.X
 
84
    caption = self.CAPTION
 
85
    Container.PrintAt(Y,X,caption, color)
 
86
 
 
87
  def GotFocus(self, v1, v2, v3):
 
88
    self.Paint(1, None, None)
 
89
    return 1
 
90
 
 
91
  def LostFocus(self, v1, v2, v3):
 
92
    self.Paint(0, None, None)
 
93
    return 1
 
94
 
 
95