Example #1
0
/* Add a moverecord to the game list window.  NOTE: This function must be
   called _before_ applying the moverecord, so it can be displayed
   correctly. */
extern void GTKAddMoveRecord( moverecord *pmr )
{
    gamelistrow *pglr;
    int i, numRows, fPlayer;
    const char *pch = GetMoveString(pmr, &fPlayer, TRUE);
    if (!pch)
		return;

	i = -1;
	numRows = GTK_CLIST( pwGameList )->rows;
	if (numRows > 0)
	{
		pglr = gtk_clist_get_row_data(GTK_CLIST(pwGameList), numRows - 1);
		if (pglr &&
			!(pglr->fCombined || pglr->apmr[ 1 ] || ( fPlayer != 1 && pglr->apmr[ 0 ] )))
			/* Add to second half of current row */
			i = numRows - 1;
	}
	if (i == -1)
		/* Add new row */
		i = AddMoveRecordRow();

    pglr = gtk_clist_get_row_data( GTK_CLIST( pwGameList ), i );

	if (fPlayer == -1)
	{
		pglr->fCombined = TRUE;
		fPlayer = 0;
	}
	else
		pglr->fCombined = FALSE;

    pglr->apmr[fPlayer] = pmr;
    
    gtk_clist_set_text(GTK_CLIST(pwGameList), i, fPlayer + 1, pch);

    SetCellColour(i, fPlayer + 1, pmr);
}
Example #2
0
/* Select a moverecord as the "current" one.  NOTE: This function must be
   called _after_ applying the moverecord. */
extern void GTKSetMoveRecord( moverecord *pmr ) {

    /* highlighted row/col in game record */
    static int yCurrent = -1, xCurrent = -1;

    GtkCList *pcl = GTK_CLIST( pwGameList );
    gamelistrow *pglr;
    int i;
	/* Avoid lots of screen updates */
	if (!frozen)
		SetAnnotation( pmr );

#ifdef UNDEF
{
	GtkWidget* pwWin = GetPanelWidget(WINDOW_HINT);
    if (pwWin)
	{
		hintdata *phd = g_object_get_data(G_OBJECT(pwWin), "user_data");
		phd->fButtonsValid = FALSE;
		CheckHintButtons(phd);
	}
}
#endif
    
	if (yCurrent != -1 && xCurrent != -1)
	{
		moverecord *pmrLast = NULL;
		pglr = gtk_clist_get_row_data(pcl, yCurrent);
		if (pglr)
		{
			pmrLast = pglr->apmr[xCurrent - 1];
			if (pmrLast)
				SetCellColour(yCurrent, xCurrent, pmrLast);
		}
		if (!pmrLast)
		   gtk_clist_set_cell_style(pcl, yCurrent, xCurrent, psGameList);
	}

    yCurrent = xCurrent = -1;

    if( !pmr )
	return;
    
    if( pmr == plGame->plNext->p ) {
	g_assert( pmr->mt == MOVE_GAMEINFO );
	yCurrent = 0;
	
	if( plGame->plNext->plNext->p ) {
	    moverecord *pmrNext = plGame->plNext->plNext->p;

	    if( pmrNext->mt == MOVE_NORMAL && pmrNext->fPlayer == 1 )
		xCurrent = 2;
	    else
		xCurrent = 1;
	} else
	    xCurrent = 1;
    } else {
	for( i = pcl->rows - 1; i >= 0; i-- ) {
	    pglr = gtk_clist_get_row_data( pcl, i );
	    if( pglr->apmr[ 1 ] == pmr ) {
		xCurrent = 2;
		break;
	    } else if( pglr->apmr[ 0 ] == pmr ) {
		xCurrent = 1;
		break;
	    }
	}
	
	yCurrent = i;
	
	if( yCurrent >= 0 && !( pmr->mt == MOVE_SETDICE &&
				yCurrent == pcl->rows - 1 ) ) {
	    do {
		if( ++xCurrent > 2 ) {
		    xCurrent = 1;
		    yCurrent++;
		}

		pglr = gtk_clist_get_row_data( pcl, yCurrent );
	    } while( yCurrent < pcl->rows - 1 && !pglr->apmr[ xCurrent - 1 ] );
	    
	    if( yCurrent >= pcl->rows )
		AddMoveRecordRow();
	}
    }

	/* Highlight current move */
	gtk_clist_set_cell_style(pcl, yCurrent, xCurrent, psCurrent);

	if( gtk_clist_row_is_visible( pcl, yCurrent ) != GTK_VISIBILITY_FULL )
		gtk_clist_moveto( pcl, yCurrent, xCurrent, 0.8f, 0.5f );
}
Example #3
0
/* Use SetRowColour to set the colour of all the cells in a row  */
void __fastcall TColourStringGrid::SetRowColour(int ARow, TColor tc)
{
   for(int x = FixedCols; x < FColCount; x++)
	  SetCellColour(x,ARow,tc);
}
Example #4
0
void __fastcall TColourStringGrid::SetColColour(int ACol, TColor tc)
{
   for(int x = FixedRows; x < FRowCount; x++)
	  SetCellColour(ACol,x,tc);
}