Kenneth Tilton wrote:
> 
> Werner Thie wrote:
>> Hi
>>
>> Don't know if Ken with it's server side UI generation has a fancy 
>> designer at hand (my LISP experience was before GUIs) but going further 
>> than aggregating a few elements, UI writing and maintenance becomes a 
>> pain real fast.
> 
> What we do in Lisp is use macros and other neat features of the language 
> to make the code assembling a GUI so dense that it is faster to juggle 
> the code than it would be to mess with a GUI builder:
> 
> (defun search-panel-kt (self)
>    (hbox (:align-y 'middle :spacing 12)
>      (:allow-grow-y :js-false
>        :padding 4)
>      (lbl "Search for:")
>      (textfield :symbol-string ;; WARNING -- new and untested
>        :add '(:flex 1)
>        :allow-grow-x t
>        :onchangevalue (lambda (self req)
>                         (let ((sympart (req-val req "value")))
>                           (setf (sym-seg (u^ qxl-session)) sympart))))
>      (button "Search" (:enabled (c? (> (length (value (psib))) 1)))
>        :onexec (b-when sympart (value (psib))
>                  (print `(:sympart-onexec ,sympart))
>                  (setf (sym-seg (u^ qxl-session)) sympart)))))
> 
> And because it is code (and because I am driving qooxdoo dynamically 
> from the code) I can move things around in the code and hit refresh in 
> the browser and see the result. Even against a "build" version, which I 
> only need to regenerate if I start using a new qx class.
> 
> Note also the "enabled" rule*. In this case it is just looking at 
> another widget, but it could also being looking at business data and 
> making a decision based on business logic. Even better, instead of just 
> deciding the enabled state of a widget, a rule for the children of a 
> composite widget could decide to put up a whole new (or just slightly 
> modified interface) based on business logic. This lets GUIs be leaner, 
> smarter, and more helpful, showing users only what is appropriate for 
> the state of their particular browsing experience as it unfolds.
> 
> kt
> 
> * Actually, I took that rule out of the demo. A bit of trouble detecting 
> /as they type/ (that being the whole idea) whether the field is empty or 
> not -- the (I think) "input" event happens before the text gets updated, 
> so I ended up guessing (badly) based on the keystrokes whether the field 
> was empty or not and punted on that.
> 

[A link to the subject og this stuff: http://teamalgebra.com/]

I meant to share the remote table model, which relies on a subclass I 
created of the qx remote model. With that, the three callbacks are 
parameters so there is no need to subclass further, and then I write 
code like this:

(defun symbols-found-rethought (self)
   (make-kid 'qxl-table-remote
     :md-name :sym-info-table
     :add '(:flex 1)
     :allow-grow-x t
     :allow-grow-y t

     ;; next three are for data model delegate
     ;; the first is a Lisp anonymous function. The sort fn could be
     ;; as well, it is not much longer. See below for those.
     :cb-row-count (lambda (self req)
                     (declare (ignore req))
                     (length (sym-info (u^ qxl-session))))
     :cb-load-row-data 'sym-get
     :cb-sort-row-data 'sym-sort

     :block-size 100
     ;; column attributes get dispersed variously to table, table model,
     ;; table column model, resize behavior....
     :columns (flet ((mtc (n i &rest iargs)
                       (apply 'make-table-column :name n :id i iargs)))
                (list
                 (mtc "Symbol Name" 'name :width 192)
                 (mtc "Package" 'pkg)
                 (mtc "Function" 'fntype)
                 (mtc "Setf" 'setf? :width 48 :renderer 'boolean)
                 (mtc "Var" 'var? :width 48)
                 (mtc "Class" 'class? :width 48 :renderer 'boolean)
                 (mtc "Exp" 'exported? :width 48 :renderer 'boolean)
                 ))))

(defun sym-get (self req)
   (let* ((start (req-val req "start"))
          (row-count (req-val req "count")))
     (setf start (parse-integer start))
     (setf row-count (parse-integer row-count))

     (loop for sym in (sym-info (u^ qxl-session))
         for n upfrom 0
         when (< (1- start) n (+ start row-count))
         collect (list
                  (cons :name (symbol-info-name sym))
                  (cons :pkg (b-if nns (remove "" (package-nicknames 
(symbol-info-pkg sym))
                                         :test 'string-equal)
                               (car nns)
                               (package-name (symbol-info-pkg sym))))
                  (cons :fntype (symbol-info-fntype sym))
                  (cons :var? (symbol-info-var? sym))
                  (cons :setf? (symbol-info-setf? sym))
                  (cons :class? (symbol-info-class? sym))
                  (cons :exported? (symbol-info-exported? sym))))))

(defun sym-sort (self req)
   (prog1 nil
     (setf (sym-sort-spec (u^ qxl-session))
       (list (req-val req "key")(req-val req "order")))))

kt

-- 
http://www.stuckonalgebra.com
"The best Algebra tutorial program I have seen... in a class by itself." 
Macworld

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to