void __fastcall TIntMinerField::InvalidateCells(const TCells AChangedCells, const TCells ARedCells)
{
  for(int i=0; i < AChangedCells.Length; i++)
    InvalidateCell(AChangedCells[i].x, AChangedCells[i].y);
  for(int i=0; i < ARedCells.Length; i++)
    InvalidateCell(ARedCells[i].x, ARedCells[i].y);
}
Пример #2
0
NS_IMETHODIMP nsTreeSelection::SetCurrentColumn(nsITreeColumn* aCurrentColumn)
{
  if (!mTree) {
    return NS_ERROR_UNEXPECTED;
  }
  if (mCurrentColumn == aCurrentColumn) {
    return NS_OK;
  }

  if (mCurrentColumn) {
    if (mFirstRange)
      mTree->InvalidateCell(mFirstRange->mMin, mCurrentColumn);
    if (mCurrentIndex != -1)
      mTree->InvalidateCell(mCurrentIndex, mCurrentColumn);
  }
  
  mCurrentColumn = aCurrentColumn;
  
  if (mCurrentColumn) {
    if (mFirstRange)
      mTree->InvalidateCell(mFirstRange->mMin, mCurrentColumn);
    if (mCurrentIndex != -1)
      mTree->InvalidateCell(mCurrentIndex, mCurrentColumn);
  }

  return NS_OK;
}
void __fastcall TIntMinerField::MouseDownHandler(System::TObject* Sender, Controls::TMouseButton Button, Classes::TShiftState Shift, int X, int Y)
{
  int ACol, ARow;

  SetCaptureControl(FGrid->Views[0]->Site);
  MouseToCell(X, Y, ACol, ARow);
  if((ACol == - 1) || (ARow == -1))
    return;

  if((Shift == (TShiftState() << ssLeft << ssRight)) || (Shift == (TShiftState() << ssLeft << ssRight))
    || (Shift == (TShiftState() << ssMiddle)) || (Shift == (TShiftState() << ssLeft << ssMiddle))
    || (Shift == (TShiftState() << ssRight << ssMiddle))) {
    FireImageChanged(imAstonisment);
    FSurprised = true;
    for(int i=-1; i <=1; i++)
      for(int j=-1; j <=1; j++)
          if(CheckFieldBounds(ACol+i, ARow+j) && (
            (CellState[ACol+i][ARow+j].CellState == csClosed)
            || (CellState[ACol+i][ARow+j].CellState == csQuestionMarked))) {
            AddPressedCell(ACol+i, ARow+j);
            InvalidateCell(ACol+i, ARow+j);
          };
    return;
  };

  if(Button == mbLeft) {
    FireImageChanged(imAstonisment);
    FSurprised = true;
    if((CellState[ACol][ARow].CellState == csClosed)
        || (CellState[ACol][ARow].CellState == csQuestionMarked)) {
        AddPressedCell(ACol, ARow);
        InvalidateCell(ACol, ARow);
      };
    return;
  };

  if(Button == mbRight) {
    if(CellState[ACol][ARow].CellState == csOpened) return;
    if(CellState[ACol][ARow].CellState == csClosed) {
      FireMinerFieldEvent(ACol, ARow, meBombMarkCell);
      FireSetMineCountEvent(mcDecMineCount);
    }
    else
    if((CellState[ACol][ARow].CellState == csBombMarked) &&
      FQuestionMarkCell) {
      FireMinerFieldEvent(ACol, ARow, meQuestionMarkCell);
      FireSetMineCountEvent(mcIncMineCount);
    }
    else {
      FireMinerFieldEvent(ACol, ARow, meCloseCell);
      if(!FQuestionMarkCell) FireSetMineCountEvent(mcIncMineCount);
    };
    InvalidateCell(ACol, ARow);
  };
}
Пример #4
0
    void ColorMapGridControl::FinishEdit(const char* szText, int nValue, int nLastChar)
    {
        int rowIndex = m_cellActive.m_nRow - 1;
        int colIndex = m_cellActive.m_nCol - 1;

        double val;
        if ((!IsValidReal(szText, val)) || (val < 0.0) || (val > 1.0))
            val = 0.0;

        SC_ColorSpec& currSpec = gColorMap.colorMapColors[rowIndex];

        switch (colIndex )
            {
            case 0 : {currSpec.RH = val; break;}
            case 1 : {currSpec.GS = val; break;}
            case 2 : {currSpec.BV = val; break;}
            case 3 : {break;}
            }

        if (rowIndex >= gColorMap.ncolorMap)
            {
                for (int i = gColorMap.ncolorMap; i < rowIndex; i++)
                    gColorMap.colorMapColors[i] = SC_ColorSpec(0.0, 0.0, 0.0);
                m_nCurrRow = gColorMap.ncolorMap - 1;
                gColorMap.ncolorMap = rowIndex + 1;
                UpdateModifiedRows();
            }
        else
            {
                for (int j = 1; j < GetColCount(); j++)
                    {
                        CGridCell* pCell = GetCell(rowIndex + 1, j);
                        pCell->UpdateText();
                        InvalidateCell(rowIndex + 1, j);
                    }
            }

        ResetCell(m_cellActive.m_nRow, m_cellActive.m_nCol);

        StopEdit(false);

        // if the right key continue editing on next cell
        switch (nLastChar) {
        case VK_TAB:
        case VK_DOWN:
        case VK_UP:
        case VK_RIGHT:
        case VK_LEFT:
        case VK_NEXT:
        case VK_PRIOR:
        case VK_HOME:
        case VK_END:
            OnKeyDown(nLastChar, 0, 0);
            UpdateWindow();
            if (m_cellActive != m_cellActiveOld)
                StartEdit(nLastChar);
            break;
        }
    }
void __fastcall TIntMinerField::MouseMoveHandler(System::TObject* Sender, Classes::TShiftState Shift, int X, int Y)
{
  int ACol, ARow;
  MouseToCell(X, Y, ACol, ARow);
  if((ACol == - 1) || (ARow == -1)) {
    if(FPressedCells.Length != 0)
      UnpressAndInvalidate();
    if(FSurprised) {
      FireImageChanged(imSmile);
      FSurprised = false;
    };
    return;
  };
  if(Shift == (TShiftState() << ssLeft)) {
    if((CellState[ACol][ARow].CellState == csOpened)) {
      if(FPressedCells.Length != 0) {
        UnpressAndInvalidate();
        InvalidateCell(ACol, ARow);
      };
    } else
    if((CellState[ACol][ARow].CellState == csClosed)
      || (CellState[ACol][ARow].CellState == csQuestionMarked))
      if(!IsExistsInArray(FPressedCells, ACol, ARow)) {
        UnpressAndInvalidate();
        AddPressedCell(ACol, ARow);
        InvalidateCell(ACol, ARow);
      }
    return;
  }

  if((Shift == (TShiftState() << ssLeft << ssRight)) || (Shift == (TShiftState() << ssLeft << ssRight))
    || (Shift == (TShiftState() << ssMiddle)) || (Shift == (TShiftState() << ssLeft << ssMiddle))
    || (Shift == (TShiftState() << ssRight << ssMiddle))) {
    UnpressAndInvalidate();
    for(int i=-1; i<=1; i++)
      for(int j=-1; j<=1; j++)
        if(CheckFieldBounds(ACol+i, ARow+j) &&
          ((CellState[ACol+i][ARow+j].CellState == csClosed) ||
          (CellState[ACol+i][ARow+j].CellState == csQuestionMarked))) {
            AddPressedCell(ACol+i, ARow+j);
            InvalidateCell(ACol+i, ARow+j);
          }
   }
}
void __fastcall TIntMinerField::UnpressAndInvalidate(void)
{
  TCells CellsToInvalidate;
  CellsToInvalidate.Length = FPressedCells.Length;
  for(int i=0; i < FPressedCells.Length; i++)
    CellsToInvalidate[i] = FPressedCells[i];
  FPressedCells.Length = 0;
  for(int i=0; i < CellsToInvalidate.Length; i++)
    InvalidateCell(CellsToInvalidate[i].x, CellsToInvalidate[i].y);
}
Пример #7
0
bool BitmapExportPaletteControl::SetHighlightedCellFromSortedIndex(ReDrawInfoType *pInfo, INT32 paletteIndex)
{
	if (paletteIndex == m_MouseOverCell)
		return false;

	// Invalidate the old cell
	if (m_MouseOverCell != INVALID_COLOUR_VALUE)
		InvalidateCell(pInfo, m_MouseOverCell);

	m_MouseOverCell = paletteIndex;

	// See if the mouse is in a valid cell
	if (m_MouseOverCell == INVALID_COLOUR_VALUE)
		return true;

	// Invalidate the new cell so it will be redrawn
	InvalidateCell(pInfo, m_MouseOverCell);

	return true;
}
Пример #8
0
static BOOL NTAPI
GuiSetScreenInfo(IN OUT PFRONTEND This,
                 PCONSOLE_SCREEN_BUFFER Buff,
                 SHORT OldCursorX,
                 SHORT OldCursorY)
{
    PGUI_CONSOLE_DATA GuiData = This->Context;

    /* Do nothing if the window is hidden */
    if (!GuiData->IsWindowVisible) return TRUE;

    if (GuiData->ActiveBuffer == Buff)
    {
        /* Redraw char at old position (remove cursor) */
        InvalidateCell(GuiData, OldCursorX, OldCursorY);
        /* Redraw char at new position (show cursor) */
        InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
    }

    return TRUE;
}
Пример #9
0
static BOOL NTAPI
GuiSetCursorInfo(IN OUT PFRONTEND This,
                 PCONSOLE_SCREEN_BUFFER Buff)
{
    PGUI_CONSOLE_DATA GuiData = This->Context;

    /* Do nothing if the window is hidden */
    if (!GuiData->IsWindowVisible) return TRUE;

    if (GuiData->ActiveBuffer == Buff)
    {
        InvalidateCell(GuiData, Buff->CursorPosition.X, Buff->CursorPosition.Y);
    }

    return TRUE;
}
Пример #10
0
/********************************************************************************************
>	void BitmapExportPaletteControl::RedrawSelectedCell(ReDrawInfoType *pInfo)
	Author:		Jonathan_Payne (Xara Group Ltd) <*****@*****.**>
	Created:	19/12/2000
	Inputs:		pInfo struct
	Purpose:	Redraws the selected cell, to be used after SetSelectedCell[Toggle]*()
				functions
********************************************************************************************/
void BitmapExportPaletteControl::RedrawSelectedCell(ReDrawInfoType *pInfo)
{
	InvalidateCell(pInfo, m_SelectedCell);
}
Пример #11
0
static VOID NTAPI
GuiWriteStream(IN OUT PFRONTEND This,
               SMALL_RECT* Region,
               SHORT CursorStartX,
               SHORT CursorStartY,
               UINT ScrolledLines,
               PWCHAR Buffer,
               UINT Length)
{
    PGUI_CONSOLE_DATA GuiData = This->Context;
    PCONSOLE_SCREEN_BUFFER Buff;
    SHORT CursorEndX, CursorEndY;
    RECT ScrollRect;

    if (NULL == GuiData || NULL == GuiData->hWindow) return;

    /* Do nothing if the window is hidden */
    if (!GuiData->IsWindowVisible) return;

    Buff = GuiData->ActiveBuffer;
    if (GetType(Buff) != TEXTMODE_BUFFER) return;

    if (0 != ScrolledLines)
    {
        ScrollRect.left = 0;
        ScrollRect.top = 0;
        ScrollRect.right = Buff->ViewSize.X * GuiData->CharWidth;
        ScrollRect.bottom = Region->Top * GuiData->CharHeight;

        ScrollWindowEx(GuiData->hWindow,
                       0,
                       -(int)(ScrolledLines * GuiData->CharHeight),
                       &ScrollRect,
                       NULL,
                       NULL,
                       NULL,
                       SW_INVALIDATE);
    }

    DrawRegion(GuiData, Region);

    if (CursorStartX < Region->Left || Region->Right < CursorStartX
            || CursorStartY < Region->Top || Region->Bottom < CursorStartY)
    {
        InvalidateCell(GuiData, CursorStartX, CursorStartY);
    }

    CursorEndX = Buff->CursorPosition.X;
    CursorEndY = Buff->CursorPosition.Y;
    if ((CursorEndX < Region->Left || Region->Right < CursorEndX
            || CursorEndY < Region->Top || Region->Bottom < CursorEndY)
            && (CursorEndX != CursorStartX || CursorEndY != CursorStartY))
    {
        InvalidateCell(GuiData, CursorEndX, CursorEndY);
    }

    // HACK!!
    // Set up the update timer (very short interval) - this is a "hack" for getting the OS to
    // repaint the window without having it just freeze up and stay on the screen permanently.
    Buff->CursorBlinkOn = TRUE;
    SetTimer(GuiData->hWindow, CONGUI_UPDATE_TIMER, CONGUI_UPDATE_TIME, NULL);
}