1 /* $Id: ttyicon.c,v 1.3 2000/09/29 17:25:15 amura Exp $ */
2 /*
3  * Name:	MG 2a
4  *		Iconify the MG window using Leo Schwab's iconify() routine.
5  * Last Edit:	07-Jan-88	mic@emx.utexas.edu
6  * Created:	04-Jan-88	mic@emx.utexas.edu
7  */
8 
9 /*
10  * $Log: ttyicon.c,v $
11  * Revision 1.3  2000/09/29 17:25:15  amura
12  * small patch for new iconify()
13  *
14  * Revision 1.2  2000/07/28 11:26:37  amura
15  * edit icon to Ng 1.4
16  *
17  * Revision 1.1.1.1  2000/06/27 01:48:01  amura
18  * import to CVS
19  *
20  */
21 
22 #include	"config.h"	/* Dec.19,1992 Add by H.Ohkubo */
23 #ifdef	DO_ICONIFY
24 
25 #include <exec/types.h>
26 #include <exec/memory.h>
27 #include <intuition/intuition.h>
28 #include "iconify.h"
29 #undef	TRUE
30 #undef	FALSE
31 #include "def.h"
32 
33 /*
34  * Simple Mg 2a icon image.  We need a more imaginative one.
35  */
36 
37 #ifdef	KANJI	/* Dec.19,1992 by H.Ohkubo */
38 		/* 27 Jul 2000 rewrite for Ng 1.4 by amura */
39 UWORD	mg2a[] = {
40 /* Bit Plane #0 */
41 
42    0x3fff, 0xffff, 0xffff, 0xfffe,
43    0x3fff, 0xffff, 0xffff, 0xfffe,
44    0x3ffd, 0xefff, 0xffff, 0xfffe,
45    0x3ff2, 0x97ff, 0xfeff, 0xffbe,
46    0x3fe3, 0x2fff, 0xf17f, 0xf85e,
47    0x3fe1, 0x3fbf, 0xc2ff, 0xf0be,
48    0x3fc2, 0x605f, 0xc2ff, 0xe0be,
49    0x3fc0, 0x445f, 0xc5ff, 0xc97e,
50    0x3f80, 0x88bf, 0xc5ff, 0x917e,
51    0x3f80, 0x88bf, 0x8bff, 0x13be,
52    0x3f21, 0x117f, 0x8bfe, 0x00be,
53    0x3f21, 0x117f, 0x17fc, 0x017e,
54    0x3e62, 0x22ff, 0x17df, 0xc77e,
55    0x3e53, 0x02fe, 0x2e2f, 0x8bfe,
56    0x398f, 0xc402, 0x2227, 0x881e,
57    0x3ffc, 0x0bff, 0xdfdf, 0xf7fe,
58    0x3fff, 0xf7ff, 0xffff, 0xfffe,
59    0x3fff, 0xffff, 0xffff, 0xfffe,
60    0x3fff, 0xffff, 0xffff, 0xfffe,
61 
62 /* Bit Plane #1 */
63 
64    0x0000, 0x0000, 0x0000, 0x0000,
65    0x1fff, 0xffff, 0xffff, 0xfffc,
66    0x1ff3, 0x9fff, 0xffff, 0xfffc,
67    0x1fed, 0x6fff, 0xf1ff, 0xf87c,
68    0x1fdc, 0xdfff, 0xceff, 0xf7bc,
69    0x1fde, 0xc07f, 0xbdff, 0xef7c,
70    0x1fbd, 0x9fbf, 0xbdff, 0xdf7c,
71    0x1fbf, 0xbbbf, 0xbbff, 0xb6fc,
72    0x1f7f, 0x777f, 0xbbff, 0x6efc,
73    0x1f7f, 0x777f, 0x77fe, 0xec7c,
74    0x1ede, 0xeeff, 0x77fd, 0xff7c,
75    0x1ede, 0xeefe, 0xeffb, 0xfefc,
76    0x1d9d, 0xddfe, 0xee38, 0x38fc,
77    0x1dac, 0xfdfd, 0xdddf, 0x77fc,
78    0x1800, 0x3801, 0xc1c7, 0x701c,
79    0x1ffb, 0xf7fe, 0x3e3f, 0x8ffc,
80    0x1ffc, 0x0fff, 0xffff, 0xfffc,
81    0x1fff, 0xffff, 0xffff, 0xfffc,
82    0x0000, 0x0000, 0x0000, 0x0000,
83 
84    };
85 #else	/* Original Code */
86 UWORD mg2a[160] = {
87 /* Bit Plane #0 */
88 
89    0x0000,0x0000,0x0000,0x0000,
90    0x3fff,0xffff,0xffff,0xf000,
91    0x3fff,0xffff,0xffff,0xf000,
92    0x3c00,0x0000,0x0000,0xf000,
93    0x3cc1,0x8f80,0x0000,0xf000,
94    0x3ce3,0x9ce0,0x0000,0xf000,
95    0x3cf7,0xb800,0x0000,0xf000,
96    0x3cff,0xb9e0,0x0000,0xf000,
97    0x3cfb,0xb8e0,0x0000,0xf000,
98    0x3ce3,0x9ce3,0xf000,0xf000,
99    0x3ce3,0x8fe7,0x3800,0xf000,
100    0x3c00,0x0000,0x39f8,0xf000,
101    0x3c00,0x0000,0xf01c,0xf000,
102    0x3c00,0x0003,0x80fc,0xf000,
103    0x3c00,0x0007,0x3b1c,0xf000,
104    0x3c00,0x0007,0xf9ee,0xf000,
105    0x3c00,0x0000,0x0000,0xf000,
106    0x3fff,0xffff,0xffff,0xf000,
107    0x3fff,0xffff,0xffff,0xf000,
108    0x0000,0x0000,0x0000,0x0000,
109 
110 /* Bit Plane #1 */
111 
112    0xffff,0xffff,0xffff,0xfc00,
113    0xffff,0xffff,0xffff,0xfc00,
114    0xf000,0x0000,0x0000,0x3c00,
115    0xf000,0x0000,0x0000,0x3c00,
116    0xf040,0x8000,0x0000,0x3c00,
117    0xf020,0x8420,0x0000,0x3c00,
118    0xf010,0x8800,0x0000,0x3c00,
119    0xf000,0x8820,0x0000,0x3c00,
120    0xf020,0x8820,0x0000,0x3c00,
121    0xf020,0x8420,0x1000,0x3c00,
122    0xf020,0x8021,0x0800,0x3c00,
123    0xf000,0x0000,0x0808,0x3c00,
124    0xf000,0x0000,0x1004,0x3c00,
125    0xf000,0x0000,0x8004,0x3c00,
126    0xf000,0x0001,0x0804,0x3c00,
127    0xf000,0x0000,0x0802,0x3c00,
128    0xf000,0x0000,0x0000,0x3c00,
129    0xf000,0x0000,0x0000,0x3c00,
130    0xffff,0xffff,0xffff,0xfc00,
131    0xffff,0xffff,0xffff,0xfc00
132 };
133 #endif	/* KANJI */
134 
135 static struct Image iconimg = {		/*  Icon Image  */
136  	0, 0,
137 #ifdef	KANJI	/* Dec.19,1992 by H.Ohkubo */
138 	64, 19, 2,
139 #else	/* Original */
140 	54, 20, 2,
141 #endif
142 	NULL,	/* filled in later */
143 	0x3, 0,
144 	NULL
145 };
146 
147 /*
148  * Iconify MG's window using tthide(), iconify(), and ttshow().
149  */
150 
tticon(f,n)151 int tticon(f, n)
152 {
153 	static UWORD	iconX = 0, iconY = 0;
154 	UWORD		*chipbitmap;
155 	struct Image	*chipimg;
156 	extern short	toggling;
157 	extern APTR	AllocMem();
158 
159 	/* copy the bitmap into chip memory */
160 	if (NULL == (chipbitmap = (UWORD * )
161 		AllocMem((ULONG) sizeof(mg2a), MEMF_CHIP | MEMF_PUBLIC))) {
162 		ewprintf("Can't allocate image bitmap");
163 		return FALSE;
164 	}
165 	bcopy((char *)mg2a, (char *)chipbitmap, (int) sizeof(mg2a));
166 
167 	/* copy the image structure too */
168 	if (NULL == (chipimg = (struct Image *)
169 		AllocMem((ULONG) sizeof(iconimg), MEMF_CHIP | MEMF_PUBLIC))) {
170 		FreeMem(chipbitmap, (ULONG) sizeof(iconimg));
171 		ewprintf("Can't allocate image structure");
172 		return FALSE;
173 	}
174 	bcopy((char *)&iconimg, (char *)chipimg, (int) sizeof(iconimg));
175 	chipimg->ImageData = chipbitmap;
176 
177 	/* hide the window, display the icon, then redisplay the window */
178 	tthide(FALSE);	/* not resizing */
179 
180 #ifdef	ICON_WB
181 	iconify(&iconX, &iconY, chipimg->Width, chipimg->Height, "Ng iconified",
182 		(APTR) chipimg, (int) ICON_WB); /* iconify	*/
183 #else
184 	iconify(&iconX, &iconY, chipimg->Width, chipimg->Height, NULL,
185 		(APTR) chipimg, (int) ICON_IMAGE); /* iconify	*/
186 #endif
187 	FreeMem(chipimg, (ULONG) sizeof(iconimg));
188 	FreeMem(chipbitmap, (ULONG) sizeof(mg2a));
189 
190 	ttshow(FALSE);	/* no resize */
191 	return TRUE;
192 }
193 #endif DO_ICONIFY
194