/*******************************************************************************
*  Copyright 1991-1996 by ORCA Software, Inc.                                  *
*                                                                              *
*  All rights reserved.  May not be reproduced or distributed, in printed or   *
*  electronic form, without permission of ORCA Software, Inc.  May not be      *
*  distributed as object code, separately or linked with other object modules, *
*  without permission.                                                         *
*******************************************************************************/

#define NULL_STX (STX)0

typedef enum
{
  STX_CB_CHAR,
  STX_CB_CHANGE,
  STX_CB_DBL,
  STX_CB_FOCUS
}

STX_CB_TYPE;

typedef struct _stx_cb_data
{
  STX stx;
  STX_CB_TYPE cb_type;
  int cid;
  XinWindow win;
  union
  {
    /* nothing for change notify */
    BOOLEAN refused;
    struct
    {
      int ch;
      BOOLEAN shift;
      BOOLEAN control;
      BOOLEAN alt;
      BOOLEAN is_paste;
      BOOLEAN refused;
    } chr;
  } v;
} STX_CB_DATA;

typedef void ( *STX_CB ) ( STX_CB_DATA * stx_cb_data );

typedef struct _stx_def
{
  int cid;
  XinPoint pnt;
  short pixel_width;
  short pix_char_width;
  unsigned long attrib;
  short text_size;
  XinFont *font;
  XinColor back_color;
  XinColor enabled_color;       /* but inactive */
  XinColor disabled_color;
  XinColor active_color;
  XinColor active_back_color;
  XinColor disabled_back_color;
  XinColor hilight_color;       /* for well and platform fields */
  XinColor shadow_color;        /* for well and platform fields */
  XinRect xi_rct;
  STX_CB stx_cb;
  long app_data;
  char *parent;
  BOOLEAN well;
  BOOLEAN platform;
  BOOLEAN auto_tab;
  BOOLEAN scroll_bar;
  BOOLEAN cr_ok;
  BOOLEAN var_len_text;
  XI_OBJ *parent_obj;
  BOOLEAN button;
  BOOLEAN button_on_left;
  XinRect button_rect;
  XinFlag no_button_space;
  int button_width;
} STX_DEF;

typedef struct _stx_data
{
  int cid;
  XinWindow win;
  XinRect rct;
  XinRect edit_rect;
  unsigned long attrib;
  short pixel_width;
  short pix_baseline;
  XinFont *font;
  XinColor back_color;
  XinColor enabled_color;       /* but inactive */
  XinColor disabled_color;
  XinColor disabled_back_color;
  XinColor active_color;
  XinColor active_back_color;
  XinColor hilight_color;       /* for well and platform fields */
  XinColor shadow_color;        /* for well and platform fields */
  STX_CB stx_cb;
  short text_size;
  long app_data;
  BOOLEAN have_mouse;
  XI_TEXT *xi_text;
  BOOLEAN multi_line;
  BOOLEAN well;
  BOOLEAN platform;
  BOOLEAN auto_tab;
  BOOLEAN scroll_bar;
  BOOLEAN cr_ok;
  BOOLEAN var_len_text;
  char *buf;
  BOOLEAN has_focus;
  XI_OBJ *parent_obj;
  BOOLEAN button;
  BOOLEAN button_on_left;
  XinRect button_rect;
  XinFlag no_button_space;
  int button_width;
#ifdef XI_USE_TX_SUPPORT
  BOOLEAN use_text_edit;
  long txedit;
#endif
} STX_DATA;

#define STX_LOSE_FOCUS NULL_STX

STX stx_create( XinWindow win, STX_DEF * stx_def, XinRect *field_button );
void stx_delete( STX stx, BOOLEAN destroy_font );
void stx_destroy_font( STX stx );
BOOLEAN stx_event( STX stx, XinEvent * ep );
void stx_focus_set( long stx, BOOLEAN set );
unsigned long stx_get_attrib( STX stx );
int stx_get_cid( STX stx );
long stx_get_app_data( STX stx );
void stx_get_sel( STX stx, int *c1, int *c2 );
XinRect *stx_get_rect( STX stx, XinRect * rct );
XinRect *stx_get_inside_rect( STX stx, XinRect * rect );
char *stx_get_text( STX stx, char *s, int len );
void stx_set_app_data( STX stx, long data );
void stx_set_attrib( STX stx, unsigned long attrib );
void stx_set_bufsize( STX stx, short size );
void stx_set_focus( STX stx );
void stx_set_pos( STX stx, XinPoint p );
void stx_set_rect( XinWindow win, STX stx, XinRect *new_rect, XinRect *field_button );
void stx_set_sel( STX stx, int c1, int c2 );
void stx_set_text( STX stx, char *s );
XI_TEXT *stx_xi_text_get( STX stx );
BOOLEAN stx_cr_is_ok( STX stx );
void stx_update_colors( STX stx );
void stx_set_font( STX stx, XinFont* font );

#ifdef XI_USE_TX_SUPPORT
BOOLEAN xi_is_txedit( XI_OBJ * xi_obj );
BOOLEAN xi_xvt_tx_event( XinWindow win, XinEvent * ep );
void xi_tx_edit_move( XI_OBJ * xi_obj );

#endif