亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? slider.c

?? STM32+Grlib
?? C
?? 第 1 頁 / 共 2 頁
字號:
//*****************************************************************************
//
// slider.c - A simple slider widget class.
//
// Copyright (c) 2008-2010 Texas Instruments Incorporated.  All rights reserved.
// Software License Agreement
// 
// Texas Instruments (TI) is supplying this software for use solely and
// exclusively on TI's microcontroller products. The software is owned by
// TI and/or its suppliers, and is protected under applicable copyright
// laws. You may not combine this software with "viral" open-source
// software in order to form a larger program.
// 
// THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
// NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
// NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
// CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 5821 of the Stellaris Graphics Library.
//
//*****************************************************************************

#include "driverlib/debug.h"
#include "grlib/grlib.h"
#include "grlib/widget.h"
#include "grlib/slider.h"

//*****************************************************************************
//
//! \addtogroup slider_api
//! @{
//
//*****************************************************************************

//*****************************************************************************
//
// Make sure min and max are defined.
//
//*****************************************************************************
#ifndef min
#define min(a, b)               (((a) < (b)) ? (a) : (b))
#endif

#ifndef max
#define max(a, b)               (((a) < (b)) ? (b) : (a))
#endif

//*****************************************************************************
//
// Converts a slider value to a position on the display.
//
// \param pSlider is a pointer to the slider widget for which the conversion is
// being requested.
// \param lValue is the slider value that is to be converted to a position.
//
// Converts a value within the range represented by a slider into a position
// along the slider control.  The function converts taking into account the
// slider position and style as well as its range.
//
// \return Returns the screen position (x coordinate for horizontal sliders or
// y coordinate for vertical ones) that represents the value passed.
//
//*****************************************************************************
static short
SliderValueToPosition(tSliderWidget *pSlider, long lValue)
{
    unsigned short usSize;
    long lRange;
    long lPos;

    //
    // First look for the trivial cases.  To ensure correct display and remove
    // artifacts caused by rounding errors, we specifically catch the cases
    // where the value provided is at either end of the slider range.  In these
    // cases we return values that are outside the actual widget rectangle.
    // This is detected while drawing so that the relevant bars fill the full
    // area and don't leave single pixel lines at either end even when the
    // slider is at full scale.  These cases also catch out-of-range values
    // and peg them at one end of the range or the other.
    //
    // First check for values at the top of the range.
    //
    if(lValue >= pSlider->lMax)
    {
        //
        // Is this a vertical slider?
        //
        if(pSlider->ulStyle & SL_STYLE_VERTICAL)
        {
            //
            // Vertical slider case.  Return the top position.
            //
            lPos = pSlider->sBase.sPosition.sYMin - 1;

            //
            // Adjust by 1 to move past the border if this widget has one.
            //
            if(pSlider->ulStyle & SL_STYLE_OUTLINE)
            {
                lPos++;
            }
        }
        else
        {
            //
            // Horizontal slider case.  Return the rightmost position.
            //
            lPos = pSlider->sBase.sPosition.sXMax + 1;

            //
            // Adjust by 1 to move past the border if this widget has one.
            //
            if(pSlider->ulStyle & SL_STYLE_OUTLINE)
            {
                lPos--;
            }
        }
        return((short)lPos);
    }

    //
    // Now look at the bottom end of the range.
    //
    if(lValue <= pSlider->lMin)
    {
        //
        // Is this a vertical slider?
        //
        if(pSlider->ulStyle & SL_STYLE_VERTICAL)
        {
            //
            // Vertical slider case.  Return the bottom position.
            //
            lPos = pSlider->sBase.sPosition.sYMax + 1;

            //
            // Adjust by 1 to move past the border if this widget has one.
            //
            if(pSlider->ulStyle & SL_STYLE_OUTLINE)
            {
                lPos--;
            }
        }
        else
        {
            //
            // Horizontal slider case.  Return the leftmost position.
            //
            lPos = pSlider->sBase.sPosition.sXMin - 1;

            //
            // Adjust by 1 to move past the border if this widget has one.
            //
            if(pSlider->ulStyle & SL_STYLE_OUTLINE)
            {
                lPos++;
            }
        }
        return((short)lPos);
    }

    //
    // What is the length of the whole slider?
    //
    if(pSlider->ulStyle & SL_STYLE_VERTICAL)
    {
        //
        // Vertical slider case.
        //
        usSize = (pSlider->sBase.sPosition.sYMax -
                  pSlider->sBase.sPosition.sYMin) + 1;
    }
    else
    {
        //
        // Horizontal slider case.
        //
        usSize = (pSlider->sBase.sPosition.sXMax -
                  pSlider->sBase.sPosition.sXMin) + 1;
    }

    //
    // Adjust the range if the slider has an outline (which removes 2 pixels).
    //
    if(pSlider->ulStyle & SL_STYLE_OUTLINE)
    {
        usSize -= 2;
    }

    //
    // Determine the range of the slider (the number of individual integers
    // represented by the widget).
    //
    lRange = (pSlider->lMax - pSlider->lMin) + 1;

    //
    // Now we can determine the relevant position relative to the start of the
    // slider.
    //
    lPos = ((lValue * (long)usSize) / lRange);

    //
    // Clip the calculated position to the valid range based on the slider
    // size.
    //
    lPos = max(lPos, 0);
    lPos = min(lPos, (long)usSize - 1);

    //
    // Adjust for the position of the widget relative to the screen origin.
    //
    if(pSlider->ulStyle & SL_STYLE_VERTICAL)
    {
        //
        // Vertical case - adjust the Y coordinate.
        //
        lPos = pSlider->sBase.sPosition.sYMax - lPos;
    }
    else
    {
        //
        // Horizontal case - adjust the X coordinate.
        //
        lPos += pSlider->sBase.sPosition.sXMin;
    }

    //
    // If the widget has an outline, make sure to adjust for this too.
    //
    lPos += ((pSlider->ulStyle & SL_STYLE_OUTLINE) ? 1 : 0);

    //
    // Convert to the expected return type and hand the caller the final
    // value.
    //
    return((short)lPos);
}

//*****************************************************************************
//
// Converts a slider position to a value within its range.
//
// \param pSlider is a pointer to the slider widget for which the conversion is
// being requested.
// \param usPos is a position within the slider.  This is an x coordinate for
// a horizontal slider or a y coordinate for a vertical one.  In both cases,
// the position is relative to the display origin.
//
// Converts a screen position into a value within the current range of the
// slider.  The function converts taking into account the slider position and
// style as well as its range.
//
// \return Returns the slider value represented by the position passed.
//
//*****************************************************************************
static long
SliderPositionToValue(tSliderWidget *pSlider, short sPos)
{
    short sMax;
    short sMin;
    long lValue;

    //
    // Determine the bounds of the control on the display.
    //
    if(pSlider->ulStyle & SL_STYLE_VERTICAL)
    {
        sMax = pSlider->sBase.sPosition.sYMax;
        sMin = pSlider->sBase.sPosition.sYMin;
    }
    else
    {
        sMax = pSlider->sBase.sPosition.sXMax;
        sMin = pSlider->sBase.sPosition.sXMin;
    }

    //
    // Adjust for the outline if present.
    //
    if(pSlider->ulStyle & SL_STYLE_OUTLINE)
    {
        sMax--;
        sMin--;
    }

    //
    // If the control is too narrow, this is a bug but handle it gracefully
    // rather than throwing a divide by zero later.
    //
    ASSERT(sMax > sMin);
    if(sMax <= sMin)
    {
        return(pSlider->lMin);
    }

    //
    // Clip the supplied position to the extent of the widget.
    //
    sPos = min(sMax, sPos);
    sPos = max(sMin, sPos);

    //
    // Adjust the position to make it relative to the start of the slider.
    //
    if(pSlider->ulStyle & SL_STYLE_VERTICAL)
    {
        sPos = sMax - sPos;
    }

    else
    {
        sPos -= sMin;
    }

    //
    // Calculate the value represented by this position.
    //
    lValue = ((long)sPos * ((pSlider->lMax - pSlider->lMin) + 1)) /
             (long)((sMax - sMin) + 1);

    //
    // Adjust for the bottom of the value range.
    //
    lValue += pSlider->lMin;

    //
    // Hand the conversion result back to the caller.
    //
    return(lValue);
}

//*****************************************************************************
//
//! Draws a slider.
//!
//! \param pWidget is a pointer to the slider widget to be drawn.
//! \param pDirty is the subrectangle of the widget which is to be redrawn.
//! This is expressed in screen coordinates.
//!
//! This function draws a slider on the display.  This is called in response to
//! a \b #WIDGET_MSG_PAINT message or when the slider position changes.
//!
//! \return None.
//
//*****************************************************************************
static void
SliderPaint(tWidget *pWidget, tRectangle *pDirty)
{
    tRectangle sClipRect, sValueRect, sEmptyRect, sActiveClip;
    tSliderWidget *pSlider;
    tContext sCtx;
    long lX, lY, bIntersect;
    short sPos;

    //
    // Check the arguments.
    //
    ASSERT(pWidget);

    //
    // Convert the generic widget pointer into a slider widget pointer.
    //
    pSlider = (tSliderWidget *)pWidget;

    //
    // Initialize a drawing context.
    //
    GrContextInit(&sCtx, pWidget->pDisplay);

    //
    // Initialize the clipping region based on the update rectangle passed.
    //
    bIntersect = GrRectIntersectGet(pDirty, &(pSlider->sBase.sPosition),
                                    &sClipRect);
    GrContextClipRegionSet(&sCtx, &sClipRect);

    //
    // Draw the control outline if necessary.
    //
    if(pSlider->ulStyle & SL_STYLE_OUTLINE)
    {
        //
        // Outline the slider with the outline color.
        //
        GrContextForegroundSet(&sCtx, pSlider->ulOutlineColor);
        GrRectDraw(&sCtx, &(pWidget->sPosition));

        //
        // Adjust the clipping rectangle to prevent the outline from being
        // corrupted later.
        //
        if(sClipRect.sXMin == pWidget->sPosition.sXMin)
        {
            sClipRect.sXMin++;
        }

        if(sClipRect.sYMin == pWidget->sPosition.sYMin)
        {
            sClipRect.sYMin++;
        }

        if(sClipRect.sXMax == pWidget->sPosition.sXMax)
        {
            sClipRect.sXMax--;
        }

        if(sClipRect.sYMax == pWidget->sPosition.sYMax)
        {
            sClipRect.sYMax--;
        }
    }

    //
    // Determine the position associated with the current slider value.
    //
    sPos = SliderValueToPosition(pSlider, pSlider->lValue);

    //
    // Remember this so that the dirty rectangle code in the click handler
    // draws the correct thing the first time it is called.
    //
    pSlider->sPos = sPos;

    //
    // Determine the rectangles for the active and empty portions of the
    // widget.
    //
    if(pSlider->ulStyle & SL_STYLE_VERTICAL)
    {
        //
        // Determine the rectangle corresponding to the bottom (value) portion
        // of the slider.
        //
        sValueRect.sXMin = pWidget->sPosition.sXMin;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品高潮呻吟久久| 日韩欧美第一区| 欧美二区乱c少妇| 精品国产污污免费网站入口 | 精品国产网站在线观看| 欧美在线观看视频在线| 成人av先锋影音| 欧美一区二区黄| 国产精品久久久久久妇女6080| 7777精品伊人久久久大香线蕉| www.视频一区| 在线不卡中文字幕播放| 在线亚洲精品福利网址导航| 99久久精品费精品国产一区二区| 国产精品99久久久久久久女警| 日韩av一区二| 欧洲日韩一区二区三区| 国产在线精品国自产拍免费| 免费看日韩a级影片| 国产精品成人免费在线| 国产精品午夜免费| 久久激情五月婷婷| 欧美探花视频资源| 国产精品国产成人国产三级| 国产日产欧美一区二区三区| 国产农村妇女精品| 久久99国产精品免费网站| 久久99久久99精品免视看婷婷| 久久99久久99小草精品免视看| 精久久久久久久久久久| 国产精品一区不卡| 日韩欧美国产麻豆| 五月天亚洲婷婷| 欧美丝袜丝交足nylons图片| 一本一本大道香蕉久在线精品| 在线观看91精品国产入口| 成年人午夜久久久| 国产精品素人视频| av亚洲精华国产精华精| 欧洲精品视频在线观看| 日韩欧美久久一区| 精品一区免费av| 欧美成人精品1314www| 精品成人在线观看| 国产毛片精品一区| 国产欧美精品区一区二区三区| 亚洲老司机在线| 在线观看免费视频综合| 精品嫩草影院久久| 国产九色精品成人porny| www.av精品| 亚洲美女精品一区| 欧美色爱综合网| 五月婷婷激情综合网| 成人少妇影院yyyy| 亚洲卡通动漫在线| 欧美日韩亚洲综合在线 | 久久久精品蜜桃| 国产成人av电影在线观看| 欧美系列日韩一区| 日本aⅴ亚洲精品中文乱码| 成人自拍视频在线观看| 欧美乱妇23p| 麻豆国产91在线播放| 91日韩在线专区| 亚洲成人精品在线观看| 国产在线精品国自产拍免费| 欧美午夜视频网站| 久久精品国产一区二区三 | 欧美成人精品1314www| 亚洲三级电影全部在线观看高清| 日韩专区欧美专区| 国产亚洲人成网站| 欧美色综合网站| 久久精品国内一区二区三区| 91社区在线播放| 免费成人在线播放| 亚洲欧美精品午睡沙发| 成人午夜视频网站| 视频一区视频二区在线观看| 91在线国产福利| 日产精品久久久久久久性色| 99久久777色| 精品一区二区av| 亚洲三级在线播放| 精品成人a区在线观看| 日日摸夜夜添夜夜添精品视频| 欧美在线|欧美| 国产99久久精品| 首页综合国产亚洲丝袜| 欧美日韩一卡二卡三卡 | 亚洲电影你懂得| 国产午夜亚洲精品午夜鲁丝片| 精品一区二区日韩| 一区二区视频免费在线观看| 色视频一区二区| 国产福利精品导航| 日韩国产精品大片| 亚洲精品免费看| 国产精品五月天| ww久久中文字幕| 日韩精品一区二| 欧美精品在欧美一区二区少妇| 亚洲福利国产精品| 中文字幕一区二区三区蜜月| 91蜜桃网址入口| 成人精品高清在线| 国产一区二区三区免费在线观看| 久久无码av三级| 欧美刺激脚交jootjob| 精品一区二区国语对白| 中日韩免费视频中文字幕| 9i在线看片成人免费| 一区二区三区欧美| 亚洲欧美日韩电影| 中文字幕中文字幕一区| 91蝌蚪国产九色| 91丝袜高跟美女视频| 亚洲va欧美va人人爽| 精品成人a区在线观看| 99视频精品在线| 91麻豆视频网站| 91蜜桃网址入口| 色女孩综合影院| 欧美日韩在线综合| 欧美色图天堂网| 欧美撒尿777hd撒尿| 国内久久婷婷综合| 国产一区二区三区四| 国产精品第13页| 一区二区三区四区亚洲| 91麻豆精品国产无毒不卡在线观看| 国内精品写真在线观看| 亚洲天堂成人网| 亚洲一区二区三区美女| 国产网站一区二区三区| 欧美三级蜜桃2在线观看| 国产盗摄视频一区二区三区| 亚洲一区二区在线观看视频| 久久嫩草精品久久久精品一| 欧美日韩一卡二卡| 欧美精品一区二区三区久久久| 99精品久久只有精品| 国产在线不卡一卡二卡三卡四卡| 亚洲免费毛片网站| 天天综合网 天天综合色| 国产精品久久久久久久久动漫| 日韩午夜电影在线观看| 在线看一区二区| 26uuu国产日韩综合| 欧美日韩精品欧美日韩精品 | 国产欧美精品一区aⅴ影院| 91麻豆精品国产91久久久久久| 不卡一区中文字幕| 欧美人伦禁忌dvd放荡欲情| 99精品视频在线播放观看| 国模大尺度一区二区三区| 天天影视网天天综合色在线播放| 中文字幕一区二区三区视频| 2020国产精品| 亚洲与欧洲av电影| 国产成人免费9x9x人网站视频| 美女视频一区在线观看| 午夜欧美在线一二页| 亚洲女与黑人做爰| 久久99精品国产麻豆婷婷| 奇米888四色在线精品| 亚洲电影在线播放| 丁香啪啪综合成人亚洲小说 | 日韩欧美成人激情| 亚洲视频电影在线| 国产一区二区91| 欧美日韩亚洲另类| 国产日韩欧美精品综合| 国产视频911| 亚洲一区精品在线| 91网站最新地址| 久久免费电影网| 免费在线观看成人| 欧美日韩一区精品| 成人欧美一区二区三区白人| 国产精品久久网站| 国产在线一区二区综合免费视频| 久久91精品国产91久久小草 | 欧美精品久久一区| 国产精品日韩精品欧美在线| 国产欧美一区二区在线观看| 国产亲近乱来精品视频| 中文字幕日韩一区| 国产成人综合在线观看| 成人教育av在线| 久久精品综合网| 裸体健美xxxx欧美裸体表演| 精品中文字幕一区二区小辣椒| 久久99精品网久久| 欧美刺激午夜性久久久久久久| 在线电影院国产精品| 欧美www视频| 国产一区二区三区四区在线观看| 成人国产一区二区三区精品|