diff --git a/doc/docs/dialogs/cmd.md b/doc/docs/dialogs/cmd.md
new file mode 100644
index 0000000..bdbe6dd
--- /dev/null
+++ b/doc/docs/dialogs/cmd.md
@@ -0,0 +1,132 @@
+# Botón de comando (button)
+
+---
+
+## Propiedades
+
+---
+
+### **type**
+
+Devuelve el tipo de control.
+
+```py
+ app.debug(button.type)
+```
+
+
+
+### **value**
+
+Devuelve o establece la etiqueta del control.
+
+```py
+ button.value = 'Cerrar'
+```
+
+
+
+## Métodos
+
+---
+
+## Eventos
+
+---
+
+### **action**
+
+Se ejecuta al dar click con el botón primario del ratón y con las teclas ++enter++ y ++"Barra Espaciadora"++ cuando el botón de comando tiene el foco.
+
+```py
+ def button_action(self, event):
+
+ return
+```
+
+
+
+### **click**
+
+Se ejecuta al dar click con cualquier botón del ratón.
+
+```py
+ def button_click(self, event):
+
+ return
+```
+
+
+
+### **double_click**
+
+Se ejecuta al dar doble click con cualquier botón del ratón.
+
+```py
+ def button_double_click(self, event):
+
+ return
+```
+
+## Propiedades pyUNO
+
+| Nombre | Descripción |
+| ------ | ----------- |
+| Align | |
+| BackgroundColor | |
+| ContextWritingMode | |
+| DefaultButton | |
+| DefaultControl | |
+| EnableVisible | |
+| Enabled | |
+| FocusOnClick | |
+| FontCharWidth | |
+| FontCharset | |
+| FontDescriptor | |
+| FontEmphasisMark | |
+| FontFamily | |
+| FontHeight | |
+| FontKerning | |
+| FontName | |
+| FontOrientation | |
+| FontPitch | |
+| FontRelief | |
+| FontSlant | |
+| FontStrikeout | |
+| FontStyleName | |
+| FontType | |
+| FontUnderline | |
+| FontWeight | |
+| FontWidth | |
+| FontWordLineMode | |
+| Graphic | |
+| Height | |
+| HelpText | |
+| HelpURL | |
+| ImageAlign | |
+| ImagePosition | |
+| ImageURL | |
+| Label | |
+| MultiLine | |
+| Name | |
+| PositionX | |
+| PositionY | |
+| Printable | |
+| PushButtonType | |
+| ReferenceDevice | |
+| Repeat | |
+| RepeatDelay | |
+| ResourceResolver | |
+| State | |
+| Step | |
+| TabIndex | |
+| Tabstop | |
+| Tag | |
+| TextColor | |
+| TextLineColor | |
+| Toggle | |
+| VerticalAlign | |
+| Width | |
+| WritingMode | |
+
+
diff --git a/doc/docs/dialogs/image.md b/doc/docs/dialogs/image.md
new file mode 100644
index 0000000..eeec58e
--- /dev/null
+++ b/doc/docs/dialogs/image.md
@@ -0,0 +1,47 @@
+# Imagen (image)
+
+---
+
+## Propiedades
+
+---
+
+## Métodos
+
+---
+
+## Eventos
+
+---
+
+## Propiedades pyUNO
+
+| Nombre | Descripción |
+| ------ | ----------- |
+| BackgroundColor | |
+| Border | |
+| BorderColor | |
+| ContextWritingMode | |
+| DefaultControl | |
+| EnableVisible | |
+| Enabled | |
+| Graphic | |
+| Height | |
+| HelpText | |
+| HelpURL | |
+| ImageURL | |
+| Name | |
+| PositionX | |
+| PositionY | |
+| Printable | |
+| ResourceResolver | |
+| ScaleImage | |
+| ScaleMode | |
+| Step | |
+| TabIndex | |
+| Tabstop | |
+| Tag | |
+| Width | |
+| WritingMode | |
+
+
\ No newline at end of file
diff --git a/doc/docs/dialogs/index.md b/doc/docs/dialogs/index.md
new file mode 100644
index 0000000..067628e
--- /dev/null
+++ b/doc/docs/dialogs/index.md
@@ -0,0 +1,267 @@
+
+# Crear cuadros de diálogo
+
+### **create**
+
+---
+
+#### Desde "Mis Macros"
+
+Si el cuadro de diálogo esta en la librería `Standard`.
+
+```py
+def crear_cuadro_de_dialogo1():
+ propiedades = {
+ 'Location': 'user',
+ 'Name': 'Dialog1',
+ }
+ dialog = app.dialog.create(propiedades)
+ dialog.open()
+ return
+```
+
+Si el cuadro de diálogo esta en otra librería.
+
+```py
+def crear_cuadro_de_dialogo2():
+ propiedades = {
+ 'Location': 'user',
+ 'Library': 'MiAplicacion',
+ 'Name': 'Dialog1',
+ }
+ dialog = app.dialog.create(propiedades)
+ dialog.open()
+ return
+```
+
+
+
+#### Dentro de un archivo
+
+Si el cuadro de diálogo esta en el documento activo en la librería `Standard`.
+
+```py
+def crear_cuadro_de_dialogo3():
+ propiedades = {
+ 'Location': 'document',
+ 'Name': 'Dialog1',
+ }
+ dialog = app.dialog.create(propiedades)
+ dialog.open()
+ return
+```
+
+Si el cuadro de diálogo esta en otro documento en la librería `Standard`.
+
+```py
+def crear_cuadro_de_dialogo4():
+ documento = app.docs['OtroArchivo.ods']
+ propiedades = {
+ 'Location': 'document',
+ 'Document': documento,
+ 'Name': 'Dialog1',
+ }
+ dialog = app.dialog.create(propiedades)
+ dialog.open()
+ return
+```
+
+
+
+#### Desde archivo
+
+Crear un cuadro de diálogo desde un archivo `xdl` previamente creado desde el editor de cuadros de diálogo dentro de LibreOffice y exportado a un archivo.
+
+```py
+def crear_cuadro_de_dialogo():
+ path = '/home/elmau/Desktop/mi_dialogo.xdl'
+ propiedades = {'Path': path}
+
+ dialog = app.dialog.create(propiedades)
+ dialog.open()
+ return
+```
+
+
+
+#### Crear dinámicamente
+
+Crear un cuadro de diálogo vacío.
+
+```py
+def crear_cuadro_de_dialogo():
+ dialog = app.dialog.create()
+ dialog.open()
+ return
+```
+
+Cambiar las propiedades iniciales.
+
+```py
+ propiedades = dict(
+ Name = 'MiDialogo',
+ Title = 'Maldito Mundo',
+ Width = 200,
+ Height = 100,
+ )
+
+ dialog = app.dialog.create(propiedades)
+ dialog.open()
+```
+
+
+
+!!! tip Importante
+
+ Cualquier propiedad usada al crear el cuadro de diálogo, debe ser la original del control pyUNO.
+
+#### Propiedades
+
+| Nombre | Descripción |
+| ------ | ----------- |
+| AllDialogChildren | |
+| BackgroundColor | Color de fondo |
+| Closeable | Permite cerrar el cuadro de diálogo con el icono `X` |
+| Decoration |
+| DefaultControl |
+| DesktopAsParent |
+| DialogSourceURL |
+| Enabled |
+| FontCharWidth |
+| FontCharset |
+| FontDescriptor |
+| FontEmphasisMark |
+| FontFamily |
+| FontHeight |
+| FontKerning |
+| FontName |
+| FontOrientation |
+| FontPitch |
+| FontRelief |
+| FontSlant |
+| FontStrikeout |
+| FontStyleName |
+| FontType |
+| FontUnderline |
+| FontWeight |
+| FontWidth |
+| FontWordLineMode |
+| Graphic |
+| HScroll |
+| Height | Altura del control |
+| HelpText |
+| HelpURL |
+| ImageURL |
+| Moveable |
+| Name | Nombre del control |
+| PositionX | Posición en el eje X |
+| PositionY | Posición en el eje Y |
+| ResourceResolver |
+| ScrollHeight |
+| ScrollLeft |
+| ScrollTop |
+| ScrollWidth |
+| Sizeable | Si el control cambia de tamaño |
+| Step |
+| TabIndex |
+| Tag |
+| TextColor |
+| TextLineColor |
+| Title | Título del cuadro de diálogo |
+| VScroll | Mostrar barra de desplazamiento vertial |
+| Width | Ancho del control |
+
+
+
+### **add_control**
+
+---
+
+Agrega un control al cuadro de diálogo.
+
+```py
+ propiedades = {
+ 'Type': 'label',
+ 'Name': 'lbl_info',
+ 'Label': 'Esta es una etiqueta.',
+ 'Width': 100,
+ 'Height': 15,
+ 'Border': 1,
+ 'X': 5,
+ 'Y': 5,
+ }
+ dialog.add_control(propiedades)
+```
+
+
+
+## Eventos
+
+---
+
+Todos los eventos de todos los controles de un cuadro de diálogo se controlan por medio de una clase Python que se pasa a la propiedad `events` del cuadro de diálogo.
+
+Cada método de esta clase que tenga en su nombre la estructura que corresponde al nombre del control más el nombre del evento, responderá a dicho evento de dicho control.
+
+`NOMBRE_CONTROL_NOMBRE_EVENTO`
+
+Ejemplo:
+
+```py
+import easymacro as app
+
+class Eventos():
+
+ def __init__(self, dialog):
+ self.d = dialog
+
+ def cmd_cerrar_action(self, event):
+ self.d.close(1)
+ return
+
+def main():
+ propiedades = dict(
+ Name = 'MiDialogo',
+ Title = 'Maldito Mundo',
+ Width = 200,
+ Height = 100,
+ )
+
+ dialog = app.dialog.create(propiedades)
+ dialog.events = Eventos
+
+ propiedades = {
+ 'Type': 'button',
+ 'Name': 'cmd_cerrar',
+ 'Label': 'Cerrar',
+ 'Width': 40,
+ 'Height': 15,
+ }
+ dialog.add_control(propiedades)
+ dialog.open()
+ return
+```
+
+
+
+Cada control agregado al cuadro de diálogo es instanciado como una propiedad del mismo cuadro de diálogo. En el ejemplo anterior, el botón de comando `cmd_cerrar` es accesible desde cualquier variable que apunte al cuadro de diálogo, en el mismo ejemplo anterior en:
+
+```py
+ dialog.cmd_cerrar
+```
+
+Como en la clase `Eventos` en:
+```py
+ self.d.cmd_cerrar
+```
+
+
+
+## Controles
+
+---
+
+#### [Etiqueta (label)](label/)
+#### [Botón de comando (button)](cmd/)
+
+
diff --git a/doc/docs/dialogs/label.md b/doc/docs/dialogs/label.md
new file mode 100644
index 0000000..fb72179
--- /dev/null
+++ b/doc/docs/dialogs/label.md
@@ -0,0 +1,101 @@
+# Etiqueta (label)
+
+---
+
+## Propiedades
+
+---
+
+### **type**
+
+Devuelve el tipo de control.
+
+```py
+ app.debug(label.type)
+```
+
+
+
+### **value**
+
+Devuelve o establece la etiqueta del control.
+
+```py
+ label.value = 'Mi etiqueta'
+```
+
+
+
+## Métodos
+
+---
+
+## Eventos
+
+---
+
+### **click**
+
+Se ejecuta al dar click con cualquier botón del ratón.
+
+```py
+ def label_click(self, event):
+
+ return
+```
+
+
+
+## Propiedades pyUNO
+
+
+| Nombre | Descripción |
+| ------ | ----------- |
+| Align | |
+| BackgroundColor | |
+| Border | |
+| BorderColor | |
+| ContextWritingMode | |
+| DefaultControl | |
+| EnableVisible | |
+| Enabled | |
+| FontCharWidth | |
+| FontCharset | |
+| FontDescriptor | |
+| FontEmphasisMark | |
+| FontFamily | |
+| FontHeight | |
+| FontKerning | |
+| FontName | |
+| FontOrientation | |
+| FontPitch | |
+| FontRelief | |
+| FontSlant | |
+| FontStrikeout | |
+| FontStyleName | |
+| FontType | |
+| FontUnderline | |
+| FontWeight | |
+| FontWidth | |
+| FontWordLineMode | |
+| Height | |
+| HelpText | |
+| HelpURL | |
+| Label | |
+| MultiLine | |
+| Name | |
+| NoLabel | |
+| PositionX | |
+| PositionY | |
+| Printable | |
+| ReferenceDevice | |
+| ResourceResolver | |
+| Step | |
+| TabIndex | |
+| Tabstop | |
+| Tag | |
+| TextColor | |
+| TextLineColor | |
+| VerticalAlign | |
+| Width | |
+| WritingMode | |
diff --git a/doc/docs/dialogs/link.md b/doc/docs/dialogs/link.md
new file mode 100644
index 0000000..b3b41a7
--- /dev/null
+++ b/doc/docs/dialogs/link.md
@@ -0,0 +1,88 @@
+# Hipervínculo (link)
+
+---
+
+## Propiedades
+
+### **label**
+
+Devuelve o establece la etiqueta.
+
+
+
+### **url**
+
+Devuelve o establece el vínculo web.
+
+
+
+### **value**
+
+Devuelve o establece el vínculo web y la etiqueta.
+
+
+
+---
+
+## Métodos
+
+---
+
+## Eventos
+
+---
+
+## Propiedades pyUNO
+
+| Nombre | Descripción |
+| ------ | ----------- |
+| Align | |
+| BackgroundColor | |
+| Border | |
+| BorderColor | |
+| ContextWritingMode | |
+| DefaultControl | |
+| EnableVisible | |
+| Enabled | |
+| FontCharWidth | |
+| FontCharset | |
+| FontDescriptor | |
+| FontEmphasisMark | |
+| FontFamily | |
+| FontHeight | |
+| FontKerning | |
+| FontName | |
+| FontOrientation | |
+| FontPitch | |
+| FontRelief | |
+| FontSlant | |
+| FontStrikeout | |
+| FontStyleName | |
+| FontType | |
+| FontUnderline | |
+| FontWeight | |
+| FontWidth | |
+| FontWordLineMode | |
+| Height | |
+| HelpText | |
+| HelpURL | |
+| Label | |
+| MultiLine | |
+| Name | |
+| NoLabel | |
+| PositionX | |
+| PositionY | |
+| Printable | |
+| ResourceResolver | |
+| Step | |
+| TabIndex | |
+| Tabstop | |
+| Tag | |
+| TextColor | |
+| TextLineColor | |
+| URL | |
+| VerticalAlign | |
+| Width | |
+| WritingMode | |
+
+
\ No newline at end of file
diff --git a/doc/docs/dialogs/md.md b/doc/docs/dialogs/md.md
new file mode 100644
index 0000000..8d50632
--- /dev/null
+++ b/doc/docs/dialogs/md.md
@@ -0,0 +1,17 @@
+# Control (label)
+
+---
+
+## Propiedades
+
+---
+
+## Métodos
+
+---
+
+## Eventos
+
+---
+
+## Propiedades pyUNO
\ No newline at end of file
diff --git a/doc/docs/dialogs/text.md b/doc/docs/dialogs/text.md
new file mode 100644
index 0000000..221e402
--- /dev/null
+++ b/doc/docs/dialogs/text.md
@@ -0,0 +1,112 @@
+# Cuadro de texto (text)
+
+---
+
+## Propiedades
+
+---
+
+### **value**
+
+Establece o recupera el valor del control.
+
+```py
+ app.debug(text.value)
+```
+
+
+## Métodos
+
+---
+
+### **set_focus**
+
+Envía el foco al control.
+
+
+
+## Eventos
+
+---
+
+### **focus_gained**
+
+Se produce al recibir el foco.
+
+
+
+### **focus_lost**
+
+Se produce al perder el foco.
+
+
+
+### **text_changed**
+
+Se produce al cambiar el contenido del control.
+
+
+
+## Propiedades pyUNO
+
+| Nombre | Descripción |
+| ------ | ----------- |
+| Align | |
+| AutoHScroll | |
+| AutoVScroll | |
+| BackgroundColor | |
+| Border | |
+| BorderColor | |
+| ContextWritingMode | |
+| DefaultControl | |
+| EchoChar | |
+| EnableVisible | |
+| Enabled | |
+| FontCharWidth | |
+| FontCharset | |
+| FontDescriptor | |
+| FontEmphasisMark | |
+| FontFamily | |
+| FontHeight | |
+| FontKerning | |
+| FontName | |
+| FontOrientation | |
+| FontPitch | |
+| FontRelief | |
+| FontSlant | |
+| FontStrikeout | |
+| FontStyleName | |
+| FontType | |
+| FontUnderline | |
+| FontWeight | |
+| FontWidth | |
+| FontWordLineMode | |
+| HScroll | |
+| HardLineBreaks | |
+| Height | |
+| HelpText | |
+| HelpURL | |
+| HideInactiveSelection | |
+| LineEndFormat | |
+| MaxTextLen | |
+| MultiLine | |
+| Name | |
+| PaintTransparent | |
+| PositionX | |
+| PositionY | |
+| Printable | |
+| ReadOnly | |
+| ResourceResolver | |
+| Step | |
+| TabIndex | |
+| Tabstop | |
+| Tag | |
+| Text | |
+| TextColor | |
+| TextLineColor | |
+| VScroll | |
+| VerticalAlign | |
+| Width | |
+| WritingMode | |
+
+
\ No newline at end of file
diff --git a/doc/mkdocs.yml b/doc/mkdocs.yml
index 3c66251..e32dd43 100644
--- a/doc/mkdocs.yml
+++ b/doc/mkdocs.yml
@@ -32,6 +32,13 @@ nav:
- Página de dibujo:
- dp/drawpage.md
- Formas: dp/shapes.md
+ - Cuadros de diálogo:
+ - dialogs/index.md
+ - Etiqueta: dialogs/label.md
+ - Botón de comando: dialogs/cmd.md
+ - Cuadro de texto: dialogs/text.md
+ - Hipervínculo: dialogs/link.md
+ - Imagen: dialogs/image.md
- Ejemplos de uso:
- examples/index.md
theme:
@@ -57,6 +64,8 @@ markdown_extensions:
- pymdownx.snippets
- pymdownx.tabbed:
alternate_style: true
+ - tables
+ - pymdownx.keys
#~ extra:
#~ alternate:
#~ - name: Español
diff --git a/source/easymacro/easydialog.py b/source/easymacro/easydialog.py
index e1cd473..38c94d7 100644
--- a/source/easymacro/easydialog.py
+++ b/source/easymacro/easydialog.py
@@ -9,7 +9,7 @@ from .easydocs import LODocuments
from .easymain import (log, TITLE,
BaseObject, Color,
create_instance, set_properties)
-from .easytools import _, LOInspect, Paths, Services
+from .easytools import _, LOInspect, Paths, Services, debug, mri
__all__ = [
@@ -18,16 +18,17 @@ __all__ = [
]
-COLOR_ON_FOCUS = Color()('LightYellow')
+# ~ COLOR_ON_FOCUS = Color()('LightYellow')
SEPARATION = 5
MODELS = {
'label': 'com.sun.star.awt.UnoControlFixedTextModel',
'text': 'com.sun.star.awt.UnoControlEditModel',
'button': 'com.sun.star.awt.UnoControlButtonModel',
'link': 'com.sun.star.awt.UnoControlFixedHyperlinkModel',
+ 'image': 'com.sun.star.awt.UnoControlImageControlModel',
+ # ~ ToDo
'radio': 'com.sun.star.awt.UnoControlRadioButtonModel',
'checkbox': 'com.sun.star.awt.UnoControlCheckBoxModel',
- 'image': 'com.sun.star.awt.UnoControlImageControlModel',
'listbox': 'com.sun.star.awt.UnoControlListBoxModel',
'roadmap': 'com.sun.star.awt.UnoControlRoadmapModel',
'tree': 'com.sun.star.awt.tree.TreeControlModel',
@@ -43,6 +44,7 @@ TYPE_CONTROL = {
'stardiv.Toolkit.UnoFixedTextControl': 'label',
'stardiv.Toolkit.UnoEditControl': 'text',
'stardiv.Toolkit.UnoButtonControl': 'button',
+ 'stardiv.Toolkit.UnoImageControlControl': 'image',
}
IMPLEMENTATIONS = {
@@ -50,6 +52,7 @@ IMPLEMENTATIONS = {
'link': 'stardiv.Toolkit.UnoFixedHyperlinkControl',
'roadmap': 'stardiv.Toolkit.UnoRoadmapControl',
'pages': 'stardiv.Toolkit.UnoMultiPageControl',
+ 'text': 'stardiv.Toolkit.UnoEditControl',
}
@@ -57,8 +60,9 @@ def add_listeners(events, control):
name = control.Model.Name
listeners = {
'addActionListener': EventsButton,
- # ~ 'addMouseListener': EventsMouse,
- # ~ 'addFocusListener': EventsFocus,
+ 'addMouseListener': EventsMouse,
+ 'addFocusListener': EventsFocus,
+ 'addTextListener': EventsText,
# ~ 'addItemListener': EventsItem,
# ~ 'addKeyListener': EventsKey,
# ~ 'addTabListener': EventsTab,
@@ -72,6 +76,9 @@ def add_listeners(events, control):
is_roadmap = control.ImplementationName == IMPLEMENTATIONS['roadmap']
is_pages = control.ImplementationName == IMPLEMENTATIONS['pages']
+ # ~ if control.ImplementationName == IMPLEMENTATIONS['text']:
+ # ~ mri(control)
+
for key, value in listeners.items():
if hasattr(control, key):
if is_grid and key == 'addMouseListener':
@@ -84,7 +91,7 @@ def add_listeners(events, control):
control.addItemListener(EventsItemRoadmap(events, name))
continue
- getattr(control, key)(listeners[key](events, name))
+ getattr(control, key)(value(events, name))
if is_grid:
controllers = EventsGrid(events, name)
@@ -118,7 +125,8 @@ class UnoBaseObject(object):
@property
def properties(self):
- data = LOInspect(self.obj).properties
+ properties = self.model.PropertySetInfo.Properties
+ data = {p.Name: getattr(self.model, p.Name) for p in properties}
return data
@properties.setter
def properties(self, properties: dict):
@@ -363,6 +371,41 @@ class UnoLabel(UnoBaseObject):
self.model.Label = value
+class UnoLabelLink(UnoLabel):
+
+ def __init__(self, obj):
+ super().__init__(obj)
+
+ @property
+ def type(self):
+ return 'link'
+
+ @property
+ def value(self):
+ """Get link"""
+ return self.model.URL
+ @value.setter
+ def value(self, value):
+ self.model.Label = value
+ self.model.URL = value
+
+ @property
+ def url(self):
+ """Get link"""
+ return self.model.URL
+ @url.setter
+ def url(self, value):
+ self.model.URL = value
+
+ @property
+ def label(self):
+ """Get label"""
+ return self.model.Label
+ @label.setter
+ def label(self, value):
+ self.model.Label = value
+
+
# ~ https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1awt_1_1UnoControlEditModel.html
class UnoText(UnoBaseObject):
@@ -418,14 +461,34 @@ class UnoButton(UnoBaseObject):
self.model.ImageURL = Paths.to_url(value)
+class UnoImage(UnoBaseObject):
+
+ def __init__(self, obj):
+ super().__init__(obj)
+
+ @property
+ def type(self):
+ return 'button'
+
+ @property
+ def value(self):
+ return self.model.ImageURL
+ @value.setter
+ def value(self, value):
+ if isinstance(value, str):
+ self.model.ImageURL = value
+ else:
+ self.model.Graphic = value._get_graphic()
+
+
UNO_CLASSES = {
'label': UnoLabel,
- 'text': UnoText,
'button': UnoButton,
- # ~ 'link': UnoLabelLink,
+ 'text': UnoText,
+ 'link': UnoLabelLink,
+ 'image': UnoImage,
# ~ 'radio': UnoRadio,
# ~ 'checkbox': UnoCheckBox,
- # ~ 'image': UnoImage,
# ~ 'listbox': UnoListBox,
# ~ 'roadmap': UnoRoadmap,
# ~ 'tree': UnoTree,
@@ -441,10 +504,10 @@ class DialogBox(BaseObject):
SERVICE_DIALOG = 'com.sun.star.awt.UnoControlDialog'
def __init__(self, properties: dict={}):
- self._controls = {}
obj = self._create(properties)
super().__init__(obj)
self._init_controls()
+ self._modal = False
def _create_from_path(self, path: str):
dp = create_instance(self.SERVICE, True)
@@ -458,13 +521,16 @@ class DialogBox(BaseObject):
name = properties['Name']
library = properties.get('Library', 'Standard')
location = properties.get('Location', 'application').lower()
+
if location == 'user':
location = 'application'
url = f'vnd.sun.star.script:{library}.{name}?location={location}'
if location == 'document':
- doc = LODocuments().active.obj
+ doc = properties.get('Document', LODocuments().active)
+ if hasattr(doc, 'obj'):
+ doc = doc.obj
dp = create_instance(self.SERVICE, arguments=doc)
else:
dp = create_instance(self.SERVICE, True)
@@ -500,39 +566,30 @@ class DialogBox(BaseObject):
tipo = control.ImplementationName
name = control.Model.Name
if not tipo in TYPE_CONTROL:
- log.debug(f'Type control: {tipo}')
+ debug(f'Type control: {tipo}')
raise AttributeError(f"Has no class '{tipo}'")
control = UNO_CLASSES[TYPE_CONTROL[tipo]](control)
setattr(self, name, control)
- self._controls[name] = control
return
def execute(self):
return self.obj.execute()
- def open(self):
+ def open(self, modal=False):
+ self._modal = modal
+ if modal:
+ self.visible = True
+ return
return self.execute()
def close(self, value=0):
- value = self.obj.endDialog(value)
+ if self._modal:
+ self.visible = False
+ self.obj.dispose()
+ else:
+ value = self.obj.endDialog(value)
return value
- # ~ def close(self, value=0):
- # ~ if self._modal:
- # ~ value = self.obj.endDialog(value)
- # ~ else:
- # ~ self.visible = False
- # ~ self.obj.dispose()
- # ~ return value
-
- # ~ def show(self, modal=True):
- # ~ self._modal = modal
- # ~ if modal:
- # ~ return self.obj.execute()
- # ~ else:
- # ~ self.visible = True
- # ~ return
-
@property
def model(self):
return self.obj.Model
@@ -576,6 +633,17 @@ class DialogBox(BaseObject):
def color_on_focus(self, value):
self._color_on_focus = get_color(value)
+ @property
+ def properties(self):
+ properties = self.model.PropertySetInfo.Properties
+ data = {}
+ for p in properties:
+ try:
+ data[p.Name] = getattr(self.model, p.Name)
+ except:
+ continue
+ return data
+
@property
def events(self):
return self._events
@@ -601,9 +669,14 @@ class DialogBox(BaseObject):
properties['Label'] = properties['URL']
return properties
+ if tipo == 'label':
+ properties['VerticalAlign'] = properties.get('VerticalAlign', 1)
+ return properties
+
if tipo == 'button':
if 'ImageURL' in properties:
properties['ImageURL'] = self._set_image_url(properties['ImageURL'])
+ properties['ImageAlign'] = properties.get('ImageAlign', 0)
properties['FocusOnClick'] = properties.get('FocusOnClick', False)
return properties
@@ -659,7 +732,7 @@ class DialogBox(BaseObject):
control.events = self.events
setattr(self, name, control)
- self._controls[name] = control
+
return control
diff --git a/source/easymacro/easyevents.py b/source/easymacro/easyevents.py
index 8ce65a6..71713d2 100644
--- a/source/easymacro/easyevents.py
+++ b/source/easymacro/easyevents.py
@@ -5,14 +5,24 @@ import unohelper
from com.sun.star.awt import XActionListener
from com.sun.star.lang import XEventListener
+from com.sun.star.awt import XFocusListener
+from com.sun.star.util import XModifyListener
+from com.sun.star.awt import XMouseListener
+from com.sun.star.awt import XMouseMotionListener
+from com.sun.star.awt import XTextListener
from com.sun.star.sheet import XRangeSelectionListener
-from .easymain import Macro, dict_to_property
+from .easymain import Macro, Color, dict_to_property
__all__ = [
'EventsButton',
+ 'EventsFocus',
+ 'EventsModify',
+ 'EventsMouse',
+ 'EventsMouseLink',
'EventsRangeSelectionListener',
+ 'EventsText',
]
@@ -93,6 +103,9 @@ class EventsRangeSelectionListener(EventsListenerBase, XRangeSelectionListener):
class EventsButton(EventsListenerBase, XActionListener):
+ """
+ See: https://api.libreoffice.org/docs/idl/ref/interfacecom_1_1sun_1_1star_1_1awt_1_1XActionListener.html
+ """
def __init__(self, controller, name):
super().__init__(controller, name)
@@ -102,3 +115,96 @@ class EventsButton(EventsListenerBase, XActionListener):
if hasattr(self._controller, event_name):
getattr(self._controller, event_name)(event)
return
+
+
+class EventsMouse(EventsListenerBase, XMouseListener, XMouseMotionListener):
+
+ def __init__(self, controller, name):
+ super().__init__(controller, name)
+
+ def mousePressed(self, event):
+ event_name = f'{self._name}_click'
+ if event.ClickCount == 2:
+ event_name = f'{self._name}_double_click'
+ if hasattr(self._controller, event_name):
+ getattr(self._controller, event_name)(event)
+ return
+
+ def mouseReleased(self, event):
+ pass
+
+ def mouseEntered(self, event):
+ pass
+
+ def mouseExited(self, event):
+ pass
+
+ # ~ XMouseMotionListener
+ def mouseMoved(self, event):
+ pass
+
+ def mouseDragged(self, event):
+ pass
+
+
+class EventsMouseLink(EventsMouse):
+
+ def mouseEntered(self, event):
+ obj = event.Source.Model
+ obj.TextColor = Color()('blue')
+ return
+
+ def mouseExited(self, event):
+ obj = event.Source.Model
+ obj.TextColor = 0
+ return
+
+
+class EventsFocus(EventsListenerBase, XFocusListener):
+
+ def __init__(self, controller, name):
+ super().__init__(controller, name)
+
+ def focusGained(self, event):
+ service = event.Source.Model.ImplementationName
+ if service == 'stardiv.Toolkit.UnoControlListBoxModel':
+ return
+
+ event_name = f'{self._name}_focus_gained'
+ if hasattr(self._controller, event_name):
+ getattr(self._controller, event_name)(event)
+
+ # ~ obj = event.Source.ModelBackgroundColor = 16777184
+ return
+
+ def focusLost(self, event):
+ event_name = f'{self._name}_focus_lost'
+ if hasattr(self._controller, event_name):
+ getattr(self._controller, event_name)(event)
+
+ # ~ event.Source.Model.BackgroundColor = -1
+ return
+
+
+class EventsModify(EventsListenerBase, XModifyListener):
+
+ def __init__(self, controller, name):
+ super().__init__(controller, name)
+
+ def modified(self, event):
+ event_name = f'{self._name}_modified'
+ if hasattr(self._controller, event_name):
+ getattr(self._controller, event_name)(event)
+ return
+
+
+class EventsText(EventsListenerBase, XTextListener):
+
+ def __init__(self, controller, name):
+ super().__init__(controller, name)
+
+ def textChanged(self, event):
+ event_name = f'{self._name}_text_changed'
+ if hasattr(self._controller, event_name):
+ getattr(self._controller, event_name)(event)
+ return