1/* Copyright (c) 1995-2002
2 *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Copyright (c) 1987 Oliver Laumann
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file COPYING); if not, write to the
18 * Free Software Foundation, Inc.,
19 * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
20 *
21 ****************************************************************
22 * $Id: overlay.h,v 1.3 1994/05/31 12:32:31 mlschroe Exp $ FAU
23 */
24
25/*
26 * This is the overlay structure. It is used to create a seperate
27 * layer over the current windows.
28 */
29
30struct mchar;	/* forward declaration */
31
32struct LayFuncs
33{
34  void	(*lf_LayProcess) __P((char **, int *));
35  void	(*lf_LayAbort) __P((void));
36  void	(*lf_LayRedisplayLine) __P((int, int, int, int));
37  void	(*lf_LayClearLine) __P((int, int, int, int));
38  int	(*lf_LayRewrite) __P((int, int, int, struct mchar *, int));
39  int	(*lf_LayResize) __P((int, int));
40  void	(*lf_LayRestore) __P((void));
41};
42
43struct layer
44{
45  struct canvas *l_cvlist;	/* list of canvases displaying layer */
46  int	 l_width;
47  int	 l_height;
48  int    l_x;			/* cursor position */
49  int    l_y;
50  int    l_encoding;
51  struct LayFuncs *l_layfn;
52  char	*l_data;
53
54  struct layer *l_next;		/* layer stack, should be in data? */
55  struct layer *l_bottom;	/* bottom element of layer stack */
56  int	 l_blocking;
57};
58
59#define LayProcess		(*flayer->l_layfn->lf_LayProcess)
60#define LayAbort		(*flayer->l_layfn->lf_LayAbort)
61#define LayRedisplayLine	(*flayer->l_layfn->lf_LayRedisplayLine)
62#define LayClearLine		(*flayer->l_layfn->lf_LayClearLine)
63#define LayRewrite		(*flayer->l_layfn->lf_LayRewrite)
64#define LayResize		(*flayer->l_layfn->lf_LayResize)
65#define LayRestore		(*flayer->l_layfn->lf_LayRestore)
66
67#define LaySetCursor()	LGotoPos(flayer, flayer->l_x, flayer->l_y)
68#define LayCanResize(l)	(l->l_layfn->LayResize != DefResize)
69
70/* XXX: AArgh! think again! */
71
72#define LAY_CALL_UP(fn) do				\
73	{ 						\
74	  struct layer *oldlay = flayer; 		\
75	  struct canvas *oldcvlist, *cv;		\
76	  debug("LayCallUp\n");				\
77	  flayer = flayer->l_next;			\
78	  oldcvlist = flayer->l_cvlist;			\
79	  debug1("oldcvlist: %x\n", oldcvlist);		\
80	  flayer->l_cvlist = oldlay->l_cvlist;		\
81	  for (cv = flayer->l_cvlist; cv; cv = cv->c_lnext)	\
82		cv->c_layer = flayer;			\
83	  fn;						\
84	  flayer = oldlay;				\
85	  for (cv = flayer->l_cvlist; cv; cv = cv->c_lnext)	\
86		cv->c_layer = flayer;			\
87	  flayer->l_next->l_cvlist = oldcvlist;		\
88	} while(0)
89
90#define LAY_DISPLAYS(l, fn) do				\
91	{ 						\
92	  struct display *olddisplay = display;		\
93	  struct canvas *cv;				\
94	  for (display = displays; display; display = display->d_next) \
95	    {						\
96	      for (cv = D_cvlist; cv; cv = cv->c_next)	\
97		if (cv->c_layer == l)			\
98		  break;				\
99	      if (cv == 0)				\
100		continue;				\
101	      fn;					\
102	    }						\
103	  display = olddisplay;				\
104	} while(0)
105
106