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

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

?? sdltextbox.cpp

?? 基于SDL的圖形化貪心算法演示,支持節點的拖放
?? 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,
						SDL_Color p_tboxcol,
                        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_boxcol = 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, m_boxcol );
        SDLLine( p_dest, m_x, m_y + m_h, m_x + m_w, m_y + m_h, m_boxcol );
        SDLLine( p_dest, m_x, m_y, m_x, m_y + m_h, m_boxcol );
        SDLLine( p_dest, m_x + m_w, m_y, m_x + m_w, m_y + m_h, m_boxcol );
    }

    // 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();
        }
		
		GetFocus( false );

    }
    else
    {
        // only accept 'character' keys
		//SDLK_0
		
		
		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一区二区三区免费野_久草精品视频
国产在线看一区| 久久国产尿小便嘘嘘尿| 欧美电视剧免费观看| 成人app网站| 日韩不卡在线观看日韩不卡视频| 国产色产综合产在线视频 | 欧洲在线/亚洲| 国产一区二区在线观看视频| 亚洲成人免费视| 综合在线观看色| 欧美极品少妇xxxxⅹ高跟鞋| 欧美精品色一区二区三区| 91丨porny丨最新| 国产精品1区2区3区在线观看| 五月天激情综合网| 亚洲精品欧美激情| 中文字幕一区二区三区精华液| 精品福利二区三区| 成人免费视频视频| 国内国产精品久久| 麻豆91免费观看| 色www精品视频在线观看| 一区二区三区不卡视频 | 中文字幕第一区综合| 日韩欧美中文字幕公布| 欧美丰满高潮xxxx喷水动漫| 日本大香伊一区二区三区| 国产91在线观看| 国产在线不卡一卡二卡三卡四卡| 天天综合色天天综合| 亚洲1区2区3区4区| 一区二区三区.www| 亚洲综合免费观看高清在线观看| 国产精品久久久久久久久动漫| 国产网红主播福利一区二区| 2020日本不卡一区二区视频| 欧美成人精精品一区二区频| 日韩欧美中文字幕一区| 日韩欧美成人一区二区| 欧美一级精品在线| 日韩欧美国产一区二区在线播放| 欧美高清视频一二三区 | 精品一区免费av| 久久成人久久爱| 精品一区二区三区免费视频| 精品在线免费观看| 国产精品一二三四| 99久久99久久精品国产片果冻| 成人自拍视频在线观看| av在线不卡电影| 91丨porny丨首页| 欧洲人成人精品| 欧美精品久久99| 欧美大片免费久久精品三p| 日韩欧美在线1卡| 久久精品一区蜜桃臀影院| 国产三级一区二区| ...xxx性欧美| 亚洲电影激情视频网站| 视频一区中文字幕国产| 激情伊人五月天久久综合| 国产在线国偷精品产拍免费yy| 国产成人亚洲综合a∨婷婷图片| 成人午夜短视频| 欧美性高清videossexo| 欧美男同性恋视频网站| 日韩精品最新网址| 国产日韩成人精品| 亚洲一区二区在线免费观看视频| 午夜视频在线观看一区二区三区| 六月丁香婷婷久久| 99久久精品费精品国产一区二区| 色噜噜夜夜夜综合网| 日韩一区二区三区在线| 国产欧美视频在线观看| 亚洲精品乱码久久久久| 日本欧美在线观看| 成人免费观看av| 欧美另类久久久品| 国产亚洲欧美激情| 亚洲无线码一区二区三区| 久久精品国产99| av不卡免费在线观看| 91麻豆精品久久久久蜜臀| 久久婷婷成人综合色| 综合久久久久久久| 久久久精品影视| 亚洲天堂2014| 国产精品综合一区二区| 色综合久久综合网欧美综合网| 欧美日韩黄色一区二区| 国产欧美日韩精品一区| 天天操天天色综合| av成人动漫在线观看| 欧美一区二区久久久| 国产精品伦理一区二区| 欧美日韩一级二级| 成人高清av在线| 日韩色视频在线观看| 亚洲精品视频在线观看网站| 日韩欧美在线一区二区三区| 日韩一区二区在线观看视频播放| 国产精品福利一区二区| 亚洲福利一区二区三区| 久久成人免费日本黄色| 欧美怡红院视频| 综合网在线视频| 国产a精品视频| 日韩视频在线一区二区| 亚洲乱码中文字幕| 国产成人免费9x9x人网站视频| 欧美四级电影在线观看| 亚洲国产精华液网站w| 国产一区二区电影| 日韩一区二区在线看| 亚洲一区二区精品3399| 不卡一二三区首页| 国产日韩精品久久久| 精彩视频一区二区| 欧美v日韩v国产v| 日韩国产精品久久| 3d动漫精品啪啪一区二区竹菊| 亚洲综合一区二区精品导航| 99视频一区二区| 最新中文字幕一区二区三区| 国产成人在线影院| 欧美国产精品中文字幕| 国产精品亚洲一区二区三区在线| 欧美一二三区精品| 奇米影视在线99精品| 欧美精品一卡两卡| 丝袜美腿一区二区三区| 欧美日韩性生活| 午夜天堂影视香蕉久久| 欧美日韩免费不卡视频一区二区三区| 亚洲美女在线一区| 日本黄色一区二区| 亚洲在线观看免费视频| 91国在线观看| 亚洲午夜精品在线| 制服丝袜亚洲播放| 久久成人久久爱| 国产色91在线| 99久久国产综合精品麻豆| 成人免费一区二区三区视频 | 激情五月播播久久久精品| 日韩精品一区二区三区swag| 九色综合国产一区二区三区| 26uuu成人网一区二区三区| 国内精品伊人久久久久av影院| 精品sm捆绑视频| www.成人网.com| 一区二区三区影院| 欧美乱妇一区二区三区不卡视频| 免费一级片91| 国产日韩欧美一区二区三区综合| 成人免费黄色大片| 亚洲一区免费视频| 精品免费日韩av| 成人黄色av网站在线| 一二三区精品视频| 欧美日韩国产高清一区二区三区 | 国产精品久久久久久妇女6080 | 日本va欧美va精品| 久久影院电视剧免费观看| jizzjizzjizz欧美| 亚洲va欧美va天堂v国产综合| 日韩欧美中文一区| 94-欧美-setu| 免费视频一区二区| 国产精品国产三级国产aⅴ原创| 欧美午夜片在线观看| 经典三级在线一区| 亚洲欧美电影一区二区| 欧美一二三四在线| 色婷婷亚洲精品| 国产乱子伦视频一区二区三区 | 午夜视频在线观看一区二区三区| 欧美精品一区二区在线播放| 99久久久久免费精品国产 | 亚洲一区二区三区四区在线| 欧美一区二区精品| av在线免费不卡| 蜜臀99久久精品久久久久久软件| 国产精品视频一二三区| 色综合天天综合给合国产| 麻豆精品视频在线| 综合久久久久久| 欧美一区二区三区不卡| 国产视频一区二区三区在线观看| 亚洲青青青在线视频| 欧美久久久一区| 1000部国产精品成人观看| 一区二区三区在线观看动漫| 无码av中文一区二区三区桃花岛| 免费av网站大全久久| 粉嫩av亚洲一区二区图片| 欧美主播一区二区三区| 欧美刺激午夜性久久久久久久| 国产精品三级久久久久三级|