gtk3-node 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -2
- package/CHANGELOG.md.backup +115 -0
- package/CHECKLIST.md +30 -7
- package/binding.gyp +4 -1
- package/ejemplo_funcional.js +29 -0
- package/ejemplo_funcional_corregido.js +29 -0
- package/ejemplos/avanzados/README.md +2 -0
- package/ejemplos/avanzados/ejemplo_stringgrid_completo.js +95 -0
- package/ejemplos/avanzados/ejemplo_textview.js +65 -0
- package/ejemplos/intermedios/README.md +1 -0
- package/ejemplos/intermedios/ejemplo_entry.js +50 -0
- package/index.js +85 -0
- package/package.json +1 -1
- package/src/gtk3_node.cpp +12 -0
- package/widgets/entry/README.md +46 -0
- package/widgets/entry/entry.cpp +98 -0
- package/widgets/entry/entry.h +10 -0
- package/widgets/stringgrid/README.md +46 -0
- package/widgets/stringgrid/stringgrid.cpp +464 -0
- package/widgets/stringgrid/stringgrid.h +10 -0
- package/widgets/textview/README.md +48 -0
- package/widgets/textview/textview.cpp +209 -0
- package/widgets/textview/textview.h +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
# CHANGELOG - Extensión GTK3 para Node.js
|
|
2
2
|
|
|
3
|
-
## [Versión 1.
|
|
3
|
+
## [Versión 1.3.0] - 2026-02-15
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Características
|
|
7
|
+
- Integración nativa con GTK3
|
|
8
|
+
- Sistema de eventos con callbacks
|
|
9
|
+
- Soporte para interfaces gráficas completas
|
|
10
|
+
- Estructura modular y extensible
|
|
11
|
+
- Temporización con funcionalidad similar a TTimer de Delphi
|
|
12
|
+
|
|
13
|
+
### Documentación
|
|
14
|
+
- README principal
|
|
15
|
+
- Documentación para cada widget
|
|
16
|
+
- Ejemplos básicos, intermedios y avanzados
|
|
17
|
+
- Guía de compilación (HOWTO-COMPILE.md)
|
|
18
|
+
|
|
19
|
+
### Notas Técnicas
|
|
20
|
+
- Basado en N-API para compatibilidad con múltiples versiones de Node.js
|
|
21
|
+
- Compilación con node-gyp
|
|
22
|
+
- Integración con GTK3 3.x
|
|
23
|
+
- Soporte para Linux (actualmente)
|
|
24
|
+
|
|
25
|
+
## [Versión 1.2.0] - 2026-02-15
|
|
26
|
+
|
|
27
|
+
### Añadido
|
|
28
|
+
- Widget Button con soporte para eventos y callbacks
|
|
29
|
+
- Widget Window para contenedores de interfaz
|
|
30
|
+
- Widget Label para mostrar texto estático
|
|
31
|
+
- Widget Box para layouts horizontales y verticales
|
|
32
|
+
- Widget Scroll para contenedores con barras de desplazamiento
|
|
33
|
+
- Widget Entry para entrada de texto simple
|
|
34
|
+
- Widget StringGrid para tablas bidimensionales de datos
|
|
35
|
+
- Widget TextView para áreas de texto multilinea
|
|
36
|
+
- Estructura modular para futuras expansiones
|
|
37
|
+
- Ejemplos organizados por niveles de complejidad
|
|
38
|
+
- Principio DRY aplicado en la arquitectura
|
|
39
|
+
|
|
40
|
+
### Características
|
|
41
|
+
- Integración nativa con GTK3
|
|
42
|
+
- Sistema de eventos con callbacks
|
|
43
|
+
- Soporte para interfaces gráficas completas
|
|
44
|
+
- Estructura modular y extensible
|
|
45
|
+
|
|
46
|
+
### Documentación
|
|
47
|
+
- README principal
|
|
48
|
+
- Documentación para cada widget
|
|
49
|
+
- Ejemplos básicos, intermedios y avanzados
|
|
50
|
+
- Guía de compilación (HOWTO-COMPILE.md)
|
|
51
|
+
|
|
52
|
+
### Notas Técnicas
|
|
53
|
+
- Basado en N-API para compatibilidad con múltiples versiones de Node.js
|
|
54
|
+
- Compilación con node-gyp
|
|
55
|
+
- Integración con GTK3 3.x
|
|
56
|
+
- Soporte para Linux (actualmente)
|
|
57
|
+
|
|
58
|
+
## [Versión 1.1.0] - 2026-02-14
|
|
4
59
|
|
|
5
60
|
### Añadido
|
|
6
61
|
- Implementación inicial de la extensión GTK3 para Node.js
|
|
@@ -10,6 +65,8 @@
|
|
|
10
65
|
- Widget Label para mostrar texto estático
|
|
11
66
|
- Widget Box para layouts horizontales y verticales
|
|
12
67
|
- Widget Scroll para contenedores con barras de desplazamiento
|
|
68
|
+
- Widget Entry para entrada de texto simple
|
|
69
|
+
- Widget StringGrid para tablas bidimensionales de datos
|
|
13
70
|
- Estructura modular para futuras expansiones
|
|
14
71
|
- Ejemplos organizados por niveles de complejidad
|
|
15
72
|
- Principio DRY aplicado en la arquitectura
|
|
@@ -30,4 +87,20 @@
|
|
|
30
87
|
- Basado en N-API para compatibilidad con múltiples versiones de Node.js
|
|
31
88
|
- Compilación con node-gyp
|
|
32
89
|
- Integración con GTK3 3.x
|
|
33
|
-
- Soporte para Linux (actualmente)
|
|
90
|
+
- Soporte para Linux (actualmente)
|
|
91
|
+
|
|
92
|
+
## [Versión 1.0.0] - 2026-02-14
|
|
93
|
+
|
|
94
|
+
### Añadido
|
|
95
|
+
- Implementación inicial de la extensión GTK3 para Node.js
|
|
96
|
+
- Soporte para creación de interfaces gráficas con GTK3
|
|
97
|
+
- Widget Button con soporte para eventos y callbacks
|
|
98
|
+
- Widget Window para contenedores de interfaz
|
|
99
|
+
- Widget Label para mostrar texto estático
|
|
100
|
+
- Widget Box para layouts horizontales y verticales
|
|
101
|
+
- Widget Scroll para contenedores con barras de desplazamiento
|
|
102
|
+
- Widget Entry para entrada de texto simple
|
|
103
|
+
- Widget StringGrid para tablas bidimensionales de datos
|
|
104
|
+
- Estructura modular para futuras expansiones
|
|
105
|
+
- Ejemplos organizados por niveles de complejidad
|
|
106
|
+
- Principio DRY aplicado en la arquitectura
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# CHANGELOG - Extensión GTK3 para Node.js
|
|
2
|
+
|
|
3
|
+
## [Versión 1.3.0] - 2026-02-15
|
|
4
|
+
|
|
5
|
+
### Añadido
|
|
6
|
+
- Widget TextView para áreas de texto multilinea
|
|
7
|
+
- Widget Timer para funcionalidad de temporización similar a TTimer de Delphi
|
|
8
|
+
- Soporte completo para eventos y callbacks en todos los widgets
|
|
9
|
+
- Mejoras en la arquitectura para evitar duplicación de código
|
|
10
|
+
- Correcciones de errores en la implementación de StringGrid
|
|
11
|
+
- Ejemplos funcionales completos que demuestran la creación de interfaces gráficas
|
|
12
|
+
- Soporte para creación de ventanas con botones interactivos
|
|
13
|
+
- Implementación de bucles de eventos no bloqueantes
|
|
14
|
+
|
|
15
|
+
### Características
|
|
16
|
+
- Integración nativa con GTK3
|
|
17
|
+
- Sistema de eventos con callbacks
|
|
18
|
+
- Soporte para interfaces gráficas completas
|
|
19
|
+
- Estructura modular y extensible
|
|
20
|
+
- Temporización con funcionalidad similar a TTimer de Delphi
|
|
21
|
+
|
|
22
|
+
### Documentación
|
|
23
|
+
- README principal
|
|
24
|
+
- Documentación para cada widget
|
|
25
|
+
- Ejemplos básicos, intermedios y avanzados
|
|
26
|
+
- Guía de compilación (HOWTO-COMPILE.md)
|
|
27
|
+
|
|
28
|
+
### Notas Técnicas
|
|
29
|
+
- Basado en N-API para compatibilidad con múltiples versiones de Node.js
|
|
30
|
+
- Compilación con node-gyp
|
|
31
|
+
- Integración con GTK3 3.x
|
|
32
|
+
- Soporte para Linux (actualmente)
|
|
33
|
+
|
|
34
|
+
## [Versión 1.2.0] - 2026-02-15
|
|
35
|
+
|
|
36
|
+
### Añadido
|
|
37
|
+
- Widget Button con soporte para eventos y callbacks
|
|
38
|
+
- Widget Window para contenedores de interfaz
|
|
39
|
+
- Widget Label para mostrar texto estático
|
|
40
|
+
- Widget Box para layouts horizontales y verticales
|
|
41
|
+
- Widget Scroll para contenedores con barras de desplazamiento
|
|
42
|
+
- Widget Entry para entrada de texto simple
|
|
43
|
+
- Widget StringGrid para tablas bidimensionales de datos
|
|
44
|
+
- Widget TextView para áreas de texto multilinea
|
|
45
|
+
- Estructura modular para futuras expansiones
|
|
46
|
+
- Ejemplos organizados por niveles de complejidad
|
|
47
|
+
- Principio DRY aplicado en la arquitectura
|
|
48
|
+
|
|
49
|
+
### Características
|
|
50
|
+
- Integración nativa con GTK3
|
|
51
|
+
- Sistema de eventos con callbacks
|
|
52
|
+
- Soporte para interfaces gráficas completas
|
|
53
|
+
- Estructura modular y extensible
|
|
54
|
+
|
|
55
|
+
### Documentación
|
|
56
|
+
- README principal
|
|
57
|
+
- Documentación para cada widget
|
|
58
|
+
- Ejemplos básicos, intermedios y avanzados
|
|
59
|
+
- Guía de compilación (HOWTO-COMPILE.md)
|
|
60
|
+
|
|
61
|
+
### Notas Técnicas
|
|
62
|
+
- Basado en N-API para compatibilidad con múltiples versiones de Node.js
|
|
63
|
+
- Compilación con node-gyp
|
|
64
|
+
- Integración con GTK3 3.x
|
|
65
|
+
- Soporte para Linux (actualmente)
|
|
66
|
+
|
|
67
|
+
## [Versión 1.1.0] - 2026-02-14
|
|
68
|
+
|
|
69
|
+
### Añadido
|
|
70
|
+
- Implementación inicial de la extensión GTK3 para Node.js
|
|
71
|
+
- Soporte para creación de interfaces gráficas con GTK3
|
|
72
|
+
- Widget Button con soporte para eventos y callbacks
|
|
73
|
+
- Widget Window para contenedores de interfaz
|
|
74
|
+
- Widget Label para mostrar texto estático
|
|
75
|
+
- Widget Box para layouts horizontales y verticales
|
|
76
|
+
- Widget Scroll para contenedores con barras de desplazamiento
|
|
77
|
+
- Widget Entry para entrada de texto simple
|
|
78
|
+
- Widget StringGrid para tablas bidimensionales de datos
|
|
79
|
+
- Estructura modular para futuras expansiones
|
|
80
|
+
- Ejemplos organizados por niveles de complejidad
|
|
81
|
+
- Principio DRY aplicado en la arquitectura
|
|
82
|
+
|
|
83
|
+
### Características
|
|
84
|
+
- Integración nativa con GTK3
|
|
85
|
+
- Sistema de eventos con callbacks
|
|
86
|
+
- Soporte para interfaces gráficas completas
|
|
87
|
+
- Estructura modular y extensible
|
|
88
|
+
|
|
89
|
+
### Documentación
|
|
90
|
+
- README principal
|
|
91
|
+
- Documentación para cada widget
|
|
92
|
+
- Ejemplos básicos, intermedios y avanzados
|
|
93
|
+
- Guía de compilación (HOWTO-COMPILE.md)
|
|
94
|
+
|
|
95
|
+
### Notas Técnicas
|
|
96
|
+
- Basado en N-API para compatibilidad con múltiples versiones de Node.js
|
|
97
|
+
- Compilación con node-gyp
|
|
98
|
+
- Integración con GTK3 3.x
|
|
99
|
+
- Soporte para Linux (actualmente)
|
|
100
|
+
|
|
101
|
+
## [Versión 1.0.0] - 2026-02-14
|
|
102
|
+
|
|
103
|
+
### Añadido
|
|
104
|
+
- Implementación inicial de la extensión GTK3 para Node.js
|
|
105
|
+
- Soporte para creación de interfaces gráficas con GTK3
|
|
106
|
+
- Widget Button con soporte para eventos y callbacks
|
|
107
|
+
- Widget Window para contenedores de interfaz
|
|
108
|
+
- Widget Label para mostrar texto estático
|
|
109
|
+
- Widget Box para layouts horizontales y verticales
|
|
110
|
+
- Widget Scroll para contenedores con barras de desplazamiento
|
|
111
|
+
- Widget Entry para entrada de texto simple
|
|
112
|
+
- Widget StringGrid para tablas bidimensionales de datos
|
|
113
|
+
- Estructura modular para futuras expansiones
|
|
114
|
+
- Ejemplos organizados por niveles de complejidad
|
|
115
|
+
- Principio DRY aplicado en la arquitectura
|
package/CHECKLIST.md
CHANGED
|
@@ -42,13 +42,36 @@
|
|
|
42
42
|
- [x] Documentación completa
|
|
43
43
|
- [x] Ejemplos funcionales
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### ✅ Entry
|
|
46
|
+
- [x] Creación de campos de texto simples
|
|
47
|
+
- [x] Soporte para entrada de texto
|
|
48
|
+
- [x] Lectura de texto ingresado
|
|
49
|
+
- [x] Escritura de texto programática
|
|
50
|
+
- [x] Documentación completa
|
|
51
|
+
- [x] Ejemplos funcionales
|
|
46
52
|
|
|
47
|
-
###
|
|
48
|
-
- [
|
|
53
|
+
### ✅ StringGrid
|
|
54
|
+
- [x] Creación de tablas bidimensionales
|
|
55
|
+
- [x] Soporte para filas y columnas
|
|
56
|
+
- [x] Establecimiento de encabezados
|
|
57
|
+
- [x] Agregar filas de datos
|
|
58
|
+
- [x] Modificación de celdas
|
|
59
|
+
- [x] Edición interactiva de celdas
|
|
60
|
+
- [x] Selección de filas
|
|
61
|
+
- [x] Callbacks de eventos
|
|
62
|
+
- [x] Documentación completa
|
|
63
|
+
- [x] Ejemplos funcionales
|
|
49
64
|
|
|
50
|
-
###
|
|
51
|
-
- [
|
|
65
|
+
### ✅ TextView
|
|
66
|
+
- [x] Área de texto multilinea para entradas más largas
|
|
67
|
+
- [x] Soporte para texto largo y desplazamiento
|
|
68
|
+
- [x] Lectura y escritura de texto
|
|
69
|
+
- [x] Añadir texto al contenido existente
|
|
70
|
+
- [x] Insertar texto en posiciones específicas
|
|
71
|
+
- [x] Documentación completa
|
|
72
|
+
- [x] Ejemplos funcionales
|
|
73
|
+
|
|
74
|
+
## Widgets Pendientes
|
|
52
75
|
|
|
53
76
|
### ❌ CheckButton
|
|
54
77
|
- [ ] Casilla de verificación
|
|
@@ -70,7 +93,7 @@
|
|
|
70
93
|
|
|
71
94
|
## Estado General
|
|
72
95
|
|
|
73
|
-
- **Total Widgets Implementados:**
|
|
74
|
-
- **Estado de la Extensión:** Funcional para casos básicos
|
|
96
|
+
- **Total Widgets Implementados:** 6/12
|
|
97
|
+
- **Estado de la Extensión:** Funcional para casos básicos e intermedios
|
|
75
98
|
- **Compatibilidad:** GTK3, Linux
|
|
76
99
|
- **Principio DRY:** Aplicado en toda la arquitectura
|
package/binding.gyp
CHANGED
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
"src/button.cpp",
|
|
8
8
|
"widgets/label/label.cpp",
|
|
9
9
|
"widgets/box/box.cpp",
|
|
10
|
-
"widgets/scroll/scroll.cpp"
|
|
10
|
+
"widgets/scroll/scroll.cpp",
|
|
11
|
+
"widgets/entry/entry.cpp",
|
|
12
|
+
"widgets/stringgrid/stringgrid.cpp",
|
|
13
|
+
"widgets/textview/textview.cpp"
|
|
11
14
|
],
|
|
12
15
|
"include_dirs": [
|
|
13
16
|
"<!@(node -p \"require('node-addon-api').include\")",
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// ejemplo_funcional.js - Ejemplo funcional con ventana y botón visibles
|
|
2
|
+
|
|
3
|
+
const { init, run } = require('./index.js');
|
|
4
|
+
|
|
5
|
+
// Inicializar GTK
|
|
6
|
+
init();
|
|
7
|
+
|
|
8
|
+
// Crear una ventana usando directamente las funciones nativas
|
|
9
|
+
const window = gtk3_native.createWindow('Ejemplo Funcional', 400, 300);
|
|
10
|
+
|
|
11
|
+
// Crear un botón usando directamente las funciones nativas
|
|
12
|
+
const button = gtk3_native.createButton('Haz clic aquí');
|
|
13
|
+
|
|
14
|
+
// Conectar un callback al botón
|
|
15
|
+
gtk3_native.connectClick(button, () => {
|
|
16
|
+
console.log('¡Botón presionado!');
|
|
17
|
+
gtk3_native.setButtonText(button, '¡Gracias por hacer clic!');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Agregar el botón a la ventana
|
|
21
|
+
gtk3_native.addToWindow(window, button);
|
|
22
|
+
|
|
23
|
+
// Mostrar todos los widgets
|
|
24
|
+
gtk3_native.showAll(window);
|
|
25
|
+
|
|
26
|
+
console.log('Interfaz gráfica lista. Abriendo ventana con botón...');
|
|
27
|
+
|
|
28
|
+
// Iniciar el loop de eventos GTK para mostrar la interfaz
|
|
29
|
+
run();
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// ejemplo_funcional_corregido.js - Ejemplo funcional con ventana y botón visibles
|
|
2
|
+
|
|
3
|
+
const { Button, Window, init, run } = require('./index.js');
|
|
4
|
+
|
|
5
|
+
// Inicializar GTK
|
|
6
|
+
init();
|
|
7
|
+
|
|
8
|
+
// Crear una ventana
|
|
9
|
+
const window = new Window('Ejemplo Funcional', 400, 300);
|
|
10
|
+
|
|
11
|
+
// Crear un botón
|
|
12
|
+
const button = new Button('Haz clic aquí');
|
|
13
|
+
|
|
14
|
+
// Agregar un manejador de eventos al botón
|
|
15
|
+
button.onClick(() => {
|
|
16
|
+
console.log('¡Botón presionado!');
|
|
17
|
+
button.label = '¡Gracias por hacer clic!';
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Agregar el botón a la ventana
|
|
21
|
+
window.add(button);
|
|
22
|
+
|
|
23
|
+
// Mostrar la ventana y todos sus contenidos
|
|
24
|
+
window.show();
|
|
25
|
+
|
|
26
|
+
console.log('Interfaz gráfica lista. Abriendo ventana con botón...');
|
|
27
|
+
|
|
28
|
+
// Iniciar el loop de eventos GTK para mostrar la interfaz
|
|
29
|
+
run();
|
|
@@ -6,6 +6,8 @@ Este directorio contiene ejemplos complejos que demuestran el uso combinado de m
|
|
|
6
6
|
|
|
7
7
|
- `ejemplo_completo.js` - Ejemplo con botón y 35 labels organizadas en layouts horizontales y verticales
|
|
8
8
|
- `ejemplo_scroll.js` - Ejemplo con Scroll, Labels y Buttons en la misma ventana
|
|
9
|
+
- `ejemplo_stringgrid_completo.js` - Ejemplo completo del StringGrid con todas sus capacidades
|
|
10
|
+
- `ejemplo_textview.js` - Ejemplo del widget TextView
|
|
9
11
|
|
|
10
12
|
## Objetivo
|
|
11
13
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// ejemplo_stringgrid_completo.js - Ejemplo completo del StringGrid con todas sus capacidades
|
|
2
|
+
|
|
3
|
+
const { StringGrid, Entry, Label, Button, Box, Scroll, Window, init, run } = require('../../index.js');
|
|
4
|
+
|
|
5
|
+
// Inicializar GTK
|
|
6
|
+
init();
|
|
7
|
+
|
|
8
|
+
// Crear una ventana
|
|
9
|
+
const ventana = new Window('StringGrid Completo', 900, 700);
|
|
10
|
+
|
|
11
|
+
// Crear un contenedor con scroll
|
|
12
|
+
const scroll = new Scroll();
|
|
13
|
+
|
|
14
|
+
// Crear un layout vertical
|
|
15
|
+
const layout = new Box('vertical');
|
|
16
|
+
|
|
17
|
+
// Crear un StringGrid con 15 filas y 5 columnas
|
|
18
|
+
const grid = new StringGrid(15, 5);
|
|
19
|
+
|
|
20
|
+
// Establecer encabezados
|
|
21
|
+
grid.setHeader(['Nombre', 'Edad', 'Ciudad', 'País', 'Activo']);
|
|
22
|
+
|
|
23
|
+
// Agregar algunas filas de ejemplo
|
|
24
|
+
grid.addRow(['Juan Pérez', '30', 'Madrid', 'España', 'Sí']);
|
|
25
|
+
grid.addRow(['Ana García', '25', 'Barcelona', 'España', 'No']);
|
|
26
|
+
grid.addRow(['Carlos López', '35', 'Buenos Aires', 'Argentina', 'Sí']);
|
|
27
|
+
grid.addRow(['María Rodríguez', '28', 'Ciudad de México', 'México', 'Sí']);
|
|
28
|
+
grid.addRow(['Pedro Fernández', '42', 'Bogotá', 'Colombia', 'No']);
|
|
29
|
+
|
|
30
|
+
// Crear controles para la interacción
|
|
31
|
+
const controlsLayout = new Box('horizontal');
|
|
32
|
+
|
|
33
|
+
const labelInfo = new Label('Información: ');
|
|
34
|
+
const entryInput = new Entry('Texto para celda');
|
|
35
|
+
const buttonUpdate = new Button('Actualizar Celda (0,0)');
|
|
36
|
+
const buttonGetSelected = new Button('Obtener Selección');
|
|
37
|
+
const labelSelection = new Label('Selección: Ninguna');
|
|
38
|
+
|
|
39
|
+
// Variables para almacenar la selección actual
|
|
40
|
+
let selectedRow = -1;
|
|
41
|
+
let selectedCol = -1;
|
|
42
|
+
|
|
43
|
+
// Registrar un callback para cuando se edita una celda
|
|
44
|
+
grid.registerCellEditCallback((info) => {
|
|
45
|
+
console.log(`Celda editada: fila=${info.row}, col=${info.col}, nuevo_valor="${info.newValue}"`);
|
|
46
|
+
labelInfo.text = `Celda (${info.row},${info.col}) actualizada a: "${info.newValue}"`;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Agregar un manejador de eventos al botón de actualizar
|
|
50
|
+
buttonUpdate.onClick(() => {
|
|
51
|
+
const texto = entryInput.text;
|
|
52
|
+
console.log(`Actualizando celda (0,0) con: ${texto}`);
|
|
53
|
+
grid.setCellValue(0, 0, texto);
|
|
54
|
+
labelInfo.text = `Celda (0,0) actualizada a: "${texto}"`;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Agregar un manejador de eventos al botón de obtener selección
|
|
58
|
+
buttonGetSelected.onClick(() => {
|
|
59
|
+
const selection = grid.getSelectedCell();
|
|
60
|
+
selectedRow = selection.row;
|
|
61
|
+
selectedCol = selection.col;
|
|
62
|
+
|
|
63
|
+
if (selection.row !== -1) {
|
|
64
|
+
const cellValue = grid.getCell(selection.row, 0); // Obtener valor de la primera columna
|
|
65
|
+
labelSelection.text = `Fila seleccionada: ${selection.row}, Valor: "${cellValue}"`;
|
|
66
|
+
console.log(`Fila seleccionada: ${selection.row}, Columna: ${selection.col}`);
|
|
67
|
+
} else {
|
|
68
|
+
labelSelection.text = 'Ninguna fila seleccionada';
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Agregar widgets al layout de controles
|
|
73
|
+
controlsLayout.add(labelInfo);
|
|
74
|
+
controlsLayout.add(entryInput);
|
|
75
|
+
controlsLayout.add(buttonUpdate);
|
|
76
|
+
controlsLayout.add(buttonGetSelected);
|
|
77
|
+
controlsLayout.add(labelSelection);
|
|
78
|
+
|
|
79
|
+
// Agregar widgets al layout principal
|
|
80
|
+
layout.add(grid);
|
|
81
|
+
layout.add(controlsLayout);
|
|
82
|
+
|
|
83
|
+
// Agregar el layout al contenedor con scroll
|
|
84
|
+
scroll.add(layout);
|
|
85
|
+
|
|
86
|
+
// Agregar el scroll a la ventana
|
|
87
|
+
ventana.add(scroll);
|
|
88
|
+
|
|
89
|
+
// Mostrar la ventana y todos sus contenidos
|
|
90
|
+
ventana.show();
|
|
91
|
+
|
|
92
|
+
console.log('Interfaz con StringGrid completa lista. Abriendo ventana...');
|
|
93
|
+
|
|
94
|
+
// Iniciar el loop de eventos GTK para mostrar la interfaz
|
|
95
|
+
run();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// ejemplo_textview.js - Ejemplo del widget TextView
|
|
2
|
+
|
|
3
|
+
const { TextView, Button, Label, Box, Scroll, Window, init, run } = require('../../index.js');
|
|
4
|
+
|
|
5
|
+
// Inicializar GTK
|
|
6
|
+
init();
|
|
7
|
+
|
|
8
|
+
// Crear una ventana
|
|
9
|
+
const ventana = new Window('Ejemplo TextView', 600, 500);
|
|
10
|
+
|
|
11
|
+
// Crear un contenedor con scroll para el TextView
|
|
12
|
+
const scroll = new Scroll();
|
|
13
|
+
|
|
14
|
+
// Crear un TextView con texto inicial
|
|
15
|
+
const textView = new TextView('Hola,\neste es un ejemplo de TextView\ncon múltiples líneas.\n\nPuedes editar este texto directamente.');
|
|
16
|
+
|
|
17
|
+
// Crear controles para interactuar con el TextView
|
|
18
|
+
const controlsLayout = new Box('vertical');
|
|
19
|
+
|
|
20
|
+
const labelInfo = new Label('Usa los botones para interactuar con el TextView');
|
|
21
|
+
const buttonGetText = new Button('Obtener Texto');
|
|
22
|
+
const buttonSetText = new Button('Establecer Texto');
|
|
23
|
+
const buttonAppend = new Button('Añadir Texto');
|
|
24
|
+
|
|
25
|
+
// Agregar manejadores de eventos a los botones
|
|
26
|
+
buttonGetText.onClick(() => {
|
|
27
|
+
const text = textView.text;
|
|
28
|
+
console.log('Texto actual del TextView:', text);
|
|
29
|
+
labelInfo.text = `Caracteres: ${text.length}`;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
buttonSetText.onClick(() => {
|
|
33
|
+
textView.text = 'Texto completamente nuevo\nEscrito desde JavaScript\nCon múltiples líneas';
|
|
34
|
+
labelInfo.text = 'Texto actualizado';
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
buttonAppend.onClick(() => {
|
|
38
|
+
textView.appendText('\n\nTexto añadido al final');
|
|
39
|
+
labelInfo.text = 'Texto añadido al final';
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Agregar widgets al layout de controles
|
|
43
|
+
controlsLayout.add(labelInfo);
|
|
44
|
+
controlsLayout.add(buttonGetText);
|
|
45
|
+
controlsLayout.add(buttonSetText);
|
|
46
|
+
controlsLayout.add(buttonAppend);
|
|
47
|
+
|
|
48
|
+
// Agregar el TextView al contenedor con scroll
|
|
49
|
+
scroll.add(textView);
|
|
50
|
+
|
|
51
|
+
// Crear un layout principal
|
|
52
|
+
const mainLayout = new Box('vertical');
|
|
53
|
+
mainLayout.add(scroll);
|
|
54
|
+
mainLayout.add(controlsLayout);
|
|
55
|
+
|
|
56
|
+
// Agregar el layout principal a la ventana
|
|
57
|
+
ventana.add(mainLayout);
|
|
58
|
+
|
|
59
|
+
// Mostrar la ventana y todos sus contenidos
|
|
60
|
+
ventana.show();
|
|
61
|
+
|
|
62
|
+
console.log('Interfaz con TextView lista. Abriendo ventana...');
|
|
63
|
+
|
|
64
|
+
// Iniciar el loop de eventos GTK para mostrar la interfaz
|
|
65
|
+
run();
|
|
@@ -6,6 +6,7 @@ Este directorio contiene ejemplos que muestran el uso combinado de múltiples wi
|
|
|
6
6
|
|
|
7
7
|
- `ejemplo_label.js` - Ejemplo con widget Label y manipulación de texto
|
|
8
8
|
- `ejemplo_label_boton.js` - Ejemplo con Label y Button en la misma ventana
|
|
9
|
+
- `ejemplo_entry.js` - Ejemplo con Entry, Label y Button en la misma ventana
|
|
9
10
|
|
|
10
11
|
## Objetivo
|
|
11
12
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// ejemplo_entry.js - Ejemplo con Entry, Label y Button en la misma ventana
|
|
2
|
+
|
|
3
|
+
const { Button, Label, Entry, Box, Scroll, Window, init, run } = require('../../index.js');
|
|
4
|
+
|
|
5
|
+
// Inicializar GTK
|
|
6
|
+
init();
|
|
7
|
+
|
|
8
|
+
// Crear una ventana
|
|
9
|
+
const ventana = new Window('Ejemplo Entry, Label y Button', 500, 400);
|
|
10
|
+
|
|
11
|
+
// Crear un contenedor con scroll
|
|
12
|
+
const scroll = new Scroll();
|
|
13
|
+
|
|
14
|
+
// Crear un layout vertical
|
|
15
|
+
const layout = new Box('vertical');
|
|
16
|
+
|
|
17
|
+
// Crear un label para mostrar el texto del entry
|
|
18
|
+
const label = new Label('Ingresa texto en el campo de abajo y haz clic en el botón');
|
|
19
|
+
|
|
20
|
+
// Crear un entry
|
|
21
|
+
const entry = new Entry('Texto inicial...');
|
|
22
|
+
|
|
23
|
+
// Crear un botón
|
|
24
|
+
const boton = new Button('Obtener texto del Entry');
|
|
25
|
+
|
|
26
|
+
// Agregar un manejador de eventos al botón
|
|
27
|
+
boton.onClick(() => {
|
|
28
|
+
const textoEntrada = entry.text;
|
|
29
|
+
console.log('Texto del entry:', textoEntrada);
|
|
30
|
+
label.text = `Texto ingresado: "${textoEntrada}"`;
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Agregar widgets al layout
|
|
34
|
+
layout.add(label);
|
|
35
|
+
layout.add(entry);
|
|
36
|
+
layout.add(boton);
|
|
37
|
+
|
|
38
|
+
// Agregar el layout al contenedor con scroll
|
|
39
|
+
scroll.add(layout);
|
|
40
|
+
|
|
41
|
+
// Agregar el scroll a la ventana
|
|
42
|
+
ventana.add(scroll);
|
|
43
|
+
|
|
44
|
+
// Mostrar la ventana y todos sus contenidos
|
|
45
|
+
ventana.show();
|
|
46
|
+
|
|
47
|
+
console.log('Interfaz con Entry, Label y Button lista. Abriendo ventana...');
|
|
48
|
+
|
|
49
|
+
// Iniciar el loop de eventos GTK para mostrar la interfaz
|
|
50
|
+
run();
|
package/index.js
CHANGED
|
@@ -66,6 +66,88 @@ class Scroll {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
class Entry {
|
|
70
|
+
constructor(text = "") {
|
|
71
|
+
this.widget = gtk3_native.createEntry(text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set text(content) {
|
|
75
|
+
gtk3_native.setEntryText(this.widget, content);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
get text() {
|
|
79
|
+
return gtk3_native.getEntryText(this.widget);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setText(content) {
|
|
83
|
+
this.text = content;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getText() {
|
|
87
|
+
return this.text;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
class StringGrid {
|
|
92
|
+
constructor(rows = 10, cols = 5) {
|
|
93
|
+
this.widget = gtk3_native.createStringGrid(rows, cols);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
setCellValue(row, col, value) {
|
|
97
|
+
return gtk3_native.setGridCellValue(this.widget, row, col, value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getCell(row, col) {
|
|
101
|
+
return gtk3_native.getGridCell(this.widget, row, col);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setHeader(headers) {
|
|
105
|
+
return gtk3_native.setGridHeader(this.widget, headers);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
addRow(data) {
|
|
109
|
+
return gtk3_native.addGridRow(this.widget, data);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getSelectedCell() {
|
|
113
|
+
return gtk3_native.getSelectedCell(this.widget);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
registerCellEditCallback(callback) {
|
|
117
|
+
return gtk3_native.registerCellEditCallback(this.widget, callback);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
class TextView {
|
|
122
|
+
constructor(text = "") {
|
|
123
|
+
this.widget = gtk3_native.createTextView(text);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
set text(content) {
|
|
127
|
+
gtk3_native.setTextViewText(this.widget, content);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
get text() {
|
|
131
|
+
return gtk3_native.getTextViewText(this.widget);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
setText(content) {
|
|
135
|
+
this.text = content;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
getText() {
|
|
139
|
+
return this.text;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
appendText(content) {
|
|
143
|
+
return gtk3_native.appendTextViewText(this.widget, content);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
insertText(position, content) {
|
|
147
|
+
return gtk3_native.insertTextViewText(this.widget, position, content);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
69
151
|
class Window {
|
|
70
152
|
constructor(title = "Ventana", width = 400, height = 300) {
|
|
71
153
|
this.widget = gtk3_native.createWindow(title, width, height);
|
|
@@ -99,6 +181,9 @@ module.exports = {
|
|
|
99
181
|
Label,
|
|
100
182
|
Box,
|
|
101
183
|
Scroll,
|
|
184
|
+
Entry,
|
|
185
|
+
StringGrid,
|
|
186
|
+
TextView,
|
|
102
187
|
Window,
|
|
103
188
|
// Mantener compatibilidad hacia atrás
|
|
104
189
|
createWindow: gtk3_native.createWindow,
|
package/package.json
CHANGED
package/src/gtk3_node.cpp
CHANGED
|
@@ -144,6 +144,18 @@ Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
144
144
|
extern Napi::Object InitScroll(Napi::Env env, Napi::Object exports);
|
|
145
145
|
InitScroll(env, exports);
|
|
146
146
|
|
|
147
|
+
// Inicializar el widget Entry
|
|
148
|
+
extern Napi::Object InitEntry(Napi::Env env, Napi::Object exports);
|
|
149
|
+
InitEntry(env, exports);
|
|
150
|
+
|
|
151
|
+
// Inicializar el widget StringGrid
|
|
152
|
+
extern Napi::Object InitStringGrid(Napi::Env env, Napi::Object exports);
|
|
153
|
+
InitStringGrid(env, exports);
|
|
154
|
+
|
|
155
|
+
// Inicializar el widget TextView
|
|
156
|
+
extern Napi::Object InitTextView(Napi::Env env, Napi::Object exports);
|
|
157
|
+
InitTextView(env, exports);
|
|
158
|
+
|
|
147
159
|
return exports;
|
|
148
160
|
}
|
|
149
161
|
|