Beispiel #1
0
void KkrBoardView::showCell(int col, int row)
{
    if(m_pScrollArea != nullptr) {
        const QRect cellRect = getCellRect(col, row);
        // the top/right clue cell must be also in the visible area
        m_pScrollArea->ensureVisible(cellRect.x(), cellRect.y(),
                                     FRAME_THICK+CELL_WIDTH, FRAME_THICK+CELL_WIDTH);
    }
}
Beispiel #2
0
void TableView::getShowCells(const cocos2d::Rect& area, std::vector<uint16_t>* dst)
{
	Rect _cellRect;
	for (int i = 0; i < m_totalCnt; ++i)
	{
		getCellRect(i, &_cellRect);
		if (!area.intersectsRect(_cellRect))
			continue;
		dst->push_back(i);
	}
}
Beispiel #3
0
//virtual
BOOL LLNameListCtrl::handleToolTip(S32 x, S32 y, MASK mask)
{
	BOOL handled = FALSE;
	S32 column_index = getColumnIndexFromOffset(x);
	LLNameListItem* hit_item = dynamic_cast<LLNameListItem*>(hitItem(x, y));
	if (hit_item
		&& column_index == mNameColumnIndex)
	{
		// ...this is the column with the avatar name
		LLUUID avatar_id = hit_item->getUUID();
		if (avatar_id.notNull())
		{
			// ...valid avatar id

			LLScrollListCell* hit_cell = hit_item->getColumn(column_index);
			if (hit_cell)
			{
				S32 row_index = getItemIndex(hit_item);
				LLRect cell_rect = getCellRect(row_index, column_index);
				// Convert rect local to screen coordinates
				LLRect sticky_rect;
				localRectToScreen(cell_rect, &sticky_rect);

				// Spawn at right side of cell
				LLPointer<LLUIImage> icon = LLUI::getUIImage("Info_Small");
				LLCoordGL pos( sticky_rect.mRight - info_icon_size, sticky_rect.mTop - (sticky_rect.getHeight() - icon->getHeight())/2 );

				// Should we show a group or an avatar inspector?
				bool is_group = hit_item->isGroup();
				bool is_experience = hit_item->isExperience();

				LLToolTip::Params params;
				params.background_visible( false );
				params.click_callback( boost::bind(&LLNameListCtrl::showInspector, this, avatar_id, is_group, is_experience) );
				params.delay_time(0.0f);		// spawn instantly on hover
				params.image( icon );
				params.message("");
				params.padding(0);
				params.pos(pos);
				params.sticky_rect(sticky_rect);

				LLToolTipMgr::getInstance()->show(params);
				handled = TRUE;
			}
		}
	}
	if (!handled)
	{
		handled = LLScrollListCtrl::handleToolTip(x, y, mask);
	}
	return handled;
}
Beispiel #4
0
int TableView::getCellIndex(const Vec2& position)
{
	if (m_totalCnt == 0)return -1;

	Rect _rect;
	for (int i = 0; i < m_totalCnt; ++i)
	{
		getCellRect(i, &_rect);
		if (_rect.containsPoint(position))
			return i;
	}
	return -1;
}
void	LLNameListCtrl::mouseOverHighlightNthItem( S32 target_index )
{
	S32 cur_index = getHighlightedItemInx();
	if (cur_index != target_index)
	{
		bool is_mouse_over_name_cell = false;

		S32 mouse_x, mouse_y;
		LLUI::getMousePositionLocal(this, &mouse_x, &mouse_y);

		S32 column_index = getColumnIndexFromOffset(mouse_x);
		LLScrollListItem* hit_item = hitItem(mouse_x, mouse_y);
		if (hit_item && column_index == mNameColumnIndex)
		{
			// Get the name cell which is currently under the mouse pointer.
			LLScrollListCell* hit_cell = hit_item->getColumn(column_index);
			if (hit_cell)
			{
				is_mouse_over_name_cell = getCellRect(cur_index, column_index).pointInRect(mouse_x, mouse_y);
			}
		}

		// If the tool tip is visible and the mouse is over the currently highlighted item's name cell,
		// we should not reset the highlighted item index i.e. set mHighlightedItem = -1
		// and should not increase the width of the text inside the cell because it may
		// overlap the tool tip icon.
		if (LLToolTipMgr::getInstance()->toolTipVisible() && is_mouse_over_name_cell)
			return;

		if(0 <= cur_index && cur_index < (S32)getItemList().size())
		{
			LLScrollListItem* item = getItemList()[cur_index];
			if (item)
			{
				LLScrollListText* cell = dynamic_cast<LLScrollListText*>(item->getColumn(mNameColumnIndex));
				if (cell)
					cell->setTextWidth(cell->getTextWidth() + info_icon_size);
			}
			else
			{
				llwarns << "highlighted name list item is NULL" << llendl;
			}
		}
		if(target_index != -1)
		{
			LLScrollListItem* item = getItemList()[target_index];
			LLScrollListText* cell = dynamic_cast<LLScrollListText*>(item->getColumn(mNameColumnIndex));
			if (item)
			{
				if (cell)
					cell->setTextWidth(cell->getTextWidth() - info_icon_size);
			}
			else
			{
				llwarns << "target name item is NULL" << llendl;
			}
		}
	}

	LLScrollListCtrl::mouseOverHighlightNthItem(target_index);
}
Beispiel #6
0
static XP_Bool
drawCell( BoardCtxt* board, XP_U16 col, XP_U16 row, XP_Bool skipBlanks )
{
    XP_Bool success = XP_TRUE;
    XP_Rect cellRect;
    Tile tile;
    XP_Bool isBlank, isEmpty, recent, pending = XP_FALSE;
    XWBonusType bonus;
    ModelCtxt* model = board->model;
    DictionaryCtxt* dict = model_getDictionary( model );
    XP_U16 modelCol, modelRow;

    if ( dict != NULL && getCellRect( board, col, row, &cellRect ) ) {

        /* We want to invert EITHER the current pending tiles OR the most recent
         * move.  So if the tray is visible AND there are tiles missing from it,
         * show them.  Otherwise show the most recent move.
         */
        XP_U16 selPlayer = board->selPlayer;
        XP_U16 curCount = model_getCurrentMoveCount( model, selPlayer );
        XP_Bool showPending = board->trayVisState == TRAY_REVEALED
            && curCount > 0;

        flipIf( board, col, row, &modelCol, &modelRow );

        /* This 'while' is only here so I can 'break' below */
        while ( board->trayVisState == TRAY_HIDDEN ||
                !rectContainsRect( &board->trayBounds, &cellRect ) ) {
            XP_UCHAR ch[4] = {'\0'};
            XP_S16 owner = -1;
            XP_Bool invert = XP_FALSE;
            XP_Bitmaps bitmaps;
            XP_Bitmaps* bptr = NULL;
            const XP_UCHAR* textP = NULL;
            HintAtts hintAtts;
            CellFlags flags = CELL_NONE;
            XP_Bool isOrigin;
            XP_U16 value = 0;

            isEmpty = !model_getTile( model, modelCol, modelRow, showPending,
                                        selPlayer, &tile, &isBlank,
                                        &pending, &recent );
            if ( dragDropIsBeingDragged( board, col, row, &isOrigin ) ) {
                flags |= isOrigin? CELL_DRAGSRC : CELL_DRAGCUR;
                if ( isEmpty && !isOrigin ) {
                    dragDropTileInfo( board, &tile, &isBlank );
                    //isEmpty = XP_FALSE;
                }
                showPending = pending = XP_TRUE;
            }

            if ( isEmpty ) {
                isBlank = XP_FALSE;
                flags |= CELL_ISEMPTY;
            } else if ( isBlank && skipBlanks ) {
                break;
            } else {
                Tile valTile = isBlank? dict_getBlankTile( dict ) : tile;
                value = dict_getTileValue( dict, valTile );

                if ( board->showColors ) {
                    owner = (XP_S16)model_getCellOwner( model, modelCol, 
                                                        modelRow );
                }

                invert = showPending? pending : recent;

                if ( board->showCellValues ) {
                    XP_SNPRINTF( ch, VSIZE(ch), "%d", value );
                    textP = ch;
                } else {
                    if ( dict_faceIsBitmap( dict, tile ) ) {
                        dict_getFaceBitmaps( dict, tile, &bitmaps );
                        bptr = &bitmaps;
                    }
                    textP = dict_getTileString( dict, tile );
                }
            }
            bonus = model_getSquareBonus( model, col, row );
            hintAtts = figureHintAtts( board, col, row );

            if ( (col==board->star_row) && (row==board->star_row) ) {
                flags |= CELL_ISSTAR;
            }
            if ( invert ) {
                flags |= CELL_HIGHLIGHT;
            }
            if ( isBlank ) {
                flags |= CELL_ISBLANK;
            }
#ifdef KEYBOARD_NAV
            if ( cellFocused( board, col, row ) ) {
                flags |= CELL_ISCURSOR;
            }
#endif
#ifdef XWFEATURE_CROSSHAIRS
            flags |= flagsForCrosshairs( board, col, row );
#endif

            XP_Bool androidPlaying = model_androidPlaying(model, modelCol, modelRow);
            XP_S16 nMoves = model_getNMoves(model);
            if (androidPlaying && 1 < nMoves){
                flags |= CELL_ANDROID_PLAYING;
            }

            success = draw_drawCell( board->draw, &cellRect, textP, bptr,
                                     tile, value, owner, bonus, hintAtts, 
                                     flags );

            break;
        }
    }
    return success;
} /* drawCell */
Beispiel #7
0
static void
drawBoard( BoardCtxt* board )
{
    if ( board->needsDrawing 
         && draw_boardBegin( board->draw, &board->boardBounds, 
                             board->sd[SCROLL_H].scale,
                             board->sd[SCROLL_V].scale,
                             dfsFor( board, OBJ_BOARD ) ) ) {

        XP_Bool allDrawn = XP_TRUE;
        XP_S16 ii;
        XP_S16 col, row, nVisCols;
        ModelCtxt* model = board->model;
        BoardArrow const* arrow = NULL;
        ScrollData* hsd = &board->sd[SCROLL_H];
        ScrollData* vsd = &board->sd[SCROLL_V];
        BlankQueue bq;

        scrollIfCan( board ); /* this must happen before we count blanks
                                 since it invalidates squares */

        /* This is freaking expensive!!!! PENDING FIXME Can't we start from
           what's invalid rather than scanning the entire model every time
           somebody dirties a single cell? */
        model_listPlacedBlanks( model, board->selPlayer, 
                                board->trayVisState == TRAY_REVEALED, &bq );
        dragDropAppendBlank( board, &bq );
        invalBlanksWithNeighbors( board, &bq );

        /* figure out now, before clearing inval bits, if we'll need to draw
           the arrow later */
        if ( board->trayVisState == TRAY_REVEALED ) {
            BoardArrow const* tmpArrow = &board->selInfo->boardArrow;
            if ( tmpArrow->visible ) {
                XP_U16 col = tmpArrow->col;
                XP_U16 row = tmpArrow->row;
                if ( INVAL_BIT_SET( board, col, row )
                     && !cellOccupied( board, col, row, XP_TRUE ) ) {
                    arrow = tmpArrow;
                }
            }
        }

        // Draw most cells.
        nVisCols = model_numCols( model ) - board->zoomCount;
        for ( row = vsd->offset; row <= vsd->lastVisible; ++row ) {
            RowFlags rowFlags = board->redrawFlags[row];
            if ( rowFlags != 0 ) {
                RowFlags failedBits = 0;
                for ( col = 0; col < nVisCols; ++col ) {
                    RowFlags colMask = 1 << (col + hsd->offset);
                    if ( 0 != (rowFlags & colMask) ) {
                        if ( !drawCell( board, col + hsd->offset,
                                        row, XP_TRUE )) {
                            failedBits |= colMask;
                            allDrawn = XP_FALSE;
                        }
                    }
                }
                board->redrawFlags[row] = failedBits;
            }
        }
        // Show once; it's being done.
        model_clearAndroidPlaying();

        /* draw the blanks we skipped before */
        for ( ii = 0; ii < bq.nBlanks; ++ii ) {
            if ( !drawCell( board, bq.col[ii], bq.row[ii], XP_FALSE ) ) {
                allDrawn = XP_FALSE;
            }
        }

        if ( !!arrow ) {
            XP_U16 col = arrow->col;
            XP_U16 row = arrow->row;
            XP_Rect arrowRect;
            if ( getCellRect( board, col, row, &arrowRect ) ) {
                XWBonusType bonus;
                HintAtts hintAtts;
                CellFlags flags = CELL_NONE;
                bonus = model_getSquareBonus( model, col, row );
                hintAtts = figureHintAtts( board, col, row );
#ifdef KEYBOARD_NAV
                if ( cellFocused( board, col, row ) ) {
                    flags |= CELL_ISCURSOR;
                }
#endif
#ifdef XWFEATURE_CROSSHAIRS
                flags |= flagsForCrosshairs( board, col, row );
#endif

                draw_drawBoardArrow( board->draw, &arrowRect, bonus, 
                                     arrow->vert, hintAtts, flags );
            }
        }

        /* I doubt the two of these can happen at the same time */
        drawTradeWindowIf( board );
#ifdef POINTER_SUPPORT
        drawDragTileIf( board );
#endif
        draw_objFinished( board->draw, OBJ_BOARD, &board->boardBounds, 
                          dfsFor( board, OBJ_BOARD ) );

        board->needsDrawing = !allDrawn;
    }
} /* drawBoard */
Beispiel #8
0
void ListCtrl::onDraw( HDC hdc, const Rect& rcPaint )
{
	Rect rc = getRect();
	if (!verify())
	{
		WfxRender::drawFrame(hdc, rc, WBTN_BKGND_MOUSE, getDispatcher());
		return;
	}
	LCDrawItemInfo* pDrawItemInfo = getDrawItemInfo();
	pDrawItemInfo->clear();
	pDrawItemInfo->m_hDC = hdc;
	Rect rcCell;
	DWORD dwState = WCS_NORMAL;
	ULONG nLayer = 0;
	BOOL bRowexpanded = FALSE;
	COLORREF clrText = 0;
	LONG nLayerOffset = 0;
	LONG nTotalRow = getTotalRows();
	LONG nTotalCol = getTotalColumns();
	ULONG nSeqBarWidth = getRowNumBarWidth();
	ObjectAdapterBase* pOjbect = NULL;
	for (LONG nRow = m_nStartRow, nRowNum = 0; nRow <= m_nEndRow; nRow++, nRowNum++)
	{
		pDrawItemInfo->m_nRow = nRow;
		WFX_CONDITION(m_rgRowNumRect.size() > nRowNum);
		pDrawItemInfo->m_prcItem = &m_rgRowNumRect[nRowNum];
		pDrawItemInfo->m_dwState = 0;
		onDrawSeqBar(pDrawItemInfo);
		nLayer = getLayer(nRow);
		nLayerOffset = (nLayer - 1) * 30;
		clrText = getColor(nLayer);
		if (m_bHasSubItem)
		{
			bRowexpanded = isExpanded(nRow);
		}
		pOjbect = m_pArrayAdapter->getAt(nRow);
		WFX_CONDITION(pOjbect != NULL);

		for (LONG nCol = m_nStartCol; nCol <= m_nEndCol; nCol++)
		{
			WFX_CONDITION(nCol < pOjbect->getCount());
			AttributeBase* pAttribute = pOjbect->getAt(nCol);
			WFX_CONDITION(pAttribute != NULL);

			CellID cellID(nRow, nCol);
			dwState = WCS_NORMAL;
			if (m_bHasSubItem && nCol == 0)
			{
				if (bRowexpanded)
				{
					dwState |= WCS_EXPAND;
				}
				else
				{
					dwState |= WCS_CLOSE;
				}
			}
			if (m_cellSelected == cellID)
			{
				dwState |= WCS_SELECTED;
			}
			if (m_cellMouseMove == cellID)
			{
				dwState |= WCS_MOUSEMOVE;
			}
			rcCell = getCellRect(nRow, nCol);
			rcCell.left += nLayerOffset;
			pDrawItemInfo->m_nCol = nCol;
			pDrawItemInfo->m_prcItem = &rcCell;
			pDrawItemInfo->m_dwState = dwState;
			pDrawItemInfo->m_pszText = pAttribute->getText().c_str();
			pDrawItemInfo->m_dwFormat = pAttribute->getFormat();
			onDrawItem(pDrawItemInfo);
		}
	}
	WfxRender::drawFrame(hdc, rc, WBTN_BKGND_MOUSE, getDispatcher());
}
Beispiel #9
0
void KkrBoardView::drawCell(QPainter &p, int col, int row) const
{
    static const char * digits[] = {
        " ",  "1",  "2",  "3",  "4",  "5",  "6",  "7",  "8",  "9",
        "10", "11", "12", "13", "14", "15", "16", "17", "18", "19",
        "20", "21", "22", "23", "24", "25", "26", "27", "28", "29",
        "30", "31", "32", "33", "34", "35", "36", "37", "38", "39",
        "40", "41", "42", "43", "44", "45"
    };
    const QRect cellRect{getCellRect(col, row)};
    switch(m_pBoardData->getCellType(col, row)) {
    case CellType::CellAnswer:
    {
        if(m_curCol == col && m_curRow == row) {
            QBrush brCyan(Qt::cyan);
            p.fillRect(cellRect, brCyan);
        }
        const int ans = m_pBoardData->getAnswer(col, row);
        if(ans != EMPTY_ANSWER) {
            p.setFont(m_fontAns);
            p.drawText(cellRect, Qt::AlignCenter | Qt::AlignHCenter, digits[ans]);
        }
    }
        break;
    case CellType::CellClue:
    {
        const bool onCursor = m_curCol==col && m_curRow==row;
        QBrush brWhite(Qt::white);
        QBrush brBlack(Qt::black);
        QBrush brCyan(Qt::cyan);

        if(onCursor && m_curClue==CursorClue::None)
            p.setBrush(brCyan);
        else
            p.setBrush(brBlack);
        std::array<QPoint, 3> points;

        // upper right triangle
        points[0] = cellRect.topLeft(); points[0] += QPoint(2,1);
        points[1] = cellRect.topRight(); points[1] += QPoint(-1,1);
        points[2] = cellRect.bottomRight(); points[2] += QPoint(-1,-2);
        p.drawPolygon(points.data(), static_cast<int>(points.size()));

        // bottom left triangle
        points[0] = cellRect.topLeft(); points[0] += QPoint(1,2);
        points[1] = cellRect.bottomLeft(); points[1] += QPoint(1,-1);
        points[2] = cellRect.bottomRight(); points[2] += QPoint(-2,-1);
        p.drawPolygon(points.data(), static_cast<int>(points.size()));

        if(m_pBoardData->getClueRight(col, row) != CLOSED_CLUE) {
            const QRect clueRect{getClueRectRight(cellRect)};
            if(onCursor && m_curClue==CursorClue::Right)
                p.fillRect(clueRect, brCyan);
            else
                p.fillRect(clueRect, brWhite);
            p.setFont(m_fontClue);
            p.drawText(clueRect, Qt::AlignCenter | Qt::AlignHCenter,
                        digits[m_pBoardData->getClueRight(col, row)]);
        }

        if(m_pBoardData->getClueDown(col, row) != CLOSED_CLUE) {
            const QRect clueRect{getClueRectDown(cellRect)};
            if(onCursor && m_curClue==CursorClue::Down)
                p.fillRect(clueRect, brCyan);
            else
                p.fillRect(clueRect, brWhite);
            p.setFont(m_fontClue);
            p.drawText(clueRect, Qt::AlignCenter | Qt::AlignHCenter,
                       digits[m_pBoardData->getClueDown(col, row)]);
        }
    }
        break;
    default:
        Q_ASSERT(false);
    }
}
Beispiel #10
0
void TableView::arrangeCells(bool reload)
{
	//如果需要重新刷新,则清除掉缓存的m_showCells
	if (reload)
		m_showCells.clear();

	//获取当前哪些CELL会被显示
	std::vector<uint16_t> _showCells;
	getShowCells(Rect(-m_container->getPositionX(), -m_container->getPositionY(), _contentSize.width, _contentSize.height), &_showCells);
	
	//找出交集集合
	std::vector<uint16_t> _intersecCells;
	{
		for (auto it = _showCells.begin(); it != _showCells.end(); ++it)
		{
			auto _it = std::find(m_showCells.begin(), m_showCells.end(), *it);
			if (_it == m_showCells.end())continue;
			_intersecCells.push_back(*it);
		}
	}

	//找出差异集合
	std::vector<uint16_t> _diffCells;
	{
		for (auto it = _showCells.begin(); it != _showCells.end(); ++it)
		{
			auto _it = std::find(m_showCells.begin(), m_showCells.end(), *it);
			if (_it != m_showCells.end())continue;
			_diffCells.push_back(*it);
		}
	}

	//先让所有的缓存对象通通隐藏
	for (const auto& it : m_cachedCellList)
	{
		it.second->setVisible(false);
	}

	Rect _cellRect;

	if (!_diffCells.empty())
	{
		for (auto it = _diffCells.begin(); it != _diffCells.end(); ++it)
		{
			uint16_t _originIdx = -1;
			GridCell* _cachedCell = getAvailableCachedCell(_intersecCells, *it, &_originIdx);
			if (_cachedCell != nullptr)
			{
				if (_originIdx != *it || reload)
					m_cellForIndexCallfunc(this, _cachedCell, *it);
			}
			else
			{
				_cachedCell = m_cellForIndexCallfunc(this, _cachedCell, *it);
				m_container->addChild(_cachedCell);
			}

			_intersecCells.push_back(*it);
			m_cachedCellList[*it] = _cachedCell;

			getCellRect(*it, &_cellRect);
			_cachedCell->setPosition(_cellRect.getMidX(), _cellRect.getMidY());
			int a = 20;
		}
	}

	//让可显示的对象显示出来
	if (!_showCells.empty())
	{
		for (auto it = _showCells.begin(); it != _showCells.end(); ++it)
		{
			auto _it = m_cachedCellList.find(*it);
			if (_it == m_cachedCellList.end())continue;
			_it->second->setVisible(true);
		}
	}

	m_showCells = _showCells;
}
Beispiel #11
0
Rect TableView::getCellRect(uint32_t idx)
{
	Rect _rect;
	getCellRect(idx, &_rect);
	return _rect;
}