home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.amiga.programmer
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!gatech!concert!samba!usenet
- From: Todd_Lewis@unc.edu (Todd M. Lewis)
- Subject: Re: Simple Question...
- Message-ID: <1993Jan7.202049.14130@samba.oit.unc.edu>
- Sender: usenet@samba.oit.unc.edu
- Nntp-Posting-Host: guitar.oit.unc.edu
- Organization: UNC Office of Information Technology
- References: <skelly.0n2s@amiganet.chi.il.us>
- Date: Thu, 7 Jan 1993 20:20:49 GMT
- Lines: 192
-
- In article <skelly.0n2s@amiganet.chi.il.us> skelly@amiganet.chi.il.us (Sean
- Kelly) writes:
- >
- >
- > I am relatively new to C programming (been at it about 6 months) and
- >pretty much understand it with one MAJOR exception - WINDOWS! I have written
- >about 20 or so programs all of which work fine, but most of which would be
- much
- >nicer if I could figure out how the hell to work with windows. I have four
- >different books (three of which are Amiga specific) on C and none of them
- >really get into windows much. Would someone mind posting a little code that I
- >could use as an example of how to send text to a window?? I know pretty well
- >how to define one, but have never been able to get any text to show up in
- >them...
- >
- >%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%
- >% Sean Kelly - Sysop Amizon BBS (312)594-1146 %
- >% Always looking for classic video games for the following systems: %
- >% %
- >% Atari 2600-Atari 5200-ColecoVision-Atari 5200-Intellivision-Vectrex %
- >%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%^%
-
- This is a _little_ more than what you asked for, but it was handy, small,
- and it does put text into windows. Hope it helps.
- --
- _/_/_/ _/ Todd_Lewis@unc.edu You can lead a horse to
- _/ _/ utoddl@guitar.oit.unc.edu Mohammad, but you can't make
- _/ _/_/_/ a mountain drink a mole hill.
- #include <exec/types.h>
- #include <intuition/intuition.h>
- #include <graphics/rastport.h>
- #include <string.h>
-
- #ifdef LATTICE
- #include <proto/all.h>
- #elif AZTEC_C
- #include <functions.h>
- void _cli_parse( void ) {}
- void _wb_parse( void ) {}
- #endif
-
- static struct TextAttr TOPAZ60 = {
- (STRPTR)"topaz.font",
- TOPAZ_SIXTY,0,0
- };
- static struct ExtNewScreen NewScreenStructure = {
- 0,0, /* screen XY origin relative to View */
- 640,200, /* screen width and height */
- 2, /* screen depth (number of bitplanes) */
- 0,1, /* detail and block pens */
- HIRES, /* display modes for this screen */
- CUSTOMSCREEN, /* screen type */
- &TOPAZ60, /* pointer to default screen font */
- (UBYTE *)"Old-look screen", /* screen title */
- NULL, /* first in list of custom screen gadgets */
- NULL, /* pointer to custom BitMap structure */
- NULL, /* pointer to Extensions **NEW FOR V36+***/
- };
-
- static struct NewWindow NewWindowStructure1 = {
- 50,24, /* window XY origin relative to TopLeft of screen */
- 528,128, /* window width and height */
- 0,1, /* detail and block pens */
- CLOSEWINDOW, /* IDCMP flags */
- WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+
- WINDOWCLOSE+ACTIVATE+NOCAREREFRESH, /* other window flags */
- NULL, /* first gadget in gadget list */
- NULL, /* custom CHECKMARK imagery */
- (UBYTE *)"Old-look Window", /* window title */
- NULL, /* custom screen pointer */
- NULL, /* custom bitmap */
- 5,5, /* minimum width and height */
- -1,-1, /* maximum width and height */
- CUSTOMSCREEN, /* destination screen type */
- };
-
- static char *old_look_text[] =
- {
- "This is what an old_style window looks like on",
- "a custom screen. It doesn't have the 3-D style",
- "under any version of the OS. Under 2.0 or above,",
- "however, it does have a solid title bar rather",
- "than the 1.x style banded title bar. This is true",
- "for all \"old\" program's windows.",
- NULL,
- };
-
- static char *new_look_text[] =
- {
- "This is what a new-style window looks like on",
- "a custom screen. Under v36 or above it has",
- "the 3-D style, but under 1.3.x or below it looks",
- "like any other standard window.",
- NULL,
- };
-
- static struct Screen *screen;
- static struct Window *window;
-
- struct Library *IntuitionBase;
- struct Library *GfxBase;
-
- static WORD screen_pens[] = {~0};
-
- static struct TagItem screen_tags[] =
- {
- {SA_Pens, 0 },
- {TAG_END, 0 }
- };
-
- void do_text( struct Window *w, char *txt[] )
- {
- SHORT i=2;
- SetDrMd( w->RPort, JAM2 );
- SetAPen( w->RPort, 1 );
- SetBPen( w->RPort, 0 );
- while( *txt )
- {
- Move( w->RPort, w->BorderLeft+2, w->BorderTop*i );
- Text( w->RPort, (UBYTE *)*txt, strlen( *txt ) );
- i++;
- txt++;
- }
- }
-
- void wait_for_CLOSEWINDOW( void )
- {
- UBYTE flag = 0;
- struct IntuiMessage *message = NULL;
- ULONG class;
-
- while ( !flag )
- {
- Wait( 1L << window->UserPort->mp_SigBit );
- while( message = (struct IntuiMessage *)GetMsg(window->UserPort) )
- {
- class = message->Class;
- ReplyMsg( (struct Message *)message );
- switch( class )
- {
- case CLOSEWINDOW :
- flag = 1;
- break;
- default:
- break;
- }
- }
- }
- }
-
- int main( int argc, char *argv[] )
- {
- if ( (IntuitionBase = OpenLibrary((UBYTE *)"intuition.library",33L) ) &&
- (GfxBase = OpenLibrary((UBYTE *)"graphics.library", 33L) ) )
- {
- /*** Normal, "Old-look" screen ***/
- if ( (screen = OpenScreen( (struct NewScreen *)&NewScreenStructure ) ))
- {
- NewWindowStructure1.Screen = screen;
- if ( (window = OpenWindow( &NewWindowStructure1 ) ) )
- {
- do_text( window, old_look_text );
- wait_for_CLOSEWINDOW();
- CloseWindow( window );
- }
- CloseScreen( screen );
- }
-
- /*** Set up for "New-look" screen ***/
- NewScreenStructure.DefaultTitle = (UBYTE *)"New-look screen";
- NewScreenStructure.Type |= NS_EXTENDED;
- NewScreenStructure.Extension = screen_tags;
- screen_tags[0].ti_Data = (ULONG)&screen_pens[0];
-
- if ( (screen = OpenScreen( (struct NewScreen *)&NewScreenStructure )))
- {
- NewWindowStructure1.Screen = screen;
- NewWindowStructure1.Title = (UBYTE *)"New-look window";
- if ( (window = OpenWindow( &NewWindowStructure1 ) ) )
- {
- do_text( window, new_look_text );
- wait_for_CLOSEWINDOW();
- CloseWindow( window );
- }
- CloseScreen( screen );
- }
- }
- if ( IntuitionBase ) CloseLibrary( IntuitionBase );
- if ( GfxBase ) CloseLibrary( GfxBase );
- }
-
-
-