Add button form control
This commit is contained in:
parent
f052c634ab
commit
0efa92b6a9
|
@ -57,28 +57,13 @@ class FormControlBase(object):
|
|||
return
|
||||
|
||||
|
||||
class FormButton(FormControlBase):
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
|
||||
|
||||
class LOForm(ObjectBase):
|
||||
|
||||
def __init__(self, obj):
|
||||
super().__init__(obj)
|
||||
self._init_controls()
|
||||
|
||||
def __getitem__(self, index):
|
||||
if isinstance(index, int):
|
||||
return self._controls[index]
|
||||
else:
|
||||
return getattr(self, index)
|
||||
|
||||
def _get_type_control(self, name):
|
||||
types = {
|
||||
# ~ 'stardiv.Toolkit.UnoFixedTextControl': 'label',
|
||||
'com.sun.star.form.OButtonModel': 'formbutton',
|
||||
# ~ 'stardiv.Toolkit.UnoEditControl': 'text',
|
||||
# ~ 'stardiv.Toolkit.UnoRoadmapControl': 'roadmap',
|
||||
# ~ 'stardiv.Toolkit.UnoFixedHyperlinkControl': 'link',
|
||||
|
|
|
@ -1511,6 +1511,13 @@ class LOFormControl(LOBaseObject):
|
|||
def tag(self, value):
|
||||
self._m.Tag = value
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
return self._m.Enabled
|
||||
@enabled.setter
|
||||
def enabled(self, value):
|
||||
self._m.Enabled = value
|
||||
|
||||
def set_focus(self):
|
||||
self._view.setFocus()
|
||||
return
|
||||
|
@ -1550,9 +1557,27 @@ class LOFormControlText(LOFormControl):
|
|||
self._m.Text = value
|
||||
|
||||
|
||||
class LOFormControlButton(LOFormControl):
|
||||
|
||||
def __init__(self, obj, view):
|
||||
super().__init__(obj, view)
|
||||
|
||||
@property
|
||||
def type(self):
|
||||
return 'button'
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
return self._m.Label
|
||||
@value.setter
|
||||
def value(self, value):
|
||||
self._m.Text = Label
|
||||
|
||||
|
||||
FORM_CONTROL_CLASS = {
|
||||
'label': LOFormControlLabel,
|
||||
'text': LOFormControlText,
|
||||
'button': LOFormControlButton,
|
||||
}
|
||||
|
||||
|
||||
|
@ -1560,6 +1585,7 @@ class LOForm(object):
|
|||
MODELS = {
|
||||
'label': 'com.sun.star.form.component.FixedText',
|
||||
'text': 'com.sun.star.form.component.TextField',
|
||||
'button': 'com.sun.star.form.component.CommandButton',
|
||||
}
|
||||
|
||||
def __init__(self, obj, draw_page):
|
||||
|
@ -1620,6 +1646,14 @@ class LOForm(object):
|
|||
def doc(self):
|
||||
return self.obj.Parent.Parent
|
||||
|
||||
def _special_properties(self, tipo, args):
|
||||
if tipo == 'button':
|
||||
# ~ if 'ImageURL' in args:
|
||||
# ~ args['ImageURL'] = self._set_image_url(args['ImageURL'])
|
||||
args['FocusOnClick'] = args.get('FocusOnClick', False)
|
||||
return args
|
||||
return args
|
||||
|
||||
def add(self, args):
|
||||
name = args['Name']
|
||||
tipo = args.pop('Type').lower()
|
||||
|
@ -1631,6 +1665,7 @@ class LOForm(object):
|
|||
control.setSize(Size(w, h))
|
||||
control.setPosition(Point(x, y))
|
||||
model = self.doc.createInstance(self.MODELS[tipo])
|
||||
args = self._special_properties(tipo, args)
|
||||
_set_properties(model, args)
|
||||
control.Control = model
|
||||
self.obj.insertByIndex(len(self), model)
|
||||
|
|
Loading…
Reference in New Issue