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

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

?? sdltextbox.cpp

?? 以圖形界面的方式形象的描述了數據結構中翰諾塔的過程
?? CPP
字號:
// ============================================================================
// Data Structures For Game Programmers
// Ron Penton
// SDLTextBox.cpp
// This is a basic SDLGUI library that I've set up for use with the game demos
// I've used in the book.
// ============================================================================
#include "SDLTextBox.h"
#include <string.h>





// -------------------------------------------------------
// Name:        SDLTextBox::SDLTextBox
// Description: This constructs the text box
// Arguments:   - p_x: x coordinate
//              - p_y: y coordinate
//              - p_w, p_h: the width and height.
//              - p_string: a pointer to the string of
//                          the text box
//              - p_size: the max size of the string.
//              - p_tforecol: the foreground color of the 
//                            text
//              - p_tbackcol: the background color of the
//                            text
//              - p_font: the font of the text.
//              - p_func: the function this calls when
//                        enter is pressed.
// -------------------------------------------------------
SDLTextBox::SDLTextBox( int p_x, int p_y,
                        int p_w, int p_h,
                        char* p_string,
                        int p_size,
                        SDL_Color p_tforecol,
                        SDL_Color p_tbackcol,
                        TTF_Font* p_font,
                        bool p_enabled,
                        void (*p_func)(void) )
{
    m_x = p_x;
    m_y = p_y;
    m_w = p_w;
    m_h = p_h;
    m_string = p_string;
    m_size = p_size;
    m_tforecol = p_tforecol;
    m_tbackcol = p_tbackcol;
    m_font = p_font;
    m_hasFocus = false;
    m_enabled = p_enabled;
    m_func = p_func;

    m_blink = false;
    m_timer = SDL_GetTicks();
}


// ----------------------------------------------------------------
//  Name:           Draw
//  Description:    draws the item on a surface
//  Arguments:      p_dest: the destination surface
//  Return Value:   None
// ----------------------------------------------------------------
void SDLTextBox::Draw( SDL_Surface* p_dest )
{
    // render text
    int blinkx = m_x + 1;

    // if the string has some letters in it
    if( m_string[0] != '\0' )
    {
        // render the text
        SDL_Surface* text = TTF_RenderText_Shaded( m_font, m_string, 
                                                   m_tforecol, m_tbackcol );

        // find out if the text is longer than the width of the box
        if( text->w > m_w )
        {
            // the text is larger than the box, 
            // so render only the right part of the text.
            SDL_Rect sourcerect;
            SDL_Rect destrect;

            sourcerect.w = m_w;
            sourcerect.h = text->h;
            sourcerect.x = text->w - m_w;
            sourcerect.y = 0;
            destrect.w = m_w;
            destrect.h = text->h;
            destrect.x = m_x;
            destrect.y = m_y + ((m_h - text->h) / 2);
            SDL_BlitSurface( text, &sourcerect, p_dest, &destrect );
            blinkx = m_x + m_w - 1;
        }
        else
        {
            // render the whole string
            SDLBlit( text, p_dest, m_x, m_y + ((m_h - text->h) / 2));
            blinkx = m_x + text->w + 1;
        }

        SDL_FreeSurface( text );
    }

    // draw the box.
    if( m_hasFocus == true )
    {
        // red if the box has the focus
        SDLLine( p_dest, m_x, m_y, m_x + m_w, m_y, RED );
        SDLLine( p_dest, m_x, m_y + m_h, m_x + m_w, m_y + m_h, RED );
        SDLLine( p_dest, m_x, m_y, m_x, m_y + m_h, RED );
        SDLLine( p_dest, m_x + m_w, m_y, m_x + m_w, m_y + m_h, RED );
    }
    else
    {
        // grey if the box doesn't have the focus   
        SDLLine( p_dest, m_x, m_y, m_x + m_w, m_y, GREY );
        SDLLine( p_dest, m_x, m_y + m_h, m_x + m_w, m_y + m_h, GREY );
        SDLLine( p_dest, m_x, m_y, m_x, m_y + m_h, GREY );
        SDLLine( p_dest, m_x + m_w, m_y, m_x + m_w, m_y + m_h, GREY );
    }

    // draw blinking cursor.
    if( m_blink == false && m_hasFocus == true )
    {
        SDLLine( p_dest, blinkx, m_y + 2,
                 blinkx, m_y + m_h - 2, BLACK );
    }
    if( SDL_GetTicks() - m_timer > 500 )
    {
        m_timer = SDL_GetTicks();
        m_blink = !m_blink;
    }

}

// ----------------------------------------------------------------
//  Name:           ClickDown
//  Description:    Tells the item that it was clicked on.
//  Arguments:      None
//  Return Value:   None
// ----------------------------------------------------------------
void SDLTextBox::ClickDown()
{
    // do nothing
}


// ----------------------------------------------------------------
//  Name:           ClickUp
//  Description:    Tells the item that it a mouse was released
//                  on this item
//  Arguments:      None
//  Return Value:   None
// ----------------------------------------------------------------
void SDLTextBox::ClickUp()
{
    // do nothing
}

// ----------------------------------------------------------------
//  Name:           IsOver
//  Description:    determines if a set of coordinates is over this
//                  item
//  Arguments:      p_x, p_y: the coordinates
//  Return Value:   true if the coordinates are over this item
// ----------------------------------------------------------------
bool SDLTextBox::IsOver( int p_x, int p_y )
{
    if( p_x >= m_x && p_x < (m_x + m_w) )
    {
        if( p_y >= m_y && p_y < (m_y + m_h) )
        {
            return true;
        }
    }
    return false;
}


// ----------------------------------------------------------------
//  Name:           ResetOnUp
//  Description:    This tells the item to reset itself because
//                  the user unclicked the mouse (only valid
//                  for some items)
//  Arguments:      None
//  Return Value:   None
// ----------------------------------------------------------------
void SDLTextBox::ResetOnUp()
{
    // do nothing
    return;
}

    
// ----------------------------------------------------------------
//  Name:           CanGetFocus
//  Description:    determines if the item can get the focus
//  Arguments:      None
//  Return Value:   true if the item can get the focus
// ----------------------------------------------------------------
bool SDLTextBox::CanGetFocus()
{
    if( m_enabled == true )
        return true;
    return false;
}

// ----------------------------------------------------------------
//  Name:           GetFocus
//  Description:    tells the item to get the focus or not.
//  Arguments:      p_focus: true if the item gets the focus
//  Return Value:   None
// ----------------------------------------------------------------
void SDLTextBox::GetFocus( bool p_focus )
{
    m_hasFocus = p_focus;
}


// ----------------------------------------------------------------
//  Name:           KeyPress
//  Description:    tells the GUI that a key was pressed when this
//                  item was in focus
//  Arguments:      p_key: the that was pressed
//                  p_mod: the keyboard modifier flag (shift, alt, 
//                         control).
//                  p_char: the UNICODE representation of the key
//  Return Value:   None
// ----------------------------------------------------------------
void SDLTextBox::KeyPress( SDLKey p_key, SDLMod p_mod, Uint16 p_char )
{
    int current = strlen( m_string );
    char k = (char)p_char;

    if( p_key == SDLK_DELETE || p_key == SDLK_BACKSPACE )
    {
        m_string[current - 1] = 0;
    }
    else if( p_key == SDLK_RETURN )
    {
        if( m_func != 0 )
        {
            m_func();
        }
    }
    else
    {
        // only accept 'character' keys
        if( p_key >= SDLK_SPACE && p_key <= SDLK_z )
        {
            if( current < m_size )
            {
                m_string[current] = k;
                m_string[current+1] = 0;
            }
        }
    }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区三区四区在线| 在线不卡免费av| 中文一区一区三区高中清不卡| 精品一区二区三区免费播放| 欧美一区二区三区视频免费| 另类的小说在线视频另类成人小视频在线| 91精品国产麻豆| 韩国欧美国产1区| 综合电影一区二区三区| 欧美探花视频资源| 麻豆中文一区二区| 国产精品女主播av| 91成人在线观看喷潮| 日本va欧美va精品发布| 国产亚洲1区2区3区| 欧美性受xxxx黑人xyx| 另类小说欧美激情| 国产精品视频观看| 欧美日韩精品一二三区| 国产一区二区三区不卡在线观看 | 欧美日韩高清在线| 国产福利一区二区三区视频在线| 国产精品你懂的在线| 欧美喷潮久久久xxxxx| 国产在线观看一区二区| 亚洲美腿欧美偷拍| 日韩欧美国产综合在线一区二区三区| 成人综合在线网站| 91福利在线观看| 精品一区二区三区视频在线观看 | 一区二区三区日韩精品视频| 欧美男同性恋视频网站| 高清不卡在线观看av| 三级欧美韩日大片在线看| 欧美国产日韩在线观看| 在线观看网站黄不卡| 久久99久久精品欧美| 一区二区高清在线| 欧美精品一区二区三区在线| 欧美色手机在线观看| 粉嫩在线一区二区三区视频| 香蕉久久一区二区不卡无毒影院 | 高清不卡一二三区| 美女尤物国产一区| 亚洲精品免费电影| 久久精品亚洲乱码伦伦中文 | 亚洲成人动漫精品| 中文字幕中文字幕在线一区| 久久综合精品国产一区二区三区| 在线精品视频免费播放| 成人免费看视频| 韩国av一区二区三区| 欧美a一区二区| 亚洲夂夂婷婷色拍ww47| 国产精品萝li| 久久―日本道色综合久久| 欧美一区二区三区公司| 在线视频欧美区| 91一区二区在线观看| 国产成人午夜视频| 国产乱一区二区| 久久爱www久久做| 手机精品视频在线观看| 亚洲激情中文1区| 国产精品久久久久四虎| 国产欧美日韩另类视频免费观看| 日韩精品一区二区三区在线| 这里只有精品视频在线观看| 欧美福利视频一区| 欧美日韩国产精品成人| 欧美男男青年gay1069videost| 91精品91久久久中77777| 91视频免费观看| 99精品一区二区三区| 白白色 亚洲乱淫| av亚洲精华国产精华精华| 成人妖精视频yjsp地址| 丁香桃色午夜亚洲一区二区三区| 国产福利一区在线| 成人动漫中文字幕| 99久久久免费精品国产一区二区| av电影一区二区| 色狠狠一区二区| 中文字幕在线视频一区| 成人欧美一区二区三区黑人麻豆 | 色呦呦网站一区| 欧美综合欧美视频| 88在线观看91蜜桃国自产| 91精品国产福利在线观看| 日韩欧美一区二区久久婷婷| 久久亚洲精品小早川怜子| 中文子幕无线码一区tr| 一区二区三区美女视频| 午夜欧美在线一二页| 卡一卡二国产精品| 国产精品2024| 色老头久久综合| 日韩精品专区在线| 中文天堂在线一区| 亚洲mv大片欧洲mv大片精品| 日本大胆欧美人术艺术动态| 国产综合色视频| 成人av免费在线播放| 欧美色手机在线观看| 26uuu久久天堂性欧美| 国产精品系列在线| 亚洲不卡一区二区三区| 国产主播一区二区| 91老师片黄在线观看| 91精品福利在线一区二区三区| 精品国产免费久久| 亚洲欧美一区二区三区国产精品 | 国产日韩欧美精品一区| 亚洲综合自拍偷拍| 精品一区二区久久| 91论坛在线播放| 欧美精品一区二区久久婷婷| 亚洲婷婷综合久久一本伊一区| 亚洲444eee在线观看| 国产宾馆实践打屁股91| 欧美日韩在线直播| 国产免费成人在线视频| 日韩精品成人一区二区三区| 成人午夜私人影院| 91精品国产日韩91久久久久久| 国产精品理论片在线观看| 日本特黄久久久高潮| 92精品国产成人观看免费| 精品欧美久久久| 亚洲国产毛片aaaaa无费看| 国产一区二区免费看| 欧美视频一区在线| 国产精品久久久久影院色老大| 日韩av成人高清| 91久久精品网| 国产精品嫩草99a| 精品午夜一区二区三区在线观看| 欧美体内she精高潮| 最近日韩中文字幕| 国产不卡视频一区| 精品999久久久| 日本亚洲电影天堂| 欧美日韩精品一区二区在线播放| 国产精品久久久久aaaa樱花 | 欧美大白屁股肥臀xxxxxx| 一区二区三区国产精品| 成人黄色电影在线| 26uuu国产在线精品一区二区| 午夜国产精品一区| 欧美日韩免费在线视频| 亚洲欧洲av一区二区三区久久| 国内外精品视频| 2019国产精品| 国产在线不卡一区| 久久人人爽爽爽人久久久| 激情六月婷婷久久| 精品国产成人在线影院| 免费欧美在线视频| 日韩欧美在线影院| 蜜桃在线一区二区三区| 91精品国产综合久久久久久漫画| 午夜精品视频在线观看| 欧美日韩国产系列| 人人超碰91尤物精品国产| 日韩一区二区三区电影在线观看 | 日韩美女精品在线| 成人免费黄色大片| 国产精品久久综合| 不卡av在线网| 亚洲美女偷拍久久| 欧美丝袜丝nylons| 日韩电影网1区2区| 日韩精品中午字幕| 国产在线观看免费一区| 中文字幕第一区| www.av亚洲| 亚洲精品国产一区二区精华液| 一本色道a无线码一区v| 一区二区日韩电影| 欧美巨大另类极品videosbest | 国产成人av一区二区三区在线| 国产片一区二区| 色婷婷综合久久久久中文 | 自拍av一区二区三区| 91成人免费在线| 日日嗨av一区二区三区四区| 欧美一区二区三区电影| 国产剧情一区二区三区| 亚洲视频一区二区免费在线观看| 91黄色在线观看| 日日夜夜一区二区| 久久午夜老司机| 色综合天天狠狠| 日本中文字幕一区二区视频| 精品国产sm最大网站免费看| 成人免费毛片aaaaa**| 亚洲国产精品久久人人爱| 日韩你懂的在线播放| 成人一级视频在线观看| 丝瓜av网站精品一区二区|