/* sui_dinfo.h
 *
 * Header file for DINFO (data info structures) common functions
 * 
 * Version 0.1
 * Copyright holders and project originators
 *   (C) 2002 by Roman Bartosinski, bartosr@centrum.cz
 *   (C) 2002 by PiKRON Ltd. http://www.pikron.com
 *   (C) 2001 by Pavel Pisa pisa@cmp.felk.cvut.cz
 *
 * The SUITK project can be used and copied under next licenses
 *   - MPL - Mozilla Public License
 *   - GPL - GNU Public License
 *   - LGPL - Lesser GNU Public License
 *   - and other licenses added by project originators
 * Code can be modified and re-distributed under any combination
 * of the above listed licenses. If contributor does not agree with
 * some of the licenses, he can delete appropriate line.
 * Warning, if you delete all lines, you are not allowed to
 * distribute code or build project.
 *
 */

#ifndef _SUI_EVENT_H_
  #define _SUI_EVENT_H_

  #include "sui_internal.h"

/* event struct */
  struct sui_event;

/*********************************************************/
/* Event types and structs                               */
/*********************************************************/

/**
 * struct sui_event - Common suitk event structure
 * @what: Code of event.(See 'event_code' enum with 'SUEV_' prefix)
 * @buttons: Mouse flags of pressed buttons in mouse events.
 * @dblclk: Mouse button was double clicked.
 * @x: Mouse horizontal position in mouse events. 
 * @y: Mouse vertical position in mouse events.
 * @keycode: Key code in keyboard events.
 * @modifiers: Flags of keyboard modifiers (SHIFT,CTRL,ALT,...) in keyboard events.
 * @scancode: Scan code of key in keybord events. 
 *
 * File: sui_base.h
 */
  typedef struct sui_event {
    unsigned short what;
    union {
      struct { 
        short buttons; 
        short dblclk; 
        int x; 
        int y; 
      } mouse;      
      struct { 
        unsigned short keycode;
        unsigned short modifiers; /* key modifiers mask */
        unsigned short scancode;
      } keydown;
      struct { 
        short command;
        void *ptr;
        long info;
      } message;
      struct {
       #if 0
        sui_dc_t *dc;
       #else
        void *dc;
       #endif
      } draw;
    } u_u;
  } sui_event_t;

/**
 * enum event_code - Code of SUITK events ['SUEV_' prefix]
 * @SUEV_MDOWN: Mouse button is down.
 * @SUEV_MUP: Mouse button is up.
 * @SUEV_MMOVE: Mouse is in move.
 * @SUEV_MAUTO: 
 * @SUEV_KDOWN: Key is down.
 * @SUEV_KUP: Key is up.
 * @SUEV_DRAW: Draw widget.
 * @SUEV_REDRAW: Redraw widget.
 * @SUEV_COMMAND: Command event.
 * @SUEV_BROADCAST: Bradcast event.
 * @SUEV_SIGNAL: ?
 * @SUEV_GLOBAL: ?
 * @SUEV_FREE: ?
 * @SUEV_NOTHING: ?
 * @SUEV_MOUSE: ?
 * @SUEV_KEYBOARD: ?
 * @SUEV_MESSAGE: ?
 * @SUEV_DEFMASK: ?
 * @SUEV_GRPMASK: ?
 * File: sui_base.h
 */
  enum event_code {
    /* Event codes */
    SUEV_MDOWN     = 0x0001,
    SUEV_MUP       = 0x0002,
    SUEV_MMOVE     = 0x0004,
    SUEV_MAUTO     = 0x0008,
    SUEV_KDOWN     = 0x0010,
    SUEV_KUP       = 0x0020,
    SUEV_DRAW      = 0x0040,
    SUEV_REDRAW    = 0x0080,
    SUEV_COMMAND   = 0x0100,
    SUEV_BROADCAST = 0x0200,
    SUEV_SIGNAL    = 0x0400,
    SUEV_GLOBAL    = 0x0800,  
    SUEV_FREE      = 0x8000,
    SUEV_NOTHING   = 0x0000,
    /* Event masks */
    SUEV_MOUSE     = 0x000f,
    SUEV_KEYBOARD  = 0x0030,
    SUEV_MESSAGE   = 0x7FC0,
    SUEV_DEFMASK   = SUEV_MDOWN|SUEV_DRAW|SUEV_KDOWN|SUEV_REDRAW
                     |SUEV_COMMAND|SUEV_SIGNAL|SUEV_BROADCAST|SUEV_FREE,
    SUEV_GRPMASK   = SUEV_DEFMASK|SUEV_MESSAGE|SUEV_MOUSE|SUEV_KEYBOARD
  };
  
/**
 * enum command_event - Command codes for command event ['SUCM_' prefix]
 * @SUCM_VALID: VALID command event.
 * @SUCM_QUIT: QUIT command event.
 * @SUCM_ERROR: ERROR command event.
 * @SUCM_MENU: MENU command event. Open, select, close, ... menu.
 * @SUCM_CLOSE: CLOSE command event.
 * @SUCM_ZOOM: ZOOM command event.
 * @SUCM_RESIZE: RESIZE command event.
 * @SUCM_NEXT: NEXT command event. Mainly for change widget focus by pressing TAB key.
 * @SUCM_PREV: PREV command event. Mainly for change widget focus by pressing SHIFT+TAB key.
 * @SUCM_HELP: HELP command event.
 * @SUCM_OK: OK button pressed.
 * @SUCM_CANCEL: CANCEL button pressed.
 * @SUCM_YES: YES button pressed.
 * @SUCM_NO: NO button pressed.
 * @SUCM_DEFAULT: DEFAULT button pressed.
 * @SUCM_FOCUSASK: Which widget has focus ?
 * @SUCM_FOCUSSET: Set focus to the widget.
 * @SUCM_FOCUSREL: Release focus from the widget.
 * @SUCM_INIT: Initialize widget.
 * @SUCM_DONE: Done widget - decrement reference counter, deallocate widget data.
 * @SUCM_NEWDISPLAY: Create new screen from pointer to screen.
 * @SUCM_DISPNUMB: Create new screen from number to screen.
 * @SUCM_CHANGE_STBAR: Status bar is changed.
 * @SUCM_NEXT_GROUP: Change focus between groups (like as ALT+TAB in Windows).
 * @SUCM_PREV_GROUP: Change focus between groups.
 *
 * File: sui_base.h
 */  
  enum command_event {
    /* Standard command codes */
    SUCM_VALID         = 0,
    SUCM_QUIT          = 1,
    SUCM_ERROR         = 2,
    SUCM_MENU          = 3,
    SUCM_CLOSE         = 4,
    SUCM_ZOOM          = 5,
    SUCM_RESIZE        = 6,
    SUCM_NEXT          = 7,
    SUCM_PREV          = 8,
    SUCM_HELP          = 9,
    SUCM_OK            = 10,
    SUCM_CANCEL        = 11,
    SUCM_YES           = 12,
    SUCM_NO            = 13,
    SUCM_DEFAULT       = 14,
  
    SUCM_FOCUSASK      = 15,
    SUCM_FOCUSSET      = 16,
    SUCM_FOCUSREL      = 17,
    SUCM_INIT          = 18,	/* ptr=dc */
    SUCM_DONE          = 19,
    
    SUCM_NEWDISPLAY    = 20,	/* ptr=new display */
    SUCM_DISPNUMB      = 21,	/* info=number of new display */
    SUCM_CHANGE_STBAR  = 22,

    SUCM_NEXT_GROUP    = 23, /* added for change focus between groups */
    SUCM_PREV_GROUP    = 24,

    SUCM_EVC_LINK_TO   = 25,    /* ptr=evc_link, info=dst */
  };

  enum sui_signal_event {
    SUSIG_DINFO_CHANGING= 1,    /* ptr=dinfo */
    SUSIG_DINFO_CHANGED = 2,    /* ptr=dinfo */
  };

#endif /* _SUI_EVENT_H_ */

