From: Marco Antoniotti
Subject: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <lwu2q8hta3.fsf@copernico.parades.rm.cnr.it>
Hi

I have the same problem as before. I.e. there seems to be *absolutely no* 
way to get the size of anything in CAPI before you have actually
displayed the thing on the screen.

Am I wrong?

I did exchanged some email with Harlequin support, and they were very
kind, considered that I just downloaded their P.Ed. from the net.  But
they were of no real help (I.e. they said: you must display something
on the screen).

However, it is now something that it is bugging me way too much. I basically
want to do

CL USER 1 > (make-instance 'capi:push-button :text "ZOT")
...

CL USER 2 > (gimme-the-size *)
100
100

I can even settle with something less.

CL USER 20 > (defvar op (make-instance 'capi:output-pane))
...

CL USER 21 > (defvar px-op (gp:create-pixmap-port op 100 100))
... ; You already get an error here.

CL USER 22 > (gp:get-string-extent pxp-op "Quanto son grossa?")
n1
n2
n3
n4

At this point I don't care how I do the thing.  I just want to achieve
the effect of 'XtManageChildren' with CAPI.  It can be as wasteful as you
want.  I just do not want to see anything on the screen *before* I say
so, which is *after* I ask for the sizes of objects on a window.

Any ideas out there?

Cheers


-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa

From: Lawrence G. Mayka
Subject: Re: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <37b14fea.32564597@news.sprynet.com>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> wrote:

>I have the same problem as before. I.e. there seems to be *absolutely no* 
>way to get the size of anything in CAPI before you have actually
>displayed the thing on the screen.

I haven't looked at CAPI in a while.  Can you create the object to be
invisible/unmapped, so that it doesn't actually appear on the screen
to the user?


Lawrence G. Mayka
·······@sprynet.com
From: Marco Antoniotti
Subject: Re: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <lwhfm51gia.fsf@copernico.parades.rm.cnr.it>
·······@sprynet.com (Lawrence G. Mayka) writes:

> Marco Antoniotti <·······@copernico.parades.rm.cnr.it> wrote:
> 
> >I have the same problem as before. I.e. there seems to be *absolutely no* 
> >way to get the size of anything in CAPI before you have actually
> >displayed the thing on the screen.
> 
> I haven't looked at CAPI in a while.  Can you create the object to be
> invisible/unmapped, so that it doesn't actually appear on the screen
> to the user?

That is exactly the problem.  You can create the object, but its
internal state is not "complete" until you 'map' the *whole* widget
tree onto the display (using X/Xt parlance).

Here is the typical example

;;; An interface, a layout, and a button.

(defvar ii (make-instance 'capi:interface))

(defvar pb (make-instance 'capi:push-button :text "ZOT" :min-width 100))

(defvar ll (make-instance 'capi:simple-layout :description (list pb)))

(setf (capi:pane-layout ii) ll)

(capi:invalidate-pane-constraints ii)

(capi:calculate-constraints ii)

;;; At this point you'd think to get some meaningful answers from the
;;; following...

CL-USER 9 > (capi:with-geometry pb (values capi:%width% capi:%height%))
NIL
NIL

;;; You don't. So you think....

CL-USER 10 > (capi-internals:get-constraints pb)

Error: No applicable methods for #<STANDARD-GENERIC-FUNCTION CAPI-LIBRARY:REPRESENTATION-FONT-HEIGHT 2086B4CC> with args (NIL)
  1 (continue) Call #<STANDARD-GENERIC-FUNCTION CAPI-LIBRARY:REPRESENTATION-FONT-HEIGHT 2086B4CC> again
  2 (abort) Return to level 0.
  3 Return to top loop level 0.

Type :b for backtrace, :c <option number> to proceed,  or :? for other options


It looks like the problem is in the font representation not being
there.  As a amtter of fact, when you create an instance of an interface,
SIMPLE-PANE-FONT is NIL. *After* you DISPLAY the interafe, that slot
contains :DEFAULT-PORT-FONT.  So you think that maybe, just setting
that slot would get you somewhere.  Of course it does not.

I hope Harelquin people are listening here.  I did talk with them and
they were very nice and patient with me (given that I just downloaded
their P.Ed. from their site), and I must thank them for this.
However, IMHO this is a very big hole in CAPI and they should fix it
ASAP.

Cheers


-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Anu Triendl
Subject: Re: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <37b19f39.164769818@news.adis.at>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> wrote:

>I have the same problem as before. I.e. there seems to be *absolutely no* 
>way to get the size of anything in CAPI before you have actually
>displayed the thing on the screen.
>
>Am I wrong?

Yes, :min-width is the answer. Try this:

CL-USER 1 > (capi:contain
              (make-instance 'capi:push-button :text "ZOT"
                             :min-width 200))
#<CAPI:PUSH-BUTTON "ZOT" 2040E8C4>
CL-USER 2> (capi:contain
              (make-instance 'capi:output-pane
                             :min-width 300))
#<CAPI:OUTPUT-PANE  218A345C>

The class browser lists :width as the only relevant initarg, which
does nothing. Also  (make-instance 'capi:editor-pane  :min-width 300)
will not work properly. In this case you need to use define-interface,
like in:

CL-USER 3  > (capi:define-interface test-interface ()
    ()
    (:panes
     (text-in capi:collector-pane)) ; or capi:editor-pane
    (:default-initargs
     :min-width 300))
TEST-INTERFACE

CL-USER 4 > (capi:contain (make-instance 'test-interface))
#<TEST-INTERFACE "Untitled LispWorks Interface - 3" 21837714>

There are many more things slightly off in CAPI, in particular in the
Lispworks for Windows version... 

Anu

······@adis.at
Dr Triendl Consulting, Stadtschlaining, Austria, www.adis.at/triendl
From: Marco Antoniotti
Subject: Re: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <lwlnbh1k2g.fsf@copernico.parades.rm.cnr.it>
·······@adis.at (Anu Triendl) writes:

> Marco Antoniotti <·······@copernico.parades.rm.cnr.it> wrote:
> 
> >I have the same problem as before. I.e. there seems to be *absolutely no* 
> >way to get the size of anything in CAPI before you have actually
> >displayed the thing on the screen.
> >
> >Am I wrong?
> 
> Yes, :min-width is the answer. Try this:
> 
> CL-USER 1 > (capi:contain
>               (make-instance 'capi:push-button :text "ZOT"
>                              :min-width 200))
> #<CAPI:PUSH-BUTTON "ZOT" 2040E8C4>
> CL-USER 2> (capi:contain
>               (make-instance 'capi:output-pane
>                              :min-width 300))
> #<CAPI:OUTPUT-PANE  218A345C>

Noooonee!  (This is Italian slang for "nooooopeeeeee")

You are *not* allowed to use CAPI:CONTAIN in my case (or DISPLAY and
SHOW-INTERFACE).

If you use one of the above everything works fine.  But there is *no*
way (well I believe I found an ugly kludge to work aournd this) to
achieve the effect of XtManageChild in CAPI. I.e. to get all the slots
of an element filled *before* having the damn thing showing on your
screen/display/video (i.e. having the damn thing 'mapped' in Xt
parlance).

All in all I believe this is a really bad shortcoming in CAPI.
Basically, CAPI adopts a one-way lazy computation of sizes and
positions: they are all set up *only* when an element tree (let's call
them 'widgets') is showing on the screen. It would seem to be really
easy to modify the set up in order to allow one to actually have a
not-so-lazy sizes and position computation.  The programmer could
be given some more control, e.g. by giving her/him a
CAPI:CALCULATE-CONSTRAINTS capable of working even when the widget
tree has not been CONTAINed or DISPLAYed.

I guess I should move to Franz's ACL!
Chi ha orecchie per intendere, intenda. :)

Cheers

-- 
Marco Antoniotti ===========================================
PARADES, Via San Pantaleo 66, I-00186 Rome, ITALY
tel. +39 - 06 68 10 03 17, fax. +39 - 06 68 80 79 26
http://www.parades.rm.cnr.it/~marcoxa
From: Anu Triendl
Subject: Re: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <37b3cca0.307486681@news.adis.at>
Marco Antoniotti <·······@copernico.parades.rm.cnr.it> wrote:

>> CL-USER 2> (capi:contain
>>               (make-instance 'capi:output-pane
>>                              :min-width 300))
>> #<CAPI:OUTPUT-PANE  218A345C>
>
>Noooonee!  (This is Italian slang for "nooooopeeeeee")
>You are *not* allowed to use CAPI:CONTAIN in my case (or DISPLAY and
>SHOW-INTERFACE).

Sorry for misinterpreting the question. There seems to be no nice way
to move or resize a window under CAPI, but I am happy about anything
that does work in CAPI and keep a file with examples of methods and
initargs that work/fail, e.g.: 

For classes  check-button-panel and radio-button-panel colors and
fonts are all fine
> (setq ww (capi:contain 
       (make-instance 'capi:check-button-panel 
           :items  '(this and that)
           :background :sienna
           :foreground :turquoise1
           :min-width 300
           :layout-class 'capi:column-layout
           :font (gp:gf nil "times"   :bold :roman 23))))
 #<CAPI:CHECK-BUTTON-PANEL [3 items] 2043237C>(setq w (capi:contain
 (setf (capi:simple-pane-background ww) :forestgreen)
 (setf (capi:simple-pane-foreground ww) :red)

For classes push-button and push-button-panel:
 (setq ww (capi:contain 
       (make-instance 'capi:push-button  :text "ZOT" :min-width 300)))
none of the color initargs and writers work. They set the slot though.

For classes capi:collector-pane and capi:editor-pane
 (setq ww (capi:contain 
       (make-instance 'capi:collector-pane :background :lightcoral)))
initargs :font and :text dont even set the slot, but the corresponding
writers work
 (setf (capi:editor-pane-text ww) "Latest news")
 (setf (capi:simple-pane-font ww) (gp:gf nil "times" :bold :italic 15))

>I guess I should move to Franz's ACL!
>Chi ha orecchie per intendere, intenda. :)

The din is rather loud lately. Still I would love Capi to survive.
After all it promises free delivery to the Windows world and is easy
to use unless you want it to do fancy things, like moving windows on
the screen...

Ciao

Anu
From: Martin Simmons
Subject: Re: I can't believe I can't do this! (Harlequin CAPI problem)
Date: 
Message-ID: <01bee811$dcbb67f0$35ee58c0@cutler>
Anu Triendl <·······@adis.at> wrote in article
<··················@news.adis.at>...

> For classes push-button and push-button-panel:
>  (setq ww (capi:contain 
>        (make-instance 'capi:push-button  :text "ZOT" :min-width 300)))
> none of the color initargs and writers work. They set the slot though.

I think that is because Windows doesn't support color changes for
push-buttons.


> For classes capi:collector-pane and capi:editor-pane
>  (setq ww (capi:contain 
>        (make-instance 'capi:collector-pane :background :lightcoral)))
> initargs :font and :text dont even set the slot, but the corresponding
> writers work
>  (setf (capi:editor-pane-text ww) "Latest news")
>  (setf (capi:simple-pane-font ww) (gp:gf nil "times" :bold :italic 15))

For subclasses of capi:editor-pane, the font must be fixed-width (e.g.
"Courier New" on Windows).  The problem with :text is possibly an
oversight, but note that capi:collector-pane is primarily a way of
collecting stream-based output.  The :text initarg works for
capi:editor-pane.

-- 
Martin Simmons
······@harlequin.co.uk