;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: user; Base: 10 -*- ;;; 11/29/2006 RJF ;;; Richard Fateman (c) 2006. All rights reserved. ;;; Redistribution is permitted free and without conditions. No warranties. ;;; Example stuff for outlining with menus ;; using .net via rdnzl ;;(in-package :rdnzl-user) (eval-when (compile load eval) (load "c:/lisp/rdnzl-0.10.6/load"); or where ever it is (use-package :rdnzl) ) (enable-rdnzl-syntax) (import-types "System.Windows.Forms" "Application" "DockStyle" "Form" "TextBox" "Control" "MenuStrip" "ToolStripItem" "ToolStripDropDownItem" "ToolStripPanel" "ToolStrip" "ToolStripMenuItem" "DockStyle" "ToolStripDropDownMenu" ;do I need all these? ) (import-types "System.Drawing" "Color" "KnownColor" "Bitmap" "Image") (import-type "System.EventHandler") (use-namespace "System.Windows.Forms") (use-namespace "System.Drawing") (use-namespace "System") ;;(setf ximage (new "Bitmap" "c:\\lisp\\dotplus.bmp")) ;; could be installed as [%Image ..] on buttons. (defvar ms2 nil);message panels (defvar ms3 nil) (defparameter outline-ht (make-hash-table)) (defparameter outline-count 0) (defparameter same-event-handler (new "EventHandler" #'(lambda(a b) (declare(ignore b)) (setf [%Text ms2] [ToString a]) (setf [%Text ms3] (format nil "~a" (gethash (read-from-string [%ToolTipText (cast a "ToolStripMenuItem")]) outline-ht)))))) (defun make-tool-strip(L parent) ;; use just event handler for all clicks. (loop for i in L do (let ((r (new "ToolStripMenuItem" (format nil "~a" (if (atom i) i (car i)))))) [Add [%DropDownItems parent] r] (setf (gethash outline-count outline-ht) i) (setf [%ToolTipText r] (format nil "~s" outline-count)) (incf outline-count) ;; (setf[%Image r] ximage) ;optional if we want an image here [+Click r same-event-handler] (unless (atom i) (make-tool-strip (cdr i) r))))) (defun outline(L) ;; display a dynamic outline, with [same] event for each click, display in window (let ((f (new "Form")) (mm (new "MenuStrip")) (out (new "ToolStripMenuItem" "Outline"))) (setf [%Width f] 490) (setf [%Text f] "Outline Window") ;; set up result window (setf ms2 (new "TextBox")) (setf [%Text ms2] "Selection name will appear here") (setf [%BackColor ms2] [%LightYellow "Color"]) (setf [%Dock ms2][$Bottom "DockStyle"]) [Add [%Controls f] ms2] ;; set up data window (setf ms3 (new "TextBox")) (setf [%Text ms3] "Selection value appear here") (setf [%BackColor ms3] [%CadetBlue "Color"]) (setf [%Dock ms3][$Bottom "DockStyle"]) [Add [%Controls f] ms3] (setf [%MainMenuStrip f] mm) [Add [%Items mm] out] (make-tool-strip L out) [Add [%Controls f] mm] (mp:process-run-function "outlinewind" #'(lambda() [Application.Run f] [Dispose f])) [BringToFront f] )) (defparameter ctree '("sum of 20 terms" ("terms 1-10" "op=+" a b c d e f g h i ("power" "op=expt" a b)) ("terms 11-20" "op=+" a b c d e f g h i ("product of 5 terms" "op=*" q r s t u)) ) ) ;; try (outline ctree) ;; see the window. click on Outline.