[comp.sys.apollo] David Letterman's top ten list of Apollo questions.

bennett@vlsisj.VLSI.COM (Michael Bennett) (02/17/89)

Does anyone know how to:

  1) Create a window from a 'C' program that can NOT be resized
     by the user? I have a window that must be a fixed size, but
     currently the user can "grow" it and things get messed up.

  2) Create a window whose size includes the legend and border?
     It seems that when I use:

       window.left   = 100;
       window.top    = 100;
       window.width  = 100;
       window.height = 100;
       pad_$create_window("", (unsigned short) 0, pad_$transcript,
         window_no, window, ios_id, status);

     the window specified is really the interior of the window. The
     exterior of the window that I get is l=96, t=76,b=204,r=204.
     These numbers are different on different machines. I think that
     is because the size of the fonts used on those machines is
     different, so the legend changes size.

  3) Access the node id with a 'C' procedure?
     The closest I found was in /usr/include/apollo/osinfo.h
     osinfo_$node_type which seems to give the model and
     number of cpus.

  4) Place cursor on a named window using the Display Manager (DM)?

  5) Determine the contents of the DM search buffer, preferably using
     DM commands.  Or, how about from a shell script.

  6) Query (all DM) windows info from 'C' program?

  7) Get a the name of the process a 'C' program or shell script is
     running in from that program or shell script?

  8) Use the DM mark stack to do anything useful?  i.e. How in heck
     does that #!&$% mark stack work?

  9) Get the parameters (baseline, line height, etc) for a fixed pitch font?
     The method I use now is show below. It seems to work for f5x9 but not for
     f9x15.

    static gpr_$string_t text = "A";
    gpr_$offset_t size;
    gpr_$offset_t start;
    short int pitch;

    gpr_$inq_text_extent(text, (short int) 1, size, status);
    check_status;
    gpr_$move((short int) 0, (short int) 0, status);
    check_status;
    gpr_$inq_text_offset(text, (short int) 1, start, pitch, status);
    check_status;

    font_info.font_size   = size.y_size;
    font_info.pitch       = pitch;
    font_info.leading     = 2;
    font_info.line_height = size.y_size + font_info.leading;
    font_info.margin      = pitch;
    font_info.base_line   = size.y_size - start.y_size;

x            |     jjjjjj     |     jjjjjj     |
x            +----------------+----------------+      ---              ---
x                                                      |                |
x |- margin -|                                      leading             |
x                                                      |                |
x            +----------------|----------------+      ---               |
x            |                |  hh            |       |                |
x            |                |  hh            |       |                |
x            |          jj    |  hh            |       |                |
x            |          jj    |  hh            |       |                |
x <-border   |                |  hh            |    fontsize      lineheight
x            |          jj    |  hhhhhhh       |       |                |
x            |          jj    |  hh    hh      |       |                |
x            |          jj    |  hh    hh      |       |                |
x            |          jj    |  hh    hh      |       |                |
x            |          jj    |  hh    hh      |       |                |
x            |          jj    |  hh    hh      |       |        ---     |
x            |          jj    |                |       |         |      |
x            |          jj    |                |       |         |      |
x            |    jj    jj    |                |       |      baseline  |
x            |    jj    jj    |                |       |         |      |
x            |     jjjjjj     |                |       |         |      |
x            o----------------|----------------+      ---       ---    ---
             ^
           origin             |----- pitch ----|


  10) Who cuts David Letterman's hair?


Thanks!
--
Michael Bennett   (408) 434-7851 (W)
vlsisj!bennett@decwrl.dec.com
bennett@vlsisj.uucp
{amdcad,hplabs,pyramid,sun,ucbvax}!decwrl!vlsisj!bennett

lee@ssc-vax.UUCP (Lee Carver) (02/21/89)

In article <15210@vlsisj.VLSI.COM>, bennett@vlsisj.VLSI.COM (Michael Bennett) writes:
> Does anyone know how to:
> 
>   2) Create a window whose size includes the legend and border?
>      It seems that when I use:
> 
>        window.left   = 100;
>        window.top    = 100;
>        window.width  = 100;
>        window.height = 100;
>        pad_$create_window("", (unsigned short) 0, pad_$transcript,
>          window_no, window, ios_id, status);
> 
>      the window specified is really the interior of the window. The
>      exterior of the window that I get is l=96, t=76,b=204,r=204.
>      These numbers are different on different machines. I think that
>      is because the size of the fonts used on those machines is
>      different, so the legend changes size.

You can try getting the current font size, and then working out the
calculation yourself, but this is tough.  The standard font calls
don't provide all the information that really exists.

>   7) Get a the name of the process a 'C' program or shell script is
>      running in from that program or shell script?

   #  process-name:  get the name of the current process
   #
   pst -c @
      | fpat '<active>' @
      | edstr -e 's/  */ /g' @
      | exfld -t ' ' $6

This works because the shell scripts normally run 'inprocess'.  Note
that it writes the process name to standard out, which you can
easily capture with 'active functions':

	proc := (( ^"process-name" ))

> 
>   8) Use the DM mark stack to do anything useful?  i.e. How in heck
>      does that #!&$% mark stack work?

You can use it to set up your icon areas.  The problem is that most
interesting Apollo commands seem to clear the mark stack.

> 
>   9) Get the parameters (baseline, line height, etc) for a fixed pitch font?
>      The method I use now is show below. It seems to work for f5x9 but not for
>      f9x15.

I remember a similar problem.  It seems that the 'interline font
spacing' is not available from any Apollo calls.  That was my
problem, at least.  Never did build up the nerve to read the font
files directly (where the information really DOES exist, see
EDFONT).

-----

As an aside, it seems that X has a more complete model of fonts and
windows anyway.  I realize that X is not everyones answer
(especially in the sort term), but all the information appears to be
available.  You may be able to wait.

Except for that fixed size window problem.  I really wonder what you
are up to, and what the basis for you user interface is that
REQUIRES a fixed size window.  Anyway, X won't (easily) let you fix
it at a single size.  You must be prepared to run in whatever window
you get.  It is the USERS option to decide how much real-estate he
can dedicate to a single application.  (Sorry about the high-horse,
but @#$&*%&#$#!!)

Lee Carver
Boeing Aerospace

conliffe@caen.engin.umich.edu (Darryl C. Conliffe) (02/21/89)

In article <15210@vlsisj.VLSI.COM>, bennett@vlsisj.VLSI.COM (Michael Bennett) writes:
> Does anyone know how to:
> 
>   8) Use the DM mark stack to do anything useful?  i.e. How in heck
>      does that #!&$% mark stack work?
> 
> --
> Michael Bennett   (408) 434-7851 (W)


Yep, there is a use for the mark stack.

To use the mark, try these key definitions:

  KD R1S CMS;DR KE
  #  SHIFT-POP:   Clear stack and mark current location for future return.
  
  KD R2S GM;RM KE
  #  SHIFT-AGAIN: Return to last mark.
  
  KD F3 /[*a-zA-Z._:@-$0-9@@@/@@@\*]/dr; echo; \[*a-zA-Z._@-$0-9@@@/@@@\*]\;/?/XC word;TL KE
  #  Put your cursor on a word or filename, press and hold F3 to copy a word.
  
  KD F3U TL;gm;es ' ';XP word;/[*a-zA-Z._@-$0-9@@@/@@@\*]/dr KE
  #  Release will use previous mark (Shift-POP) for new word location.
  
  KD F7S ES ' ';EE;DR;TR;XC TO_EOL KE
  #  Copy to EOL to buffer TO_EOL
  
  KD F7C DR;XP TO_EOL KE
  #  Copy image in TO_EOL to current cursor location.

In an open pad, hit SHIFT-POP to mark where you want a copy of the string
you are going to select.  Move the cursor to the string you want to copy.
Hit F3, and a copy will come to the position marked.

You can also mark a position (SHIFT-POP), move the cursor to a position
on a line of text, hit SHIFT-F7 (to copy), hit SHIFT-AGAIN to return to the
original mark, then hit CONTROL-F7 to paste the text at the new position.

Got it?

(By the way, I had to use * in the definitions to get them safely
 posted.  To get them to work, substitute a tilda for *.)

-- 
___________________

 Darryl C. Conliffe  conliffe@caen.engin.umich.edu  (313) 721-6069
-------------------

avenger@runx.ips.oz (Troy Rollo ) (02/22/89)

> 
> Does anyone know how to:
> 
>   1) Create a window from a 'C' program that can NOT be resized
>      by the user? I have a window that must be a fixed size, but
>      currently the user can "grow" it and things get messed up.

	Well you *could* do it by copying the entire screen to the graphics
only screen but that would mean you'd have no other DM control facilities
either..... from memory it can't be done on the DM screen.

>   4) Place cursor on a named window using the Display Manager (DM)?

	One way might be to use wi twice - that would leave the cursor on the
window after a little stuffing about by the dm.

	----------------------------------------------------------------
Internet: avenger@runx.ips.oz.au
UUCP: uunet!runx.ips.oz.au!avenger

"Watch out for Gobbledocks - they'll steal all your silicon chippies"

dbfunk@ICAEN.UIOWA.EDU (David B. Funk) (02/23/89)

Re posting <15210@vlsisj.VLSI.COM>:

> 1) Create a window from a 'C' program that can NOT be resized
>    by the user? I have a window that must be a fixed size, but
>    currently the user can "grow" it and things get messed up.

There's no way that I know to prevent a user from trying to resize
a window, but you can prevent them from succeeding. Write a gpr
refresh routine that will check the window size & location when
called, and if the window is not where you want it, put it back.
The net effect will be: the user grabs the window, stretches it,
but when they let go, it will snap back to its starting location.
(I'm assuming that you're using GPR direct mode graphics)

>  2) Create a window whose size includes the legend and border?

Create the window, then turn the border off, you'll get the whole
window to use then. If you want a border, draw it your self.
The different window border sizes are caused by the legend fonts sizes.
You could find out what kind of legend font the machine was using,
read it, and then subtract its parameters from your window size
if you want to keep the DM legend.

> Access the node id with a 'C' procedure?

There are lots of different system calls that have the node ID
as part of the info returned. Any UID created on the node will
have the node ID as the bottom 20 bits. Most kinds of process
info calls will give you a process UID, easiest is proc2_$who_am_i.

>  4) Place cursor on a named window using the Display Manager (DM)?

That's not easy. If you first turn it into an icon, when you un-icon
it, the cursor will usually end up on it. Lots of work.

>  5) Determine the contents of the DM search buffer, preferably using
>     DM commands.  Or, how about from a shell script.

I don't know that there is a way to do that. The search buffer is internal
to the DM.

>   6) Query (all DM) windows info from 'C' program?

Read the contents of the "all_group" paste buffer. Try the following:
"cat `node_data/paste_buffers/all_group" This will give you the names
of all windows & icons on the screen.

>  7) Get a the name of the process a 'C' program or shell script is
>     running in from that program or shell script?

Get the parent process ID (getppid), capture the output from a "ps -agN"
and grab the first 32 characters from the line with the matching
PID. (this will work at sr9.7 or sr10)

>  8) Use the DM mark stack to do anything useful?  i.e. How in heck
>     does that #!&$% mark stack work?

Check out some of the key defs in "/domain_examples/keydefs",
EG "/domain_examples/keydefs/full/kd"

> 9) Get the parameters (baseline, line height, etc) for a fixed pitch font?
>    The method I use now is show below. It seems to work for f5x9 but not for
>    f9x15.

Read the font file header, all the answers are in there. For a pre-sr10
font file, see the insert file /sys/ins/smdu.ins.* for the interpetation.
For a sr10 font file, use <apollo/fontn.h> or /sys/ins/fontn.ins.*

lambert@cheops.eecs.unsw.oz (Timothy Lambert) (02/23/89)

From article <15210@vlsisj.VLSI.COM>, by bennett@vlsisj.VLSI.COM (Michael Bennett):
> Does anyone know how to:
> 
>   1) Create a window from a 'C' program that can NOT be resized
>      by the user?

You could redefine the GROW key and M1 or
whenever they change the size, change it back.
> 
>   2) Create a window whose size includes the legend and border?

Create the window and then use pad_$set_full_window

>   4) Place cursor on a named window using the Display Manager (DM)?
> 
wi -i name;wi -w name

>   6) Query (all DM) windows info from 'C' program?
> 
You can get all their names by looking in `node_data/paste_buffers/all_group

Tim