]> ncurses.scripts.mit.edu Git - ncurses.git/blob - panel/panel.priv.h
cd470a983b16e3c2101f9d262aac42162d00d103
[ncurses.git] / panel / panel.priv.h
1 /* $Id: panel.priv.h,v 1.10 1999/09/29 15:21:58 juergen Exp $ */
2
3 #ifndef _PANEL_PRIV_H
4 #define _PANEL_PRIV_H
5
6 #if HAVE_CONFIG_H
7 #  include <ncurses_cfg.h>
8 #endif
9
10 #include <stdlib.h>
11 #include <string.h>
12 #include <assert.h>
13
14 #if HAVE_LIBDMALLOC
15 #  include <dmalloc.h>    /* Gray Watson's library */
16 #endif
17
18 #if HAVE_LIBDBMALLOC
19 #  include <dbmalloc.h>   /* Conor Cahill's library */
20 #endif
21
22 #include <nc_panel.h>
23 #include "panel.h"
24
25 #if ( CC_HAS_INLINE_FUNCS && !defined(TRACE) )
26 #  define INLINE inline
27 #else
28 #  define INLINE
29 #endif
30
31 #ifdef USE_RCS_IDS
32 #  define MODULE_ID(id) static const char Ident[] = id;
33 #else
34 #  define MODULE_ID(id) /*nothing*/
35 #endif
36
37
38 #ifdef TRACE
39    extern const char *_nc_my_visbuf(const void *);
40 #  ifdef TRACE_TXT
41 #    define USER_PTR(ptr) _nc_visbuf((const char *)ptr)
42 #  else
43 #    define USER_PTR(ptr) _nc_my_visbuf((const char *)ptr)
44 #  endif
45
46    extern void _nc_dPanel(const char*, const PANEL*);
47    extern void _nc_dStack(const char*, int, const PANEL*);
48    extern void _nc_Wnoutrefresh(const PANEL*);
49    extern void _nc_Touchpan(const PANEL*);
50    extern void _nc_Touchline(const PANEL*, int, int);
51
52 #  define dBug(x) _tracef x
53 #  define dPanel(text,pan) _nc_dPanel(text,pan)
54 #  define dStack(fmt,num,pan) _nc_dStack(fmt,num,pan)
55 #  define Wnoutrefresh(pan) _nc_Wnoutrefresh(pan)
56 #  define Touchpan(pan) _nc_Touchpan(pan)
57 #  define Touchline(pan,start,count) _nc_Touchline(pan,start,count)
58 #else /* !TRACE */
59 #  define dBug(x)
60 #  define dPanel(text,pan)
61 #  define dStack(fmt,num,pan)
62 #  define Wnoutrefresh(pan) wnoutrefresh((pan)->win)
63 #  define Touchpan(pan) touchwin((pan)->win)
64 #  define Touchline(pan,start,count) touchline((pan)->win,start,count)
65 #endif
66
67 #define _nc_stdscr_pseudo_panel _nc_panelhook()->stdscr_pseudo_panel
68 #define _nc_top_panel _nc_panelhook()->top_panel
69 #define _nc_bottom_panel _nc_panelhook()->bottom_panel
70
71 #define EMPTY_STACK() (_nc_top_panel==_nc_bottom_panel)
72 #define Is_Bottom(p)  (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_bottom_panel->above==(p))) 
73 #define Is_Top(p) (((p)!=(PANEL*)0) && !EMPTY_STACK() && (_nc_top_panel==(p)))
74 #define Is_Pseudo(p) ((p) && ((p)==_nc_bottom_panel))
75
76 /*+-------------------------------------------------------------------------
77         _nc_panel_is_linked(pan) - check to see if panel is in the stack
78 --------------------------------------------------------------------------*/
79 /* This works! The only case where it would fail is, when the list has
80    only one element. But this could only be the pseudo panel at the bottom */
81 #define _nc_panel_is_linked(p) ((((p)->above!=(PANEL*)0)||((p)->below!=(PANEL*)0)||((p)==_nc_bottom_panel)) ? TRUE : FALSE)
82
83 #define PSTARTX(pan) ((pan)->win->_begx)
84 #define PENDX(pan)   ((pan)->win->_begx + getmaxx((pan)->win))
85 #define PSTARTY(pan) ((pan)->win->_begy)
86 #define PENDY(pan)   ((pan)->win->_begy + getmaxy((pan)->win))
87
88 /*+-------------------------------------------------------------------------
89         PANELS_OVERLAPPED(pan1,pan2) - check panel overlapped
90 ---------------------------------------------------------------------------*/
91 #define PANELS_OVERLAPPED(pan1,pan2) \
92 (( !(pan1) || !(pan2) || \
93        PSTARTY(pan1) >= PENDY(pan2) || PENDY(pan1) <= PSTARTY(pan2) ||\
94        PSTARTX(pan1) >= PENDX(pan2) || PENDX(pan1) <= PSTARTX(pan2) ) \
95      ? FALSE : TRUE)
96
97
98 #define PANEL_UPDATE(pan,panstart) { int y; PANEL* pan2 = panstart;\
99    if (!pan2) {\
100       Touchpan(pan);\
101       pan2 = _nc_bottom_panel;\
102    }\
103    while(pan2) {\
104       if ((pan2 != pan) && PANELS_OVERLAPPED(pan,pan2)) {\
105         for(y = PSTARTY(pan); y < PENDY(pan); y++) {\
106           if( (y >= PSTARTY(pan2)) && (y < PENDY(pan2)) &&\
107               ((is_linetouched(pan->win,y - PSTARTY(pan)) == TRUE)) )\
108             Touchline(pan2,y - PSTARTY(pan2),1);\
109         }\
110       }\
111       pan2 = pan2->above;\
112     }\
113 }
114 #endif /* _PANEL_PRIV_H */