From junrue at common-lisp.net Mon Jul 9 04:15:26 2007 From: junrue at common-lisp.net (junrue at common-lisp.net) Date: Mon, 9 Jul 2007 00:15:26 -0400 (EDT) Subject: [graphic-forms-cvs] r468 - in trunk: . docs/manual docs/website src src/tests/uitoolkit src/uitoolkit/widgets Message-ID: <20070709041526.9191961051@common-lisp.net> Author: junrue Date: Mon Jul 9 00:15:15 2007 New Revision: 468 Added: trunk/src/uitoolkit/widgets/defmenu.lisp - copied, changed from r433, trunk/src/uitoolkit/widgets/menu-language.lisp trunk/src/uitoolkit/widgets/defwindow.lisp Removed: trunk/src/uitoolkit/widgets/menu-language.lisp Modified: trunk/NEWS.txt trunk/README.txt trunk/docs/manual/clhs-table.xml trunk/docs/manual/gfw-function-symbols.xml trunk/docs/manual/gfw-macro-symbols.xml trunk/docs/manual/introduction.xml trunk/docs/website/index.html trunk/graphic-forms-uitoolkit.asd trunk/src/packages.lisp trunk/src/tests/uitoolkit/event-tester.lisp trunk/src/uitoolkit/widgets/thread-context.lisp Log: added GFW:DEFMENU2 and GFW:MAKE-MENU, along with various bits of thread context infrastructure, and revised GFW:DEFMENU; updated docs Modified: trunk/NEWS.txt ============================================================================== --- trunk/NEWS.txt (original) +++ trunk/NEWS.txt Mon Jul 9 00:15:15 2007 @@ -1,4 +1,7 @@ +. Added a new macro GFW:DEFMENU2 and associated function GFW:MAKE-MENU + to allow applications to create reusable menu factories. + . Latest CFFI is required to take advantage of built-in support for the stdcall calling convention. Modified: trunk/README.txt ============================================================================== --- trunk/README.txt (original) +++ trunk/README.txt Mon Jul 9 00:15:15 2007 @@ -17,7 +17,7 @@ http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/cclan/asdf/ *note: ASDF is bundled with SBCL* - - CFFI (cffi-061208 or later) + - CFFI (cffi-XXXXXX or later) http://common-lisp.net/project/cffi/ - Closer to MOP @@ -44,7 +44,7 @@ ------------------------------------- Graphic-Forms currently supports Allegro CL 8.0, CLISP 2.40 or higher, -LispWorks 4.4.6, and SBCL 0.9.15 or higher (with a small patch). +LispWorks 4.4.6, and SBCL 1.0.5 or higher (with a small patch). Known Problems Modified: trunk/docs/manual/clhs-table.xml ============================================================================== --- trunk/docs/manual/clhs-table.xml (original) +++ trunk/docs/manual/clhs-table.xml Mon Jul 9 00:15:15 2007 @@ -2,7 +2,7 @@ @@ -12,6 +12,7 @@ + Modified: trunk/docs/manual/gfw-function-symbols.xml ============================================================================== --- trunk/docs/manual/gfw-function-symbols.xml (original) +++ trunk/docs/manual/gfw-function-symbols.xml Mon Jul 9 00:15:15 2007 @@ -3880,4 +3880,28 @@ + + + + + + The symbol identifying a menu factory + function previously defined via gfw:defmenu2. + + + + + gfw:menu + + + + This function invokes the menu factory function identified by + to create a new native menu hierarchy. + + + gfw:defmenu + gfw:menu-bar + + + Modified: trunk/docs/manual/gfw-macro-symbols.xml ============================================================================== --- trunk/docs/manual/gfw-macro-symbols.xml (original) +++ trunk/docs/manual/gfw-macro-symbols.xml Mon Jul 9 00:15:15 2007 @@ -398,6 +398,49 @@ + + + + + + A symbol identifying the new menu factory. + + + + + + Menu definition forms. + + + + + + + + function + + + + This macro defines a language for constructing menu hierarchies. For example: + +(gfw:defmenu2 + :name 'test-menu + :menu ((:item "&File" :submenu ((:item "&Open...") + (:item "&Save..." :disabled) + (:item :separator) + (:item "E&xit" :callback #'some-fn))) + (:item "&Tools" :submenu ((:item "&Fonts" :disabled) + (:item "&Colors" :checked))) + (:item "&Help" :submenu ((:item "&About" :image some-image))))) + + + + gfw:menu-bar + gfw:make-menu + gfw:defmenu + + + @@ -417,17 +460,23 @@ This macro defines a language for constructing menu hierarchies. For example: (gfw:defmenu - ((:item "&File" :submenu ((:item "&Open...") - (:item "&Save..." :disabled) - (:item :separator) - (:item "E&xit" :callback #'some-fn))) + ((:item "&File" :submenu ((:item "&Open...") + (:item "&Save..." :disabled) + (:item :separator) + (:item "E&xit" :callback #'some-fn))) (:item "&Tools" :submenu ((:item "&Fonts" :disabled) (:item "&Colors" :checked))) - (:item "&Help" :submenu ((:item "&About" :image some-image))))) + (:item "&Help" :submenu ((:item "&About" :image some-image))))) + Unlike gfw:defmenu2, this macro creates an anonymous + menu factory and then immediately invokes it, thus allowing the direct + construction of a menu hierarchy that can be immediately set on a window. + The factory function is then discarded. gfw:menu-bar + gfw:make-menu + gfw:defmenu2 Modified: trunk/docs/manual/introduction.xml ============================================================================== --- trunk/docs/manual/introduction.xml (original) +++ trunk/docs/manual/introduction.xml Mon Jul 9 00:15:15 2007 @@ -50,7 +50,7 @@ CLISP 2.40 or later LispWorks 4.4.6 - SBCL 0.9.15 or later + SBCL 1.0.5 or later a small patch to enable the stdcall calling convention for callbacks Modified: trunk/docs/website/index.html ============================================================================== --- trunk/docs/website/index.html (original) +++ trunk/docs/website/index.html Mon Jul 9 00:15:15 2007 @@ -50,7 +50,7 @@
  • Allegro CL 8.0 or later
  • CLISP 2.40 or later
  • LispWorks 5.0.1
  • -
  • SBCL 1.0.2 or later
  • +
  • SBCL 1.0.5 or later
  • Mailing Lists

    Modified: trunk/graphic-forms-uitoolkit.asd ============================================================================== --- trunk/graphic-forms-uitoolkit.asd (original) +++ trunk/graphic-forms-uitoolkit.asd Mon Jul 9 00:15:15 2007 @@ -142,7 +142,7 @@ (:file "list-box") (:file "menu") (:file "menu-item") - (:file "menu-language") + (:file "defmenu") (:file "progress-bar") (:file "event") (:file "scrolling-helper") @@ -157,7 +157,8 @@ (:file "layout") (:file "border-layout") (:file "heap-layout") - (:file "flow-layout"))))))))) + (:file "flow-layout") + (:file "defwindow"))))))))) (defmethod perform :after ((op load-op) (c (eql (find-system :graphic-forms-uitoolkit)))) (pushnew :graphic-forms *features*)) Modified: trunk/src/packages.lisp ============================================================================== --- trunk/src/packages.lisp (original) +++ trunk/src/packages.lisp Mon Jul 9 00:15:15 2007 @@ -442,6 +442,7 @@ #:default-message-filter #:default-widget #:defmenu + #:defmenu2 #:delay-of #:delete-all #:delete-item @@ -524,6 +525,7 @@ #:location #:lock #:locked-p + #:make-menu #:mapchildren #:maximize #:maximized-p Modified: trunk/src/tests/uitoolkit/event-tester.lisp ============================================================================== --- trunk/src/tests/uitoolkit/event-tester.lisp (original) +++ trunk/src/tests/uitoolkit/event-tester.lisp Mon Jul 9 00:15:15 2007 @@ -1,7 +1,7 @@ ;;;; ;;;; event-tester.lisp ;;;; -;;;; Copyright (C) 2006, Jack D. Unrue +;;;; Copyright (C) 2006-2007, Jack D. Unrue ;;;; All rights reserved. ;;;; ;;;; Redistribution and use in source and binary forms, with or without Copied: trunk/src/uitoolkit/widgets/defmenu.lisp (from r433, trunk/src/uitoolkit/widgets/menu-language.lisp) ============================================================================== --- trunk/src/uitoolkit/widgets/menu-language.lisp (original) +++ trunk/src/uitoolkit/widgets/defmenu.lisp Mon Jul 9 00:15:15 2007 @@ -1,7 +1,7 @@ ;;;; -;;;; menu-language.lisp +;;;; defmenu.lisp ;;;; -;;;; Copyright (C) 2006, Jack D. Unrue +;;;; Copyright (C) 2006-2007, Jack D. Unrue ;;;; All rights reserved. ;;;; ;;;; Redistribution and use in source and binary forms, with or without @@ -170,6 +170,8 @@ (defstruct menu-item-data text image) (defun generate-menusystem-code (sexp generator-sym) + (if (null sexp) + (error 'gfs:toolkit-error :detail "a value for :MENU is required")) (let ((code nil)) (mapcar #'(lambda (var) (setf code (append (process-item-form var generator-sym) code))) @@ -208,8 +210,28 @@ ;;; top-level API for the menu language ;;; +(defmacro defmenu2 (&key name menu) + (let ((gen (gensym)) + (tmp-name (gensym))) + `(let ((,tmp-name ,name)) + (if (get-menu-factory (thread-context) ,tmp-name) + (warn 'gfs:toolkit-warning + :detail (format nil "a menu with name ~S already exists" ,tmp-name))) + (put-menu-factory (thread-context) + ,tmp-name + (lambda () + (let ((,gen (make-instance 'win32-menu-generator))) + ,@(generate-menusystem-code menu gen) + (pop (menu-stack-of ,gen)))))))) + (defmacro defmenu (sexp) - (let ((gen (gensym))) - `(let ((,gen (make-instance 'win32-menu-generator))) - ,@(generate-menusystem-code sexp gen) - (pop (menu-stack-of ,gen))))) + `(funcall (defmenu2 :menu ,sexp))) + +(defun make-menu (menu-name) + (if (not (symbolp menu-name)) + (error 'toolkit-error :detail "the menu name must be a symbol")) + (let ((menu-fn (get-menu-factory (thread-context) menu-name))) + (unless menu-fn + (error 'gfs:toolkit-error + :detail (format nil "~a does not identify any existing menu" menu-name))) + (funcall menu-fn))) Added: trunk/src/uitoolkit/widgets/defwindow.lisp ============================================================================== --- (empty file) +++ trunk/src/uitoolkit/widgets/defwindow.lisp Mon Jul 9 00:15:15 2007 @@ -0,0 +1,35 @@ +;;;; +;;;; defwindow.lisp +;;;; +;;;; Copyright (C) 2007, Jack D. Unrue +;;;; All rights reserved. +;;;; +;;;; Redistribution and use in source and binary forms, with or without +;;;; modification, are permitted provided that the following conditions +;;;; are met: +;;;; +;;;; 1. Redistributions of source code must retain the above copyright +;;;; notice, this list of conditions and the following disclaimer. +;;;; +;;;; 2. Redistributions in binary form must reproduce the above copyright +;;;; notice, this list of conditions and the following disclaimer in the +;;;; documentation and/or other materials provided with the distribution. +;;;; +;;;; 3. Neither the names of the authors nor the names of its contributors +;;;; may be used to endorse or promote products derived from this software +;;;; without specific prior written permission. +;;;; +;;;; THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS "AS IS" AND ANY +;;;; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +;;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS- +;;;; CLAIMED. IN NO EVENT SHALL THE AUTHORS AND CONTRIBUTORS BE LIABLE FOR ANY +;;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +;;;; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +;;;; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +;;;; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +;;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +;;;; + +(in-package :graphic-forms.uitoolkit.widgets) + Modified: trunk/src/uitoolkit/widgets/thread-context.lisp ============================================================================== --- trunk/src/uitoolkit/widgets/thread-context.lisp (original) +++ trunk/src/uitoolkit/widgets/thread-context.lisp Mon Jul 9 00:15:15 2007 @@ -58,6 +58,8 @@ (top-level-visitor-func :initform nil :accessor top-level-visitor-func) (top-level-visitor-results :initform nil :accessor top-level-visitor-results) (utility-hwnd :initform (cffi:null-pointer) :accessor utility-hwnd) + (menu-factories :initform (make-hash-table :test #'eql)) + (window-factories :initform (make-hash-table :test #'eql)) (widget-in-progress :initform nil :accessor widget-in-progress)) (:documentation "Thread context objects maintain 'global' data for each thread possessing an event loop.")) @@ -280,3 +282,27 @@ (event-wparam event) wparam (event-lparam event) lparam) event)) + +(defun get-menu-factory (tc menu-name) + "Returns a function that creates a menu hierarchy based on a template defined via DEFMENU2." + (gethash menu-name (slot-value tc 'menu-factories))) + +(defun put-menu-factory (tc menu-name fn) + "Stores a function that creates a menu hierarchy based on a template defined via DEFMENU2." + (when menu-name + (if (not (symbolp menu-name)) + (error 'gfs:toolkit-error :detail "the menu name must be a symbol")) + (setf (gethash menu-name (slot-value tc 'menu-factories)) fn)) + fn) + +(defun get-window-factory (tc win-name) + "Returns a function that creates a window based on a template defined via DEFWINDOW." + (gethash win-name (slot-value tc 'window-factories))) + +(defun put-window-factory (tc win-name fn) + "Stores a function that creates a window based on a template defined via DEFWINDOW." + (when win-name + (if (not (symbolp win-name)) + (error 'gfs:toolkit-error :detail "the window name must be a symbol")) + (setf (gethash win-name (slot-value tc 'win-factories)) fn)) + fn) From junrue at common-lisp.net Mon Jul 9 04:17:22 2007 From: junrue at common-lisp.net (junrue at common-lisp.net) Date: Mon, 9 Jul 2007 00:17:22 -0400 (EDT) Subject: [graphic-forms-cvs] r469 - trunk/src/tests/uitoolkit Message-ID: <20070709041722.1E1FA61059@common-lisp.net> Author: junrue Date: Mon Jul 9 00:17:21 2007 New Revision: 469 Modified: trunk/src/tests/uitoolkit/event-tester.lisp Log: revised event-tester menu creation to test GFW:DEFMENU2 and GFW:MAKE-MENU Modified: trunk/src/tests/uitoolkit/event-tester.lisp ============================================================================== --- trunk/src/tests/uitoolkit/event-tester.lisp (original) +++ trunk/src/tests/uitoolkit/event-tester.lisp Mon Jul 9 00:17:21 2007 @@ -289,22 +289,24 @@ (setf *event-counter* 0) (let ((echo-md (make-instance 'event-tester-echo-dispatcher)) (exit-md (make-instance 'event-tester-exit-dispatcher)) - (menubar nil)) + (menu-factory nil)) (setf *event-tester-window* (make-instance 'gfw:top-level :dispatcher (make-instance 'event-tester-window-events) :style '(:workspace :horizontal-scrollbar :vertical-scrollbar))) (initialize-scrollbars) - (setf menubar (gfw:defmenu ((:item "&File" :callback #'manage-file-menu - :submenu ((:item "Timer" :callback #'manage-timer) - (:item "" :separator) - (:item "E&xit" :dispatcher exit-md))) - (:item "&Test Menu" :dispatcher echo-md - :submenu ((:item "&Checked Item" :checked :dispatcher echo-md) - (:item "&Submenu" :dispatcher echo-md - :submenu ((:item "&Item A" :dispatcher echo-md :disabled) - (:item "&Item B" :dispatcher echo-md))))) - (:item "&Help" :dispatcher echo-md - :submenu ((:item "&About" :dispatcher echo-md)))))) - (setf (gfw:menu-bar *event-tester-window*) menubar) + (setf menu-factory + (gfw:defmenu2 :name 'event-tester-menu + :menu ((:item "&File" :callback #'manage-file-menu + :submenu ((:item "Timer" :callback #'manage-timer) + (:item "" :separator) + (:item "E&xit" :dispatcher exit-md))) + (:item "&Test Menu" :dispatcher echo-md + :submenu ((:item "&Checked Item" :checked :dispatcher echo-md) + (:item "&Submenu" :dispatcher echo-md + :submenu ((:item "&Item A" :dispatcher echo-md :disabled) + (:item "&Item B" :dispatcher echo-md))))) + (:item "&Help" :dispatcher echo-md + :submenu ((:item "&About" :dispatcher echo-md)))))) + (setf (gfw:menu-bar *event-tester-window*) (gfw:make-menu 'event-tester-menu)) (setf (gfw:image *event-tester-window*) (make-instance 'gfg:icon-bundle :file (merge-pathnames "default.ico"))) (gfw:show *event-tester-window* t)))