View Raw SPL
/*****************************************************************************
*                                                                            *
*   SETXAUTOSCALE.SPL Copyright (C) 2018 DSP Development Corporation         *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Sets window X autoscaling                                   *
*                                                                            *
*   Revisions:   13 Jul 2018  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#include 

#if @HELP_SETXAUTOSCALE

    SETXAUTOSCALE

    Purpose: Sets window X autoscaling

    Syntax:  SETXAUTOSCALE(win, on_off)

              win    - an optional window, defaults to current window
              on_off - an integer 0:off 1:autoscale on (default 1)

    Returns: Nothing

    Example:
             W1: gsin(1000,1/1000,4);setxautoscale(0);

             Turns off X autoscaling in W1.

    Example:
             setxautoscale(W1, 1)

             Turns on X autoscaling for Window 1.

    Remarks:
             SETXAUTOSCALE is useful for data in real time Windows.

    See Also:
             Rttinit
             Getautoscale
             Getxautoscale
             Getyautoscale
             Setautoscale
             Setyautoscale
#endif


/* turn X autoscaling ON/OFF */
setxautoscale(win, val)
{
        local exstyle;

        /* autoscaling is a winexstyle bit */
        if (argc < 1)
        {
                return((winexstyle(W0) & EX_WIN_X_NOSCALE) == 0);
        }
        else if (argc == 1)
        {
                if (iswindow(win))
                {
                        return((winexstyle(win) & EX_WIN_X_NOSCALE) == 0);
                }
                else
                {
                        val = win == 0;
                        exstyle = winexstyle(W0);
                        
                        /* clear EX_WIN_X_NOSCALE bit */
                        exstyle &= ~EX_WIN_X_NOSCALE;

                        /* set EX_WIN_X_NOSCALE bit */
                        if (val) exstyle |= EX_WIN_X_NOSCALE;
                        
                        winexstyle(W0, exstyle);
                }
        }
        else
        {
                val = val == 0;
                exstyle = winexstyle(win);
                
                /* clear EX_WIN_X_NOSCALE bit */
                exstyle &= ~EX_WIN_X_NOSCALE;
                
                if (val) exstyle |= EX_WIN_X_NOSCALE;
                
                winexstyle(win, exstyle);
        }
}