From marsijanin at gmail.com Fri Oct 2 16:33:01 2009 From: marsijanin at gmail.com (marsijanin at gmail.com) Date: Fri, 02 Oct 2009 20:33:01 +0400 Subject: [cells-gtk-devel] cells-gtk & cl-2d Message-ID: <873a61kb7m.fsf@fobos.mars> Good ${current_time_of_day} I'm trying to use cl-2d plotting library (http://github.com/tpapp/cl-2d) with cl-cairo2 support in cells-gtk. First I tried to make an cl-2d:frame from cells-gtk:cairo-context of cells-gtk:cairo-drawing-area: CL-USER> (in-package :cgtk) # CGTK> (defmodel test-app (gtk-app) () (:default-initargs :title "Test" :position :center :width 800 :height 600 :kids (c? (the-kids (mk-hbox :kids (list (make-instance 'cairo-drawing-area :width 640 :height 480 :fm-parent *parent* :md-name :draw :expand t :fill t) (mk-button :label "test" :on-clicked (callback (w e d) ;; cl-cairo2::with-gtk-context dose not setup ;; width, height & pixel-based-p properties of the context ;; needed by cl-2d:as-frame (with-accessors ((widget-width width) (widget-height height) (context cairo-context)) (find-widget :draw) (with-slots ((context-width cl-cairo2:width) (context-height cl-cairo2:height) (context-pixel-based-p cl-cairo2:pixel-based-p)) context (setf context-width widget-width context-height widget-height context-pixel-based-p t)) (print (cl-2d::vertical-interval (cl-2d:as-frame context)))))))))))) # CGTK> (cells-gtk-init) "----------UTILSRESET----------------------------------" #() CGTK> (start-win 'test-app) "----------UTILSRESET----------------------------------" 0> registering handlers for #.(sb-sys:int-sap #x080d2898) 0> c-link> query link :draw cells-store2 nil # ;; <--- vertical-interval of the cl-2d:frame, created by calling cl-2d:frame 0> c-link> kick link :draw cells-store2 # 0> not-to-be cairo-drawing area erasing everything drawTEST-APP6 And then I tried to call cl-2d:plot-simple on with cl-2d:frame and got strange error about unknown CAIRO_STATUS_T value: CGTK> (defmodel test-app (gtk-app) () (:default-initargs :title "Test" :position :center :width 800 :height 600 :kids (c? (the-kids (mk-hbox :kids (list (make-instance 'cairo-drawing-area :width 640 :height 480 :fm-parent *parent* :md-name :draw :expand t :fill t) (mk-button :label "test" :on-clicked (callback (w e d) ;; cl-cairo2::with-gtk-context dose not setup ;; width, height & pixel-based-p properties of the context ;; needed by cl-2d:as-frame (with-accessors ((widget-width width) (widget-height height) (context cairo-context)) (find-widget :draw) (with-slots ((context-width cl-cairo2:width) (context-height cl-cairo2:height) (context-pixel-based-p cl-cairo2:pixel-based-p)) context (setf context-width widget-width context-height widget-height context-pixel-based-p t)) (cl-2d:plot-simple (cl-2d:as-frame context) (cl-2d:make-interval 1 2) (cl-2d:make-interval 3 4) :x-title "x" :y-title "y")))))))))) STYLE-WARNING: redefining SHARED-INITIALIZE :AFTER (# #) in DEFMETHOD # CGTK> (start-win 'test-app) 1> c-link> kick link :draw cells-store2 # 0> registering handlers for #.(sb-sys:int-sap #x0810f8c0) 0> c-link> query link :draw cells-store2 # 0> show error message 0> md-awaken :after 1> processing dlg .2> running dialog 1> showed dialog -9 :no 1> destroying self (not-to-be) 0> >>>> ERROR REPORTING --> # And here is debugger output: -1208503376 is not defined as a value for enum type #. [Condition of type SIMPLE-ERROR] Restarts: 0: [TERMINATE-THREAD] Terminate this thread (#) Backtrace: 0: ((LAMBDA (CELLS-GTK::C2)) #) Locals: CELLS-GTK::C2 = # 1: (CELLS-GTK::MAIN-LOOP) Locals: SB-KERNEL:*HANDLER-CLUSTERS* = : SB-KERNEL:*RESTART-CLUSTERS* = : #:COUNT[MAIN-LOOP]594 = : #:G600 = (#) #:NEXT[MAIN-LOOP]592 = : #:START[MAIN-LOOP]593 = : 2: ((FLET CELLS-GTK::GTK-THREAD)) Locals: CELLS-GTK::GTK-MAIN-THREAD = # 3: ((LAMBDA ())) Locals: CELLS-GTK::GTK-MAIN-THREAD = # CELLS-GTK::SO = # 4: ((LAMBDA ())) [No Locals] 5: ((FLET #:WITHOUT-INTERRUPTS-BODY-[BLOCK375]380)) [No Locals] 6: ((FLET SB-THREAD::WITH-MUTEX-THUNK)) [No Locals] Catch-tags: SB-IMPL::%END-OF-THE-WORLD SB-INT:TOPLEVEL-CATCHER 7: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-MUTEX]267)) [No Locals] 8: (SB-THREAD::CALL-WITH-MUTEX ..) Locals: SB-DEBUG::ARG-0 = # SB-DEBUG::ARG-1 = #S(SB-THREAD:MUTEX ..) SB-DEBUG::ARG-2 = # SB-DEBUG::ARG-3 = T 9: ((LAMBDA ())) [No Locals] 10: ("foreign function: #x8063A3B") 11: ("foreign function: #x80523BD") 12: ("foreign function: #x805BC20") 13: ("foreign function: #xB7FA965C") Can anyone please help to solve this problem? Best, Nikolay V. Razbegaev. From peter.hildebrandt at gmail.com Fri Oct 2 17:26:42 2009 From: peter.hildebrandt at gmail.com (Peter Hildebrandt) Date: Fri, 2 Oct 2009 19:26:42 +0200 Subject: [cells-gtk-devel] cells-gtk & cl-2d In-Reply-To: <873a61kb7m.fsf@fobos.mars> References: <873a61kb7m.fsf@fobos.mars> Message-ID: <7758b2680910021026n7b57cf23m58739b3d4f4921ed@mail.gmail.com> Hi Nikolay, I am not familiar with cl-2d, therefore just a few general suggestions (1) Have you tried the cl-cairo2 mailing list? At first glance this looks more like a cl-cairo than like a cells-gtk problem (2) Try deactivating threading (you might need to recompile the whole thing to make sure everything is up to date). There is a constant in one of the central files (cells-gtk.asd ?). That might give you better debugging output (3) Have you looked into the 2d drawing functions I included in the drawing-area widget? Of course I don't know what you are trying to do, but possibly the approach there will work for you. Currently it only supports a few basic shapes (circles, arcs, rectangles, lines, arrows), but on the plus side, there is full support for user interaction (mouse-over events, drag and drop support, etc.) Good luck Peter On Fri, Oct 2, 2009 at 6:33 PM, wrote: > Good ${current_time_of_day} > > I'm trying to use cl-2d plotting library (http://github.com/tpapp/cl-2d) > with cl-cairo2 support in cells-gtk. First I tried to make an > cl-2d:frame from cells-gtk:cairo-context of cells-gtk:cairo-drawing-area: > > > CL-USER> (in-package :cgtk) > # > CGTK> (defmodel test-app (gtk-app) > () > (:default-initargs :title "Test" > :position :center > :width 800 :height 600 > :kids (c? > (the-kids > (mk-hbox > :kids > (list > (make-instance 'cairo-drawing-area :width 640 :height 480 > :fm-parent *parent* :md-name :draw > :expand t :fill t) > (mk-button :label "test" > :on-clicked (callback (w e d) > ;; cl-cairo2::with-gtk-context dose > not setup > ;; width, height & pixel-based-p > properties of the context > ;; needed by cl-2d:as-frame > (with-accessors ((widget-width > width) > (widget-height > height) > (context > cairo-context)) (find-widget :draw) > (with-slots ((context-width > cl-cairo2:width) > (context-height > cl-cairo2:height) > > (context-pixel-based-p cl-cairo2:pixel-based-p)) context > (setf context-width widget-width > context-height widget-height > context-pixel-based-p t)) > (print (cl-2d::vertical-interval > (cl-2d:as-frame context)))))))))))) > > # > CGTK> (cells-gtk-init) > > "----------UTILSRESET----------------------------------" > #() > CGTK> (start-win 'test-app) > > "----------UTILSRESET----------------------------------" > 0> registering handlers for #.(sb-sys:int-sap #x080d2898) > 0> c-link> query link :draw cells-store2 nil > # ;; <--- vertical-interval of the > cl-2d:frame, created by calling cl-2d:frame > 0> c-link> kick link :draw cells-store2 # > 0> not-to-be cairo-drawing area erasing everything drawTEST-APP6 > > And then I tried to call cl-2d:plot-simple on with cl-2d:frame and > got strange error about unknown CAIRO_STATUS_T value: > > > CGTK> (defmodel test-app (gtk-app) > () > (:default-initargs :title "Test" > :position :center > :width 800 :height 600 > :kids (c? > (the-kids > (mk-hbox > :kids > (list > (make-instance 'cairo-drawing-area :width 640 :height 480 > :fm-parent *parent* :md-name :draw > :expand t :fill t) > (mk-button :label "test" > :on-clicked (callback (w e d) > ;; cl-cairo2::with-gtk-context dose > not setup > ;; width, height & pixel-based-p > properties of the context > ;; needed by cl-2d:as-frame > (with-accessors ((widget-width > width) > (widget-height > height) > (context > cairo-context)) (find-widget :draw) > (with-slots ((context-width > cl-cairo2:width) > (context-height > cl-cairo2:height) > > (context-pixel-based-p cl-cairo2:pixel-based-p)) context > (setf context-width widget-width > context-height widget-height > context-pixel-based-p t)) > (cl-2d:plot-simple (cl-2d:as-frame > context) > > (cl-2d:make-interval 1 2) > > (cl-2d:make-interval 3 4) > :x-title "x" > :y-title > "y")))))))))) > > > STYLE-WARNING: > redefining SHARED-INITIALIZE :AFTER (# > #) in DEFMETHOD > # > CGTK> (start-win 'test-app) > 1> c-link> kick link :draw cells-store2 # > 0> registering handlers for #.(sb-sys:int-sap #x0810f8c0) > 0> c-link> query link :draw cells-store2 # > 0> show error message > 0> md-awaken :after > 1> processing dlg > .2> running dialog > 1> showed dialog -9 :no > 1> destroying self (not-to-be) > 0> >>>> ERROR REPORTING --> # > > And here is debugger output: > > > -1208503376 is not defined as a value for enum type # CL-CAIRO2::CAIRO_STATUS_T>. > [Condition of type SIMPLE-ERROR] > > Restarts: > 0: [TERMINATE-THREAD] Terminate this thread (# RUNNING {B0D1409}>) > > Backtrace: > 0: ((LAMBDA (CELLS-GTK::C2)) #) > Locals: > CELLS-GTK::C2 = # > 1: (CELLS-GTK::MAIN-LOOP) > Locals: > SB-KERNEL:*HANDLER-CLUSTERS* = : > SB-KERNEL:*RESTART-CLUSTERS* = : > #:COUNT[MAIN-LOOP]594 = : > #:G600 = (#) > #:NEXT[MAIN-LOOP]592 = : > #:START[MAIN-LOOP]593 = : > 2: ((FLET CELLS-GTK::GTK-THREAD)) > Locals: > CELLS-GTK::GTK-MAIN-THREAD = # RUNNING {B0D1409}> > 3: ((LAMBDA ())) > Locals: > CELLS-GTK::GTK-MAIN-THREAD = # RUNNING {B0D1409}> > CELLS-GTK::SO = # > 4: ((LAMBDA ())) > [No Locals] > 5: ((FLET #:WITHOUT-INTERRUPTS-BODY-[BLOCK375]380)) > [No Locals] > 6: ((FLET SB-THREAD::WITH-MUTEX-THUNK)) > [No Locals] > Catch-tags: > SB-IMPL::%END-OF-THE-WORLD > SB-INT:TOPLEVEL-CATCHER > 7: ((FLET #:WITHOUT-INTERRUPTS-BODY-[CALL-WITH-MUTEX]267)) > [No Locals] > 8: (SB-THREAD::CALL-WITH-MUTEX ..) > Locals: > SB-DEBUG::ARG-0 = # {AF142205}> > SB-DEBUG::ARG-1 = #S(SB-THREAD:MUTEX ..) > SB-DEBUG::ARG-2 = # {B0D1409}> > SB-DEBUG::ARG-3 = T > 9: ((LAMBDA ())) > [No Locals] > 10: ("foreign function: #x8063A3B") > 11: ("foreign function: #x80523BD") > 12: ("foreign function: #x805BC20") > 13: ("foreign function: #xB7FA965C") > > > Can anyone please help to solve this problem? > > Best, Nikolay V. Razbegaev. > > _______________________________________________ > cells-gtk-devel site list > cells-gtk-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cells-gtk-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kielhorn.martin at googlemail.com Tue Oct 6 18:37:34 2009 From: kielhorn.martin at googlemail.com (Martin Kielhorn) Date: Tue, 6 Oct 2009 19:37:34 +0100 Subject: [cells-gtk-devel] Editable Table Message-ID: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> Hi, I want a table with numbers and when I click on one number I want to change it to a new value. I managed to copy the table from test-gtk/test-tree-view.lisp and I added :editable t to the def-columns call. I can edit the number, but the system doesn't store the value back into one of my variables, e.g. (position$ (nth 2 *items*)). So when I press enter after the edit, the old value will be shown again. I hoped the :on-edit slot of listbox could be used for this task but the format is never executed. Or is it only possible to do it like in the Cells-Tree-View example? It seemed quite complicated to me, as I don't want two copies of branched trees. I think that is the next thing I would be glad to hear how :on-edit is to be used. [I run the following code in sbcl with threads.] (require :asdf) (require :cells-gtk) (defpackage :mk (:use :cells :cl :cells-gtk)) (in-package :mk) (defmodel myapp (gtk-app) () (:default-initargs :width 400 :height 300 :md-name :mk-top :kids (c-in nil))) (init-gtk) (start-win 'myapp) (defmodel listbox-test-item () ((position :accessor position$ :initarg :position :initform nil) (curvature :accessor curvature$ :initarg :curvature :initform nil))) (defparameter *items* (list (make-be 'listbox-test-item :position (coerce (random 20) 'double-float) :curvature (coerce (random 20) 'double-float)) (make-be 'listbox-test-item :position (coerce (random 20) 'double-float) :curvature (coerce (random 20) 'double-float)))) (let ((top (find-widget :mk-top))) (setf (kids top) (list (mk-vbox :fm-parent top :kids (kids-list? (mk-listbox :md-name :listbox :selection-mode :single :columns (def-columns (:double (:title "Position") (lambda (node) '(:editable t))) (:double (:title "Curvature"))) :items *items* :print-fn (lambda (item) (list (position$ item) (curvature$ item))) :on-edit (lambda (node col new-val) (format t "~a~%" (list node col new-val))))))))) Regards, Martin -- Martin Kielhorn Randall Division of Cell & Molecular Biophysics King's College London, New Hunt's House Guy's Campus, London SE1 1UL, U.K. tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435 -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.hildebrandt at gmail.com Tue Oct 6 19:52:46 2009 From: peter.hildebrandt at gmail.com (Peter Hildebrandt) Date: Tue, 6 Oct 2009 21:52:46 +0200 Subject: [cells-gtk-devel] Editable Table In-Reply-To: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> References: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> Message-ID: <7758b2680910061252g4a2fb2f3ta1a3b161be1cbd5@mail.gmail.com> Hi Martin, This should be possible--and as a matter of fact I used similar functionality in my MSc project. I had a table in which I could enter numbers, symbols, and even functions (which--using cells--got compiled in real time like this: (compiled-fn :initform (c? (compile ^fn))) ) I will try to locate the code later (unfortunately I am on a business trip right now, but I might find it somewhere anyways ...) Best Peter PS. We're seeing a lot of traffic (comparably) on this list lately. It's great to see people actually using cells-gtk. On Tue, Oct 6, 2009 at 8:37 PM, Martin Kielhorn < kielhorn.martin at googlemail.com> wrote: > Hi, > I want a table with numbers and when I click on one number I want to change > it to > a new value. I managed to copy the table from test-gtk/test-tree-view.lisp > and I added > :editable t to the def-columns call. I can edit the number, but the system > doesn't store > the value back into one of my variables, e.g. (position$ (nth 2 *items*)). > So when I press > enter after the edit, the old value will be shown again. > > I hoped the :on-edit slot of listbox could be used for this task but the > format is never executed. > > Or is it only possible to do it like in the Cells-Tree-View example? > It seemed quite complicated to me, as I don't want two copies of branched > trees. > I think that is the next thing I would be glad to hear how :on-edit is to > be used. > > [I run the following code in sbcl with threads.] > > (require :asdf) > (require :cells-gtk) > > (defpackage :mk > (:use :cells :cl :cells-gtk)) > > (in-package :mk) > > (defmodel myapp (gtk-app) > () > (:default-initargs :width 400 :height 300 > :md-name :mk-top > :kids (c-in nil))) > (init-gtk) > (start-win 'myapp) > > (defmodel listbox-test-item () > ((position :accessor position$ :initarg :position :initform nil) > (curvature :accessor curvature$ :initarg :curvature :initform nil))) > > (defparameter *items* > (list (make-be 'listbox-test-item > :position (coerce (random 20) 'double-float) > :curvature (coerce (random 20) 'double-float)) > (make-be 'listbox-test-item > :position (coerce (random 20) 'double-float) > :curvature (coerce (random 20) 'double-float)))) > > (let ((top (find-widget :mk-top))) > (setf > (kids top) > (list > (mk-vbox > :fm-parent top > :kids > (kids-list? > (mk-listbox :md-name :listbox > :selection-mode :single > :columns (def-columns > (:double (:title "Position") (lambda (node) '(:editable > t))) > (:double (:title "Curvature"))) > :items *items* > :print-fn (lambda (item) > (list (position$ item) > (curvature$ item))) > :on-edit (lambda (node col new-val) > (format t "~a~%" (list node col new-val))))))))) > > > Regards, Martin > -- > Martin Kielhorn > Randall Division of Cell & Molecular Biophysics > King's College London, New Hunt's House > Guy's Campus, London SE1 1UL, U.K. > tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435 > > _______________________________________________ > cells-gtk-devel site list > cells-gtk-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cells-gtk-devel > -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter.hildebrandt at gmail.com Wed Oct 7 07:23:16 2009 From: peter.hildebrandt at gmail.com (Peter Hildebrandt) Date: Wed, 7 Oct 2009 09:23:16 +0200 Subject: [cells-gtk-devel] Editable Table In-Reply-To: <7758b2680910061252g4a2fb2f3ta1a3b161be1cbd5@mail.gmail.com> References: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> <7758b2680910061252g4a2fb2f3ta1a3b161be1cbd5@mail.gmail.com> Message-ID: <7758b2680910070023t4fc4c1d3xf6edd9ce15976f13@mail.gmail.com> Hi Martin, here's the object inspector I wrote: (defmodel net-ed-object-inspector (frame) () (:default-initargs :kids (list (mk-listbox :md-name :active-object-desc :selection-mode :single :on-edited (lambda (self item col type new-value) (declare (ignorable self col type)) ;; accept the editing when it is an editable entry (when (desc-item-editable item) (deb "edited to ~a --> calling setter" new-value) (funcall (desc-item-setter item) new-value))) :columns (def-columns (:string (:title "Name")) (:string (:title "Value") #'(lambda (var) (declare (ignore var))) t) (:boolean (:title "r/w"))) :items (c? (when-bind (obj (active-object (upper self net-editor))) (desc-items obj))) :print-fn (lambda (item) (when item (list (desc-item-label item) (desc-item-getter item) (desc-item-editable item)))))))) Where desc-item works like this (defstruct desc-item label getter setter editable) and is typically created with make-desc like this ...... (:readers ((desc-items (make-desc (color :editable t) (tag :editable t)))) make-desc is defined as (defmacro make-desc (&rest fields) `(list ;; heading (make-desc-item :label "Type" :getter (format nil "~:(~a~)" (type-of self)) :setter #'(lambda (new-val) (declare (ignore new-val))) :editable nil) ,@@(loop for field-desc in fields for field-spec = (if (atom field-desc) (list field-desc) field-desc) for field = (first field-spec) for field-properties = (rest field-spec) for editable = (getf field-properties :editable) collecting `(make-desc-item :label ,(format nil "~:(~a~)" field) :getter (prin1-to-string (,(intern (string field) :net-ed) self)) :setter #'(lambda (new-val) (setf (,(intern (string field) :net-ed) self) (read-from-string new-val))) :editable ,editable)))) Hope you'll be able to deduct the necessary parts from this code. I gotta get back to work now ... Kind regards Peter On Tue, Oct 6, 2009 at 9:52 PM, Peter Hildebrandt < peter.hildebrandt at gmail.com> wrote: > > Hi Martin, > > This should be possible--and as a matter of fact I used similar > functionality in my MSc project. I had a table in which I could enter > numbers, symbols, and even functions (which--using cells--got compiled in > real time like this: (compiled-fn :initform (c? (compile ^fn))) ) > > I will try to locate the code later (unfortunately I am on a business trip > right now, but I might find it somewhere anyways ...) > > Best > Peter > > PS. We're seeing a lot of traffic (comparably) on this list lately. It's > great to see people actually using cells-gtk. > > On Tue, Oct 6, 2009 at 8:37 PM, Martin Kielhorn < > kielhorn.martin at googlemail.com> wrote: > >> Hi, >> I want a table with numbers and when I click on one number I want to >> change it to >> a new value. I managed to copy the table from test-gtk/test-tree-view.lisp >> and I added >> :editable t to the def-columns call. I can edit the number, but the system >> doesn't store >> the value back into one of my variables, e.g. (position$ (nth 2 *items*)). >> So when I press >> enter after the edit, the old value will be shown again. >> >> I hoped the :on-edit slot of listbox could be used for this task but the >> format is never executed. >> >> Or is it only possible to do it like in the Cells-Tree-View example? >> It seemed quite complicated to me, as I don't want two copies of branched >> trees. >> I think that is the next thing I would be glad to hear how :on-edit is to >> be used. >> >> [I run the following code in sbcl with threads.] >> >> (require :asdf) >> (require :cells-gtk) >> >> (defpackage :mk >> (:use :cells :cl :cells-gtk)) >> >> (in-package :mk) >> >> (defmodel myapp (gtk-app) >> () >> (:default-initargs :width 400 :height 300 >> :md-name :mk-top >> :kids (c-in nil))) >> (init-gtk) >> (start-win 'myapp) >> >> (defmodel listbox-test-item () >> ((position :accessor position$ :initarg :position :initform nil) >> (curvature :accessor curvature$ :initarg :curvature :initform nil))) >> >> (defparameter *items* >> (list (make-be 'listbox-test-item >> :position (coerce (random 20) 'double-float) >> :curvature (coerce (random 20) 'double-float)) >> (make-be 'listbox-test-item >> :position (coerce (random 20) 'double-float) >> :curvature (coerce (random 20) 'double-float)))) >> >> (let ((top (find-widget :mk-top))) >> (setf >> (kids top) >> (list >> (mk-vbox >> :fm-parent top >> :kids >> (kids-list? >> (mk-listbox :md-name :listbox >> :selection-mode :single >> :columns (def-columns >> (:double (:title "Position") (lambda (node) '(:editable >> t))) >> (:double (:title "Curvature"))) >> :items *items* >> :print-fn (lambda (item) >> (list (position$ item) >> (curvature$ item))) >> :on-edit (lambda (node col new-val) >> (format t "~a~%" (list node col new-val))))))))) >> >> >> Regards, Martin >> -- >> Martin Kielhorn >> Randall Division of Cell & Molecular Biophysics >> King's College London, New Hunt's House >> Guy's Campus, London SE1 1UL, U.K. >> tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435 >> >> _______________________________________________ >> cells-gtk-devel site list >> cells-gtk-devel at common-lisp.net >> http://common-lisp.net/mailman/listinfo/cells-gtk-devel >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kielhorn.martin at googlemail.com Wed Oct 7 08:36:16 2009 From: kielhorn.martin at googlemail.com (Martin Kielhorn) Date: Wed, 7 Oct 2009 09:36:16 +0100 Subject: [cells-gtk-devel] Fwd: Editable Table In-Reply-To: <1ae41e820910070130k272441f9qf8859ba4a469170c@mail.gmail.com> References: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> <7758b2680910061252g4a2fb2f3ta1a3b161be1cbd5@mail.gmail.com> <7758b2680910070023t4fc4c1d3xf6edd9ce15976f13@mail.gmail.com> <1ae41e820910070130k272441f9qf8859ba4a469170c@mail.gmail.com> Message-ID: <1ae41e820910070136h48b4e040if2d1d6bd46c037d1@mail.gmail.com> ---------- Forwarded message ---------- From: Martin Kielhorn Date: 2009/10/7 Subject: Re: [cells-gtk-devel] Editable Table To: Peter Hildebrandt 2009/10/7 Peter Hildebrandt > > Hi Martin, > > here's the object inspector I wrote: > Thanks for the fast response. Your code looks interesting. I'll try to make something out of it later. I have to get rid of the references to obj and net-editor first. Yesterday I understood the tree-view example and managed to change it, so that it will only display a table. If an entry isn't parsed as a single-float I draw it red: (require :asdf) (require :cells-gtk) (defpackage :mk (:use :cl :cells :cells-gtk)) (in-package :mk) (defmodel mk-app (gtk-app) () (:default-initargs :md-name :mk-app :width 300 :height 200 :kids (c-in nil))) (init-gtk) (start-win 'mk-app) (defmodel node (family) ((thickness :accessor thickness :initarg :position :initform (c-in (coerce (random 100) 'single-float))) (curvature :accessor curvature :initarg :curvature :initform (c-in (coerce (random 100) 'single-float))))) (defparameter *root* (make-instance 'node :md-name :tree :kids (kids-list? (make-kid 'node) (make-kid 'node) (make-kid 'node)))) (def-cells-tree-view node-tree () (thickness :title "Thickness" :type :string :writer-fn #'(lambda (val) (format t "writer-fn ~a~%" val) (read-from-string val)) :reader-fn #'(lambda (val) (format t "reader-fn ~a~%" val) (prin1-to-string val)) :render-fn #'(lambda (node) (if (eql 'single-float (type-of (thickness node))) '(:editable t :foreground "black") '(:editable t :foreground "red")))) (curvature :title "Curvature")) (setf (kids (find-widget :mk-app)) (list (mk-vbox :fm-parent (find-widget :mk-app) :kids (kids-list? (mk-node-tree *root* :expand t :fill t :md-name :tree-1))))) Regards, Martin -- Martin Kielhorn Randall Division of Cell & Molecular Biophysics King's College London, New Hunt's House Guy's Campus, London SE1 1UL, U.K. tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435 -- Martin Kielhorn Randall Division of Cell & Molecular Biophysics King's College London, New Hunt's House Guy's Campus, London SE1 1UL, U.K. tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kielhorn.martin at googlemail.com Thu Oct 8 10:25:48 2009 From: kielhorn.martin at googlemail.com (Martin Kielhorn) Date: Thu, 8 Oct 2009 11:25:48 +0100 Subject: [cells-gtk-devel] Editable Table In-Reply-To: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> References: <1ae41e820910061137w66178e70if1235da29b84c655@mail.gmail.com> Message-ID: <1ae41e820910080325v444d22b9gd2136d992c457b9f@mail.gmail.com> It turns out if I store the data as strings, editing will work as expected. With this definition of *items*: (defparameter *items* (list (make-be 'listbox-test-item :position (prin1-to-string (coerce (random 20) 'double-float)) :curvature (prin1-to-string (coerce (random 20) 'double-float))) (make-be 'listbox-test-item :position (prin1-to-string (coerce (random 20) 'double-float)) :curvature (prin1-to-string (coerce (random 20) 'double-float))))) and the following change to :columns > (let ((top (find-widget :mk-top))) > (setf > (kids top) > (list > (mk-vbox > :fm-parent top > :kids > (kids-list? > (mk-listbox :md-name :listbox > :selection-mode :single > :columns (def-columns > (:double (:title "Position") (lambda (node) '(:editable > t))) > (:double (:title "Curvature"))) > :columns (def-columns (:string (:title "Position") #'(lambda (node) '(:editable t))) (:string (:title "Curvature"))) > :items *items* > :print-fn (lambda (item) > (list (position$ item) > (curvature$ item))) > :on-edit (lambda (node col new-val) > (format t "~a~%" (list node col new-val))))))))) > The output looks like this: "----------UTILSRESET----------------------------------" 0> c-link> query link :mk-top cells-store1 nil 0> overwriting item :listbox listbox * (:6092): Gtk-CRITICAL **: gtk_tree_store_set_value: assertion `GTK_IS_TREE_STORE (tree_store)' failed (# 0 8.0d0) (:6092): Gtk-CRITICAL **: gtk_tree_store_set_value: assertion `GTK_IS_TREE_STORE (tree_store)' failed (# 0 8.0d30) -- Martin Kielhorn Randall Division of Cell & Molecular Biophysics King's College London, New Hunt's House Guy's Campus, London SE1 1UL, U.K. tel: +44 (0) 207 848 6519, fax: +44 (0) 207 848 6435 -------------- next part -------------- An HTML attachment was scrubbed... URL: