Macros and guiserver?
Posted: Mon Jul 04, 2016 12:16 pm
Hi!
I am experimenting with macros to do more "declarative" setups in guiserver. Here is a macro that I have created to make a three button setup:
I call it like this:
This creates a panel (DC-East) that has three buttons (DC-East-Next, DC-East-View and DC-East-Kill). They're all set up and ready to go.
However, I can't figure out how to pass in an optional event handler for each button and have the macro assemble it correctly for the gs:button call. I want to do something like this
I am just getting invalid function or macro expansion problems when I try to do this. Any suggestions?
Thanks!
I am experimenting with macros to do more "declarative" setups in guiserver. Here is a macro that I have created to make a three button setup:
Code: Select all
(define-macro (button3 _parent _name _buttons)
(letn ((panel (sym (string (eval _parent) "-" (eval _name))))
(slots '("west" "center" "east"))
(bname nil)
(i nil))
(gs:panel panel)
(gs:set-border-layout panel)
(dotimes (i (length (eval _buttons)))
(setq bname (sym (string panel "-" ((eval _buttons) i 0))))
(println "Setting up " bname)
(gs:button bname 'gs:no-action ((eval _buttons) i 1))
(gs:add-to panel bname (slots i))
)))
Code: Select all
(button3 'DC 'East '((Next "-->") (View "<o>") (Kill "X")))
However, I can't figure out how to pass in an optional event handler for each button and have the macro assemble it correctly for the gs:button call. I want to do something like this
Code: Select all
;; The "View" button doesn't have a handler yet, should default to gs:no-action.
(button3 'DC 'East '((Next "-->" 'next-card) (View "<o>") (Kill "X" 'kill-card)))
Thanks!