aes.h 8.51 KB
Newer Older
kollo's avatar
kollo committed
1 2 3 4 5 6 7
/* aes.h  (c) Markus Hoffmann*/

/* This file is part of X11BASIC, the basic interpreter for Unix/X
 * ============================================================
 * X11BASIC is free software and comes with NO WARRANTY - read the file
 * COPYING for details
 */
kollo's avatar
kollo committed
8 9
#ifndef __aes__
#define __aes__
kollo's avatar
kollo committed
10

kollo's avatar
kollo committed
11 12 13 14
//#define GEMFONT      "-*-fixed-*-r-normal-*-15-*-ISO10646-1"
#define GEMFONT      "*8x16*"
//#define GEMFONTSMALL "-*-fixed-*-r-normal-*-8-*-ISO10646-1"
#define GEMFONTSMALL "*5x8*"
kollo's avatar
kollo committed
15

16 17 18
#define WORD  int16_t
#define UWORD uint16_t
#define LONG  uint32_t
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34

#ifdef  _LP64
#define TEDINFO_P LONG
#define BITBLK_P LONG
#define ICONBLK_P LONG
#define USRBLK_P LONG
#define OBSPEK_P LONG
#define CHAR_P LONG
#else
#define TEDINFO_P TEDINFO *
#define BITBLK_P BITBLK *
#define ICONBLK_P BITBLK *
#define USRBLK_P USRBLK *
#define OBSPEK_P union obspecptr *
#define CHAR_P char *
#endif
kollo's avatar
kollo committed
35 36


kollo's avatar
kollo committed
37 38 39
#ifdef USE_GEM
#include <gem.h>
#endif
kollo's avatar
kollo committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
/* Object Drawing Types */
						/* Graphic types of obs	*/
#define G_BOX 20
#define G_TEXT 21
#define G_BOXTEXT 22
#define G_IMAGE 23
#define G_USERDEF 24
#define G_IBOX 25
#define G_BUTTON 26
#define G_BOXCHAR 27
#define G_STRING 28
#define G_FTEXT 29
#define G_FBOXTEXT 30
#define G_ICON 31
#define G_TITLE 32
#define G_ALERTTYP 42
						/* Object flags		 */
#define NONE 0x0
#define SELECTABLE 0x1
#define DEFAULT 0x2
#define EXIT 0x4
#define EDITABLE 0x8
#define RBUTTON 0x10
#define LASTOB 0x20
#define TOUCHEXIT 0x40
#define HIDETREE 0x80
#define INDIRECT 0x100
						/* Object states	*/
#define NORMAL 0x0
#define SELECTED 0x1
#define CROSSED 0x2
#define CHECKED 0x4
#define DISABLED 0x8
#define OUTLINED 0x10
#define SHADOWED 0x20
#define WHITEBAK 0x40
#define DRAW3D 0x80
kollo's avatar
kollo committed
77

78 79 80 81 82 83 84
#undef BLACK
#undef WHITE
#undef RED
#undef GREEN
#undef BLUE     
#undef YELLOW   
#undef MAGENTA  
kollo's avatar
kollo committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
						/* Object colors	*/
#define WHITE 0
#define BLACK 1
#define RED 2
#define GREEN 3
#define BLUE 4
#define CYAN 5
#define YELLOW 6
#define MAGENTA 7
#define LWHITE 8
#define LBLACK 9
#define LRED 10
#define LGREEN 11
#define LBLUE 12
#define LCYAN 13
#define LYELLOW 14
#define LMAGENTA 15
						/* bit blt rules	*/
#define ALL_WHITE 0
#define S_AND_D 1
#define S_ONLY 3
#define NOTS_AND_D 4
#define S_XOR_D 6
#define S_OR_D 7
#define D_INVERT 10
#define NOTS_OR_D 13
#define ALL_BLACK 15
						/* font types		*/
#define FONT_IBM 3
kollo's avatar
kollo committed
114 115 116 117 118
#define FONT_SMALLIBM 5
#define FONT_BIGIBM 6
#define FONT_SMALL 40
#define FONT_BIG 10
#define FONT_LARGE 20
kollo's avatar
kollo committed
119 120
#define FONT_DEFAULT FONT_IBM

kollo's avatar
kollo committed
121 122

#ifndef USE_GEM
kollo's avatar
kollo committed
123 124 125 126
#define EDSTART 0
#define EDINIT 1
#define EDCHAR 2
#define EDEND 3
kollo's avatar
kollo committed
127
#endif
kollo's avatar
kollo committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157

#define TE_LEFT 0
#define TE_RIGHT 1
#define TE_CNTR 2


#define R_TREE 0
#define R_OBJECT 1
#define R_TEDINFO 2
#define R_ICONBLK 3
#define R_BITBLK 4
#define R_STRING 5
#define R_IMAGEDATA 6
#define R_OBSPEC 7
#define R_TEPTEXT 8		/* sub ptrs in TEDINFO	*/
#define R_TEPTMPLT 9
#define R_TEPVALID 10
#define R_IBPMASK 11		/* sub ptrs in ICONBLK	*/
#define R_IBPDATA 12
#define R_IBPTEXT 13
#define R_BIPDATA 14		/* sub ptrs in BITBLK	*/
#define R_FRSTR 15		/* gets addr of ptr to free strings	*/
#define R_FRIMG 16		/* gets addr of ptr to free images	*/


#define RS_SIZE 17				/* NUM_RTYPES + NUM_RN	*/

#define HDR_LENGTH (RS_SIZE + 1) * 2		/* in bytes	*/


kollo's avatar
kollo committed
158 159

#ifdef USE_GEM
kollo's avatar
kollo committed
160 161
/* AES-Definitionen   */
typedef struct {
kollo's avatar
kollo committed
162 163 164 165
  short	x;
  short	y;
  unsigned short w;
  unsigned short h;
kollo's avatar
kollo committed
166
} ARECT;
kollo's avatar
kollo committed
167 168 169 170 171 172 173 174 175
#else
/* AES-Definitionen   */
typedef struct {
  int	x;
  int	y;
  unsigned int w;
  unsigned int h;
} ARECT;
#endif
kollo's avatar
kollo committed
176 177 178



kollo's avatar
kollo committed
179
#ifndef USE_GEM
kollo's avatar
kollo committed
180
#define OBJECT struct object
kollo's avatar
kollo committed
181 182 183 184 185 186 187
#define TEDINFO struct text_edinfo
#define GRECT struct grect
#define ORECT	struct orect
#define ICONBLK struct icon_block
#define BITBLK struct bit_block
#define USERBLK struct user_blk
#define PARMBLK struct parm_blk
188
#define USRBLK struct user_block
kollo's avatar
kollo committed
189

190 191 192
typedef union obspecptr {
	LONG		index;		
	OBSPEK_P        indirect;	
kollo's avatar
kollo committed
193
	// BFOBSPEC 	obspec;		
194 195 196 197 198 199
	TEDINFO_P	tedinfo;	
	BITBLK_P	bitblk;	
	ICONBLK_P	iconblk;	
	// CICONBLK_P 	ciconblk;	
	USRBLK_P        userblk;	
	CHAR_P		free_string;	
kollo's avatar
kollo committed
200
} OBSPEC;
kollo's avatar
kollo committed
201

202
OBJECT {
kollo's avatar
kollo committed
203 204 205
	WORD		ob_next;	/* -> object's next sibling	*/
	WORD		ob_head;	/* -> head of object's children */
	WORD		ob_tail;	/* -> tail of object's children */
206 207 208
	UWORD		ob_type;	/* type of object- BOX, CHAR,...*/
	UWORD		ob_flags;	/* flags			*/
	UWORD		ob_state;	/* state- SELECTED, OPEN, ...	*/
kollo's avatar
kollo committed
209
	OBSPEC		ob_spec;	/* "out"- -> anything else	*/
kollo's avatar
kollo committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
	WORD		ob_x;		/* upper left corner of object	*/
	WORD		ob_y;		/* upper left corner of object	*/
	WORD		ob_width;	/* width of obj			*/
	WORD		ob_height;	/* height of obj		*/
};


ORECT
{
	ORECT	*o_link;
	WORD	o_x;
	WORD	o_y;
	WORD	o_w;
	WORD	o_h;
} ;



GRECT
{
	WORD	g_x;
	WORD	g_y;
	WORD	g_w;
	WORD	g_h;
} ;





TEDINFO
{
242 243 244
	CHAR_P          te_ptext;	/* ptr to text (must be 1st)	*/
	CHAR_P          te_ptmplt;	/* ptr to template		*/
	CHAR_P          te_pvalid;	/* ptr to validation chrs.	*/
kollo's avatar
kollo committed
245
	WORD		te_font;	/* font				*/
kollo's avatar
kollo committed
246
	WORD		te_fontid;	/* junk word 1			*/
kollo's avatar
kollo committed
247 248
	WORD		te_just;	/* justification- left, right...*/
	WORD	        te_color;	/* color information word	*/
kollo's avatar
kollo committed
249
	WORD		te_fontsize;	/* junk word 2			*/
kollo's avatar
kollo committed
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
	WORD		te_thickness;	/* border thickness		*/
	WORD		te_txtlen;	/* length of text string	*/
	WORD		te_tmplen;	/* length of template string	*/
};



ICONBLK
{
	WORD	ib_pmask;
	WORD dummy1;
	WORD	ib_pdata;
	WORD dummy2;
	WORD	ib_ptext;
	WORD dummy3;
	WORD	ib_char;
	WORD	ib_xchar;
	WORD	ib_ychar;
	WORD	ib_xicon;
	WORD	ib_yicon;
	WORD	ib_wicon;
	WORD	ib_hicon;
	WORD	ib_xtext;
	WORD	ib_ytext;
	WORD	ib_wtext;
	WORD	ib_htext;
};


BITBLK
{
	WORD	bi_pdata;		/* ptr to bit forms data	*/
        WORD dummy;         /* LINUX-Spezifisch ! */
	WORD	bi_wb;			/* width of form in bytes	*/
	WORD	bi_hl;			/* height in lines		*/
	WORD	bi_x;			/* source x in bit form		*/
	WORD	bi_y;			/* source y in bit form		*/
	WORD	bi_color;		/* fg color of blt 		*/

};

USERBLK
{
	LONG	ub_code;
	LONG	ub_parm;
};

PARMBLK
{
	LONG	pb_tree;
	WORD	pb_obj;
	WORD	pb_prevstate;
	WORD	pb_currstate;
	WORD	pb_x, pb_y, pb_w, pb_h;
	WORD	pb_xc, pb_yc, pb_wc, pb_hc;
	LONG	pb_parm;
};


typedef struct objc_colorword {
   unsigned borderc : 4;
   unsigned textc   : 4;
   unsigned opaque  : 1;
   unsigned pattern : 3;
   unsigned fillc   : 4;
} OBJC_COLORWORD;
kollo's avatar
kollo committed
316
#endif
kollo's avatar
kollo committed
317 318 319 320 321 322 323 324 325 326 327

typedef struct {
    unsigned character   :  8;
    signed   framesize   :  8;
    unsigned framecol    :  4;
    unsigned textcol     :  4;
    unsigned textmode    :  1;
    unsigned fillpattern :  3;
    unsigned interiorcol :  4;
} bfobspec;

kollo's avatar
kollo committed
328 329
#ifndef USE_GEM

kollo's avatar
kollo committed
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
typedef struct rshdr
{
	WORD		rsh_vrsn;	/* must same order as RT_	*/
	WORD		rsh_object;
	WORD		rsh_tedinfo;
	WORD		rsh_iconblk;	/* list of ICONBLKS		*/
	WORD		rsh_bitblk;
	WORD		rsh_frstr;
	WORD		rsh_string;
	WORD		rsh_imdata;	/* image data			*/
	WORD		rsh_frimg;
	WORD		rsh_trindex;
	WORD		rsh_nobs;	/* counts of various structs	*/
	WORD		rsh_ntree;
	WORD		rsh_nted;
	WORD		rsh_nib;
	WORD		rsh_nbb;
	WORD		rsh_nstring;
	WORD		rsh_nimages;
	WORD		rsh_rssize;	/* total bytes in resource	*/
}RSHDR;
kollo's avatar
kollo committed
351
#endif
kollo's avatar
kollo committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
typedef struct rshdrv3
{
	WORD		rsh_vrsn;	/* must same order as RT_	*/
	LONG		rsh_object;
	LONG		rsh_tedinfo;
	LONG		rsh_iconblk;	/* list of ICONBLKS		*/
	LONG		rsh_bitblk;
	LONG		rsh_frstr;
	LONG		rsh_string;
	LONG		rsh_imdata;	/* image data			*/
	LONG		rsh_frimg;
	LONG		rsh_trindex;
	WORD		rsh_nobs;	/* counts of various structs	*/
	WORD		rsh_ntree;
	WORD		rsh_nted;
	WORD		rsh_nib;
	WORD		rsh_nbb;
	WORD		rsh_nstring;
	WORD		rsh_nimages;
	LONG		rsh_rssize;	/* total bytes in resource	*/
372
} RSHDRV3;
kollo's avatar
kollo committed
373

kollo's avatar
kollo committed
374
typedef struct { unsigned char r,g,b;} AESRGBCOLOR;
kollo's avatar
kollo committed
375 376 377 378 379 380 381


/* Prototypes */

extern RSHDR *rsrc;
extern int gem_colors[];

382 383 384 385 386 387 388 389 390 391 392 393 394 395
#ifdef IS_BIG_ENDIAN
  #define swap_WORD(a) (a)
  #define swap_LONG(a) (a)
#else

static inline WORD swap_WORD(WORD a) {
  return(((a<<8)&0xff00) | ((a>>8)&0xff));
}
static inline LONG swap_LONG(LONG a) {
  return(((a<<16)&0xffff0000) | ((a>>16)&0xffff));
}
#endif


kollo's avatar
kollo committed
396 397 398

void gem_init();
void load_GEMFONT(int n);
kollo's avatar
kollo committed
399 400 401 402
#ifndef USE_GEM
short form_alert(short dbut,char *n);
short form_center(OBJECT *tree,short *x,short *y,short *w,short *h);
short rsrc_free();
kollo's avatar
kollo committed
403 404
void objc_add(OBJECT *tree,int p,int c);
void objc_delete(OBJECT *tree,int object);
kollo's avatar
kollo committed
405 406 407 408 409
short rsrc_load(const char *filename);
short objc_offset(OBJECT *tree,short object,short *x,short *y);
short objc_find(OBJECT *tree,short startob, short depth,short x,short y);
short objc_draw(OBJECT *tree,short startob, short depth,short x,short y, short w, short h);
short rsrc_gaddr(short re_gtype, unsigned short re_gindex, char **re_gaddr);
kollo's avatar
kollo committed
410 411 412 413
int finded(OBJECT *tree,int start, int r);
void draw_edcursor(OBJECT *tree,int ndx);
int rootob(OBJECT *tree,int onr);
void relobxy(OBJECT *tree,int ndx,int *x, int *y);
kollo's avatar
kollo committed
414
#endif
kollo's avatar
kollo committed
415
int form_alert2(int dbut,char *n,int size, char *tval);
kollo's avatar
kollo committed
416
#endif