[cells-gtk-cvs] CVS update: public_html/faq.html

Peter Denno pdenno at common-lisp.net
Sat Oct 8 15:03:30 UTC 2005


Update of /project/cells-gtk/cvsroot/public_html
In directory common-lisp.net:/tmp/cvs-serv17298/public_html

Modified Files:
	faq.html 
Log Message:
New questions and answers.
Date: Sat Oct  8 17:03:29 2005
Author: pdenno

Index: public_html/faq.html
diff -u public_html/faq.html:1.10 public_html/faq.html:1.11
--- public_html/faq.html:1.10	Mon Oct  3 16:43:46 2005
+++ public_html/faq.html	Sat Oct  8 17:03:29 2005
@@ -36,6 +36,7 @@
       <li><a href="#q6">What GTK Widgets are implemented in cells-gtk?</a></li>
       <li><a href="#q7">Do I have to use cells?</a></li>
       <li><a href="#q8">What is libcellsgtk.so about?</a></li>
+      <li><a href="#q8.4">What is in libcellsgtk.so?</a></li>
       <li><a href="#q8.5">What is the difference between using c-input (AKA c-in) and c-formula (AKA c?) in a 
              slot's :initform?</a></li>
       <li><a href="#q9">Why do I need :owner here? It looks like c? would bind self to the mk-whatever
@@ -46,7 +47,7 @@
       <li><a href="#q12">Changing a cell value causes dependencies to fire, but what is considered a change?</li>
       <li><a href="#q13">Can I keep a window around for redisplay after using the window border 
                             'delete' button to delete it?</a></li>
-
+      <li><a href="#q14">Can I use streams with a TextView widget?</a></li>
     </ul>
 
 <p/>
@@ -205,17 +206,30 @@
   the libgtk.so you are using. 
 
 <p/>
+<strong id="q8.4">Q: What is in libcellsgtk.so?</strong><p/>
+<strong>A:</strong>For details look at the source gtk-ffi/gtk-adds.c, but generally:
+<ul>
+  <li>Get a dialog's vbox (so that you can add children to it).</li>
+  <li>Get the popup menu of a textview</li>
+  <li>Allocate text iters and tree iters</li>
+  <li>Check whether or not a widget is mapped and visible</li>
+  <li>Get the window of a widget (useful for DrawingArea).</li>
+  <li>Allocate GdkColor objects</li>
+  <li>Set the RGB values of GdkColor objects.</li>
+</ul>
 
 <p/>
 <strong id="q8.5">Q: What is the difference between using c-input (AKA c-in) and c-formula (AKA c?) in a slot's 
 :initform ?</strong><p/>
 <strong>A:</strong>The two define different kinds of cells:<br/>
 A c-input cell is a cell whose value may be set through explicit procedural code, using setf on the slot.
+Note: When the cell is referenced by other cells in a cells constraint network, setf-ing the cell
+causes the values of other cells to be recomputed. 
 <br/>
 A c-formula cell is a cell whose value is obtained through evaluation of a formula.
 <br/>
 Note that the usual semantics of :initform do not apply when :initform is given by c-formula. 
-Instead of just setting the value at initialization, the c-formula (an arbitrary lisp form) 
+Instead of just setting the value at initialization, the c-formula (generated from the supplied lisp form) 
 specifies the dynamic relationship between the slot's value and other aspects of the program state. 
 <p/>
 
@@ -266,8 +280,9 @@
 <p/>
 <strong id="q11">Q: What does this error mean? : "cellular slot FOO of #<BAR 21B555A4> cannot be setf 
                     unless initialized as inputp."</strong><p/>
-  <strong>A:</strong> This error is signalled because you tried to setf an invariant slot.
-            'inputp' refers to c-in which should have been used to initialize the slot.
+  <strong>A:</strong>This error is signalled because you tried to setf a c-formula slot.
+            'inputp' refers to c-input (declaration of an input cell) which should have been used 
+            to initialize the slot.
             Read the <a href="cgtk-primer.html">cells-gtk primer</a> for more 
             information.
 <p/>
@@ -295,12 +310,66 @@
 ... and, of course, store the widget somewhere so you can later display it with
  (gtk-widget-show-all (widget-id my-pseudo-dialog)).
 
+<p/>
+
+<strong id="q14">Q:Can I use streams with a TextView widget?</strong><p/>
+ <strong>A:</strong>Sure. Do something like this:
+
+<pre>
+(defmethod initialize-instance :after ((self your-gtk-app) &key)
+  (let ((message-textview [wherever it is]))
+    (setf *message-stream* 
+	(make-instance 'pane-stream 
+		       :buffer (buffer message-textview)
+		       :view message-textview))))
+
+(defclass pane-stream (stream:fundamental-character-output-stream)
+  ((view :initarg :view)
+   (buffer :initarg :buffer)
+   (mark :initarg :mark)
+   (offset :initform 0 :accessor offset)))
+
+(defmethod initialize-instance :after ((self pane-stream) &key)
+  (with-slots (buffer mark view) self
+     (let ((b (widget-id buffer))
+	   (v (widget-id view)))
+       (with-text-iters (iter) 
+          (cgtk:gtk-text-buffer-get-iter-at-offset b iter 0)
+	  (setf mark (cgtk:gtk-text-buffer-create-mark b "visibility" iter t)))
+       (cgtk:gtk-text-view-set-wrap-mode v 1)  ; optional, of course. 
+       (cgtk:gtk-text-view-set-editable v nil)))) ; also optional. 
+
+; Some lisps might not need this one. Some might need other methods.
+(defmethod stream:stream-line-column ((s pane-stream)) nil)
+
+(defmethod stream:stream-write-char ((s pane-stream) (c character))
+  (with-slots (view buffer offset mark) s
+     (cgtk:text-buffer-insert-text buffer offset (string c))
+     (incf offset)
+     (let ((buf (widget-id buffer)))
+       (with-text-iters (iter) 
+         (cgtk:gtk-text-buffer-get-iter-at-offset buf iter offset)
+	 (cgtk:gtk-text-buffer-move-mark buf mark iter)
+	 (cgtk:gtk-text-view-scroll-mark-onscreen (cgtk::id view) mark )))))
+
+(defmethod stream:stream-write-string ((s pane-stream) string &optional start end)
+  (with-slots (view buffer offset mark) s
+     (cgtk:text-buffer-insert-text buffer offset string)
+     (incf offset (length string))
+     (let ((buf (widget-id buffer)))
+       (with-text-iters (iter) 
+         (cgtk:gtk-text-buffer-get-iter-at-offset buf iter offset)
+	 (cgtk:gtk-text-buffer-move-mark buf mark iter)
+	 (cgtk:gtk-text-view-scroll-mark-onscreen (widget-id view) mark)))))
+
+</pre>
+
 
 <hr/>
 <address><a href="mailto:peter.denno at nist.gov">Peter Denno</a></address>
 <!-- Created: Thu Mar  3 18:45:35 EST 2005 -->
 <!-- hhmts start -->
-Last modified: Sun Mar  6 18:32:15 EST 2005
+Last modified: 2005-10-08
 <!-- hhmts end -->
 </div>
 </body>




More information about the Cells-gtk-cvs mailing list