Added DefaultWindowShapeFunc. Calls WDM_WINDOWSHAPE.
[tangerine.git] / workbench / demos / shadowborder.c
blob23c138ed2cc4686a4919c7dfb6285d54e16415f0
1 ;/* shadowborder.c - Execute me to compile me with SAS C 5.10
2 LC -b1 -cfistq -v -y -j73 shadowborder.c
3 Blink FROM LIB:c.o,shadowborder.o TO shadowborder LIBRARY LIB:LC.lib,LIB:Amiga.lib
4 quit
5 */
7 /*
8 Copyright (c) 1992 Commodore-Amiga, Inc.
10 This example is provided in electronic form by Commodore-Amiga, Inc. for
11 use with the "Amiga ROM Kernel Reference Manual: Libraries", 3rd Edition,
12 published by Addison-Wesley (ISBN 0-201-56774-1).
14 The "Amiga ROM Kernel Reference Manual: Libraries" contains additional
15 information on the correct usage of the techniques and operating system
16 functions presented in these examples. The source and executable code
17 of these examples may only be distributed in free electronic form, via
18 bulletin board or as part of a fully non-commercial and freely
19 redistributable diskette. Both the source and executable code (including
20 comments) must be included, without modification, in any copy. This
21 example may not be published in printed form or distributed with any
22 commercial product. However, the programming techniques and support
23 routines set forth in these examples may be used in the development
24 of original executable software products for Commodore Amiga computers.
26 All other rights reserved.
28 This example is provided "as-is" and is subject to change; no
29 warranties are made. All use is at your own risk. No liability or
30 responsibility is assumed.
34 ** shadowborder.c - program to show the use of an Intuition Border.
36 #define INTUI_V36_NAMES_ONLY
38 #include <exec/types.h>
39 #include <intuition/intuition.h>
41 #include <proto/exec.h>
42 #include <proto/dos.h>
43 #include <proto/intuition.h>
45 #include <stdio.h>
47 static const char version[] = "$VER: shadowborder 41.1 (14.3.1997)\n";
49 #ifdef __AROS__
50 #include <proto/alib.h>
51 #endif
53 #ifdef LATTICE
54 int CXBRK(void) { return(0); } /* Disable Lattice CTRL/C handling */
55 int chkabort(void) { return(0); } /* really */
56 #endif
58 struct IntuitionBase *IntuitionBase = NULL;
60 #define MYBORDER_LEFT (0)
61 #define MYBORDER_TOP (0)
63 /* This is the border data. */
64 WORD myBorderData[] =
66 0,0, 50,0, 50,30, 0,30, 0,0,
71 ** main routine. Open required library and window and draw the images.
72 ** This routine opens a very simple window with no IDCMP. See the
73 ** chapters on "Windows" and "Input and Output Methods" for more info.
74 ** Free all resources when done.
76 int main(int argc, char **argv)
78 struct Screen *screen;
79 struct DrawInfo *drawinfo;
80 struct Window *win;
81 struct Border shineBorder;
82 struct Border shadowBorder;
84 ULONG mySHADOWPEN = 1; /* set default values for pens */
85 ULONG mySHINEPEN = 2; /* in case can't get info... */
87 IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37);
88 if (IntuitionBase)
90 if ((screen = LockPubScreen(NULL)))
92 if ((drawinfo = GetScreenDrawInfo(screen)))
94 /* Get a copy of the correct pens for the screen.
95 ** This is very important in case the user or the
96 ** application has the pens set in a unusual way.
98 mySHADOWPEN = drawinfo->dri_Pens[SHADOWPEN];
99 mySHINEPEN = drawinfo->dri_Pens[SHINEPEN];
101 FreeScreenDrawInfo(screen,drawinfo);
103 UnlockPubScreen(NULL,screen);
106 /* open a simple window on the workbench screen for displaying
107 ** a border. An application would probably never use such a
108 ** window, but it is useful for demonstrating graphics...
110 #ifdef __AROS__
111 if ((win = OpenWindowTags(NULL,
112 WA_PubScreen, (IPTR)screen,
113 WA_RMBTrap, TRUE,
114 WA_IDCMP, IDCMP_RAWKEY,
115 TAG_END)))
116 #else
117 if ((win = OpenWindowTags(NULL,
118 WA_PubScreen, screen,
119 WA_RMBTrap, TRUE,
120 TAG_END)))
121 #endif
123 /* set information specific to the shadow component of the border */
124 shadowBorder.LeftEdge = MYBORDER_LEFT + 1;
125 shadowBorder.TopEdge = MYBORDER_TOP + 1;
126 shadowBorder.FrontPen = mySHADOWPEN;
127 shadowBorder.NextBorder = &shineBorder;
129 /* set information specific to the shine component of the border */
130 shineBorder.LeftEdge = MYBORDER_LEFT;
131 shineBorder.TopEdge = MYBORDER_TOP;
132 shineBorder.FrontPen = mySHINEPEN;
133 shineBorder.NextBorder = NULL;
135 /* the following attributes are the same for both borders. */
136 shadowBorder.BackPen = shineBorder.BackPen = 0;
137 shadowBorder.DrawMode = shineBorder.DrawMode = JAM1;
138 shadowBorder.Count = shineBorder.Count = 5;
139 shadowBorder.XY = shineBorder.XY = myBorderData;
141 /* Draw the border at 10,10 */
142 DrawBorder(win->RPort,&shadowBorder,10,10);
144 /* Draw the border again at 100,10 */
145 DrawBorder(win->RPort,&shadowBorder,100,10);
147 #ifdef __AROS__
148 Wait (1L << win->UserPort->mp_SigBit);
149 #else
150 /* Wait a bit, then quit.
151 ** In a real application, this would be an event loop, like the
152 ** one described in the Intuition Input and Output Methods chapter.
154 Delay(200);
155 #endif
157 CloseWindow(win);
159 CloseLibrary((struct Library *)IntuitionBase);
161 return 0;