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

#include 

#if @HELP_SETAUTOSCALE

    SETAUTOSCALE

    Purpose: Sets window autoscaling

    Syntax:  SETAUTOSCALE(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);setautoscale(0);

             Turns off autoscaling in W1.

    Example:
             setautoscale(W1, 1)

             Turns on autoscaling for Window 1.

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

    See Also:
             Rttinit
             Getautoscale
             Getxautoscale
             Getyautoscale
             Setxautoscale
             Setyautoscale
#endif


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

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

                        /* set EX_WIN_NOSCALE bit */
                        if (val) exstyle |= EX_WIN_NOSCALE;
                        
                        winexstyle(W0, exstyle);

                        setxautoscale(w0, not(val));
                        setyautoscale(w0, not(val));
                }
        }
        else
        {
                val = val == 0;
                exstyle = winexstyle(win);
                
                /* clear EX_WIN_NOSCALE bit */
                exstyle &= ~EX_WIN_NOSCALE;
                
                if (val) exstyle |= EX_WIN_NOSCALE;
                
                winexstyle(win, exstyle);

                setxautoscale(win, not(val));
                setyautoscale(win, not(val));
        }
}