Example #1
0
bool ListPop::OnMouseButtonDown(int x, int y, Uint8 button)
{
	if(!bListDirectory && button != 255) 
	{
		if(!getParent()->OnListButtonDown(this, listpopId))
		{
			//Don't execute
			return false;
		}
	}

	if(pCurrentList->Count() == 0 || !bEnable)
		return false;

	WaitCursor wait;

	xMouse = x;
	yMouse = y;

	if(firstListItem == -1)
	{
		//First click		
		firstListItem = 0;
		lastListItem = 0;		
		
		ResetWork();
		PopulateWorkList(true);
	}

	CalcDimensions();
	
	int height = heightList + 2*topMargin;

	//Calc position
	int xmin = x, ymin = y;

	if(bCenterListOnMouse)
	{
		xmin = x - widthList/2,
		ymin = y - height/2;
	}

	if(xmin < 2) xmin = 2;
	if(ymin < 2) ymin = 2;

	if(xmin + widthList > GameControl::Get()->Width())   xmin = GameControl::Get()->Width() - widthList;
	if(ymin + height > GameControl::Get()->Height()) ymin = GameControl::Get()->Height() - height;

	new ListPopSelect(&itens, xmin, ymin, widthList, height, widthItem, heightItem, listpopId, this, leftMargin, topMargin, bHideOnClickOutList/*, listName*/);

	return false;
}
Example #2
0
int ListPop::AddTextWork(const gedString& text, bool bDuplicate)
{
	if(nCols >= MAX_COLS-1 || (nCols+2)*widthItem >= GameControl::Get()->Width())
	{
		CalcDimensions();
		bGrow = false;
		
		if((itensCols[nCols]+5)*heightItem >= (GameControl::Get()->Height()-16))
		{
			return -1;
		}		
	}

	if(!bDuplicate)
	{
		for(int i = 0; i < itens.Count(); i++)
		{
			if(text == itens[i]) 
			{
				return i;
			}
		}
	}

	if(bGrow && itensCols[nCols]*heightItem >= (GameControl::Get()->Height()-16))
	{
		nCols++;
		heightList = GameControl::Get()->Height() - 16;
	}

	itensCols[nCols]++;
	

	//Don't grow width, but can grow height
	//Solve the bug: Key Down em asteroids.ged (show only two actions when use 640x480)
	//   http://game-editor.com/forum/viewtopic.php?t=901
	//   http://game-editor.com/forum/viewtopic.php?t=1077

	//if(bGrow)
	{
		widthItem = max(widthItem, Text::GetDimensions(text).Width() + TEXT_MARGIN);
		//if(nCols) 
		//	widthItem = min(widthItem, GameControl::Get()->Width()/MAX_COLS);
		heightList = max(heightList, itensCols[nCols]*heightItem);
	}

	itens.PushBack(text);
	return itens.Count() - 1;
}
Example #3
0
UIListBtnTypeItem::UIListBtnTypeItem(
    UIListBtnType *parent, const QString &text,
    QPixmap *pixmap, bool checkable,
    CheckState state, bool showArrow) :
    m_parent(parent), m_text(QDeepCopy<QString>(text)), m_pixmap(pixmap),
    m_checkable(checkable), m_state(state), m_data(NULL),

    m_checkRect(0,0,0,0), m_pixmapRect(0,0,0,0),
    m_textRect(0,0,0,0), m_arrowRect(0,0,0,0),

    m_showArrow(showArrow),

    m_overrideInactive(false),
    m_justify(Qt::AlignLeft | Qt::AlignVCenter)
{
    if (state >= NotChecked)
        m_checkable = true;

    CalcDimensions();

    m_parent->InsertItem(this);
}
Example #4
0
void UIListBtnTypeItem::setDrawArrow(bool flag)
{
    m_showArrow = flag;
    CalcDimensions();
}
Example #5
0
void UIListBtnTypeItem::setCheckable(bool flag)
{
    m_checkable = flag;
    CalcDimensions();
}
Example #6
0
void UIListBtnTypeItem::setPixmap(QPixmap *pixmap)
{
    m_pixmap = pixmap;
    CalcDimensions();
}
Example #7
0
void UIListBtnTypeItem::setText(const QString &text)
{
    m_text = text;
    CalcDimensions();
}