!**************************************************************************
!
! $Id: xstructures.inc,v 1.1 2008/07/19 22:30:29 jgs Exp $
!
! Description:	Common block shared in X-based graphics routines 
!
!**************************************************************************


! Keypress flags for special keys set in Mx.key_press by MX$IFEVENT, and
! sent to MX$CLIENT_EVENT and MX$ARROW.

	integer*4 L_ArrowLeft
	parameter (L_ArrowLeft = 1001)
	integer*4 L_ArrowRight
	parameter (L_ArrowRight = 1002)
	integer*4 L_ArrowUp
	parameter (L_ArrowUp = 1003)
	integer*4 L_ArrowDown
	parameter (L_ArrowDown = 1004)
	integer*4 L_ReturnKey
	parameter (L_ReturnKey = 1005)
	integer*4 L_InsertKey
	parameter (L_InsertKey = 1006)
	integer*4 L_DeleteKey
	parameter (L_DeleteKey = 1007)
	integer*4 L_F14Key
	parameter (L_F14Key = 1008)
	integer*4 L_TabKey
	parameter (L_TabKey = 1009)
	integer*4 L_HelpKey
	parameter (L_HelpKey = 1010)

! Keypress mask bits for MX.state_mask

	integer*4 L_ShiftKeyMask
	parameter (L_ShiftKeyMask = 1)
	integer*4 L_ControlKeyMask
	parameter (L_ControlKeyMask = 2)
	integer*4 L_Mod1KeyMask
	parameter (L_Mod1KeyMask = 4)
	integer*4 L_Mod2KeyMask
	parameter (L_Mod2KeyMask = 8)
	integer*4 L_Mod3KeyMask
	parameter (L_Mod3KeyMask = 16)
	integer*4 L_Mod4KeyMask
	parameter (L_Mod4KeyMask = 32)
	integer*4 L_Mod5KeyMask
	parameter (L_Mod5KeyMask = 64)
	integer*4 L_Button1Mask
	parameter (L_Button1Mask = 128)
	integer*4 L_Button2Mask
	parameter (L_Button2Mask = 256)
	integer*4 L_Button3Mask
	parameter (L_Button3Mask = 512)
	integer*4 L_ClientEventMask
	parameter (L_ClientEventMask = 32768)

	integer*4 L_AvalRedraw
	parameter (L_AvalRedraw = -2)

! COLOR flags for MX$COLORTEXT, MX$DRAW_LINES, MX$TRACE, etc.

	integer*4 L_BGColor
	parameter (L_BGColor = 0)
	integer*4 L_FGColor
	parameter (L_FGColor = -1)
	integer*4 L_XORColor
	parameter (L_XORColor = -2)
	integer*4 L_XWFGColor
	parameter (L_XWFGColor = -3)
	integer*4 L_XWBGColor
	parameter (L_XWBGColor = -4)
	integer*4 L_XWTSColor
	parameter (L_XWTSColor = -5)
	integer*4 L_XWBSColor
	parameter (L_XWBSColor = -6)
	integer*4 L_XWLoColor
	parameter (L_XWLoColor = -7)
	integer*4 L_NoColor
	parameter (L_NoColor = -8)

! MX$FILL_POLYGON flags

	integer*4 L_convex
	parameter (L_convex = 1)
	integer*4 L_nonconvex
	parameter (L_nonconvex = -1)

! MX$DRAW_MODE flags

	integer*4 L_solid
	parameter (L_solid = 800)
	integer*4 L_dashed
	parameter (L_dashed = 801)
	integer*4 L_RModeOff
	parameter (L_RModeOff = 900)
	integer*4 L_RModeOn
	parameter (L_RModeOn = 901)

	integer*4 L_PixelSymbol
	parameter (L_PixelSymbol = 1)
	integer*4 L_CircleSymbol
	parameter (L_CircleSymbol = 2)
	integer*4 L_SquareSymbol
	parameter (L_SquareSymbol = 3)
	integer*4 L_PlusSymbol
	parameter (L_PlusSymbol = 4)
	integer*4 L_XSymbol
	parameter (L_XSymbol = 5)
	integer*4 L_TriangleSymbol
	parameter (L_TriangleSymbol = 6)
	integer*4 L_ITriangleSymbol
	parameter (L_ITriangleSymbol = 7)

! MX$CLIENT_EVENT flags

	integer*4 L_SendButtonPress
	parameter (L_SendButtonPress = 1)
	integer*4 L_SendButtonRelease
	parameter (L_SendButtonRelease = -1)
	integer*4 L_SendKeyPress
	parameter (L_SendKeyPress = 2)
	integer*4 L_SendKeyRelease
	parameter (L_SendKeyRelease = -2)
	integer*4 L_SendMotion
	parameter (L_SendMotion = 3)
	integer*4 L_UserEvents_Msg
	parameter (L_UserEvents_Msg = 4)
	integer*4 L_Deiconify_Msg
	parameter (L_Deiconify_Msg = 5)
	integer*4 L_Iconify_Msg
	parameter (L_Iconify_Msg = -5)
	integer*4 L_Focus_Msg
	parameter (L_Focus_Msg = 6)
	integer*4 L_MoveResize_Msg
	parameter (L_MoveResize_Msg = 7)
	integer*4 L_Move_Msg
	parameter (L_Move_Msg = 8)
	integer*4 L_Resize_Msg
	parameter (L_Resize_Msg = 78)
	integer*4 L_Teach_Msg
	parameter (L_Teach_Msg = 999)
	integer*4 L_Learn_Msg
	parameter (L_Learn_Msg = -999)

! MX$DRAWAXIS flags

	integer*4 L_gridlines
	parameter (L_gridlines = 1)
	integer*4 L_noaxisbox
	parameter (L_noaxisbox = 2)
	integer*4 L_noxtics
	parameter (L_noxtics = 4)
	integer*4 L_noytics
	parameter (L_noytics = 8)
	integer*4 L_noxtlab
	parameter (L_noxtlab = 16)
	integer*4 L_noytlab
	parameter (L_noytlab = 32)
	integer*4 L_noxplab
	parameter (L_noxplab = 64)
	integer*4 L_noyplab
	parameter (L_noyplab = 128)
	integer*4 L_xontop
	parameter (L_xontop = 256)
	integer*4 L_yonright
	parameter (L_yonright = 512)
	integer*4 L_exactbox
	parameter (L_exactbox = 1024)
	integer*4 L_insidelab
	parameter (L_insidelab = 2048)
	integer*4 L_noxspecs
	parameter (L_noxspecs = L_noxtics+L_noxtlab+L_noxplab)
	integer*4 L_noyspecs
	parameter (L_noyspecs = L_noytics+L_noytlab+L_noyplab)

! Widget Callback Structure

	integer*4 L_CBenable
	parameter (L_CBenable = 1)
	integer*4 L_CBitem
	parameter (L_CBitem = 2)
	integer*4 L_CBnomask
	parameter (L_CBnomask = 0)
	integer*4 L_CBautomask
	parameter (L_CBautomask = 1)
	integer*4 L_CBexit
	parameter (L_CBexit = -1)
	integer*4 L_CBnoaction
	parameter (L_CBnoaction = 0)
	integer*4 L_CBokaction
	parameter (L_CBokaction = 1)

	structure /CBSTRUCT/
	  integer*4 item	! selected item
	  integer*4 mode	! callback mode
	  integer*4 optmask	! mask of toggleable items
	  integer*4 curmask	! state of toggleable items
	  integer*4 status	! return status of callback routine
	  integer*4 flags	! 
	  real*8 value	! 
	end structure


! Following is the structure for specifying real world coordinate system in
! a window.  Structure contains real world and pixel coordinates of a square
! area in the window.  x1 and x2 always specify the left and right edges of
! the square respectively.  y1 and y2 are the top and bottom.  xmin, xmax
! ymin and ymax specify real world values at each of these edges.  Mapping
! of pixel edges to real world values by the graphics libraries depends on
! value of the origin field in the Mx structure below.  Mx.origin's value
! can be 1, 2, 3 or 4 specifying the 4 quadrants of a cartesion coordinate
! system.  The mapping of edges is displayed below:
!
!                      ymax    |    ymax
!                  x          x|x          x
!                  m     2    m|m    1     m
!                  a          i|i          a
!                  x          n|n          x
!                      ymin    |    ymin
!                 -------------+--------------
!                      ymin    |    ymin
!                  x          x|x          x
!                  m     3    m|m    4     m
!                  a          i|i          a
!                  x          n|n          x
!                      ymax    |    ymax
!
! X-Plot is an example of a quadrant 1 plotting field.  stk.ymin is the
! bottom edge of the screen and stk.ymax the top.  X-Raster is a quadrant 4
! field where the stk.ymin value is at the top of the screen and stk.ymax
! is at the bottom (y values increase as you travel lower in the window.)
!

	integer*4 L_stkstruct
	parameter (L_stkstruct = 64)
	integer*4 L_xstack
	parameter (L_xstack = L_stkstruct)

	structure /STKSTRUCT/
	  real*8 xmin	! real world val at x1(origin=1,4) or x2(origin=2,4)
	  real*8 xmax	! real world val at x2(origin=1,4) or x1(origin=2,4)
	  real*8 ymin	! real world val at y2(origin=1,2) or y1(origin=3,4)
	  real*8 ymax	! real world val at y1(origin=1,2) or y2(origin=3,4)
	  real*8 xscl	! ratio of X real world units to pixel units
	  real*8 yscl	! ratio of Y real world units to pixel units
	  integer*4 x1	! left edge relative to window (pixels)
	  integer*4 y1	! top edge relative to window (pixels)
	  integer*4 x2	! right edge relative to window (pixels)
	  integer*4 y2	! bottom edge relative to window (pixels)
	end structure

! structure for specifying a pixmap image

	integer*4 L_mapstruct
	parameter (L_mapstruct = 12)

	structure /MAPSTRUCT/
	  integer*2 x, y, w, h
	  integer*4 ip
	end structure

	integer*4 L_pixstruct
	parameter (L_pixstruct = 4)

	structure /PIXSTRUCT/
	  integer*2 x
	  integer*2 y
	end structure

	integer*4 L_FreeMap
	parameter (L_FreeMap = 1)
	integer*4 L_NewMap
	parameter (L_NewMap = 2)
	integer*4 L_PutMap
	parameter (L_PutMap = 4)
	integer*4 L_MoveMap
	parameter (L_MoveMap = 8)
	integer*4 L_ClipMap
	parameter (L_ClipMap = 16)

!************************************
! Mx common graphics context structure
!************************************

	integer*4 L_stack
	parameter (L_stack = 10)
	integer*4 L_color
	parameter (L_color = 64)
	integer*4 L_zoommax
	parameter (L_zoommax = 10)

	structure /MX/

	  character*20 name	! name of primitive (used for MHELP)
	  character*40 title	! title displayed in window title bar
	  character*40 node	! display server node to plot to
	  character*80 wspace! RDA: CDE workspace(s) to display to (names or #'s)

	  integer*4 left! distance of win from left edge of screen (pixels)
	  integer*4 top! distance of win from top edge of screen (pixels)
	  integer*4 width		! width of window (pixels)
	  integer*4 height		! height of window (pixels)

	  integer*4 screen_width	! width of screen (pixels)
	  integer*4 screen_height	! height of screen (pixels)

	  integer*4 text_size_lock! /XTS value, locks text font size if abs val > 1
	  integer*4 text_w		! width of text font in pixels
	  integer*4 text_h! height of text font (plus 1/3 for line spacing)

	  logical*4 breakflag	! graphics break flag, set by window Close
	  logical*4 icon		! is window currently iconified ?
	  logical*4 noevent! process user events ? (mouse clicks, keyboard, etc)
	  integer*4 origin	! Mx.stk() origin quadrant (1, 2, 3 or 4)
	  logical*4 rmode! use double lines and extra GC for XOR graphics ?
	  logical*4 no_arrow_move! disallow mouse moves with arrow keys ?
	  integer*2 noexit! value disabling window exit: 1=CR,2=menu,3=WinMgr
	  integer*2 xs		! /XS value for macros with window setup files

	  character*20 xtag	! result to write LM click X location to
	  character*20 ytag	! result to write LM click Y location to
	  character*20 ztag	! result to write LM click Z location to
	  character*20 xytag	! result to write LM click X+Y location to

	  logical*4 exposure	! part or all of window exposed ?
	  logical*4 resize		! window resized ?
	  logical*4 motion_notify	! mouse moved in window ?
	  integer*4 xpos	! x pixel loc of mouse when event occurred
	  integer*4 ypos	! y pixel loc of mouse when event occurred
	  integer*4 button_press! mouse button pressed: 1=LM, 2=MM, 3=RM
	  integer*4 button_release! mouse button released: 1=LM, 2=MM, 3=RM
	  integer*2 key_press! integer value of keyboard key pressed (0 if none)
	  character key_char	! ASCII character of keyboard key pressed
	  character key_upchar	! upcase of key_char above
	  integer*4 state_mask	! state of modifier keys and mouse buttons

	  byte xi	! -1=normal, 1=white bg, 2=B&W white bg, -2=B&W
	  byte xcmax	! /XCMAX switch - limits the number of colors allocated
	  integer*2 shrcmap	! /XCSHR switch for ds prims sharing colormaps
	  integer*2 clast		! internal field
	  integer*2 parent! parent window xs id (if <= 0 user root window)
  	! RDA: change all color-carrying pixels to 4-bytes!!!! 
	  integer*4 xwlo! color pixel location of xwidget back contrast color
	  integer*4 xwbs! color pixel location of xwidget bottom shadow color
	  integer*4 xwts! color pixel location of xwidget top shadow color
	  integer*4 xwbg! color pixel location of xwidget background color
	  integer*4 xwfg! color pixel location of xwidget foreground color
	  integer*4 tpix		! scratch color area for mx_colorlab
	  integer*4 white		! color pixel location of fg color
	  integer*4 black		! color pixel location of bg color
	  integer*4 pixel(L_color)! color pixel locations of allocated colors

  	!-- (optional) requested screen Visual (colormap) characteristics
	  integer*4 visDepth! /VISDEPTH= typically 4,8,24 bits - Xserver dependent
	  integer*4 visClass! /VISCLASS= 0..5 = StaticGray .. TrueColor,DirectColor
	  integer*4 visID! /VISUALID=    Explicit ID (as from xdpyinfo utility)
	  integer*4 visDebug        ! /VISUALDEBUG= Debug flag
	  integer*4 scanline_pad! pixmap/window image parameter for selected visual
	  integer*4 bits_per_pixel! pixmap/window image parameter for selected visual

!+++
! jdh added
	  integer*4 font_id
	  integer*4 headless
!---

!+++
! DR 11175
	  integer*4 disable_menu
	  integer*4 filler
!---

	  record /STKSTRUCT/ stk(L_stack)	! real world coordinate systems
	  integer*4 level		! current valid stk structure in array

	  integer*4 zlevel			! internal MX$ZOOM fields
	  record /MAPSTRUCT/ zoom(L_zoommax)

	  byte GLOBALS(160)	! internal graphics library globals

	end structure

! const int_4  L_Mx	1608  !RDA: was 1288;changed 15-mar-99
! const int_4  L_Mx	1616  !JDH: was 1608;changed 05-sep-00  
	integer*4 L_Mx  ! DR 11175
	parameter (L_Mx = 1624)


