1/*
2 * Author:      William Chia-Wei Cheng (bill.cheng@acm.org)
3 *
4 * Copyright (C) 2001-2009, William Chia-Wei Cheng.
5 *
6 * This file may be distributed under the terms of the Q Public License
7 * as defined by Trolltech AS of Norway and appearing in the file
8 * LICENSE.QPL included in the packaging of this file.
9 *
10 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING
11 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
12 * PURPOSE.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
13 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
14 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
15 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
16 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 *
18 * @(#)$Header: /mm2/home/cvs/bc-src/tgif/tdgtdraw.e,v 1.6 2011/05/16 16:22:00 william Exp $
19 */
20
21#ifndef _TDGTDRAW_E_
22#define _TDGTDRAW_E_
23
24#include "tidget.h"
25
26#define TDGTDRAW_DEF_H_PAD 2
27#define TDGTDRAW_DEF_V_PAD 2
28
29struct tagTdgtDraw;
30
31typedef int (TdgtDrawRedrawCallbackFunc)ARGS_DECL((struct tagTdgtDraw *));
32typedef int (TdgtDrawEvHandlerCallbackFunc)ARGS_DECL((struct tagTdgtDraw *,
33		XEvent*));
34typedef int (TdgtDrawResetCallbackFunc)ARGS_DECL((struct tagTdgtDraw *));
35typedef int (TdgtDrawSendCmdCallbackFunc)ARGS_DECL((struct tagTdgtDraw *,
36		int cmd_type, int cmd_arg, void *pv_cmd_userdata));
37
38/*
39 * A drawing area tidget uses callback routings to handl redraws
40 *         and mouse events.
41 */
42typedef struct tagTdgtDraw {
43   TidgetInfo *pti;
44
45   SimpleWinInfo client_area;
46
47   void *pv_userdata;
48
49   /* callback functions */
50   TdgtDrawRedrawCallbackFunc *pf_redraw_callback;
51   TdgtDrawEvHandlerCallbackFunc *pf_ev_handler_callback;
52   TdgtDrawResetCallbackFunc *pf_reset_callback;
53   TdgtDrawSendCmdCallbackFunc *pf_sendcmd_callback;
54} TdgtDraw;
55
56#ifdef _INCLUDE_FROM_TDGTDRAW_C_
57#undef extern
58#define extern
59#endif /*_INCLUDE_FROM_TDGTDRAW_C_*/
60
61extern void	TdgtDrawReset ARGS_DECL((TdgtDraw*));
62extern TdgtDraw	*CreateTdgtDraw ARGS_DECL((Window parent_win,
63				TidgetInfo *parent_tidgetinfo, int ctl_id,
64				int x, int y, int client_w, int client_h,
65				int h_pad, int v_pad, int state,
66				void *pv_userdata));
67
68extern int	TdgtDrawSetUserData ARGS_DECL((TdgtDraw*, void *pv_userdata));
69extern char	*TdgtDrawGetUserData ARGS_DECL((TdgtDraw*));
70extern int	TdgtDrawSetState ARGS_DECL((TdgtDraw*, int));
71extern int	TdgtDrawGetState ARGS_DECL((TdgtDraw*));
72
73extern void	TdgtDrawSetRedrawCallback ARGS_DECL((TdgtDraw*,
74				TdgtDrawRedrawCallbackFunc*));
75extern void	TdgtDrawSetEvHandlerCallback ARGS_DECL((TdgtDraw*,
76				TdgtDrawEvHandlerCallbackFunc*));
77extern void	TdgtDrawSetResetCallback ARGS_DECL((TdgtDraw*,
78				TdgtDrawResetCallbackFunc*));
79extern void	TdgtDrawSetSendCmdCallback ARGS_DECL((TdgtDraw*,
80				TdgtDrawSendCmdCallbackFunc*));
81
82extern int	InitTdgtDraw ARGS_DECL((void));
83extern void	CleanUpTdgtDraw ARGS_DECL((void));
84
85#ifdef _INCLUDE_FROM_TDGTDRAW_C_
86#undef extern
87#ifndef _NO_RECURSIVE_EXTERN
88#define extern extern
89#endif /* ~_NO_RECURSIVE_EXTERN */
90#endif /*_INCLUDE_FROM_TDGTDRAW_C_*/
91
92#endif /*_TDGTDRAW_E_*/
93