[comp.sys.atari.st] GEM source code

rosenkra@convex.com (William Rosencranz) (03/21/91)

something just dawned on my, so please indulge me for a moment...

of all the source code ever posted here (c.b.a.st), almost all, if not
all is unix-like utilities. i don't recall ever seeing source for gem
programs, even things like gem front ends to archivers. why is this?
i think you could argue that gem applications may become more predominant
if people have examples on which to pattern new things. it is relatively
easy for someone with less experience to write a TOS application since
there is a wealth of examples to choose from. and gem is far more
difficult to program than stdio.

in this regard, i promise to post a real gem application sometime in
the next few months. source included! how 'bout that for trend setting :-)
unfortunately, the last gem appl i wrote was about 60,000 lines, and
i don't think i am going to post that sucker. it was a couple of years
ago at that, so i am a bit rusty. note that of the 60k lines, about 45k
lines of it was user interface. maybe i just answered my own question.
or maybe gem appl authors feel that they should get monetary reward for
their herculean efforts (shareware, nothing wrong with that...) and hence
keep their source close to the vest.

-bill
rosenkra@convex.com
--
Bill Rosenkranz            |UUCP: {uunet,texsun}!convex!c1yankee!rosenkra
Convex Computer Corp.      |ARPA: rosenkra%c1yankee@convex.com

steve@thelake.mn.org (Steve Yelvington) (03/22/91)

[In article <1991Mar21.101741.14347@convex.com>,
     rosenkra@convex.com (William Rosencranz) writes ... ]

> something just dawned on my, so please indulge me for a moment...
> 
> of all the source code ever posted here (c.b.a.st), almost all, if not
> all is unix-like utilities. i don't recall ever seeing source for gem
> programs, even things like gem front ends to archivers. why is this?

There has been some, but darned little. The only complete GEM apps
with source I can remember are from Jim Charlton, who wrote a nifty
binary file editor and a resource construction kit.

> in this regard, i promise to post a real gem application sometime in
> the next few months. source included! how 'bout that for trend setting :-)

Great! I don't suppose you're interested in writing a simple text-editing
window module, are you? I really don't want to reinvent the wheel. (Which
is a euphemism for ``I'm too lazy to write one myself.'')

The only GEM text editor for which I have located sources is DIARY.ACC,
which unfortunately is written in Modula-2.  Since you're a fellow who 
regards the shift key in the same way most people regard bedbugs, you 
probably know why I find that disappointing. :-)

In the spirit of Sharing More GEM Code, here's a couple of functions.
Corrections/suggestions are welcome. The third function apparently
has a bug that shows up when I add |M_BUTTON to the arguments to
evnt_multi(); if anybody sees what I did wrong please let me know.

/*
 * Function: edit_form(form) OBJECT *form;
 * Returns: int value of object used to exit the form
 * Description: This is a wrapper for form_do that handles all
 *              necessary drawing of the form, user interaction, etc.
 */
int edit_form(form)
	OBJECT *form;
	{
	int exit_obj;
	int x,y,w,h;
	graf_mouse(M_OFF,NULL);
	form_center(form, &x, &y, &w, &h);
	form_dial(FMD_START,1,1,1,1,x,y,w,h);
	form_dial(FMD_GROW,1,1,1,1,x,y,w,h);
	objc_draw(form, 0, 10, x, y, w, h);
	graf_mouse(M_ON,NULL);
	exit_obj = form_do(form, 0);
	form_dial(FMD_SHRINK,1,1,1,1,x,y,w,h);
	form_dial(FMD_FINISH,1,1,1,1,x,y,w,h);
	form[exit_obj].ob_state = NORMAL;
	return(exit_obj);
	}

/*
 * Function: g_clrscr()
 * Returns: void
 * Description: Instructs GEM to redraw the workspace 
 */
void g_clrscr()
	{
	int x,y,w,h;
	wind_get(0,WF_FULLXYWH,&x,&y,&w,&h);
	form_dial(FMD_START,1,1,1,1,x,y,w,h);
	form_dial(FMD_FINISH,1,1,1,1,x,y,w,h);
	}


/*
 * Function: show_about()
 * Returns: void
 * Description: Shows the ABOUTBOX until timeout or mouse click
 */
void show_about()
	{
	OBJECT *aboutbox;
	int x,y,w,h,junk;
	static long delay;
	delay = 4*1000L;
	rsrc_gaddr(0,ABOUTBOX, &aboutbox); /* assumes there is such a thing */
	graf_mouse(M_OFF,NULL);
	form_center(aboutbox, &x, &y, &w, &h);
	form_dial(FMD_START,1,1,1,1,x,y,w,h);
	form_dial(FMD_GROW,1,1,1,1,x,y,w,h);
	objc_draw(aboutbox, 0, 10, x, y, w, h);
	graf_mouse(M_ON,NULL);

	/* This is where I wait for a timeout or a keystroke.
           I'd like to wait for a mouse click, but adding
           MU_BUTTON to the first argument causes evnt_multi
           to return immediately. ??? */

	evnt_multi(MU_TIMER|MU_KEYBD,
		1, 1, 0,
		0,0,0,0,0,
		0,0,0,0,0,
		&junk,
		loword(delay),hiword(delay),
		&junk,&junk,		
		&junk,&junk,		
		&junk,
		&junk);

	form_dial(FMD_SHRINK,1,1,1,1,x,y,w,h);
	form_dial(FMD_FINISH,1,1,1,1,x,y,w,h);

	}
----
  Steve Yelvington / P. O. Box 38 / Marine on St. Croix, MN 55047 USA
  INTERNET: steve@thelake.mn.org    UUCP: plains!umn-cs!thelake!steve
  GEnie: S.YELVINGTO2               Delphi: YELVINGTON

rosenkra@convex.com (William Rosencranz) (03/22/91)

In article <A66918006@thelake.mn.org> steve@thelake.mn.org (Steve Yelvington) writes:
>[In article <1991Mar21.101741.14347@convex.com>,
>> in this regard, i promise to post a real gem application sometime in
>> the next few months. source included! how 'bout that for trend setting :-)
>
>Great! I don't suppose you're interested in writing a simple text-editing
>window module, are you? I really don't want to reinvent the wheel. (Which
>is a euphemism for ``I'm too lazy to write one myself.'')

i use emacs. what the heck do i need gem windows for? :-)

actually, i doubt i will have time to write something from scratch. so
let me modify this: i will post more a skeleton of an application which
may need fleshing out. sort of a tutorial.

i have some code laying around for passing messages between DAs and
applications. does this sound interesting enuf? i originally wrote it
for a MIDI application. the DA would pass data from the application to
a MIDI device (a sample dump, in this case), and pass MIDI info to the
appl. the idea was to use DAs more like device drivers, but with a
dialog. it worked well.

elements of this is:

	GEM messages, care and feeding of
	shared memory
	protocol development
	DA/AP message passing
	having an appl wake up a DA, etc.

it will take some time to get it in a form i can explain (since i forgot
most of what i did long ago). so...if at least 10 people say "do it", i will.

another thing i *could* do is to pass along a ladder-style menu system:

	 _______________
	|		|
	|_______________|
	|******* _______|_______
	|_______|		|
	|	|_______________|
	|_______|******** ______|_______
	|	|________|		|
	|_______________||______________|
			 |**************|
			 |______________|
			 |		|
			 |______________|

i wrote. it was convoluted and not general, however, but worked well. i
was planning on writing a code generator to make it general. oh, well...
one of these days...

a *simple* text editor is relatively easy. just shovel ed(1) into
a gem wrapper. the only tricky parts are scrolling: v_gtext/vro_cpyfm
or whatever instead of printf. i have a working ed(1) if you want src. it
is small, simple, and easy to modify. but i think IPC (or the menu thingie)
is much more interesting.

a better idea would be an MGR editor. done like apollo's display manager
editor. now THAT would be slick.

>The only GEM text editor for which I have located sources is DIARY.ACC,
>which unfortunately is written in Modula-2.  Since you're a fellow who 
>regards the shift key in the same way most people regard bedbugs, you 
>probably know why I find that disappointing. :-)

Ha Ha. :-) To Paraphrase A Popular Saw Heard Around These Parts: "Not
Shifting At Beginning Of Sentences Saves Many, Many Keystrokes, Not To
Mention My Little Pinky".

thanx for the code, BTW...

-bill
rosenkra@convex.com
--
Bill Rosenkranz            |UUCP: {uunet,texsun}!convex!c1yankee!rosenkra
Convex Computer Corp.      |ARPA: rosenkra%c1yankee@convex.com

paulm@unix.UUCP (Owner and User) (03/25/91)

In article <1991Mar22.123601.1378@convex.com>, rosenkra@convex.com (William Rosencranz) writes:
[...]
> it will take some time to get it in a form i can explain (since i forgot
> most of what i did long ago). so...if at least 10 people say "do it", i will.
> 
[....]

   By all means, please DO IT!

       Thanx in advance, 
       Paul Moreau
------
UUNET: ..!ccicpg!unix!paulm
------

ramaer@cs.utwente.nl (Mark Ramaer) (03/26/91)

In article <A66918006@thelake.mn.org>, steve@thelake.mn.org (Steve Yelvington) writes:
|> [deleted]
|> In the spirit of Sharing More GEM Code, here's a couple of functions.
|> Corrections/suggestions are welcome. The third function apparently
|> has a bug that shows up when I add |M_BUTTON to the arguments to
|> evnt_multi(); if anybody sees what I did wrong please let me know.
|> 

|> 	/* This is where I wait for a timeout or a keystroke.
|>            I'd like to wait for a mouse click, but adding
|>            MU_BUTTON to the first argument causes evnt_multi
|>            to return immediately. ??? */
|> 
|> 	evnt_multi(MU_TIMER|MU_KEYBD,
|> 		1, 1, 0,
|> 		0,0,0,0,0,
|> 		0,0,0,0,0,
|> 		&junk,
|> 		loword(delay),hiword(delay),
|> 		&junk,&junk,		
|> 		&junk,&junk,		
|> 		&junk,
|> 		&junk);
|> 
You are waiting for the left mouse button to be UP, this probably already the
case.  Change this into:

	int current_button_state;
	...
	vq_mouse(0,&current_button_state,&junk,&junk);
	evnt_multi(MU_TIMER|MU_KEYBD|M_BUTTON,
		MB_CLICKS, MB_MASK, current_button_state,
 		0,0,0,0,0,
 		0,0,0,0,0,
 		&junk,
 		loword(delay),hiword(delay),
 		&junk,&junk,		
 		&junk,&junk,		
 		&junk,
 		&junk);

where MB_CLICKS and MB_MASK are defined as:

#define MB_MASK 3	/* both buttons are relevant */
#define NOT 0x100	/* wait until state != current state */
#define MB_CLICKS 1|NOT /* once is enough */

or if you trust that both buttons are up when you call evnt_multi:

	evnt_multi(MU_TIMER|MU_KEYBD|M_BUTTON,
		1,1,1,
		...

It helps, i tried it yesterday. :-)

hofmann@cbnewse.att.com (james.r.hofmann) (04/09/91)

Awhile back a request was made for people on the net to release
examples of working GEM code for use as a tutorial to those trying
to learn how such code works. A good idea, but I have one question.
Aren't the include files that come with a compiler proprietary?
That being so, I can post the source (set to compile with Prospero C)
but not the include files. That would not be all that helpful.

Jim Hofmann
AT&T Bell Laboratories
Naperville, ILL
hofmann@ihlpf.att.com

steve@thelake.mn.org (Steve Yelvington) (04/10/91)

[In article <1991Apr9.123634.12778@cbnewse.att.com>,
     hofmann@cbnewse.att.com (james.r.hofmann) writes ... ]

> Awhile back a request was made for people on the net to release
> examples of working GEM code for use as a tutorial to those trying
> to learn how such code works. A good idea, but I have one question.
> Aren't the include files that come with a compiler proprietary?
> That being so, I can post the source (set to compile with Prospero C)
> but not the include files. That would not be all that helpful.

Unless the Prospero people have lost their good sense, their
.h files should be interchangable with anybody else's .h files.
I haven't used Prospero, but I have looked at the manual, and
their GEM libraries seemed conventional.

Of course, you should post any .H files written for the application,
including .H files generated by a resource editor.

GEMFAST (for Sozobon, Alcyon and assembler) uses a single GEMFAST.H
file in lieu of the standard obdefs.h and gemdefs.h files. The 
portable solution (on a system using GEMFAST) is to install
files bearing the standard names but consisting of the following
lines:

#ifndef GEMFAST_H
#include <GEMFAST.H>
#endif

If a lot of GEMFAST-dependent code starts showing up, it may be 
worthwhile to write a GEMFAST.H file that #includes the standard
files and #defines fsel_exinput if your compiler lacks that
binding.

----
  Steve Yelvington / P. O. Box 38 / Marine on St. Croix, MN 55047 USA
  INTERNET: steve@thelake.mn.org    UUCP: plains!umn-cs!thelake!steve
  GEnie: S.YELVINGTO2               Delphi: YELVINGTON

rmacgreg@cs.strath.ac.uk (Sorcerer) (04/12/91)

In article <1991Apr9.123634.12778@cbnewse.att.com> hofmann@cbnewse.att.com (james.r.hofmann) writes:
>Awhile back a request was made for people on the net to release
>examples of working GEM code for use as a tutorial to those trying
>to learn how such code works. A good idea, but I have one question.
[...deleted...]

I have been trying (without any luck) to get the remaining articles of a series
that teaches people how to program in GEM.  This series is called Professional
GEM Programming and was by Tim Orien.  If somebody out there can mail me ANY
of the articles from 14 to 17 I'd be VERY grateful.  Once I get the full
series I'll release it (one by one) onto the net.

       The Sorcerer is 'Only visiting this planet' but can be found at:

             JANET: cadx862 @uk.ac.strathclyde.computer-centre-sun 
                    rmacgreg@uk.ac.strathclyde.computer-science
  INTERNET: via nsfnet-relay.ac.uk    BITNET: via ukacrl    UUCP: via ukc.uucp

          or second star to the right and straight on 'till morning.

ramaer@cs.utwente.nl (Mark Ramaer) (05/10/91)

In article <1991May7.231318.12305@lsuc.on.ca>, jimomura@lsuc.on.ca (Jim Omura) writes:
|> 
|>      I've been working on a program for a few months now and it's got
|> one "last" problem that I can't fix.  I've been staring at it off and
|> on for months now.  The program is graphics oriented using GEM calls.
|> As far as I know I've done everything I need to do for a "clean exit"
|> back to the desktop.  But I still get 3 bombs when it returns to
|> the desktop.  Functionally the program is usable as-is.  But I don't
|> like the idea of marketting a product that bombs on exit.  I've
|> compiled the program with Sozobon C and I was wonder if this is a
|> specific problem with Sozobon.  Or is there something I don't know
|> about exiting from GEM?

I think you will have to post the text of your entry- and exit code,
because there is no problem with sozobon, I compiled some GEM programs
with sozobon and they run without problems.

and now something completely different:
The Larch

Some time ago people asked for example GEM programs.  To get a bit used 
to GEM I wrote a relatively small and not very useful text-viewer.
Because it is small I think other people can understand it, it contains
comments.
Subjects covered:
	evnt_multi, wind_..., vst_height, v_gtext, vro_cpfm, etc.
	multiple windows with the 8x8 font
	keystrokes do not necessarily go to the top windiw, but to the
	 one under the mouse.

Another program simulates the Xwindow style of multi clicking.
(Ever tried to three-double click with GEM :-( .)

If anyone is interested I will send they to comp.sources.a.s

johnb@geech.gnu.ai.mit.edu (John Bunch) (05/11/91)

Mark,

Please post you source..  I would love to lock at it..

Thanx..

John
--
************************************************************************
*        John Bunch       * 610 Morris St. * I don't want the world,   *
* johnb@gnu.ai.mit.edu    * Albany,NY      * I just want your half...  *
*                         * 12208          *        -TMBG              *
************************************************************************

bill@sugaree.uu.net (William Bishop) (05/11/91)

In article <1991May10.131802@cs.utwente.nl>, ramaer@cs.utwente.nl
 (Mark Ramaer) writes:
> 
> Some time ago people asked for example GEM programs.  To get a bit used 
> to GEM I wrote a relatively small and not very useful text-viewer.
> Because it is small I think other people can understand it, it contains
> comments.
> Subjects covered:
> 	evnt_multi, wind_..., vst_height, v_gtext, vro_cpfm, etc.
> 	multiple windows with the 8x8 font
> 	keystrokes do not necessarily go to the top windiw, but to the
> 	 one under the mouse.
> 
> Another program simulates the Xwindow style of multi clicking.
> (Ever tried to three-double click with GEM :-( .)
> 
> If anyone is interested I will send they to comp.sources.a.s

I am, please post.  Thanks!

...Bill

-- 
          **** All opinions stated above are my own!! ****
--------------------------------------------------------------------
William Bishop                 |  "Its a big country...
IKEA U.S. Services, Inc.       |      Someone's got to furnish it!"
Plymouth Commons               |                - IKEA 
Plymouth Meeting, PA 19462     |                
Tel:  (215) 834-0180           |  This space intentionally filled!!
Fax:  (215) 834-0872           |
Telex: 846223                  |