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

« back to all changes in this revision

Viewing changes to src/cursing/ComboBox.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
# ComboBox.py
 
23
#
 
24
# DESCRIPTION:
 
25
#
 
26
# NOTES:
 
27
#
 
28
 
 
29
 
 
30
from constants import *
 
31
from Menu import Menu
 
32
from Button import Button
 
33
from Control import Control
 
34
from TextBox import TextBox
 
35
 
 
36
class ComboBox(TextBox):
 
37
  def __init__(self,Parent,BoxName, Y, X, W, editable=0,**properties):
 
38
    TextBox.__init__(self, Parent, BoxName, Y, X, W-4)
 
39
    self.PARENT = Parent
 
40
    self.Y = Y
 
41
    self.X = X
 
42
    self.W = W - 4
 
43
    self.H = 1
 
44
    self.EDITABLE = editable
 
45
 
 
46
    menuName = (W-5) * ' '
 
47
    self._menu = Menu(Parent,'cbm',Y,X+1,menuName)
 
48
    self._button = Button(Parent,'cbbutt',Y,X+W-4,3,chr(tiDAW))
 
49
    self._button.SetMethod("CLICK", self._Show)
 
50
    self._menu.CANGETFOCUS = 0
 
51
    self._menu.SetMethod("CHOSEN",self._chosen)
 
52
    self._menu.maxLengthFixed = 1
 
53
    self._menu.maxLength = W - 4
 
54
    self._chosen = None
 
55
    self.VALUES = []
 
56
 
 
57
    Parent.AddControl(self._button)
 
58
##    Parent.AddControl(self._menu)
 
59
 
 
60
#  def Paint(self,v1,v2,v3):
 
61
#
 
62
#    return
 
63
#    Screen = self.PARENT.Screen()
 
64
#    Screen.AutoRefresh = 0
 
65
#    self.SetColor(1)
 
66
#    X = self.X
 
67
#    Y = self.Y
 
68
#    W = self.W
 
69
##    Screen.PrintAt(Y,X,chr(tiVLINE))
 
70
##    Screen.PrintAt(Y,X+W-1,chr(tiVLINE))
 
71
##    Screen.PrintAt(Y+1,X, chr(tiLLC) + (W-2) * chr(tiHLINE) + chr(tiLRC))
 
72
#    Screen.AutoRefresh = 1
 
73
 
 
74
  def _Show(self,v1,v2,v3):
 
75
    self._menu.ShowOff(None,None,None)
 
76
 
 
77
  def _chosen(self,menu,id,text):
 
78
    self._chosen = id
 
79
    self._menu.ChangeTitle(text)
 
80
    chosen = self.GetMethod("CHOSEN")
 
81
    if chosen!=None:
 
82
      chosen(self,id,text)
 
83
 
 
84
  def AddItem(self,id,text):
 
85
    self._menu.AddItem(id,text)
 
86
    self.VALUES.append((id, text))
 
87
 
 
88
  def Clear(self):
 
89
    self._menu.Clear()
 
90
    self.VALUES = []
 
91
 
 
92
#  def SetValue(self, value):
 
93
#    gDebug(0,'WARNING: SetValue called on a combo box... not yet implemented')
 
94
 
 
95
#  def GetValue(self):
 
96
#    gDebug(0,'WARNING: GetValue called on a combo box... not yet implemented')
 
97