#ifndef _CHINPUT_ALL_HEADER_
#  define _CHINPUT_ALL_HEADER_

#  define DEBUG_XIM

#  define __USE_GNU
#    include <fcntl.h>
#  undef  __USE_GNU

#  include <stdio.h>
#  include <sys/types.h>
#  include <sys/stat.h>
#  include <sys/socket.h>
#  include <sys/un.h>
#  include <ctype.h>
#  include <stdarg.h>
#  include <locale.h>
#  include <langinfo.h>
#  include <X11/Xlib.h>
#  include <X11/Xutil.h>
#  include <X11/Xos.h>
#  include <X11/Xatom.h>
#  include <X11/keysym.h>
#  include <X11/DECkeysym.h>
#  include <X11/cursorfont.h>
#  include <X11/Xlocale.h>

#  ifdef IMLIB
#    include <Imlib.h>
#  endif

#  include "IMdkit.h"
#  include "Xi18n.h"

#  include "ImmClient.h"
#  include "ImmServer.h"
#  include "ImmModule.h"

#  include "defs.h"
#  include "chinput.h"
#  include "hzserver.h"
#  include "hzclient.h"
#  include "xim.h"
#  include "ic.h"
#  include "keyboard.h"
#  include "docking.h"
#  include "globals.h"
#  include "enc.h"

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from chinput.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_usage (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from config.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_set_2byte (int byte_flag);
void chinput_set_punct (int punct);
void chinput_popup_window (void);
void chinput_hide_window (void);
void chinput_toggle_window_map (void);
void chinput_switch_style (void);
void chinput_set_mode (int m);
int  chinput_get_inputmethod (char *im_name);
void chinput_load_inputmethod (int id);
void chinput_switch_inputmethod (int id);
void chinput_circulate_inputmethod (int directional);


////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from color.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_alloc_color (char *forecolor, char *backcolor, char *bordercolor);
void chinput_get_font_gc (Window win, GC *gc,
		XFontStruct *font_info, char *colorname);
void chinput_get_color_gc (Window win, GC *gc, char *colorname);
int chinput_get_fontstruct (XFontStruct **font_info, char *fontname);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from convert.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_gbstring_to_big5string (char *gbstr, char *big5str, int n);
void chinput_big5string_to_gbstring (char *big5str, char *gbstr, int n);
void chinput_gbmixstring_to_big5mixstring (char *gbmixstr,
		char *big5mixstr, int n);
void chinput_big5mixstring_to_gbmixstring (char *big5mixstr,
		char *gbmixstr, int n);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from docking.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_dock_change_notify (void);
void chinput_dock_callback_dispatch (int sig_num,
		siginfo_t *sig_info, void *misc);
void chinput_dock_init (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from dock_net.c
//
////////////////////////////////////////////////////////////////////////////////
int chinput_net_create_socket (int *sock, const char *addr);
int chinput_net_connect_peer (int *sock, const char *addr);
int chinput_net_set_sock_attr (int sock);
int chinput_net_set_signal_handler (int signum, void *hdlr);
int chinput_net_clear_socket (char *message, int csock, int dsock);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from focus.c
//
////////////////////////////////////////////////////////////////////////////////
Boolean chinput_proc_focus_in (IMChangeFocusStruct *call_data);
Boolean chinput_proc_focus_out (IMChangeFocusStruct *call_data);
Boolean chinput_proc_reset_ic (IMResetICStruct *call_data);
void chinput_proc_set_current_ic (IMForwardEventStruct *call_data);
void chinput_proc_auto_hide (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from ic.c
//
////////////////////////////////////////////////////////////////////////////////
IC *chinput_find_ic (CARD16 icid);
int chinput_find_enc (IMForwardEventStruct *call_data);
int chinput_find_enc_by_ic (int icid);
void chinput_free_all_ic (void);
void chinput_create_ic (IMChangeICStruct *call_data);
void chinput_destroy_ic (IMChangeICStruct *call_data);
void chinput_set_ic (IMChangeICStruct *call_data);
void chinput_get_ic (IMChangeICStruct *call_data);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from init.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_check_pyinput (void);
void chinput_init_resource (void);
void chinput_load_rcfile (void);
void chinput_load_rcime (void);
void chinput_parse_parameters (int argc, char **argv);
void chinput_init_display (void);
void chinput_init_server_atom (void);
void chinput_init_server_font (void);
void chinput_init_server_gc (void);
void chinput_init_icon (void);
void chinput_init_daemon (void);
void chinput_init_signal_handler (void);
void chinput_init_windows (void);
void chinput_init_ime (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from keyboard.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_init_server_virtual_keyboard (int x, int y, int w, int h);
void chinput_vk_draw_window (void);
void chinput_vk_proc_window (int x0, int y0);
void chinput_vk_draw_panel (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from loop.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_enter_loop (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from offspot.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_offspot_map_windows (void);
void chinput_offspot_hide_windows (void);
void chinput_offspot_hide_status_window (IC *ic);
void chinput_offspot_flush (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from onspot.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_onspot_preedit_clear (void);
void chinput_onspot_clear (void);
void chinput_onspot_flush (void);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from overspot.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_overspot_set_location (IC *ic);
void chinput_overspot_proc_caret_window (int x0, int y0);
void chinput_overspot_proc_pointer_select (int x0, int y0);
void chinput_overspot_proc_pointer_pageup (int x0, int y0);
void chinput_overspot_proc_pointer_pagedown (int x0, int y0);
void chinput_overspot_draw_caret (char *buf, int len);
void chinput_overspot_hide_status_window (void);
void chinput_overspot_flush (void);
void chinput_init_server_caret_mode (int x1, int y1, int w1, int h1, 
		int x2, int y2, int w2, int h2);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from root.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_root_unlock_window (void);
void chinput_root_lock_window (void);
void chinput_root_draw_input_area (char *buf, int len);
void chinput_root_draw_panel (void);
void chinput_root_ka_draw_panel (void);
void chinput_root_ka_draw_button (void);
void chinput_root_ka_draw_window (void);
void chinput_root_corner_flush (void);
void chinput_root_punct_flush (void);
void chinput_root_input_flush (void);
void chinput_root_flush (void);
void chinput_root_proc_key (XEvent report);
void chinput_root_proc_2byte (XEvent report);
void chinput_root_proc_punct (XEvent report);
void chinput_root_proc_close_window (XEvent report);
void chinput_root_proc_pop_kwindow (void);
void chinput_root_proc_change_kwindow (int x0, int y0);
void chinput_root_proc_kwindow (int x0, int y0);
void chinput_root_resize_window (int count);


////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from server.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_server_proc_xim (XKeyEvent *key, char *buf, int *charcount);
int chinput_server_set_reply (char ch, char *buf);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from util.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_util_err_exit (void);
void chinput_util_print_sys_err (char *err_format, ...);
void chinput_util_print_sys_msg (char *err_format, ...);
void chinput_util_print_dbg_msg (char *msg_format, ...);
int  chinput_util_locale_to_enc (const char *locale);
Time chinput_util_get_time (void);
void chinput_util_draw_tri_btn (Display *dpy, Window win, GC dimgc, GC lightgc, 
		int x1, int y1, int x2, int y2, int x3, int y3, Boolean flag);
void chinput_util_draw_btn (Display *dpy, Window win, GC dimgc, GC lightgc, 
		int x1, int y1, int x2, int y2, Boolean flag);
void chinput_util_draw_btn_ret (Display *dpy, Window win, GC dimgc, GC lightgc, 
		int x, int y, int bw, int bh, Boolean flag);
void chinput_util_wait_btn_release (void);
Bool chinput_util_in_box (int x0, int y0, int x1, int y1, int x2, int y2);
void chinput_util_draw_sunken_border (Display *dpy, Window win,
		GC lightgc, GC dimgc, int x1, int y1, int x2, int y2);
void chinput_util_send_keysym (unsigned long keysym,
		Boolean f_shift, Boolean f_control, Boolean f_alt);
void chinput_util_send_event (unsigned char c,
		Boolean f_shift, Boolean f_control, Boolean f_alt);
int  chinput_util_err_hdlr (Display *dpy, XErrorEvent *ev);
void chinput_util_exit (void);
void chinput_util_free_all (void);
Window chinput_util_create_win (int x, int y, int w, int h);
void chinput_util_draw_str (Window win, GC gc, int x, int y, char *str, int num);
void chinput_util_draw_mbstr (Display *dpy, Window win,
		XFontSet fs, GC gc, int x, int y, char *str, int num);
void chinput_util_draw_btn_label (Display *dpy, Window win,
		GC pgc, int x1, int yy1, int x2, int y2,
		int offset, char *str, int len);
int  chinput_util_mb_strlen (char *s, int len);
void chinput_util_candidate_preprocess (char *s);
Window chinput_util_find_top_win (Window win);
void chinput_util_proc_left_btn (XEvent report);
void chinput_util_proc_right_btn (void);
void chinput_util_proc_move_win (void);
Boolean chinput_util_file_exist (char *fname);

////////////////////////////////////////////////////////////////////////////////
//
//                    Public Functions from xim.c
//
////////////////////////////////////////////////////////////////////////////////
void chinput_xim_forward_string (char *text, int len);
int  chinput_xim_forward_event  (unsigned long keysym, Boolean f_shift, Boolean f_control, Boolean f_alt);
Boolean chinput_xim_proto_hdlr (XIMS ims, IMProtocol *call_data);
void chinput_xim_init (void);

#endif
