;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; EDITOR VISUAL DEL LENGUAJE C ;; ;; Modulo: editor_c.lsp ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; ;; Autor: J. Rafael R. Ochoa ;; ;; e-mail: rochoa@zeus.umich.mx ;; ;; Universidad Michoacana de ;; ;; Morelia, Mich. MEXICO ;; ;; ;; ;; Marzo 1998 ;; ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;------------------------------- ;; posicion-renglon ;;------------------------------- ;; Variable global utilizada ;; para marcar el inicio del ;; despliegue del programa ;;;;;;;;;;;; (setq posicion-renglon 80) ;;-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- ;; ventanas ;;+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ;; Funcion encargada de la creacion de las ;; ventanas donde se desplegaran las operaciones ;; hechas por el usuario. Son variables globales ;; La ventana donde se muestra el programa y el ;; menu principal es ==> *ventana-principal* ;; Donde se muestran las opciones es en ;; ==> *ventana-secundaria* ;;;;;;;;;; (defun ventanas () (defvar *ventana-secundaria* (ghw:make-window :x 20 :y 20 :width 250 :height 400 :title "Editor visual de C - Opciones" :status :active)) (defvar *ventana-principal* (ghw:make-window :x 280 :y 20 :width 600 :height 600 :title "Editor visual de C" :status :active)) (ghw:add-to-object-method *ventana-principal* :repaint '(:after (redibuja-ventana-principal)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; COLORES PARA CONTORNOS Y RELLENOS DE FIGURAS ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar *lapiz-azul* (ghw:make-pen :color ghw:*blue* :width 3 :style :solid)) (defvar *relleno-azul* (ghw:make-brush :pattern :solid :color ghw:*blue*)) (defvar *lapiz-rojo* (ghw:make-pen :color ghw:*red* :width 3 :style :solid)) (defvar *relleno-rojo* (ghw:make-brush :pattern :solid :color ghw:*red*)) (defvar *lapiz-verde* (ghw:make-pen :color ghw:*green* :width 3 :style :solid)) (defvar *relleno-verde* (ghw:make-brush :pattern :solid :color ghw:*green*)) (defvar *lapiz-amarillo* (ghw:make-pen :color ghw:*yellow* :width 3 :style :solid)) (defvar *relleno-amarillo* (ghw:make-brush :pattern :solid :color ghw:*yellow*)) (defvar *lapiz-blanco* (ghw:make-pen :color ghw:*white* :width 3 :style :solid)) (defvar *relleno-blanco* (ghw:make-brush :pattern :solid :color ghw:*white*)) ;;--------------------------------------------------------- ;; redibuja-ventana-principal ;;--------------------------------------------------------- ;; Funcion llamada cada que hay que redibujar la ventana ;; principal ;;;;;;;;;;;;;; (defun redibuja-ventana-principal (window x y width height) (opcion-header) (opcion-global) (opcion-principal) (separador)) ;;----------------------------------- ;; separador ;;----------------------------------- ;; Dibuja un rectangulo azul que ;; divide *ventana-principal* ;;;;;;;;;;;;;;; (defun separador () (ghw:draw-rectangle *ventana-principal* 20 60 530 20 :brush *relleno-azul*)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; M E N U D E L O S H E A D E R S ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;-------------------------------- ;; muestra-encabezados ;;-------------------------------- ;; Crea los hotspots para la ;; seleccion de los headers ;;;;;;;; (defun muestra-encabezados () (elimina-todo-hotspot (obten-lista-de-hotspots *ventana-secundaria*)) (opcion-header) (let ((hotspot (ghw:make-hotspot *ventana-principal* :x 40 :y 10 :width 110 :height 40 :status :active))) (ghw:add-to-object-method hotspot :mouse-left-down '(:after (headers))))) ;;---------------------------------- ;; opcion-header ;;---------------------------------- ;; Dibuja en la *ventana-principal* ;; un cuadro con la leyenda "ENCABEZADOS" ;;;;;;;; (defun opcion-header( ) (ghw:draw-rectangle *ventana-principal* 40 10 110 40 :pen *lapiz-azul* :brush *relleno-amarillo*) (ghw:draw-text *ventana-principal* 50 20 "ENCABEZADOS")) ;;---------------------------------- ;; headers ;;---------------------------------- ;; Funcion llamada por muestra-encabezados ;; para desplegar los headers disponibles ;; en la *ventana-secundaria* ;;;;;;;;; (defun headers (hotspot &rest ignore) (limpia-ventana *ventana-secundaria*) (header-stdio) (header-string) (header-stdlib)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; M E N U D E L A S V A R I A B L E S G L O B A L E S ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;------------------------------------ ;; muestra-variables-globales ;;------------------------------------ ;; Crea un hotspot para el recuadro de ;; "Variables globales" ;;;;;;;;;;; (defun muestra-variables-globales () (elimina-todo-hotspot (obten-lista-de-hotspots *ventana-secundaria*)) (opcion-global) (let ((hotspot (ghw:make-hotspot *ventana-principal* :x 160 :y 10 :width 165 :height 40 :status :active))) (ghw:add-to-object-method hotspot :mouse-left-down '(:after (globales))))) ;;------------------------------------- ;; opcion-global ;;------------------------------------- ;; Dibuja en la *ventana-principal* ;; un cuadro con la leyenda "VARIABLES ;; GLOBALES" ;;;;;;;; (defun opcion-global () (ghw:draw-rectangle *ventana-principal* 160 10 165 40 :pen *lapiz-azul* :brush *relleno-verde*) (ghw:draw-text *ventana-principal* 170 20 "VARIABLES GLOBALES")) ;;------------------------------------ ;; globales ;;------------------------------------ ;; Funcion encargada de desplegar en ;; la *ventana-secundaria* el las ;; variables globales permitidas ;; en este programa ;;;;;;;;;; (defun globales (hotspot &rest ignore) (limpia-ventana *ventana-secundaria*) (elimina-todo-hotspot (obten-lista-de-hotspots *ventana-secundaria*)) (global-int) (global-float) (global-double) (global-char) (global-arreglo-de-caracteres) (global-apuntador-a-caracter)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; M E N U D E L P R O G R A M A P R I N C I P A L ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;------------------------------------ ;; muestra-cuerpo-del-programa ;;------------------------------------ ;; Crea un hotspot para el recuadro de ;; "Programa principal" ;;;;;;;;;;; (defun muestra-cuerpo-del-programa () (opcion-principal) (let ((hotspot (ghw:make-hotspot *ventana-principal* :x 335 :y 10 :width 200 :height 40 :status :active))) (ghw:add-to-object-method hotspot :mouse-left-down '(:after (main))))) ;;------------------------------------- ;; opcion-principal ;;------------------------------------- ;; Dibuja en la *ventana-principal* ;; un cuadro con la leyenda "PROGRAMA ;; PRINCIPAL" ;;;;;;;; (defun opcion-principal () (ghw:draw-rectangle *ventana-principal* 335 10 200 40 :pen *lapiz-amarillo* :brush *relleno-azul*) (ghw:draw-text *ventana-principal* 360 20 "PROGRAMA PRINCIPAL")) ;;---------------------------------------------- ;; programa-principal ;;---------------------------------------------- ;; Funcion que manda llamar a la funcion ;; programa principal, la cual se encuentra en ;; el archivo main.lsp ;;;;;;;; (defun programa-principal (hotspot &rest ignore) (declare (ignore hotspot)) (setq posicion-renglon (+ posicion-renglon 15)) (ghw:draw-text *ventana-principal* 10 posicion-renglon "/* Comienza el programa principal */") (setq posicion-renglon (+ posicion-renglon 30))) ;;-------------------------------------- ;; inicia-programa ;;-------------------------------------- ;; Funcion que pone en funcionamiento el ;; editor visual ;;;;;;;;;;; (defun inicia-programa () ;(setq posicion-renglon 80) (ventanas) (limpia-ventana *ventana-principal*) (limpia-ventana *ventana-secundaria*) (muestra-encabezados) (muestra-variables-globales) (muestra-cuerpo-del-programa) (separador)) ;(inicia-programa) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; F U N C I O N E S A U X I L I A R E S ;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;----------------------------------------- ;; aumenta-renglon ;;----------------------------------------- ;; Realiza el salto de linea ;;;;;;;;; (defun aumenta-renglon (cuanto) (setq posicion-renglon (+ posicion-renglon cuanto))) ;;----------------------------------------- ;; borra-hotspot ;;----------------------------------------- ;; Elimina por completo un hotspot ;;;;;;;;; (defun borra-hotspot (hotspot &rest ignore) (ghw:flush-hotspot hotspot)) ;;---------------------------- ;; terminar-aplicacion ;;---------------------------- ;; Destruye las ventanas que ;; integran al editor ;;;;;;;;; (defun terminar-aplicacion () (ghw:flush-window *ventana-principal*) (ghw:flush-window *ventana-secundaria*)) ;;------------------------------------- ;; limpia-ventana ;;------------------------------------- ;; Pone en blanco una ventana. No borra ;; los hotspots ;;;;;;;;;;; (defun limpia-ventana (nombre-ventana) (ghw:clear nombre-ventana)) ;;-------------------------------------- ;; borra-hacia-abajo ;;-------------------------------------- (defun borra-hacia-abajo (a-partir-de-aqui ventana) (ghw:clear ventana 0 a-partir-de-aqui 580 500)) ;;---------------------------------------- ;; obten-lista-de-hotspots ;;---------------------------------------- ;; Funcion que regresa la lista de ;; hotspots de una ventana ;;;;;;;;;; (defun obten-lista-de-hotspots (ventana) (let ((lista (ghw:window-hotspot-list ventana))) lista)) ;;---------------------------------------- ;; elimina-todo-hotspot ;;---------------------------------------- ;; Funcion que elimina todos los hotspots ;; de una ventana en particular ;;;;;;;;;;; (defun elimina-todo-hotspot (hotspot-list) (cond ((null hotspot-list) nil) (T (progn (ghw:flush-hotspot (car hotspot-list)) (elimina-todo-hotspot (cdr hotspot-list)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Variable: *menu-principal* ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;(defvar *menu-principal* ; (ghw:make-command-menu ; (ghw:make-command-menu-item ; :text "Archivo" ; :action ; (ghw:make-command-menu-item ; :text "Nuevo" ; (ghw:make-command-menu-item ; :text "Guardar" ; (ghw:make-command-menu-item ; :text "Salir" ; ))))))