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/tidget.e,v 1.8 2011/05/16 16:22:00 william Exp $
19 */
20
21#ifndef _TIDGET_E_
22#define _TIDGET_E_
23
24#include "tidget.h"
25
26#include "list.e"
27
28#define TDGT_NOTIFY ((long)0x80000002)
29
30typedef void (TidgetDrawMsgStringFunc)ARGS_DECL((Display*, Window, GC, int,
31                int, char*, int));
32typedef int (TidgetMsgTextWidthFunc)ARGS_DECL((XFontStruct*, char*, int));
33
34typedef struct tagTidgetManager {
35   GC gc;
36
37   int want_all_key_press_events;
38   TidgetInfo *key_press_base_tidgetinfo;
39
40   Atom notify_atom;
41
42   CVList toplevel_tidgets; /* list of (TidgetInfo*) */
43} TidgetManager;
44
45extern TidgetManager	gTidgetManager;
46
47#ifdef _INCLUDE_FROM_TIDGET_C_
48#undef extern
49#define extern
50#endif /*_INCLUDE_FROM_TIDGET_C_*/
51
52extern void	TidgetWindowNotify ARGS_DECL((Window, int ctl_id, int nf_type,
53				int nf_arg, int nf_arg2));
54extern void	TidgetNotify ARGS_DECL((TidgetInfo*, int ctl_id, int nf_type,
55				int nf_arg, int nf_arg2));
56extern void	TidgetControlNotify ARGS_DECL((TidgetInfo*, int nf_type,
57				int nf_arg, int nf_arg2));
58
59extern int	IsTdgtWindowNotifyEvent ARGS_DECL((Window, XEvent*, TdgtNtfy*));
60extern int	IsTdgtNotifyEvent ARGS_DECL((TidgetInfo*, XEvent*, TdgtNtfy*));
61
62extern void	TidgetDrawFocusRect ARGS_DECL((TidgetInfo*, SimpleWinInfo*));
63extern void	RedrawTidget ARGS_DECL((TidgetInfo*));
64extern int	TidgetEventHandler ARGS_DECL((TidgetInfo*, XEvent*,
65				TidgetInfo *pti_handler_tidget));
66extern int	IsTidgetEvent ARGS_DECL((TidgetInfo*, XEvent*,
67				TidgetInfo **ppti_handler_tidget_return));
68
69extern void	DestroyTidget ARGS_DECL((TidgetInfo**));
70extern void	SetTidgetInfoBasic ARGS_DECL((TidgetInfo*, int tidget_type,
71				void *tidget, Window parent_win, int x, int y,
72				int w, int h, int h_pad, int v_pad, int state,
73				char *caption));
74extern void	TidgetCanHaveChildren ARGS_DECL((TidgetInfo*, int));
75extern void	TidgetSetCallbacks ARGS_DECL((TidgetInfo*,
76				TidgetRedrawCallbackFunc*,
77				TidgetEvHandlerCallbackFunc*,
78				TidgetIsEventCallbackFunc*,
79				TidgetDestroyCallbackFunc*,
80				TidgetMapCallbackFunc*,
81				TidgetMoveResizeCallbackFunc*,
82				TidgetSendCmdCallbackFunc*));
83extern TidgetInfo	*NewTidgetInfo ARGS_DECL((TidgetInfo *parent_tidgetinfo,
84				int type, void *tidget, int ctl_id,
85				void *userdata));
86extern void	MapTidget ARGS_DECL((TidgetInfo*));
87extern void	TidgetMoveResize ARGS_DECL((TidgetInfo*, int x, int y, int w,
88				int h));
89extern void	ResetTidgetCommon ARGS_DECL((TidgetCommonInfo*));
90
91extern int	TidgetSendCmd ARGS_DECL((TidgetInfo*, int cmd_type, int cmd_arg,
92				void *pv_cmd_userdata));
93
94extern int	TidgetDisableRedraw ARGS_DECL((TidgetInfo*, int));
95extern int	TidgetSetDirty ARGS_DECL((TidgetInfo*, int));
96
97extern int	TidgetHasFocus ARGS_DECL((void));
98extern int	TidgetSetHasFocus ARGS_DECL((int nHasFocus));
99extern Window	TidgetGetFocusWindow ARGS_DECL((void));
100extern Window	TidgetSetFocusWindow ARGS_DECL((Window));
101extern int	TidgetIsFocus ARGS_DECL((TidgetInfo*));
102
103extern void	TidgetGetFontInfo ARGS_DECL((int *pnFontIndex, int *pnSzUnit));
104
105extern void	TidgetGetFontInfoGivenStyle ARGS_DECL((int font_style,
106				XFontStruct **pp_font_ptr, int *pn_font_width,
107				int *pn_font_height, int *pn_font_asc,
108				int *pn_font_des));
109
110extern void	TidgetManagerResetGC ARGS_DECL((void));
111extern int	TidgetManagerHandleEvent ARGS_DECL((XEvent*));
112extern int	TidgetManagerHandleAllKeyPressEvent ARGS_DECL((XEvent*));
113extern int	TidgetManagerWantAllKeyPressEvents ARGS_DECL((void));
114extern int	TidgetManagerSetWantAllKeyPressEvents ARGS_DECL((TidgetInfo*,
115				int want_all_key_press_events));
116
117extern int	InitTidget ARGS_DECL((void));
118extern void	CleanUpTidget ARGS_DECL((void));
119
120#ifdef _INCLUDE_FROM_TIDGET_C_
121#undef extern
122#ifndef _NO_RECURSIVE_EXTERN
123#define extern extern
124#endif /* ~_NO_RECURSIVE_EXTERN */
125#endif /*_INCLUDE_FROM_TIDGET_C_*/
126
127#endif /*_TIDGET_E_*/
128