Example #1
0
void RWinColorPalette::OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags )
{
	RIntPoint ptNew( kPtFirstCol );

	if (m_ptSelected.m_x >= 0 && m_ptSelected.m_y >= 0)
	{
		RIntPoint ptTopLeft( (m_ptSelected.m_x < kPtLeftCol.m_x ? kPtFirstCol : kPtLeftCol) ) ;
		RIntPoint ptPoint( m_ptSelected.m_x - ptTopLeft.m_x, m_ptSelected.m_y - ptTopLeft.m_y );

		if (m_ptSelected.m_x >= kPtLeftCol.m_x)
			ptPoint.m_x += kCellDistance;

		int nCurRow = ptPoint.m_y / kCellDistance;
		int nCurCol = ptPoint.m_x / kCellDistance;

		switch (nChar)
		{
		case VK_UP:
			nCurRow -= nRepCnt;
			break;

		case VK_DOWN:
			nCurRow += nRepCnt;
			break;

		case VK_LEFT:
			nCurCol -= nRepCnt;
			break;

		case VK_RIGHT:
			nCurCol += nRepCnt;
			break;
		}

		RBitmapImage& biPalette	= GetPaletteBitmapImage();
		int cxCols = (biPalette.GetWidthInPixels() - 
			kPtLeftCol.m_x) / kCellDistance + 1;  // One is added for first column

		int cxRows = (biPalette.GetHeightInPixels() -
			kPtLeftCol.m_y) / kCellDistance;

		nCurRow %= cxRows;
		nCurCol %= cxCols;

		if (nCurCol < 0) nCurCol += cxCols;
		if (nCurRow < 0) nCurRow += cxRows;

		ptNew.m_x = (nCurCol ? (nCurCol - 1) * kCellDistance + kPtLeftCol.m_x : kPtFirstCol.m_x);
		ptNew.m_y = nCurRow * kCellDistance + kPtLeftCol.m_y;
	}

	CRect rcInvalid( -1, -1, kCellSize.m_dx + 1, kCellSize.m_dy + 1 );
	rcInvalid.OffsetRect( m_ptSelected.m_x, m_ptSelected.m_y );
	InvalidateRect( rcInvalid, FALSE );

	RIntPoint pt( ptNew.m_x + 1, ptNew.m_y + 1 );
	m_crSelected = ColorFromPoint( pt );
	m_ptSelected = ptNew;

	GetParent()->SendMessage( UM_COLOR_CHANGED, GetDlgCtrlID(), (LPARAM) m_crSelected ) ;

	CStatic::OnKeyDown( nChar, nRepCnt, nFlags );
}
Example #2
0
CFX_ByteString IFX_Edit::GetEditAppearanceStream(
    IFX_Edit* pEdit,
    const CPDF_Point& ptOffset,
    const CPVT_WordRange* pRange /* = NULL*/,
    FX_BOOL bContinuous /* = TRUE*/,
    FX_WORD SubWord /* = 0*/) {
  CFX_ByteTextBuf sEditStream, sWords;

  CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
  int32_t nCurFontIndex = -1;

  if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
    if (pRange)
      pIterator->SetAt(pRange->BeginPos);
    else
      pIterator->SetAt(0);

    CPVT_WordPlace oldplace;

    while (pIterator->NextWord()) {
      CPVT_WordPlace place = pIterator->GetAt();

      if (pRange && place.WordCmp(pRange->EndPos) > 0)
        break;

      if (bContinuous) {
        if (place.LineCmp(oldplace) != 0) {
          if (sWords.GetSize() > 0) {
            sEditStream << GetWordRenderString(sWords.GetByteString());
            sWords.Clear();
          }

          CPVT_Word word;
          if (pIterator->GetWord(word)) {
            ptNew = CPDF_Point(word.ptWord.x + ptOffset.x,
                               word.ptWord.y + ptOffset.y);
          } else {
            CPVT_Line line;
            pIterator->GetLine(line);
            ptNew = CPDF_Point(line.ptLine.x + ptOffset.x,
                               line.ptLine.y + ptOffset.y);
          }

          if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
            sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
                        << " Td\n";

            ptOld = ptNew;
          }
        }

        CPVT_Word word;
        if (pIterator->GetWord(word)) {
          if (word.nFontIndex != nCurFontIndex) {
            if (sWords.GetSize() > 0) {
              sEditStream << GetWordRenderString(sWords.GetByteString());
              sWords.Clear();
            }
            sEditStream << GetFontSetString(pEdit->GetFontMap(),
                                            word.nFontIndex, word.fFontSize);
            nCurFontIndex = word.nFontIndex;
          }

          sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
                                     word.Word, SubWord);
        }

        oldplace = place;
      } else {
        CPVT_Word word;
        if (pIterator->GetWord(word)) {
          ptNew = CPDF_Point(word.ptWord.x + ptOffset.x,
                             word.ptWord.y + ptOffset.y);

          if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
            sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
                        << " Td\n";
            ptOld = ptNew;
          }

          if (word.nFontIndex != nCurFontIndex) {
            sEditStream << GetFontSetString(pEdit->GetFontMap(),
                                            word.nFontIndex, word.fFontSize);
            nCurFontIndex = word.nFontIndex;
          }

          sEditStream << GetWordRenderString(GetPDFWordString(
              pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
        }
      }
    }

    if (sWords.GetSize() > 0) {
      sEditStream << GetWordRenderString(sWords.GetByteString());
      sWords.Clear();
    }
  }

  CFX_ByteTextBuf sAppStream;
  if (sEditStream.GetSize() > 0) {
    int32_t nHorzScale = pEdit->GetHorzScale();
    if (nHorzScale != 100) {
      sAppStream << nHorzScale << " Tz\n";
    }

    FX_FLOAT fCharSpace = pEdit->GetCharSpace();
    if (!FX_EDIT_IsFloatZero(fCharSpace)) {
      sAppStream << fCharSpace << " Tc\n";
    }

    sAppStream << sEditStream;
  }

  return sAppStream.GetByteString();
}