Cocos2d-x串算出Size方法

项目需要,根据所输入的字符串,的需要计算串帐户Size。

包代码如下面。只需要传递一个字符串,您可以返回Size:

Size ChartDemoScene::calculateFontSize(const char *str )
{
	std::string tempString = str;
	log("tempString = %s",tempString.c_str());
	size_t computeCount = tempString.size();       //假设字符串非常长每次抽取100个字符来计算size;
	Size size = Size(0,0);
	for (int i = 0; i<computeCount ;)
	{
        std::string substring =  tempString.substr(i,1);
		if ((substring.c_str()[0] & 0x80 )!=0) //是汉字
		{
			substring = tempString.substr(i , 3);
			i += 3;
		}
		else
		{
			i++;
		}
		//CCLog("subString  = %s ",substring.c_str());
        auto tempLabel = LabelTTF::create(substring.c_str(),"",25);
        tempLabel->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT);
		Size tmpLsize = tempLabel->getContentSize();
		size.width+=tmpLsize.width;
	}

	float fHeight= 0;
	if( size.width > chartWidth)//大于容器的宽度
	{
        fHeight = (size.width / 200 );//计算须要多少行
	}
	int nHeight =  ceil(fHeight);

	if (nHeight == 0)
	{
		nHeight = 1;
	}

	Size labelSize ;
	if (size.width < chartWidth)
	{
		labelSize = Size(size.width,nHeight*32);//计算容器的Size
	}
	else
	{
        labelSize = Size(chartWidth,nHeight*28);
	}

	//CCLog("labelSize = (%f, %f)",labelSize.width ,labelSize.height);
	//CCLog("fHeight = %f  nHeight = %d " ,fHeight ,nHeight);
	return labelSize;
}

样例:

1、AppDelegate.cpp中加入例如以下代码

auto scene = ChartDemoScene::createScene();

    // run
    director->runWithScene(scene);

(1)ChartDemoScene.hChartDemoScene.h

//
//  ChartDemoScene.h
//  chartDemo
//
//  Created by chen on 14-9-2.
//
//

#ifndef __chartDemo__ChartDemoScene__
#define __chartDemo__ChartDemoScene__

#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include "../cocos2d/extensions/cocos-ext.h"
using namespace cocos2d::ui;
USING_NS_CC;
USING_NS_CC_EXT;

class ChartDemoScene : public cocos2d::Layer//,public cocos2d::extension::EditBoxDelegate
{
public:
    // there's no 'id' in cpp, so we recommend returning the class instance pointer
    static cocos2d::Scene* createScene();

    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    virtual bool init();

    // a selector callback
    void menuCloseCallback(cocos2d::Ref* pSender);

    // implement the "static create()" method manually
    CREATE_FUNC(ChartDemoScene);

//    virtual void editBoxEditingDidBegin(cocos2d::extension::EditBox* editBox);
//    virtual void editBoxEditingDidEnd(cocos2d::extension::EditBox* editBox);
//    virtual void editBoxTextChanged(cocos2d::extension::EditBox* editBox, const std::string& text);
//    virtual void editBoxReturn(cocos2d::extension::EditBox* editBox);

    void touchEvent(Ref *pSender, Widget::TouchEventType type);
    void textFieldEvent(Ref* pSender, TextField::EventType type);
    void showAlertShow(std::string contentString);
    void alertCallback(ui::Text* alert);

    Size calculateFontSize(const char *str);

    std::string getcurrTime();//获取当前年月日
    std::string getcurrMonthTime();//获取时分秒

//    EditBox* editText;
    TextField* editText;
    Text* text;
    TextField* _text;//获取被删除Item的内容
    std::string file_path;//存放消息记录
    TextField* textContent;
    ui::Button* sendBtn;
    std::string str;
    Size winSize;
    float chartWidth;
    size_t length;
    ui::ListView* _listView;

};
#endif /* defined(__chartDemo__ChartDemoScene__) */

(2)ChartDemoScene.cpp

#include "ChartDemoScene.h"
#include "stdio.h"

enum alertTag
{
    Alert_Tag = 1000

}AlertTag;

enum textTag
{
    T_Tag = 100
}TextTag;

USING_NS_CC;
int count = 1;
int _rem = 0;
Scene* ChartDemoScene::createScene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::create();
    scene->setColor(Color3B::BLACK);
    // 'layer' is an autorelease object
    auto layer = ChartDemoScene::create();
    layer->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
    layer->setContentSize(Size(640,960));
    // add layer as a child to scene
    scene->addChild(layer);

    // return the scene
    return scene;
}

// on "init" you need to initialize your instance
bool ChartDemoScene::init()
{
    bool bRet = false;
    do{
        CC_BREAK_IF(!Layer::init());
        //大背景
        winSize = Director::getInstance()->getWinSize();
        file_path = FileUtils::getInstance()->getWritablePath() + "chartContent.txt";

        chartWidth = winSize.width *3 / 5;
        auto sprite = Sprite::create("orange_edit.png");
        sprite->setScaleX(winSize.width / sprite->getContentSize().width);
        sprite->setScaleY(winSize.height / sprite->getContentSize().height);
        sprite->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
        sprite->setPosition(Vec2(winSize.width/2,winSize.height/2));
        addChild(sprite);

        auto layerColor = LayerColor::create(Color4B(43, 177, 233, 255));
        layerColor->setContentSize(Size(winSize.width,100));
        layerColor->ignoreAnchorPointForPosition(false);
        layerColor->setAnchorPoint(Vec2::ANCHOR_MIDDLE_TOP);
        layerColor->setPosition(Vec2(winSize.width/2,winSize.height));
        addChild(layerColor,4);

        //底部输入栏
        auto layout = Layout::create();
        layout->setSize(Size(winSize.width,100));
        layout->setAnchorPoint(Vec2::ZERO);
        layout->setPosition(Vec2::ZERO);
        layout->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
        layout->setBackGroundColor(Color3B(185,185,185));
        //消息显示栏
        _listView = ListView::create();
        _listView->setDirection(ui::ScrollView::Direction::VERTICAL);
        _listView->setTouchEnabled(true);
        _listView->setBounceEnabled(true);
        _listView->setGravity(cocos2d::ui::ListView::Gravity::BOTTOM);
//        _listView->setItemsMargin(2);
        _listView->setBackGroundColorType(cocos2d::ui::Layout::BackGroundColorType::SOLID);
        _listView->setBackGroundColor(Color3B::WHITE);
        _listView->setSize(Size(winSize.width,winSize.height-layout->getSize().height-25-100));
        _listView->setAnchorPoint(Vec2::ANCHOR_MIDDLE_BOTTOM);
        _listView->setPosition(Vec2(winSize.width/2,layout->getSize().height+25));
        addChild(_listView);

        //底部输入框背景
        auto bg = Sprite::create("whitebg.png");
        bg->setScaleX(winSize.width*3/5 / bg->getContentSize().width);
        bg->setScaleY(80 / bg->getContentSize().height);
        bg->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
        bg->setPosition(Vec2(winSize.width/5,layout->getSize().height/2));
        layout->addChild(bg);

        //
        editText = TextField::create("","",30);
        editText->ignoreContentAdaptWithSize(false);
        editText->setSize(Size(winSize.width*3/5,80));
        editText->setTextHorizontalAlignment(cocos2d::TextHAlignment::LEFT);
        editText->setTextVerticalAlignment(cocos2d::TextVAlignment::BOTTOM);
        editText->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
        editText->setPosition(Vec2(winSize.width/5,layout->getSize().height/2));
        editText->setColor(Color3B::BLACK);
        editText->addEventListener(CC_CALLBACK_2(ChartDemoScene::textFieldEvent, this));
        layout->addChild(editText);
        addChild(layout);

        //发送按钮
        sendBtn = ui::Button::create("orange_edit.png");
        sendBtn->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
        sendBtn->setPosition(Vec2(winSize.width - 20,layout->getSize().height/2));
        addChild(sendBtn);

        sendBtn->addTouchEventListener(CC_CALLBACK_2(ChartDemoScene::touchEvent,this));

        auto alert_Text = ui::Text::create();
        alert_Text->setSize(Size(50, 200));
        alert_Text->setTag(Alert_Tag);
        alert_Text->setOpacity(0);
        alert_Text->setFontSize(35);
        char* userdata = "11";
        alert_Text->setUserData(userdata);
        alert_Text->setColor(Color3B::BLACK);
        alert_Text->setPosition(Vec2(winSize.width/2,winSize.height/8));
        addChild(alert_Text);

        bRet = true;
    }while(0);
    return bRet;
}

Size ChartDemoScene::calculateFontSize(const char *str )
{
	std::string tempString = str;
	log("tempString = %s",tempString.c_str());
	size_t computeCount = tempString.size();       //假设字符串非常长每次抽取100个字符来计算size;
	Size size = Size(0,0);
	for (int i = 0; i<computeCount ;)
	{
        std::string substring =  tempString.substr(i,1);
		if ((substring.c_str()[0] & 0x80 )!=0) //是汉字
		{
			substring = tempString.substr(i , 3);
			i += 3;
		}
		else
		{
			i++;
		}
		//CCLog("subString  = %s ",substring.c_str());
        auto tempLabel = LabelTTF::create(substring.c_str(),"",25);
        tempLabel->setHorizontalAlignment(cocos2d::TextHAlignment::LEFT);
		Size tmpLsize = tempLabel->getContentSize();
		size.width+=tmpLsize.width;
	}

	float fHeight= 0;
	if( size.width > chartWidth)
	{
        fHeight = (size.width / 200 );
	}
	int nHeight =  ceil(fHeight);

	if (nHeight == 0)
	{
		nHeight = 1;
	}

	Size labelSize ;
	if (size.width < chartWidth)
	{
		labelSize = Size(size.width,nHeight*32);
	}
	else
	{
        labelSize = Size(chartWidth,nHeight*28);
	}

	//CCLog("labelSize = (%f, %f)",labelSize.width ,labelSize.height);
	//CCLog("fHeight = %f  nHeight = %d " ,fHeight ,nHeight);
	return labelSize;
}

void ChartDemoScene::touchEvent(cocos2d::Ref *pSender, Widget::TouchEventType type)
{
    switch (type) {
        case ui::Widget::TouchEventType::ENDED:
        {
            if(str.empty())
            {
                showAlertShow("输入内容不能为空");
                break;
            }

            log("str = %s",str.c_str());

            auto time = getcurrMonthTime().c_str();
            auto text = Text::create(time, "", 30);
            text->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
            text->setColor(Color3B::BLACK);

            auto _timeLayout = Layout::create();
            _timeLayout->setSize(Size(_listView->getSize().width,60));
            _timeLayout->setLayoutType(cocos2d::ui::Layout::Type::RELATIVE);

            auto rp_time = RelativeLayoutParameter::create();
            rp_time->setAlign(cocos2d::ui::RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT);
            text->setLayoutParameter(rp_time);
            _timeLayout->addChild(text);
            _listView->pushBackCustomItem(_timeLayout);

            if(count % 2)
           {
                count++;
                auto _lLayout = Layout::create();
                _lLayout->setSize(Size(_listView->getSize().width,80));
                _lLayout->setLayoutType(cocos2d::ui::Layout::Type::RELATIVE);

               auto _lHeader = ui::ImageView::create("logo_douban.png");
               _lHeader->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
               _lHeader->setScale(0.5);

               auto rp_l = RelativeLayoutParameter::create();
               rp_l->setMargin(Margin(10,0,0,0));
               rp_l->setRelativeName("head");
               rp_l->setAlign(cocos2d::ui::RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL);
               _lHeader->setLayoutParameter(rp_l);
               _lLayout->addChild(_lHeader);

                auto _lTextContent = TextField::create("","",30);
                _lTextContent->ignoreContentAdaptWithSize(false);
               auto size = calculateFontSize(str.c_str());
               _lTextContent->setSize(size);
               _lTextContent->setTextHorizontalAlignment(cocos2d::TextHAlignment::LEFT);

               if(size.width < chartWidth)
               {
                   _lTextContent->setTextHorizontalAlignment(cocos2d::TextHAlignment::RIGHT);
               }
                _lTextContent->setTextVerticalAlignment(cocos2d::TextVAlignment::CENTER);
                _lTextContent->setTouchEnabled(false);
               _lTextContent->setTag(T_Tag);
                _lTextContent->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
                _lTextContent->setColor(Color3B::BLACK);
                _lTextContent->setText(str);
               _lLayout->addChild(_lTextContent);
               str.clear();

               auto rp_t = RelativeLayoutParameter::create();
               rp_t->setMargin(Margin(10,0,0,0));
               rp_t->setRelativeToWidgetName("head");
               rp_t->setAlign(cocos2d::ui::RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER);
               _lTextContent->setLayoutParameter(rp_t);

               _listView->pushBackCustomItem(_lLayout);

           }else
           {
               count++;
                auto _rLayout = Layout::create();
                _rLayout->setSize(Size(_listView->getSize().width,80));
                _rLayout->setLayoutType(cocos2d::ui::Layout::Type::RELATIVE);

               auto _rHeader = ui::ImageView::create("logo_mingdao.png");
               _rHeader->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
               _rHeader->setScale(0.5);

               auto rp_r = RelativeLayoutParameter::create();
               rp_r->setMargin(Margin(0,0,10,0));
               rp_r->setRelativeName("head");
               rp_r->setAlign(cocos2d::ui::RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL);
               _rHeader->setLayoutParameter(rp_r);
               _rLayout->addChild(_rHeader);

                auto _rTextContent = TextField::create("","",30);
               _rTextContent->setTag(T_Tag);
                _rTextContent->ignoreContentAdaptWithSize(false);
               auto size = calculateFontSize(str.c_str());
               _rTextContent->setSize(size);
               _rTextContent->setTextHorizontalAlignment(cocos2d::TextHAlignment::LEFT);
                _rTextContent->setTextVerticalAlignment(cocos2d::TextVAlignment::CENTER);
                _rTextContent->setTouchEnabled(false);
                _rTextContent->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
                _rTextContent->setColor(Color3B::BLACK);
                _rTextContent->setText(str);
               str.clear();
               auto rp_l = RelativeLayoutParameter::create();
               rp_l->setMargin(Margin(0,0,10,0));
               rp_l->setRelativeToWidgetName("head");
               rp_l->setAlign(cocos2d::ui::RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER);
               _rTextContent->setLayoutParameter(rp_l);
               _rLayout->addChild(_rTextContent);

               _listView->pushBackCustomItem(_rLayout);
           }

//            if(_listView->getContentSize().height > _listView->getSize().height)
//            {
                _listView->scrollToBottom(0.5, true);
//            }
            editText->setText("");

            if(count > 3 )
            {
                _listView->removeItem(0);//删除时间标签,此时Item(0)就是内容标签
                auto temp = static_cast<Layout*>(_listView->getItem(0));//获取当前内容标签
                if(_text)
                {
                    removeChild(_text);
                }
                _text = static_cast<TextField*>(temp->getChildByTag(T_Tag));//获取内容标签
                log("string = %s", _text->getStringValue().c_str());//获取内容
                log("file_path = %s",file_path.c_str());
                FILE* fp = std::fopen(file_path.c_str(),"at+");
                CCASSERT(fp != NULL, "file open error");
                length = _text->getStringValue().length();
                log("length = %lu",length);
                fwrite(_text->getStringValue().c_str(), length, 1, fp);
                fclose(fp);

                _listView->removeItem(0);
            }

            break;
        }
        default:
            break;
    }
}

void ChartDemoScene::textFieldEvent(cocos2d::Ref *pSender, TextField::EventType type)
{
    switch (type)
    {
        case TextField::EventType::ATTACH_WITH_IME:
        {
            TextField* textField = dynamic_cast<TextField*>(pSender);
            Size widgetSize = winSize;
            runAction(CCMoveTo::create(0.225f,Vec2(0, widgetSize.height / 2.0f)));
            textField->setTextHorizontalAlignment(TextHAlignment::LEFT);
            textField->setTextVerticalAlignment(TextVAlignment::TOP);
        }
            break;

        case TextField::EventType::DETACH_WITH_IME:
        {
            TextField* textField = dynamic_cast<TextField*>(pSender);
            Size widgetSize = winSize;
            runAction(CCMoveTo::create(0.175f, Vec2(0, 0)));
            textField->setTextHorizontalAlignment(TextHAlignment::LEFT);
            textField->setTextVerticalAlignment(TextVAlignment::CENTER);

            str = editText->getStringValue().c_str();
            str += "\n";
        }
            break;

        case TextField::EventType::INSERT_TEXT:
            break;

        case TextField::EventType::DELETE_BACKWARD:
            break;

        default:
            break;
    }

}

void ChartDemoScene::showAlertShow(std::string contentString)
{
    auto alert = dynamic_cast<ui::Text*>(getChildByTag(Alert_Tag));
    if (alert->getUserData() == "11") {
        alert->setOpacity(255);
        char* userdata = "110";
        alert->setUserData(userdata);

        alert->setString(contentString);
        auto call_func = CallFunc::create(CC_CALLBACK_0(ChartDemoScene::alertCallback, this,alert));
        auto seq = Sequence::create(FadeOut::create(1.0f),call_func, NULL);
        alert->runAction(seq);
    }

}

void ChartDemoScene::alertCallback(ui::Text* alert)
{

    alert->setString("");
    char* userdata = "11";
    alert->setUserData(userdata);

}

std::string ChartDemoScene::getcurrTime()//获取当前年月日
{

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

    struct timeval now;
    struct tm* time;

    gettimeofday(&now, NULL);

    time = localtime(&now.tv_sec);
    int year = time->tm_year + 1900;

    char date[32] = {0};
    sprintf(date, "%d-%02d-%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday);
    return StringUtils::format("%s",date);

#endif

#if ( CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 )

    struct tm* tm;
    time_t timep;
    time(timep);

    tm = localtime(&timep);
    char date[32] = {0};
    sprintf(date, "%d-%02d-%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday);
    return StringUtils::format("%s",date);

#endif

}

std::string ChartDemoScene::getcurrMonthTime()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

    struct timeval now;
    struct tm* time;

    gettimeofday(&now, NULL);

    time = localtime(&now.tv_sec);
    int year = time->tm_year + 1900;
    log("year = %d",year);

    char date1[24] = {0};
    char date[8] = {0};
    sprintf(date1, "%d:%02d:%02d:%02d:%02d:%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday,time->tm_hour,time->tm_min,time->tm_sec);
    sprintf(date, "%02d:%02d",time->tm_hour,time->tm_min);
    return StringUtils::format("%s",date);

#endif

#if ( CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 )

    struct tm* tm;
    time_t timep;
    time(timep);

    tm = localtime(&timep);
    char date[32] = {0};
    sprintf(date, "%d-%02d-%02d",(int)time->tm_year + 1900,(int)time->tm_mon + 1,(int)time->tm_mday);
    return StringUtils::format("%s",date);

#endif

}

void ChartDemoScene::menuCloseCallback(Ref* pSender)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
	MessageBox("You pressed the close button. Windows Store Apps do not implement a close button.","Alert");
    return;
#endif

    Director::getInstance()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
}

版权声明:本文博客原创文章,博客,未经同意,不得转载。

时间: 2024-10-13 14:58:45

Cocos2d-x串算出Size方法的相关文章

Java中用最有效率的方法算出2 乘以8 等於几?

Java中用最有效率的方法算出2 乘以8 等於几?2 << 3,因为将一个数左移n 位,就相当于乘以了2 的n 次方,那么,一个数乘以8 只要将其左移3 位即可,而位运算cpu 直接支持的,效率最高,所以,2 乘以8 等於几的最效率的方法是2 << 3.

9.9递归和动态规划(十一)——算出有几种括号的放法可使该表达式得出result值

/** * 攻略:给定一个布尔表达式,由0.1.&.|和^等符号组成,以及一个想要的布尔结果result,实现一个函数,算出有几种括号的放法可使该表达式 * 得出result值. */ 两种方法: 方法一: /** * 思路:迭代整个表达式,将每个运算符当作第一个要加括号的运算符. * @param exp * @param result * @param s:start * @param e:end * @return */ public static int f(String exp,boo

算出日期对应的是周几

>>> 1-场景:输入日期,算出日期那天是周几. 2-直接上代码~ ------------------------------------------------------ 如果哪位朋友有更好的方法,期待交流推荐~ ------------------------------------------------------ 个人微信公众订阅号:IT知更鸟 (欢迎关注~) 原文地址:https://www.cnblogs.com/itRobins-wx/p/8676420.html

javascript基础程序(算出一个数的平方值、算出一个数的阶乘、输出!- !- !- !- !- -! -! -! -! -! 、函数三个数中的最大数)

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <script> /* 算出一个数的平方值 function add(a){ var b=Math.sqrt(a); return b; } alert(add(3));*/ /*// 算出一个数的阶乘 func

linux + eclipse + cdt 报错undefined reference......好麻烦的,这位大牛给出的方法可行,特此MARK!!!!

http://bbs.csdn.net/topics/390239632 kerosun kerosun 等级: 结帖率:96.92% 楼主 发表于: 2012-10-11 12:00:51 比如有一个tools工程,提供给其他工程通用的工具函数. 我现在的做法就只能是ctrl+c|ctrl+v一旦工具函数发生变化,还需要在用到这些函数的工程中更新,比较麻烦. 看到eclipse工程属性设置中有Project References,但是一直不会用.那位好心人能说说怎样实现我的需求. 更多0分享到

Java小知识--length,length(),size()方法详细介绍

Java中length,length(),size()区别 length属性:用于获取数组长度. eg: int ar[] = new int{1,2,3} /** * 数组用length属性取得长度 */ int lenAr = ar.length;//此处lenAr=3 System.out.println("Arr length:"+lenAr); length()方法:用于获取字符串长度. String str = "Hello World Java"; /

一次 Oracle 算出运算溢出问题 排查解决 (并非除数为零!)

前段时间 出现过这个问题,: 表中有一列为number类型 rec_recordlength (两个时间的间隔长度/秒) 部分数据 统计这个字段就会出现 "算出运算溢出" 错误,很是头疼,找不出原因 然后 今天又出现了, 然后不断排查,排查,发现是有一条数据导致的, 后来 这条数据删除重新插入就好了, 然后想到唯一动过这条数据的,是执行了rec_recordlength的更新,动作如下: update V_recordlogs set rec_recordlength=86400*(r

JavaScript弹出窗口方法

本文实例汇总了常用的JavaScript弹出窗口方法,供大家对比参考,希望能对大家有所帮助.详细方法如下: 1.无提示刷新网页: 大家有没有发现,有些网页,刷新的时候,会弹出一个提示窗口,点"确定"才会刷新.而有的页面不会提示,不弹出提示窗口,直接就刷新了.如果页面没有form,则不会弹出提示窗口如果页面有form表单,a)<form  method="post" ...>    会弹出提示窗口b)<form  method="get&q

【BioCode】删除未算出PSSM与SS的蛋白质序列

代码说明: 由于一些原因(氨基酸序列过长),没有算出PSSM与SS,按照整理出来的未算出特征的文件,删除原来的蛋白质序列: 需删除的氨基酸文件732.txt(共732条氨基酸): 删除前 氨基酸共25103*2=50206列 删除后 氨基酸共50206-732*2=48742列 代码如下: #include<stdio.h> #include<stdlib.h> #include<iostream> #include<string.h> #include&l