void main() {
		int a[3][3] = {{1, 1000, 2000},
					   {20, 1001, 5000},
					   {55, 1002, 22222}};
		Range r = getMinRange(a, 3);
		printf("%d - %d\n", r.start, r.end);
}
/*!
 * Display the menu serial message with the maximum, minimum and current values
 */
static void dispSetValueMessage(void)
{
    int num = 0;
    Direction dir;

    sendROM("\t");
    sendROM(m_currentMenu.serialMessage);
    sendNewLine(1);

    // Enter a value between x and y
    sendROM("\t");
    sendROM(inputNumRangeStr);
    transmit(intToAscii(m_currentMenu.minVal));
    sendROM(and);
    transmit(intToAscii(m_currentMenu.maxVal));
    sendNewLine(1);

    // The current value is:
    sendROM("\t");
    sendROM(currentValueStr);
    switch (m_currentMenu.menuID)
    {
        case AZ_GOTO:
            dir = getDir();
            num = (int) dir.azimuth;
            break;
        case EL_GOTO:
            dir = getDir();
            num = (int) dir.elevation;
            break;
        case AZ_MIN:
            num = getMinAzimuthAngle();
            break;
        case AZ_MAX:
            num = getMaxAzimuthAngle();
            break;
        case EL_MIN:
            num = getMaxAzimuthAngle();
            break;
        case EL_MAX:
            num = getMaxAzimuthAngle();
            break;
        case RANGE_MIN:
            num = getMinRange();
            break;
        case RANGE_MAX:
            num = getMaxRange();
            break;
        case US_SAMPLE_RATE:
            num = getUsSampleRate();
            break;
        case US_SAMPLE_AVG:
            num = getNumSamples();
            break;
    }
    transmit(intToAscii(num));
    sendNewLine(1);
}
示例#3
0
static void notifyParent( HWND hwnd, UINT code = 0 ) {         // NM_ code TODO

    NMRANGESLIDER nm = { { 0 } };
    
    nm.hdr.hwndFrom = hwnd;
    nm.hdr.idFrom = GetWindowID( hwnd );
    nm.hdr.code = code;

    nm.rsInfo._lower       = getLower      ( hwnd );
    nm.rsInfo._upper       = getUpper      ( hwnd );
    nm.rsInfo._start       = getStart      ( hwnd );
    nm.rsInfo._end         = getEnd        ( hwnd );
    nm.rsInfo._minRange    = getMinRange   ( hwnd );
    nm.rsInfo._granularity = getGranularity( hwnd );
    
    FORWARD_WM_NOTIFY(
        GetParent( hwnd ), nm.hdr.idFrom, &nm, SNDMSG );
}
示例#4
0
static void onKey(
    HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags )
{
    long start = getStart( hwnd );
    long end   = getEnd( hwnd );

    const BOOL controlKey = GetAsyncKeyState( VK_CONTROL ) < 0;

    if ( VK_ESCAPE == vk ) {
        if ( htNone != getHTCode( hwnd ) ) {
            setHTCode( hwnd, htNone );
            const LONG oldStart = getSaveStart( hwnd );
            const LONG oldEnd   = getSaveEnd  ( hwnd );
            setStart( hwnd, oldStart );
            setEnd  ( hwnd, oldEnd   );
            invalidateRect( hwnd );
            //onLButtonUp( hwnd, 0, 0, 0 ); // TODO retain capture anyway?
            // TODO notify parent
            return; //** FUNCTION EXIT POINT
        }
    }

    const UINT left_key  = isVertical( hwnd ) ? VK_UP   : VK_LEFT ;
    const UINT right_key = isVertical( hwnd ) ? VK_DOWN : VK_RIGHT;

    long granularity = getGranularity( hwnd );
    if ( granularity <= 0 ) {
        granularity = 1;
    }

    if ( left_key == vk ) {
        if ( controlKey ) {
            if ( getMinRange( hwnd ) < end - start ) {
                end -= granularity;
            }
        } else if ( getLower( hwnd ) < start ) {
            start -= granularity;
            end   -= granularity;
        }
    } else if ( right_key == vk ) {
        if ( end < getUpper( hwnd ) ) {
            end += granularity;
            if ( !controlKey ) {
                start += granularity;
            }
        }
    } else if ( VK_PRIOR == vk ) {
        scroll( hwnd, -1, 0 );
        return; //*** FUNCTION EXIT POINT
    } else if ( VK_NEXT == vk ) {
        scroll( hwnd, 1, 0 );
        return; //*** FUNCTION EXIT POINT
    } else if ( VK_HOME == vk ) {
        const long range = abs( getLower( hwnd ) - start );
        start -= range;
        end   -= range;
    } else if ( VK_END == vk ) {
        const long range = abs( getUpper( hwnd ) - end );
        start += range;
        end   += range;
    }

    start = adjust( hwnd, start );
    end   = adjust( hwnd, end   );
    if ( start != getStart( hwnd ) || end != getEnd( hwnd ) ) {
        setStart( hwnd, start );
        setEnd  ( hwnd, end );
        invalidateRect( hwnd );
        invalidateCursor();
        notifyParent( hwnd );
    }
}