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
30
from constants import *
32
from Button import Button
33
from Control import Control
34
from TextBox import TextBox
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)
44
self.EDITABLE = editable
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
57
Parent.AddControl(self._button)
58
## Parent.AddControl(self._menu)
60
# def Paint(self,v1,v2,v3):
63
# Screen = self.PARENT.Screen()
64
# Screen.AutoRefresh = 0
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
74
def _Show(self,v1,v2,v3):
75
self._menu.ShowOff(None,None,None)
77
def _chosen(self,menu,id,text):
79
self._menu.ChangeTitle(text)
80
chosen = self.GetMethod("CHOSEN")
84
def AddItem(self,id,text):
85
self._menu.AddItem(id,text)
86
self.VALUES.append((id, text))
92
# def SetValue(self, value):
93
# gDebug(0,'WARNING: SetValue called on a combo box... not yet implemented')
96
# gDebug(0,'WARNING: GetValue called on a combo box... not yet implemented')