rpatch');
      if ~isempty(otherpatch)
         % Never put new limit beyond the other limit
         otherx = get(otherpatch,'XData');
         otherx = otherx(2);
         xbnd = min(xbnd, xlim(1) + .9*(otherx-xlim(1)));
      end
      x = [xlim(1), xbnd,    xbnd,    xlim(1), xlim(1)];
      y = [ylim(1), ylim(1), ylim(2), ylim(2), ylim(1)];
      if isempty(hPatch)
         patch(x,y,[.8 .8 .8],'Parent',ax,'Tag','lowerpatch',...
            'FaceAlpha',0.6,'ButtonDownFcn',@startselect);
      else
         set(hPatch,'XData',x,'YData',y);
      end
         
      newtxt = getString(message('stats:dfstrings:button_RemoveLowerLimit'));
   else
      delete(hPatch);
      newtxt = getString(message('stats:dfstrings:button_AddLowerLimit'));
   end
else
   hPatch = findall(fig,'Tag','upperpatch');
   if isempty(hPatch) || forceadd
      otherpatch = findall(fig,'Tag','lowerpatch');
      if ~isempty(otherpatch)
         % Never put new limit beyond the other limit
         otherx = get(otherpatch,'XData');
         otherx = otherx(2);
         xbnd = max(xbnd, xlim(2) - .9*(xlim(2)-otherx));
      end
      x = [xlim(2), xbnd,    xbnd,    xlim(2), xlim(2)];
      y = [ylim(1), ylim(1), ylim(2), ylim(2), ylim(1)];
      if isempty(hPatch)
         patch(x,y,[.8 .8 .8],'Parent',ax,'Tag','upperpatch',...
            'FaceAlpha',0.6,'ButtonDownFcn',@startselect);
      else
         set(hPatch,'XData',x,'YData',y);
      end
      newtxt = getString(message('stats:dfstrings:button_RemoveUpperLimit'));
   else
      delete(hPatch);
      newtxt = getString(message('stats:dfstrings:button_AddUpperLimit'));
   end
end

% Update button text
button = findobj(fig,'Tag',whichbound);
set(button,'String',newtxt);

% ------------- function to initiate graphical selection
function startselect(varargin)

% Get figure and axis handles, define functions to do and end selection
subfig = gcbf;
ax = get(subfig,'CurrentAxes');

% Get current exclusion limits, use axis limits if none
lims = get(ax,'XLim');
hPatch = findall(subfig,'Tag','lowerpatch');
if ~isempty(hPatch)
   x = get(hPatch,'XData');
   lims(1) = max(x(:));
end
hPatch = findall(subfig,'Tag','upperpatch');
if ~isempty(hPatch)
   x = get(hPatch,'XData');
   lims(2) = min(x(:));
end

% Save information for other functions
hPatch = gcbo;
set(subfig,'WindowButtonMotionFcn',{@movepatch hPatch},...
           'WindowButtonUpFcn',@endmove);
setappdata(ax,'limits',lims);
setappdata(ax,'objmoving',hPatch);


% ------------- function to update GUI
function updateGUI()
subfig = gcbf;

hPatch = findall(subfig,'Tag','lowerpatch');
if isempty(hPatch)
   xl = '';
else
   xl = get(hPatch,'XData');
   xl = num2str(xl(2));
end
hPatch = findall(subfig,'Tag','upperpatch');
if isempty(hPatch)
   xh = '';
else
   xh = get(hPatch,'XData');
   xh = num2str(xh(2));
end

com.mathworks.toolbox.stats.Exclude.getExcludePanel.updateBoundsFields(xl, xh);


% ------------- function to complete graphical selection
function endmove(varargin)

% Turn off window functions to end selection
subfig = gcbf;
set(subfig,'WindowButtonMotionFcn',@fixcursor, 'WindowButtonUpFcn',[]);
updateGUI;

% ------------- move patch boundary
function movepatch(ignore1,ignore2,hPatch)

varargin
subfig = gcbf;
ax = get(subfig,'CurrentAxes');

% Get exclusion limits and axis limits
lims = getappdata(ax,'limits');
xlim = get(ax,'XLim');
delta = .01 * abs(xlim(2) - xlim(1));

% Extend patch to the current point, but within limits
cp = get(gca,'CurrentPoint');
x = cp(1);
if isequal(get(hPatch,'Tag'),'lowerpatch')
   lobnd = xlim(1) + min(d/*++

Copyright (c) Microsoft Corporation. All rights reserved.

Module Name:

    msptrmvc.cpp

Abstract:

    MSP base classes: declaration of video capture terminal.

--*/


#ifndef _MSPTRMVC_H_
#define _MSPTRMVC_H_
#include <winapifamily.h>

#pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)

    
/////////////////////////////////////////////////////////////////////////////
// CVideoCaptureTerminal

class CVideoCaptureTerminal : 
    public CSingleFilterStaticTerminal
{
public:

    CVideoCaptureTerminal();
    virtual ~CVideoCaptureTerminal();

public:

    static HRESULT CreateTerminal(
        IN    CComPtr<IMoniker>    pMoniker,
        IN    MSP_HANDLE           htAddress,
        OUT   ITTerminal         **ppTerm
        );

// If we add any additional interfaces to this class then
// we must uncomment and expand the following.
//
// BEGIN_COM_MAP(CVideoCaptureTerminal)
//    COM_INTERFACE_ENTRY_CHAIN(CSingleFilterStaticTerminal)
// END_COM_MAP()

DECLARE_LOG_ADDREF_RELEASE(CVideoCaptureTerminal);

private:

    // CBaseTerminal required overrides 

    virtual HRESULT AddFiltersToGraph();

    virtual LONG CountOfMediaTypes()
    {
        return 1;
    }

    virtual DWORD GetSupportedMediaTypes(void)
    {
        return (DWORD) TAPIMEDIATYPE_VIDEO;
    }

    // Helper methods.
    HRESULT CreateFilters();
    HRESULT FindCapturePin();
};



inline 
CVideoCaptureTerminal::CVideoCaptureTerminal(
    )                                   
{
    m_TerminalDirection = TD_CAPTURE;
    m_TerminalType = TT_STATIC;
}


#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
#pragma endregion

#endif // _MSPTRMVC_H_
