void add_button( HWND parent, int top, int left, int id, int FAR * pwidth, int FAR * pheight ) { HWND hbutton; HINSTANCE inst; // Note that the resource ID is the same as the control ID inst = GET_HINSTANCE( parent ); button_size( parent, id, pwidth, pheight ); hbutton = CreateWindow( "BUTTON", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, // Window style left, // horizontal top, // vertical *pwidth, // width *pheight, // height parent, // parent window (HMENU)id, // menu is really child number inst, // This instance owns this window. NULL // Pointer not needed. ); }
void measure_button(HWND parent, int button_id, MEASUREITEMSTRUCT FAR * measure ) { int width, height; // for proper typing since itemWidth and itemHeight are UNIT's button_size( parent, button_id, &width, &height ); measure->itemWidth = width; measure->itemHeight = height; }
void GoOutPopUp::onCreate(cocos2d::CCNode *parent) { cocos2d::CCSize size = parent->getContentSize(); float x_middle = size.width / 2; //label cocos2d::CCLabelTTF* label = cocos2d::CCLabelTTF::create(_("Sure"), ADLanguage::getFontName(), 40); label->setColor(cocos2d::ccc3(255,255,255)); label->setPosition(ccp(x_middle, size.height*0.7f)); parent->addChild(label); /////////////////////////////////////////////////////// cocos2d::CCMenu* menu = cocos2d::CCMenu::create(); menu->setPosition(0,0); parent->addChild(menu); float vertical = size.height * 0.25f; cocos2d::CCSize button_size(size.width*0.25,size.width*0.15); /////////////////////////////////////////////////////// OneWordButton* yes_button = OneWordButton::create(button_size, GameInfo::ORANGE_COLOR, _("Yes")); yes_button->setPosition(ccp(size.width*0.25, vertical)); CONNECT(yes_button->signalOnClick, this, &GoOutPopUp::onYes); menu->addChild(yes_button); ////////////////////////////////////////////////////// OneWordButton* no_button = OneWordButton::create(button_size, GameInfo::GREEN_COLOR, _("No")); no_button->setPosition(ccp(size.width*0.75, vertical)); CONNECT(no_button->signalOnClick, this, &GoOutPopUp::onNo); menu->addChild(no_button); }
void BuyCurrencyPopUp::onCreate(cocos2d::CCNode* parent) { _active_window = this; cocos2d::CCSize size = parent->getContentSize(); float x_middle = size.width / 2; cocos2d::CCMenu* menu = cocos2d::CCMenu::create(); menu->setPosition(0,0); parent->addChild(menu); //////////////////////////////////////////////// if(_show_back) { //create back button cocos2d::CCSprite* back_logo = cocos2d::CCSprite::create("universal/back.png"); ADMenuItem* back = ADMenuItem::create(back_logo); back->setAnchorPoint(ccp(0.5,0.5)); back->setPosition(ccp(size.width*0.1, size.height*0.9f)); back->setColor(GameInfo::WHITE_COLOR); menu->addChild(back); CONNECT(back->signalOnClick, this, &BuyCurrencyPopUp::onCloseWindow); } /////////////////////////////////////////////////// //label cocos2d::CCLabelTTF* label = cocos2d::CCLabelTTF::create(_("Buy more coins"), ADLanguage::getFontName(), 65); label->setColor(cocos2d::ccc3(255,255,255)); label->setPosition(ccp(x_middle+size.width*0.05, size.height*0.9f)); parent->addChild(label); /////////////////////////////////////////////////////// float left_width_position = size.width*0.25; float right_width_position = size.width*0.75; cocos2d::CCSize button_size(size.width*0.4,size.width*0.15); /////////////////////////////////////////////////////// std::string coins_100_price = ADInApp::getProduct("coins_100")->getPrice(); TwoWordButton* x_100 = TwoWordButton::create(button_size, GameInfo::WHITE_COLOR, "x100", coins_100_price, GameInfo::DARK_GRAY_COLOR); x_100->setAnchorPoint(ccp(0.5,0.5)); x_100->setPosition(ccp(left_width_position, size.height * 0.67f)); CONNECT(x_100->signalOnClick, this, &BuyCurrencyPopUp::onX100); menu->addChild(x_100); /////////////////////////////////////////////////////// std::string coins_1500_price = ADInApp::getProduct("coins_1500")->getPrice(); TwoWordButton* x_1500 = TwoWordButton::create(button_size, GameInfo::WHITE_COLOR, "x1500", coins_1500_price, GameInfo::DARK_GRAY_COLOR); x_1500->setAnchorPoint(ccp(0.5,0.5)); x_1500->setPosition(ccp(right_width_position, size.height * 0.67f)); CONNECT(x_1500->signalOnClick, this, &BuyCurrencyPopUp::onX1500); menu->addChild(x_1500); /////////////////////////////////////////////////////// std::string coins_5000_price = ADInApp::getProduct("coins_5000")->getPrice(); TwoWordButton* x_5000 = TwoWordButton::create(button_size, GameInfo::WHITE_COLOR, "x5000", coins_5000_price, GameInfo::DARK_GRAY_COLOR); x_5000->setAnchorPoint(ccp(0.5,0.5)); x_5000->setPosition(ccp(left_width_position, size.height * 0.5f)); CONNECT(x_5000->signalOnClick, this, &BuyCurrencyPopUp::onX5000); menu->addChild(x_5000); /////////////////////////////////////////////////////// std::string coins_20000_price = ADInApp::getProduct("coins_20000")->getPrice(); TwoWordButton* x_20000 = TwoWordButton::create(button_size, GameInfo::WHITE_COLOR, "x20000", coins_20000_price, GameInfo::DARK_GRAY_COLOR); x_20000->setAnchorPoint(ccp(0.5,0.5)); x_20000->setPosition(ccp(right_width_position, size.height * 0.5f)); CONNECT(x_20000->signalOnClick, this, &BuyCurrencyPopUp::onX20000); menu->addChild(x_20000); /////////////////////////////////////////////////////// std::string coins_1000K_price = ADInApp::getProduct("coins_1000k")->getPrice(); TwoWordButton* x_1000K = TwoWordButton::create(button_size, GameInfo::WHITE_COLOR, "x1000k", coins_1000K_price, GameInfo::ORANGE_COLOR); x_1000K->setAnchorPoint(ccp(0.5,0.5)); x_1000K->setPosition(ccp(left_width_position, size.height * 0.33f)); CONNECT(x_1000K->signalOnClick, this, &BuyCurrencyPopUp::onX1000K); menu->addChild(x_1000K); /////////////////////////////////////////////////////// std::string coins_1000KK_price = ADInApp::getProduct("coins_1000kk")->getPrice(); TwoWordButton* x_1000KK = TwoWordButton::create(button_size, GameInfo::WHITE_COLOR, "x1000kk", coins_1000KK_price, GameInfo::ORANGE_COLOR); x_1000KK->setAnchorPoint(ccp(0.5,0.5)); x_1000KK->setPosition(ccp(right_width_position, size.height * 0.33f)); CONNECT(x_1000KK->signalOnClick, this, &BuyCurrencyPopUp::onX1000KK); menu->addChild(x_1000KK); /////////////////////////////////////////////////////// if(ADVirtualCurrency::isSupported()) { OneWordButton* free = OneWordButton::create(button_size, GameInfo::WHITE_COLOR, _("Free"), GameInfo::DARK_GRAY_COLOR); free->setAnchorPoint(ccp(0.5,0.5)); free->setPosition(ccp(x_middle,size.height * 0.16f)); menu->addChild(free); CONNECT(free->signalOnClick, this, &BuyCurrencyPopUp::onX100); ADStatistics::logEvent("Free Hints Shown"); } }