Esempio n. 1
0
// MakeIcon
IconButton*
EditOnStageTool::MakeIcon()
{
	IconButton* icon = new IconButton("edit icon", 0, NULL, NULL);
	icon->SetIcon(kEditIcon, kIconWidth, kIconHeight, kIconFormat);
	return icon;
}
Esempio n. 2
0
// MakeIcon
IconButton*
NoneTool::MakeIcon()
{
	IconButton* icon = new IconButton("no tool icon", 0, NULL, NULL);
	icon->SetIcon(kWatchIcon, kIconWidth, kIconHeight, kIconFormat);
	return icon;
}
Esempio n. 3
0
void ExLineEdit::updateGeometries()
{
    QStyleOptionFrameV2 panel;
    initStyleOption(&panel);
    QRect rect = style()->subElementRect(QStyle::SE_LineEditContents, &panel, this);

    int padding = 3;

    int width = rect.width();

    int clearButton_W = this->height();

    int icons_W = 0;
    int icon_H = this->height() -2;
    int icon_W = icon_H - 4;
    for (int i = 0; i < m_left_icons.count(); i++)
    {
        IconButton *bt = m_left_icons.at(i);
        bt->setGeometry(rect.x() + 2 + icons_W,1, icon_W, icon_H);
        icons_W += icon_W ;
    }
    
    m_lineEdit->setGeometry(rect.x() + 2 + icons_W, padding,
                            width - clearButton_W - icons_W, this->height() - padding*2);

    m_clearButton->setGeometry(this->width() - clearButton_W, 0,
                               clearButton_W, this->height());
}
Esempio n. 4
0
MenuSettingRGBA::MenuSettingRGBA(GMenu2X *gmenu2x, const string &name, const string &description, RGBAColor *value)
	: MenuSetting(gmenu2x,name,description) {
	IconButton *btn;

	selPart = 0;
	_value = value;
	originalValue = *value;
	this->setR(this->value().r);
	this->setG(this->value().g);
	this->setB(this->value().b);
	this->setA(this->value().a);

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Decrease"]);
	btn->setAction(MakeDelegate(this, &MenuSettingRGBA::dec));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/y.png", gmenu2x->tr["Increase"]);
	btn->setAction(MakeDelegate(this, &MenuSettingRGBA::inc));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/left.png");
	btn->setAction(MakeDelegate(this, &MenuSettingRGBA::leftComponent));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/right.png", gmenu2x->tr["Change color component"]);
	btn->setAction(MakeDelegate(this, &MenuSettingRGBA::rightComponent));
	buttonBox.add(btn);
}
Esempio n. 5
0
void MenuSettingBool::initButton()
{
	IconButton *btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png",
									 gmenu2x->tr["Switch"]);
	btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
	buttonBox.add(btn);
}
Esempio n. 6
0
// MakeIcon
IconButton*
PickTool::MakeIcon()
{
	IconButton* icon = new IconButton("pick icon", 0, NULL, NULL);
	icon->SetIcon(kPickIcon, kIconWidth, kIconHeight, kIconFormat);
	return icon;
}
Esempio n. 7
0
void FrontCoverLayer::onClickedOneSever(CCObject* pSender)
{
	CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(pSender);
	if(menuItem)
	{
		CCNode* node = menuItem->getParent();
		CCMenu* menu = dynamic_cast<CCMenu*>(node);
		if(menu)
		{
			CCNode* parent = menu->getParent();
			IconButton* button = dynamic_cast<IconButton*>(parent);
			if(button)
			{
				int buttonIndex = button->GetButtonIndex();
				// to do
				SeverInfo* info = m_severList[buttonIndex];
				if(info)
				{
					USERINFO data = UserData::GetUserInfo();
					sprintf(data.ip,"%s",info->severIp);
					sprintf(data.lastServerName,"%s",info->name);
					data.port = info->port;
					UserData::SetUserInfo(data);
					//onCLickedSeverCloseBt(pSender);
					XLogicManager::sharedManager()->logIn();
				}
			}
		}
	}
}
Esempio n. 8
0
 LevelLauncher(int l, Canvas* c)
 {
     Box *vbox1 = new VBox();
     vbox1->add( new Spacer(),  100, 1 );
     Box *hbox = new HBox();
     hbox->add( new Spacer(),  10, 2 );
     IconButton *icon = new IconButton("level", "", Event::NOP);
     icon->canvas(c, false);
     hbox->add( icon, 300, 0 );
     hbox->add( new Spacer(),  10, 1 );
     Box *vbox = new VBox();
     vbox->add( new Spacer(),  10, 1 );
     vbox->add( new IconButton("Review","",
                               Event(Event::REPLAY,l)),
                BUTTON_HEIGHT, 1 );
     vbox->add( new Spacer(),  10, 0 );
     vbox->add( new IconButton("Play","",
                               Event(Event::PLAY,l)),
                BUTTON_HEIGHT, 1 );
     vbox->add( new Spacer(),  10, 1 );
     hbox->add( vbox, BUTTON_WIDTH, 0 );
     hbox->add( new Spacer(),  10, 2 );
     vbox1->add(hbox, 200, 0);
     vbox1->add( new Spacer(),  100, 1 );
     content()->add(vbox1);
     sizeTo(Vec2(SCREEN_WIDTH,SCREEN_HEIGHT));
     moveTo(Vec2(0,0));
     m_targetPos = Vec2( 0,0 );
 }
Esempio n. 9
0
	bool UIScrollPage::dispatchTutorialMsg(CCObject* pObject,unsigned int type)
	{
		UIMenu* menu = NULL;
		CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(pObject);
		if(menuItem)
		{
			CCNode* node = menuItem->getParent();
			menu = dynamic_cast<UIMenu*>(node);			
		}
		else
		{
			menu = dynamic_cast<UIMenu*>(pObject);
		}

		if(menu)
		{
			CCNode* parent = menu->getParent();
			IconButton* button = dynamic_cast<IconButton*>(parent);
			char name[50];
			sprintf(name,"%s_%d",this->m_strName.c_str(),button->GetButtonIndex());
			return TutorialsManager::Get()->HandleOneEvent(name,type);
		}

		return true;
	}
Esempio n. 10
0
MenuSettingInt::MenuSettingInt(
		GMenu2X *gmenu2x, Touchscreen &ts,
		const string &name, const string &description,
		int *value, int min, int max, int increment)
	: MenuSetting(gmenu2x,name,description)
{
	IconButton *btn;

	_value = value;
	originalValue = *value;
	this->min = min;
	this->max = max;
	this->increment = increment;
	setValue(this->value());

	//Delegates
	ButtonAction actionInc = MakeDelegate(this, &MenuSettingInt::inc);
	ButtonAction actionDec = MakeDelegate(this, &MenuSettingInt::dec);

	btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/l.png");
	btn->setAction(actionDec);
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png", gmenu2x->tr["Decrease"]);
	btn->setAction(actionDec);
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/r.png");
	btn->setAction(actionInc);
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Increase"]);
	btn->setAction(actionInc);
	buttonBox.add(btn);
}
Esempio n. 11
0
void CityListLayer::onPressCityBtn(CCObject* sender)
{
	if (playerMoving)
	{
		return;
	}

	CCMenuItem* menuItem = dynamic_cast<CCMenuItem*>(sender);
	if(menuItem)
	{
		CCNode* node = menuItem->getParent();
		CCMenu* menu = dynamic_cast<CCMenu*>(node);
		if(menu)
		{
			CCNode* parent = menu->getParent();
			IconButton* button = dynamic_cast<IconButton*>(parent);
			if(button)
			{
				playerMoving = true;
				int index = button->GetButtonIndex();	

				targetCityId = cityInfoList[index - 1].cityId;
				moveToCity(targetCityId, 0);
							
			}
		}
	}
}
Esempio n. 12
0
 Widget* makeButton( MenuItem* item, const Event& ev )
 {
     std::string file = item->text.substr(item->text.find(':')+1);
     std::string label = item->text.substr(0,item->text.find(':'));
     IconButton *w = new IconButton(label,file,ev);
     w->align(1);
     m_opts.push_back(w);
     return w;
 }
Esempio n. 13
0
MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter_, const string &startPath_)
	: MenuSettingStringBase(gmenu2x, name, description, value)
	, filter(filter_), startPath(startPath_)
{
	IconButton *btn;

	btn = new IconButton(gmenu2x, "uda://gmenu2x/skins/Default/imgs/buttons/x.png", gmenu2x->tr["Clear"]);
	btn->setAction(MakeDelegate(this, &MenuSettingFile::clear));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, "uda://gmenu2x/skins/Default/imgs/buttons/b.png", gmenu2x->tr["Select a file"]);
	btn->setAction(MakeDelegate(this, &MenuSettingFile::edit));
	buttonBox.add(btn);
}
Esempio n. 14
0
MenuSettingDir::MenuSettingDir(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const std::string &startPath_)
	: MenuSettingStringBase(gmenu2x, name, description, value)
	, startPath(startPath_)
{
	IconButton *btn;

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
	btn->setAction(MakeDelegate(this, &MenuSettingDir::clear));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Select a directory"]);
	btn->setAction(MakeDelegate(this, &MenuSettingDir::edit));
	buttonBox.add(btn);
}
Esempio n. 15
0
void CityListLayer::addCityBtn(int index)
{	
	//获得城市按钮位置
	stringstream nameStream;
	nameStream << "cityBtn" << index;
	string cityBtnName = nameStream.str();

	UIButton *btn = cityListLayout->FindChildObjectByName<UIButton>(cityBtnName);
	CCPoint cityPoint = btn->getPosition();

	//初始化各种位置信息
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	cityInfoList[index - 1].cityPos = ccpAdd(ccp(visibleSize.width / 2, visibleSize.height / 2), cityPoint);
	cityInfoList[index - 1].playerPos = ccpAdd(cityInfoList[index - 1].cityPos, ccp(0, -25));
	cityInfoList[index - 1].namePos = ccpAdd(cityInfoList[index - 1].cityPos, ccp(0, -30));

	//获得城市图标资源
	CCPoint pt;
    ASprite * as = AspriteManager::getInstance()->getAsprite(KICON_BIN);

	stringstream resourceNameStream;
	resourceNameStream << "map_ui_system_icon_FRAME_ICON_CITY" << index;
	string cityResourceName = resourceNameStream.str();

	int cityResourceId = getResourceIDByName(cityResourceName.c_str());
    CCSprite* cityIcon = as->getSpriteFromFrame_Middle(cityResourceId, 0, pt);
	CCSprite* citySelectIcon = as->getSpriteFromFrame_Middle(cityResourceId, 0, pt);
	citySelectIcon->setScale(1.2f);

	//创建城市图标
	IconButton * cityBtn = new IconButton(cityIcon, NULL, citySelectIcon, this, 
					menu_selector(CityListLayer::onPressCityBtn));	
	
	cityBtn->setPosition(cityInfoList[index - 1].cityPos);
	cityBtn->SetButtonIndex(index);
	cityBtn->setAnchorPoint(ccp(0.5, 0.5));
	this->addChild(cityBtn);

	//创建城市名称label
	float fontSize = GameFontManager::smallFontSize();
	CCSize nameLabelSize = CCSizeMake(200 / CC_CONTENT_SCALE_FACTOR(), fontSize);
	
	string cityName = MainLandManager::Get()->getCityName(cityInfoList[index - 1].cityId);
	UILabelTTF * cityNameLabel = UILabelTTF::create(cityName.c_str(), KJLinXin, fontSize,
				nameLabelSize, kCCTextAlignmentCenter,kCCVerticalTextAlignmentBottom);
    
	cityNameLabel->setPosition(cityInfoList[index - 1].namePos);
	this->addChild(cityNameLabel);
}
bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
{
    if (obj != m_iconbutton)
        return QObject::eventFilter(obj, event);
    switch (event->type()) {
    case QEvent::FocusIn:
        if (m_menuTabFocusTrigger && m_menu) {
            m_lineEdit->setFocus();
            m_menu->exec(m_iconbutton->mapToGlobal(m_iconbutton->rect().center()));
            return true;
        }
    default:
        break;
    }
    return QObject::eventFilter(obj, event);
}
Esempio n. 17
0
MenuSettingDir::MenuSettingDir(
		GMenu2X *gmenu2x, Touchscreen &ts_,
		const string &name, const string &description, string *value)
	: MenuSettingStringBase(gmenu2x, name, description, value)
	, ts(ts_)
{
	IconButton *btn;

	btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/cancel.png",
			gmenu2x->tr["Clear"]);
	btn->setAction(BIND(&MenuSettingDir::clear));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/accept.png",
			gmenu2x->tr["Select a directory"]);
	btn->setAction(BIND(&MenuSettingDir::edit));
	buttonBox.add(btn);
}
Esempio n. 18
0
	// page item icon set/get function
	void UIScrollPage::SetPageItemIcon(int ipage, int icolumn, int irow, string iconFile)
	{
		if (ipage > (int) m_ipageCount || ipage < 0)
			return;

		if (icolumn >(int) m_icolumn || icolumn < 0)
			return;

		if (irow > (int) m_irow || irow < 0)
			return;

		CCSprite* elfIcon1 = CCSprite::createWithSpriteFrameName(iconFile.c_str()); 
		IconButton* pButton = m_lstButton[ipage * m_irow * m_icolumn + irow * m_icolumn + icolumn];		
		if (pButton)
		{
			pButton->SetNormalIcon(elfIcon1);
		}
	}
Esempio n. 19
0
MenuSettingString::MenuSettingString(
		GMenu2X *gmenu2x, const string &name,
		const string &description, string *value,
		const string &diagTitle_, const string &diagIcon_)
	: MenuSettingStringBase(gmenu2x, name, description, value)
	, diagTitle(diagTitle_)
	, diagIcon(diagIcon_)
{
	IconButton *btn;

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/cancel.png", gmenu2x->tr["Clear"]);
	btn->setAction(MakeDelegate(this, &MenuSettingString::clear));
	buttonBox.add(btn);

	btn = new IconButton(gmenu2x, "skin:imgs/buttons/accept.png", gmenu2x->tr["Edit"]);
	btn->setAction(MakeDelegate(this, &MenuSettingString::edit));
	buttonBox.add(btn);
}
MenuSettingMultiString::MenuSettingMultiString(
    GMenu2X *gmenu2x, Touchscreen &ts,
    const string &name, const string &description,
    string *value, const vector<string> *choices_)
    : MenuSettingStringBase(gmenu2x, name, description, value)
    , choices(choices_)
{
    setSel(find(choices->begin(), choices->end(), *value) - choices->begin());

    IconButton *btn;

    btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/left.png");
    btn->setAction(MakeDelegate(this, &MenuSettingMultiString::decSel));
    buttonBox.add(btn);

    btn = new IconButton(gmenu2x, ts, "skin:imgs/buttons/right.png", gmenu2x->tr["Change value"]);
    btn->setAction(MakeDelegate(this, &MenuSettingMultiString::incSel));
    buttonBox.add(btn);
}
Esempio n. 21
0
void FrontCoverLayer::addNewSever()
{
	UILayout* m_layout = UIManager::sharedManager()->getUILayout("SplashLayout");
	if(m_severScrollPage)
	{
		CCLayer* layer = CCLayer::create();
		m_severScrollPage->addPage(layer);

		int count = m_severList.size();
		int currentPage = 0;
		int column = 3;
		int row = 2;

		ASprite *as = AspriteManager::getInstance()->getAsprite(KUI_BIN);
		int idx = map_ui_FRAME_SELECTSERVE_BUTTON;
		int selectedId = map_ui_FRAME_SELECTSERVE_BUTTON_CLICKED;
		float scale = UIManager::sharedManager()->getScaleFactor();
		float width = m_severScrollPage->getContentSize().width / scale;
		float height = m_severScrollPage->getContentSize().height / scale;

		CCRect rect = as->getframeRect(idx);

		float deltaWidth = (width - column * rect.size.width )/(column + 1);
		float deltaHeigth = (height - row * rect.size.height )/(row + 1);
		
		for(int i =0; i< count; i++)
		{
			int index = i;
			int page = index / (column * row);
			int rowIndex = (index - page * column * row) / column;
			int columnIndex = (index - page * column * row) % column;
			if(page != currentPage)
			{
				currentPage = page;
				CCLayer* newlayer = CCLayer::create();
				m_severScrollPage->addPage(newlayer);
			}

			CCPoint pt;
			CCSprite *pEmptyItem = as->getSpriteFromFrame_Middle( idx, 0, pt);
			CCSprite *pSelectedItem = as->getSpriteFromFrame_Middle(selectedId ,0,pt); 
			IconButton * pIcon = new IconButton(pEmptyItem, NULL, pSelectedItem, this, 
				menu_selector(FrontCoverLayer::onClickedOneSever));
			pIcon->autorelease();
			pIcon->SetButtonIndex(index);
			pIcon->setContentSize(pEmptyItem->getContentSize());

			float x = -width * 0.5f + deltaWidth * (columnIndex + 1) + (columnIndex + 0.5f) * rect.size.width ;
			float y = height * 0.5f - (rowIndex + 0.5f) * (deltaHeigth + rect.size.height );
			pIcon->setPosition(ccp(x, y));

			UILabelTTF* label = UILabelTTF::create(m_severList[i]->name,KJLinXin,40,pEmptyItem->getContentSize(),kCCTextAlignmentCenter,kCCVerticalTextAlignmentCenter);
			pIcon->addChild(label);
			m_lstButton.push_back(pIcon);
			CCLayer* currentLayer = m_severScrollPage->getPageLayer(currentPage);
			currentLayer->addChild(pIcon,index);	
		}
	}
}
Esempio n. 22
0
	void UIScrollPage::SetPageItemIconWithSprite(int ipage, int icolmun, int irow, CCSprite* isprite)
	{
		if (ipage > (int) m_ipageCount || ipage < 0)
			return;

		if (icolmun >(int) m_icolumn || icolmun < 0)
			return;

		if (irow > (int) m_irow || irow < 0)
			return;

		size_t index = ipage * m_irow * m_icolumn + irow * m_icolumn + icolmun;
		if(index < m_lstButton.size())
		{
			IconButton* pButton = m_lstButton[ipage * m_irow * m_icolumn + irow * m_icolumn + icolmun];		
			if (pButton)
			{
				pButton->SetNormalIcon(isprite);
			}
		}

	}
Esempio n. 23
0
void
IconStackedWidget::addPage(const QString& name, QWidget *page, const QPixmap& icon)
{
    IconButton *iconButton = new IconButton(m_iconPanel,icon, name);    

    // IconStackedWidget acts like a radio button widget with exclusive buttons
    iconButton->setCheckable(true);
    iconButton->setAutoExclusive(true);

    // If the new button is the biggest so far, update the default size
    if ((iconButton->minimumWidth() > m_buttonWidth) || (iconButton->minimumHeight() > m_buttonHeight)) {
        m_buttonWidth = std::max(iconButton->minimumWidth(),m_buttonWidth);
        m_buttonHeight = std::max(iconButton->minimumHeight(),m_buttonHeight);
        // Update the size of previous buttons
        for (iconbuttons::iterator i = m_iconButtons.begin();
            i != m_iconButtons.end(); ++i)
            (*i)->setMinimumSize(m_buttonWidth, m_buttonHeight);
    }

    iconButton->setMinimumSize(m_buttonWidth, m_buttonHeight);

    // If the list of buttons is not empty set the new buttons background to the default
    if (!m_iconButtons.size()) {
        iconButton->setChecked(true);
    }
    
    // Store the new button in a list for later modification
    m_iconButtons.push_back((IconButton *) iconButton);
    
    // Add the button to the icon layout, insert to the second point in the list
    //   the first hold the stretch item
    m_iconLayout->insertWidget(1,iconButton);

    // Add the new page to the page layout
    m_pagePanel->addWidget(page);

    // Connect the button's clicked data signal to the page select slot
    connect(iconButton, SIGNAL(clicked()), this, SLOT(slotPageSelect()));
}
Esempio n. 24
0
bool CityListLayer::init()
{
	if(!CCLayer::init())
	{
		return false;
	}

	//读取城市列表
	initCityList();

	UIManager *manager = UIManager::sharedManager();
	cityListLayout = manager->CreateUILayoutFromFile("UIplist/cityListUI.plist", this, "CityList");	

	//添加背景图片
	CCSprite * bgImg = CCSprite::create("game.png");

	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
	CCSize bgSize = bgImg->getContentSize();

	float scaleX = visibleSize.width / bgSize.width;
	float scaleY = visibleSize.height / bgSize.height;

	bgImg->setScaleX(scaleX);
	bgImg->setScaleY(scaleY);
	
	bgImg->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));

	this->addChild(bgImg, -1);

	//添加主城
	for (size_t i = 0; i < cityInfoList.size(); i++)
	{
		addCityBtn(i+1);
	}


	//添加关闭按钮
	UIButton *btn = cityListLayout->FindChildObjectByName<UIButton>("cityListCloseBtn");
	CCPoint closePoint = btn->getPosition();
	closePoint = ccpAdd(ccp(visibleSize.width / 2, visibleSize.height / 2), closePoint);

	CCPoint pt1;
	ASprite * as1 = AspriteManager::getInstance()->getAsprite(KUI_BIN);

	int normalCloseId = getResourceIDByName("map_ui_FRAME_INSTANCE_CLOSE");
	int selectCloseId = getResourceIDByName("map_ui_FRAME_INSTANCE_CLOSE_CLICKED");

	CCSprite * normalCloseBtn = as1->getSpriteFromFrame_Middle(normalCloseId, 0, pt1);
	CCSprite * selectCloseBtn = as1->getSpriteFromFrame_Middle(selectCloseId, 0, pt1);

	IconButton * closeBtn = new IconButton(normalCloseBtn, NULL, selectCloseBtn, this, 
					menu_selector(CityListLayer::closeCityList));

	closeBtn->setPosition(closePoint);

	this->addChild(closeBtn);

	//初始化玩家头像资源
	CCPoint pt;
    ASprite * as = AspriteManager::getInstance()->getAsprite(KICON_BIN);

	int playerType = UserData::Get()->GetUserType();

	stringstream playerResStream;
	playerResStream << "map_ui_system_icon_FRAME_ICON_ROLEONMAP_" << playerType;
	string playerResName = playerResStream.str();

	int playerResourceId = getResourceIDByName(playerResName.c_str());
    playerImg = as->getSpriteFromFrame_Middle(playerResourceId, 0, pt);
	playerImg->setVisible(false);	

	this->addChild(playerImg);


	playerMoving = false;
	return true;
}
Esempio n. 25
0
void ModelMgrWidget::updateModels()
{
    //
    QLayoutItem *child;
    while (child = q_horiLayoutMain->takeAt(0)) {
        QWidget *widget = child->widget();
        if (widget) {
            widget->setParent(0);
            widget->deleteLater();
        }
        delete child;
    }

    //
    IconButton *buttonHome = new IconButton(QPixmap(":/application/image/home-1.png"), this);
    buttonHome->setObjectName("buttonHome");
    buttonHome->setFixedSize(25, 25);
    buttonHome->setToolTip(QStringLiteral("主页"));
    q_horiLayoutMain->addWidget(buttonHome);

    QComboBox *comboBoxModel = new QComboBox(this);
    comboBoxModel->addItem(QStringLiteral("数据管理"));
    comboBoxModel->addItem(QStringLiteral("数据查询"));
    comboBoxModel->addItem(QStringLiteral("数据分析"));
    comboBoxModel->setMinimumWidth(QFontMetrics(comboBoxModel->font())
                                   .width(comboBoxModel->itemText(0)) + 50);
    comboBoxModel->setToolTip(QStringLiteral("只切换模式界面,不初始化界面数据"));
    q_horiLayoutMain->addWidget(comboBoxModel);

    //
    connect(buttonHome, &QPushButton::clicked, [=](bool){
        setCurrentModel(QStringLiteral("数据管理"));
    });

    //
    QStringListIterator citerModelStack(q_modelStack);
    while (citerModelStack.hasNext()) {
        const QString &model = citerModelStack.next();
        //

        JClickableLabel *labelName = new JClickableLabel(model, this);
        labelName->setObjectName("labelName");
        labelName->setAlignment(Qt::AlignVCenter);
        labelName->setText(model);
        IconButton *buttonArrow = new IconButton(QPixmap(":/application/image/arrow-1.png"), this);
        buttonArrow->setObjectName("buttonArrow");
        buttonArrow->setFixedSize(20, 25);
        q_horiLayoutMain->addWidget(labelName);
        q_horiLayoutMain->addWidget(buttonArrow);

        //
        connect(labelName, &JClickableLabel::clicked, [=](){
            setCurrentModel(labelName->text());
        });
    }

    //
    comboBoxModel->setCurrentText(q_modelStack.last());

    //
    connect(comboBoxModel, &QComboBox::currentTextChanged, [=](const QString &text){
        setCurrentModel(text, false);
        Q_EMIT currentIndexChanged(text);
    });
}
Esempio n. 26
0
	void UIScrollPage::addOneEmptyPage(int pageIndex)
	{
		CCLayer* layer = CCLayer::create();
		layer->setAnchorPoint(ccp(0, 0));
		{
			int deltaX, deltaY;
			if(m_cellBinFile == "")
			{
				m_cellBinFile = KUI_BIN;
			}
			ASprite *as = AspriteManager::getInstance()->getAsprite(m_cellBinFile);
			int idx = getResourceIDByName(m_cellAsfile.c_str());
			int selectedId = getResourceIDByName(m_cellSelectedAsfile.c_str());
			CCSize buttonSize = as->getframeRect(idx).size;
//			float contentScale = CCDirector::sharedDirector()->getContentScaleFactor();
//			buttonSize = CCSizeMake(buttonSize.width * contentScale, buttonSize.height * contentScale);

			if (m_icolumn <= 1)
				deltaX = 0;
			else
				deltaX = (getContentSize().width - 2 * m_celloffsetX - buttonSize.width) / (m_icolumn - 1);

			if (m_irow <= 1)
				deltaY = 0;
			else
				deltaY = (getContentSize().height - 2 * m_celloffsetY - buttonSize.height) / (m_irow - 1);
			
			/////////////////////////////////////////////////////////////////////////////
			// row 
			// row
			for(int r = 0; r < (int)m_irow; r++)
			{
				for(int l = 0; l < (int) m_icolumn; l++)
				{
					// clone one ccsprite 
					CCPoint pt;
					CCSprite *pEmptyItem = as->getSpriteFromFrame_Middle( idx, 0, pt);
					CCSprite *pSelectedItem = as->getSpriteFromFrame_Middle(selectedId ,0,pt); 
					IconButton * pIcon = new IconButton(pEmptyItem, NULL, pSelectedItem, this, 
						menu_selector(UIScrollPage::OnItemClicked));
					pIcon->autorelease();
					int index = pageIndex * m_icolumn * m_irow;
					index += r * m_icolumn + l;
					pIcon->SetButtonIndex(index+1);
					pIcon->setContentSize(pEmptyItem->getContentSize());
					if(m_itemType != 0)
					{
						pIcon->creatDragReceiver((DragHandlerType)m_itemType);
					}
					pIcon->SetDoubleClickHandler(this,menu_selector(UIScrollPage::OnItemDoubleClicked));
					pIcon->SetTappedHandler(this,menu_selector(UIScrollPage::OnTapped),menu_selector(UIScrollPage::OnTapCancel));
					pIcon->SetDragFlagTime(150);
					m_lstButton.push_back(pIcon);

					int x = l * deltaX + m_celloffsetX + buttonSize.width / 2 - getContentSize().width / 2 ;
					int y = getContentSize().height / 2 - (r * deltaY + m_celloffsetY + buttonSize.height / 2);

//					x /= contentScale;
//					y /= contentScale;

					pIcon->setPosition(ccp(x, y));

					char name[50];
					sprintf(name,"%s_%d",this->m_strName.c_str(),index+1);
					pIcon->SetButtonName(name);

					layer->addChild(pIcon);
				}
			}
		}

		addPage(layer);		
	}