1999-12-13 16:04:48 +00:00
|
|
|
# Accessor functions for control properties
|
|
|
|
|
|
|
|
from Controls import *
|
|
|
|
import struct
|
|
|
|
|
1999-12-19 00:06:52 +00:00
|
|
|
# These needn't go through this module, but are here for completeness
|
2001-01-09 22:10:16 +00:00
|
|
|
def SetControlData_Handle(control, part, selector, data):
|
|
|
|
control.SetControlData_Handle(part, selector, data)
|
1999-12-19 00:06:52 +00:00
|
|
|
|
2001-01-09 22:10:16 +00:00
|
|
|
def GetControlData_Handle(control, part, selector):
|
|
|
|
return control.GetControlData_Handle(part, selector)
|
1999-12-19 00:06:52 +00:00
|
|
|
|
|
|
|
_accessdict = {
|
2001-01-22 14:49:28 +00:00
|
|
|
kControlPopupButtonMenuHandleTag: (SetControlData_Handle, GetControlData_Handle),
|
1999-12-19 00:06:52 +00:00
|
|
|
}
|
|
|
|
|
1999-12-13 16:04:48 +00:00
|
|
|
_codingdict = {
|
|
|
|
kControlPushButtonDefaultTag : ("b", None, None),
|
1999-12-19 00:06:52 +00:00
|
|
|
|
1999-12-13 16:04:48 +00:00
|
|
|
kControlEditTextTextTag: (None, None, None),
|
|
|
|
kControlEditTextPasswordTag: (None, None, None),
|
1999-12-19 00:06:52 +00:00
|
|
|
|
|
|
|
kControlPopupButtonMenuIDTag: ("h", None, None),
|
2000-05-04 15:43:00 +00:00
|
|
|
|
|
|
|
kControlListBoxDoubleClickTag: ("b", None, None),
|
1999-12-13 16:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
def SetControlData(control, part, selector, data):
|
1999-12-19 00:06:52 +00:00
|
|
|
if _accessdict.has_key(selector):
|
|
|
|
setfunc, getfunc = _accessdict[selector]
|
|
|
|
setfunc(control, part, selector, data)
|
|
|
|
return
|
1999-12-13 16:04:48 +00:00
|
|
|
if not _codingdict.has_key(selector):
|
|
|
|
raise KeyError, ('Unknown control selector', selector)
|
|
|
|
structfmt, coder, decoder = _codingdict[selector]
|
|
|
|
if coder:
|
|
|
|
data = coder(data)
|
|
|
|
if structfmt:
|
|
|
|
data = struct.pack(structfmt, data)
|
|
|
|
control.SetControlData(part, selector, data)
|
|
|
|
|
|
|
|
def GetControlData(control, part, selector):
|
1999-12-19 00:06:52 +00:00
|
|
|
if _accessdict.has_key(selector):
|
|
|
|
setfunc, getfunc = _accessdict[selector]
|
|
|
|
return getfunc(control, part, selector, data)
|
1999-12-13 16:04:48 +00:00
|
|
|
if not _codingdict.has_key(selector):
|
|
|
|
raise KeyError, ('Unknown control selector', selector)
|
|
|
|
structfmt, coder, decoder = _codingdict[selector]
|
|
|
|
data = control.GetControlData(part, selector)
|
|
|
|
if structfmt:
|
|
|
|
data = struct.unpack(structfmt, data)
|
|
|
|
if decoder:
|
|
|
|
data = decoder(data)
|
2000-05-04 15:43:00 +00:00
|
|
|
if type(data) == type(()) and len(data) == 1:
|
|
|
|
data = data[0]
|
1999-12-13 16:04:48 +00:00
|
|
|
return data
|
|
|
|
|