Exemplo n.º 1
0
//功能:初开化工具栏
void CGameFrameDlg::InitToolsBar()
{
	CRect myRect(100, 100, 100+120, 100+20);

	CLabelEx * myToolsList[TOOLS_LABLE_NUM] ={ &m_OpKuang, &m_OpKuang1, &m_OpKuang2, &m_OpKuang3};

	for (int i=0; i < TOOLS_LABLE_NUM; i++)
	{
		myToolsList[i]->labelID = LABLE_ID_TYPE_TOOLS+i;//编号
		myToolsList[i]->my_hWnd = this->m_hWnd ;//

		myToolsList[i]->InitObjListData();//

		int	djUseNum = TOOLS_LABLE_USE_MAX_NUM;//可以用的个数
		for (int j=0; j<djUseNum ;j++)
		{
			myToolsList[i]->objList[j].objInt=j;
		}//End for


		myToolsList[i]->InitDrawKuang();
		myToolsList[i]->isActiveBool =  true;
		myToolsList[i]->SetBGBitmap(IDB_BITMAP_KUANG );//设置背景图
		myToolsList[i]->ShowWindow(false);
		myToolsList[i]->MoveWindow( myRect);//移动位置
	}//End for



}
void InlineColorPicker::paintEvent(QPaintEvent *e){
    QPainter p(this);
    p.setRenderHint(QPainter::Antialiasing, true);
    QPen pen1(QColor(0,0,0));
    p.setPen(pen1);
    p.drawRect(0,0,this->size().width(), this->size().height());

    QRect myRect(1,1, this->size().width()-2, this->size().height()-2);
    QLinearGradient gradient(myRect.topLeft(), myRect.topRight());

    gradient.setColorAt(0, QColor(255,0,0));
    gradient.setColorAt(0.17, QColor(255,255,0));
    gradient.setColorAt(0.34, QColor(0,255,0));
    gradient.setColorAt(0.50, QColor(0,255,255));
    gradient.setColorAt(0.66, QColor(0,0,255));
    gradient.setColorAt(0.82, QColor(255,0,255));
    gradient.setColorAt(1.0, QColor(255,0,0));

    p.fillRect(myRect,gradient);

    p.setRenderHint(QPainter::Antialiasing, true);

    p.setPen(QPen(QColor(0,0,0), 0.5));
    p.drawEllipse(x,y,14,14);

    p.setPen(QPen(QColor(255,255,255)));
    p.drawEllipse(x+1,y+1,12,12);

    p.setPen(QPen(QColor(100,100,100)));
    p.setBrush(QBrush(QColor(255,255,255,100)));
    p.drawEllipse(x+2,y+2,10,10);
}
Exemplo n.º 3
0
/**
 *	constructL method that creates the AppView object
 *	
 */  
void CTApp1Ui::ConstructL()
    {
    BaseConstructL();
	CWsScreenDevice * screen = CCoeEnv::Static()->ScreenDevice();
	TSize screenSize=screen->SizeInPixels();
	
	TInt posX = 0;
	READ_INT(KTApp1PositionX, KWServTApp1ConfigFile, posX);
	CalculateAbsL(posX, screenSize.iWidth);
	
	TInt posY = 0;
	READ_INT(KTApp1PositionY, KWServTApp1ConfigFile, posY);
	CalculateAbsL(posY, screenSize.iHeight);
	
	TInt width = 0;
	READ_INT(KTApp1Width, KWServTApp1ConfigFile, width);
	CalculateAbsL(width, screenSize.iWidth);
	
	TInt height = 0;
	READ_INT(KTApp1Height, KWServTApp1ConfigFile, height);
	CalculateAbsL(height, screenSize.iHeight);
	
    TRect myRect(TPoint(posX,posY), TPoint(width+posX,height+posY));
	iAppView = CTApp1View::NewL(myRect);
	}
Exemplo n.º 4
0
void PSUnit::Draw()
{
    CRect myRect(m_ptPosition, CSize(m_nWidth, m_nHeight));
    CClientDC dc(m_pView);
    m_pView->OnPrepareDC(&dc);
    dc.LPtoDP(&myRect);
    m_pView->InvalidateRect(myRect, FALSE);
}
void Rect::display(){

//ofSetColor(color);
ofRectangle myRect(x, y, radius, radius);



}
Exemplo n.º 6
0
void PSUnit::Destroy()
{
    CRect myRect(m_ptPosition, CSize(m_nWidth, m_nHeight));
    CClientDC dc(m_pView);
    m_pView->OnPrepareDC(&dc);
    dc.LPtoDP(&myRect);
    TG.GetData()->DeleteUnit(this);
    delete this;

    // I hope I can do this after deleting this object, considerring that m_pView is a static member.
    m_pView->InvalidateRect(myRect, FALSE);
}
Exemplo n.º 7
0
/*!
 * \brief DrawingArea::drawFigure Нарисовать фигуру.
 * \param topLeft Координата верхнего левого угла.
 * \param bottomRight Координата нижнего правого угла.
 *
 * Рисует одну из двух фигур на выбор - Прямоугольник или Эллипс. Выбор зависит от значения переменной myTool.
 * Координаты верхнего левого и нижнего правого угла задают размеры прямоугольника. Для эллипса задается размер
 * прямоугольника, внутрь которого будет вписан эллипс.
 */
void DrawingArea::drawFigure(QPoint topLeft, QPoint bottomRight)
{
    QPainter painter(&image);
    painter.setPen(QPen(myPenColor, myPenWidth, Qt::SolidLine, Qt::RoundCap,
                        Qt::RoundJoin));

    QRect myRect(topLeft, bottomRight);

    if(myTool == 2)
        painter.drawRect(myRect);
    if(myTool == 3)
        painter.drawEllipse(myRect);

    update();
}
Exemplo n.º 8
0
void PSUnit::Move(int nJump, BOOL bAnimate)
{
    // If bAnimate is TRUE, move nJump pixels towards m_pDesiredCoast,
    // if not, move it in m_pDesiredCoast.

    // Keep the current position for erasing purposes.
    CPoint ptOldPos = m_ptPosition;
    if (bAnimate)
    {
        // Calculate the distance between the current position and Target.
        int nY = (m_pDesiredCoast->m_ptDrawUnit).y - m_ptPosition.y;
        int nX = (m_pDesiredCoast->m_ptDrawUnit).x - m_ptPosition.x;
        double dDist = sqrt((nX * nX) + (nY * nY));

        // If nDist is less than nJump pixels, end the move.
        if (dDist < nJump)
        {
            m_bMoving = FALSE;
            m_pLocation = m_pDesiredLocation;
            m_pCoast = m_pDesiredCoast;
            m_ptPosition = m_pCoast->m_ptDrawUnit;
        }
        else
        {
            // Calculate the new coordinates.
            int nNewX = m_ptPosition.x + ((m_pDesiredCoast->m_ptDrawUnit).x - m_ptPosition.x) / dDist * nJump;
            int nNewY = m_ptPosition.y + ((m_pDesiredCoast->m_ptDrawUnit).y - m_ptPosition.y) / dDist * nJump;
            m_ptPosition.x = nNewX;
            m_ptPosition.y = nNewY;
        }
    }
    else
    {
        m_bMoving = FALSE;
        m_pLocation = m_pDesiredLocation;
        m_pCoast = m_pDesiredCoast;
        m_ptPosition = m_pCoast->m_ptDrawUnit;
    }
    // Erase the unit from the old position and draw it in the new one.
    CRect myRect(ptOldPos, CSize(m_nWidth, m_nHeight));
    CClientDC dc(m_pView);
    m_pView->OnPrepareDC(&dc);
    dc.LPtoDP(&myRect);
    m_pView->InvalidateRect(myRect, FALSE);
    Draw();
}
Exemplo n.º 9
0
void SeqPlot::showMW ( wxDC &dc , int b , int tx , int ty , int lx )
    {
    int ch = can->charheight / 2 ;
    int cw = can->charwidth ;
    int bottom = ty + lines * can->charheight ;
    int u ;
    for ( u = 1 ; u < d1.GetCount() ; u++ )
        {
        int tz = ty + (u-1) * ch + 1 ;
        int tw = ( tx + cw ) - lx ;
        
        if ( getMark ( b+1 ) > 0 )
           {
           dc.SetPen ( *wxGREY_PEN ) ;
           myRect ( dc , lx , tz , tw , ch*can->charheight - 2 ) ;
           }
        }

    showPlot ( dc , b , tx , ty , lx , bottom - ty - ch ) ;
    }
Exemplo n.º 10
0
void PoItemDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    if (index.column() != ProjectModel::Graph)
        return QStyledItemDelegate::paint(painter,option,index);

    QVariant graphData = index.data(Qt::DisplayRole);
    if (KDE_ISUNLIKELY( !graphData.isValid()))
    {
        painter->fillRect(option.rect,Qt::transparent);
        return;
    }

    QRect rect = graphData.toRect();
    int translated = rect.left();
    int untranslated = rect.top();
    int fuzzy = rect.width();
    int total = translated + untranslated + fuzzy;

    if (total > 0)
    {
        painter->setPen(Qt::white);
        QRect myRect(option.rect);
        myRect.setWidth(option.rect.width() * translated / total);
        painter->fillRect(myRect, m_colorScheme.foreground(KColorScheme::PositiveText));
        //painter->drawText(myRect,Qt::AlignRight,QString("%1").arg(data.left()));

        myRect.setLeft(myRect.left() + myRect.width());
        myRect.setWidth(option.rect.width() * fuzzy / total);
        painter->fillRect(myRect, m_colorScheme.foreground(KColorScheme::NeutralText));
        // painter->drawText(myRect,Qt::AlignRight,QString("%1").arg(data.width()));

        myRect.setLeft(myRect.left() + myRect.width());
        myRect.setWidth(option.rect.width() - myRect.left() + option.rect.left());
        painter->fillRect(myRect, m_colorScheme.foreground(KColorScheme::NegativeText));
        // painter->drawText(myRect,Qt::AlignRight,QString("%1").arg(data.top()));
    }
    else if (total == -1)
        painter->fillRect(option.rect,Qt::transparent);
    else if (total == 0)
        painter->fillRect(option.rect,QBrush(Qt::gray));
}
Exemplo n.º 11
0
/**
 * Chooses which image loading method to use and centers the map canvas on the current feature
 */
void eVisGenericEventBrowserGui::displayImage()
{
  //This if statement is a bit of a hack, have to track down where the 0 is comming from on initalization
  if ( "0" != mEventImagePath && 0 == displayArea->currentIndex() )
  {
    if ( mEventImagePath.startsWith( "http://", Qt::CaseInsensitive ) )
    {
      imageDisplayArea->displayUrlImage( mEventImagePath );
    }
    else
    {
      imageDisplayArea->displayImage( mEventImagePath );
    }

    //clear any selection that may be present
    mVectorLayer->removeSelection();
    if ( !mFeatureIds.isEmpty() )
    {
      //select the current feature in the layer
      mVectorLayer->select( mFeatureIds.at( mCurrentFeatureIndex ) );
      //get a copy of the feature
      QgsFeature* myFeature = featureAtId( mFeatureIds.at( mCurrentFeatureIndex ) );

      if ( !myFeature )
        return;

      QgsPoint myPoint = myFeature->geometry().asPoint();
      myPoint = mCanvas->mapSettings().layerToMapCoordinates( mVectorLayer, myPoint );
      //keep the extent the same just center the map canvas in the display so our feature is in the middle
      QgsRectangle myRect( myPoint.x() - ( mCanvas->extent().width() / 2 ), myPoint.y() - ( mCanvas->extent().height() / 2 ), myPoint.x() + ( mCanvas->extent().width() / 2 ), myPoint.y() + ( mCanvas->extent().height() / 2 ) );

      // only change the extents if the point is beyond the current extents to minimise repaints
      if ( !mCanvas->extent().contains( myPoint ) )
      {
        mCanvas->setExtent( myRect );
      }
      mCanvas->refresh();
    }
  }
}
Exemplo n.º 12
0
void PhotoCropper::paintEvent(QPaintEvent *e)
{
    QPainter painter(this);
    QRect myRect(0,0,this->width(), this->height());
    painter.drawImage(myRect, img); // first just draw the original image
    if (mode>0) {
        // unless mode 0 (no selection), probably want to:
        // 1. Dim the entire image
        painter.fillRect(myRect, dimColor);
        // 2. Draw selected area normal color
        painter.drawImage(currentCrop, img, cropInOrig());
        // 3. Draw handle type things around the edges0
        // (for now, a little white square at each corner)
        QPoint corners[] = {QPoint(currentCrop.left(), currentCrop.top()),
                            QPoint(currentCrop.right(), currentCrop.top()),
                            QPoint(currentCrop.left(), currentCrop.bottom()),
                            QPoint(currentCrop.right(), currentCrop.bottom())};
        QPoint adj(5, 5); // corner handles start 5 pixels up and left of corner point
        QPoint cornerSize(10, 10); // 10x10 pixels total
        for(int i=0; i<4; i++)
            painter.fillRect(QRect(corners[i]-adj, cornerSize), Qt::white);
    }
}
Exemplo n.º 13
0
void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation &info )
{
  QVector<QPointF> data;

  // set validity flag and status from GPS data
  // based on GGA, GSA and RMC sentences - the logic does not require all
  bool validFlag = false; // true if GPS indicates position fix
  FixStatus fixStatus = NoData;

  // no fix if any of the three report bad; default values are invalid values and won't be changed if the corresponding NMEA msg is not received
  if ( info.status == 'V' || info.fixType == NMEA_FIX_BAD || info.quality == 0 ) // some sources say that 'V' indicates position fix, but is below acceptable quality
  {
    fixStatus = NoFix;
  }
  else if ( info.fixType == NMEA_FIX_2D ) // 2D indication (from GGA)
  {
    fixStatus = Fix2D;
    validFlag = true;
  }
  else if ( info.status == 'A' || info.fixType == NMEA_FIX_3D || info.quality > 0 ) // good
  {
    fixStatus = Fix3D;
    validFlag = true;
  }
  else  // unknown status (not likely)
  {
  }

  // set visual status indicator -- do only on change of state
  if ( fixStatus != mLastFixStatus )
  {
    setStatusIndicator( fixStatus );
  }

  if ( mStackedWidget->currentIndex() == 1 && info.satInfoComplete ) //signal
  {
    mpPlot->setAxisScale( QwtPlot::xBottom, 0, info.satellitesInView.size() );
  } //signal
#ifdef WITH_QWTPOLAR
  if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
  {
    while ( !mMarkerList.isEmpty() )
    {
      delete mMarkerList.takeFirst();
    }
  } //satellites
#endif
  if ( mStackedWidget->currentIndex() == 4 ) //debug
  {
    mGPSPlainTextEdit->clear();
  } //debug

  for ( int i = 0; i < info.satellitesInView.size(); ++i ) //satellite processing loop
  {
    QgsSatelliteInfo currentInfo = info.satellitesInView.at( i );

    if ( mStackedWidget->currentIndex() == 1 && info.satInfoComplete ) //signal
    {
      data << QPointF( i, 0 );
      data << QPointF( i, currentInfo.signal );
      data << QPointF( i + 1, currentInfo.signal );
      data << QPointF( i + 1, 0 );
    } //signal

    if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
    {
      QColor bg( Qt::white ); // moved several items outside of the following if block to minimize loop time
      bg.setAlpha( 200 );
      QColor myColor;

      // Add a marker to the polar plot
      if ( currentInfo.id > 0 )       // don't show satellite if id=0 (no satellite indication)
      {
#ifdef WITH_QWTPOLAR
        QwtPolarMarker *mypMarker = new QwtPolarMarker();
#if (QWT_POLAR_VERSION<0x010000)
        mypMarker->setPosition( QwtPolarPoint( currentInfo.azimuth, currentInfo.elevation ) );
#else
        mypMarker->setPosition( QwtPointPolar( currentInfo.azimuth, currentInfo.elevation ) );
#endif
#endif
        if ( currentInfo.signal < 30 ) //weak signal
        {
          myColor = Qt::red;
        }
        else
        {
          myColor = Qt::black; //strong signal
        }
#ifdef WITH_QWTPOLAR
        QBrush symbolBrush( Qt::black );
        QSize markerSize( 9, 9 );
        QBrush textBgBrush( bg );
#if (QWT_POLAR_VERSION<0x010000)
        mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,
                                         symbolBrush, QPen( myColor ), markerSize ) );
#else
        mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
                                             symbolBrush, QPen( myColor ), markerSize ) );
#endif

        mypMarker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
        QwtText text( QString::number( currentInfo.id ) );
        text.setColor( myColor );
        text.setBackgroundBrush( textBgBrush );
        mypMarker->setLabel( text );
        mypMarker->attach( mpSatellitesWidget );
        mMarkerList << mypMarker;
#endif
      } // currentInfo.id > 0
    } //satellites
  } //satellite processing loop

  if ( mStackedWidget->currentIndex() == 1 && info.satInfoComplete ) //signal
  {
    mpCurve->setSamples( data );
    mpPlot->replot();
  } //signal
#ifdef WITH_QWTPOLAR
  if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
  {
    mpSatellitesWidget->replot();
  } //satellites
#endif
  if ( validFlag )
  {
    validFlag = info.longitude >= -180.0 && info.longitude <= 180.0 && info.latitude >= -90.0 && info.latitude <= 90.0;
  }

  QgsPointXY myNewCenter;
  if ( validFlag )
  {
    myNewCenter = QgsPointXY( info.longitude, info.latitude );
  }
  else
  {
    myNewCenter = mLastGpsPosition;
  }

  if ( mStackedWidget->currentIndex() == 0 ) //position
  {
    mTxtLatitude->setText( QString::number( info.latitude, 'f', 8 ) );
    mTxtLongitude->setText( QString::number( info.longitude, 'f', 8 ) );
    mTxtAltitude->setText( tr( "%1 m" ).arg( info.elevation, 0, 'f', 1 ) ); // don't know of any GPS receivers that output better than 0.1 m precision
    if ( mDateTimeFormat.isEmpty() )
    {
      mTxtDateTime->setText( info.utcDateTime.toString( Qt::TextDate ) );  // default format
    }
    else
    {
      mTxtDateTime->setText( info.utcDateTime.toString( mDateTimeFormat ) );  //user specified format string for testing the millisecond part of time
    }
    mTxtSpeed->setText( tr( "%1 km/h" ).arg( info.speed, 0, 'f', 1 ) );
    mTxtDirection->setText( QString::number( info.direction, 'f', 1 ) + QStringLiteral( "°" ) );
    mTxtHdop->setText( QString::number( info.hdop, 'f', 1 ) );
    mTxtVdop->setText( QString::number( info.vdop, 'f', 1 ) );
    mTxtPdop->setText( QString::number( info.pdop, 'f', 1 ) );
    mTxtHacc->setText( QString::number( info.hacc, 'f', 1 ) + "m" );
    mTxtVacc->setText( QString::number( info.vacc, 'f', 1 ) + "m" );
    mTxtFixMode->setText( info.fixMode == 'A' ? tr( "Automatic" ) : info.fixMode == 'M' ? tr( "Manual" ) : QLatin1String( "" ) ); // A=automatic 2d/3d, M=manual; allowing for anything else
    mTxtFixType->setText( info.fixType == 3 ? tr( "3D" ) : info.fixType == 2 ? tr( "2D" ) : info.fixType == 1 ? tr( "No fix" ) : QString::number( info.fixType ) ); // 1=no fix, 2=2D, 3=3D; allowing for anything else
    mTxtQuality->setText( info.quality == 2 ? tr( "Differential" ) : info.quality == 1 ? tr( "Non-differential" ) : info.quality == 0 ? tr( "No position" ) : info.quality > 2 ? QString::number( info.quality ) : QLatin1String( "" ) ); // allowing for anything else
    mTxtSatellitesUsed->setText( QString::number( info.satellitesUsed ) );
    mTxtStatus->setText( info.status == 'A' ? tr( "Valid" ) : info.status == 'V' ? tr( "Invalid" ) : QLatin1String( "" ) );
  } //position

  // Avoid refreshing / panning if we haven't moved
  if ( mLastGpsPosition != myNewCenter )
  {
    mLastGpsPosition = myNewCenter;

    // Pan based on user specified behavior
    if ( radRecenterMap->isChecked() || radRecenterWhenNeeded->isChecked() )
    {
      QgsCoordinateReferenceSystem mypSRS = mpCanvas->mapSettings().destinationCrs();
      QgsCoordinateTransform myTransform( mWgs84CRS, mypSRS ); // use existing WGS84 CRS

      QgsPointXY myPoint = myTransform.transform( myNewCenter );
      //keep the extent the same just center the map canvas in the display so our feature is in the middle
      QgsRectangle myRect( myPoint, myPoint );  // empty rect can be used to set new extent that is centered on the point used to construct the rect

      // testing if position is outside some proportion of the map extent
      // this is a user setting - useful range: 5% to 100% (0.05 to 1.0)
      QgsRectangle myExtentLimit( mpCanvas->extent() );
      myExtentLimit.scale( mSpinMapExtentMultiplier->value() * 0.01 );

      // only change the extents if the point is beyond the current extents to minimize repaints
      if ( radRecenterMap->isChecked() ||
           ( radRecenterWhenNeeded->isChecked() && !myExtentLimit.contains( myPoint ) ) )
      {
        mpCanvas->setExtent( myRect );
        mpCanvas->refresh();
      }
    } //otherwise never recenter automatically

    if ( mCbxAutoAddVertices->isChecked() )
    {
      addVertex();
    }
  } // mLastGpsPosition != myNewCenter

  // new marker position after recentering
  if ( mGroupShowMarker->isChecked() ) // show marker
  {
    if ( validFlag ) // update cursor position if valid position
    {
      // initially, cursor isn't drawn until first valid fix; remains visible until GPS disconnect
      if ( ! mpMapMarker )
      {
        mpMapMarker = new QgsGpsMarker( mpCanvas );
      }
      mpMapMarker->setSize( mSliderMarkerSize->value() );
      mpMapMarker->setCenter( myNewCenter );
    }
  }
  else
  {
    if ( mpMapMarker )
    {
      delete mpMapMarker;
      mpMapMarker = nullptr;
    }
  } // show marker
}
Exemplo n.º 14
0
void CAnsiWnd::DrawWithANSI(CDC* pDC, CRect& rect, CString* str, int nStrPos)
{
    // Set def colors
    m_nCurrentBg = 0;
    m_nCurrentFg = 7;
    m_bAnsiBold = FALSE;
    CRect OutRect;
    int indexF, indexB;

    char* src = (LPSTR)(LPCSTR)*str;

    int LeftSide =0;
    // Lets do different drawing code for selected/unselected mode. Doing to to
    // keep high speed of drawing while unselected mode


    if ( m_bSelected && nStrPos <= m_nEndSelectY && nStrPos >= m_nStartSelectY) {
        BOOL  bOldInvert = nStrPos > m_nStartSelectY;
        BOOL bNewInvert = bOldInvert;
        int CharCount = 0;
        do  {
            // Get text to draw
            char Text[BUFFER_SIZE];
            char* dest = Text;
            int TextLen = 0;
            while (*src && *src != 0x1B ) {
                // check for current bold
                if ( nStrPos == m_nStartSelectY && CharCount == m_nStartSelectX) {
                    bNewInvert = TRUE;
                }
                if ( nStrPos == m_nEndSelectY && CharCount == m_nEndSelectX) {
                    bNewInvert = FALSE;
                }
                 if ( bNewInvert != bOldInvert) 
                     break;

                *dest++ = *src++;
                TextLen++;
                CharCount ++;
            }
            *dest = 0;

            // Draw text

            // Skip \n from the end
            while ( TextLen && (Text[TextLen-1] == '\n' /*|| Text[TextLen-1] == '\r' */) )
                TextLen--;

            indexF = m_nCurrentFg + (m_bAnsiBold && !pDoc->m_bDarkOnly ? 8 : 0 );
            indexB = m_nCurrentBg; //+ (m_bAnsiBold ? 8 : 0 );

            if ( bOldInvert ) {
                pDC->SetTextColor(0xFFFFFF-pDoc->m_ForeColors[indexF]);
                pDC->SetBkColor(0xFFFFFF-pDoc->m_BackColors[indexB]);
            } else {
                pDC->SetTextColor(pDoc->m_ForeColors[indexF]);
                pDC->SetBkColor(pDoc->m_BackColors[indexB]);
            }

            CRect myRect(0,0,0,0) ;
            int XShift;
            if ( TextLen) {
                pDC->DrawText(Text, TextLen, &myRect, DT_LEFT | DT_SINGLELINE | DT_NOCLIP | DT_CALCRECT | DT_NOPREFIX );
                XShift = myRect.Width();

            } else {
                XShift = 0;
            }
            OutRect = rect;
            OutRect.left += LeftSide;
            
            // if ( *src ) 
            //    OutRect.right = OutRect.left + XShift;
            OutRect.right = OutRect.left + XShift;


            LeftSide += XShift;
            // if ( XShift || !*src ) 
            if ( XShift ) 
                pDC->ExtTextOut(OutRect.left, OutRect.top, ETO_OPAQUE, &OutRect, Text, TextLen, NULL);

            // !!!! Look for it ! Every time you draw to the end of string !!!! May be change rectangle ???

            if ( bOldInvert != bNewInvert ) {
                bOldInvert = bNewInvert;
                continue;
            }

            // Now check for ANSI colors
            if ( !*src++ ) // if end of string - get out
                break;

            // check for [ command and digit after it. IF not - skip to end of ESC command
            if ( *src++ != '[' /*|| !isdigit(*src)*/ ) {
                while ( *src && *src != 'm' ) src++;
                if ( *src == 'm' )
                    src++;
                continue;
            }
            // now Get colors command and use it
            do {        
                // may be need skip to ; . But .... Speed
                Text[0] = 0;
                dest = Text;
                while ( isdigit(*src) ) 
                    *dest++ = *src++;
                *dest = 0;
                if ( Text[0] ) 
                    SetCurrentANSI(Text);
            } while ( *src && *src++ != 'm' );
        }while ( *src );
        // draw to end of the window
        OutRect = rect;
        OutRect.left += LeftSide;
        indexF = m_nCurrentFg + (m_bAnsiBold && !pDoc->m_bDarkOnly ? 8 : 0 );
        indexB = m_nCurrentBg; //+ (m_bAnsiBold ? 8 : 0 );
        if ( bOldInvert ) {
            pDC->SetTextColor(0xFFFFFF-pDoc->m_ForeColors[indexF]);
            pDC->SetBkColor(0xFFFFFF-pDoc->m_BackColors[indexB]);
        } else {
            pDC->SetTextColor(pDoc->m_ForeColors[indexF]);
            pDC->SetBkColor(pDoc->m_BackColors[indexB]);
        }
        pDC->ExtTextOut(OutRect.left, OutRect.top, ETO_OPAQUE, &OutRect, "", 0, NULL);
    } else {
        do  {
            // Get text to draw
            char Text[BUFFER_SIZE];
            char* dest = Text;
            int TextLen = 0;
            while (*src && *src != 0x1B ) {
                *dest++ = *src++;
                TextLen++;
            }
            *dest = 0;
            // Draw text

            // Skip \n  from the end
            while ( TextLen && (Text[TextLen-1] == '\n' /*|| Text[TextLen-1] == '\r' */) )
                TextLen--;

            indexF = m_nCurrentFg + (m_bAnsiBold && !pDoc->m_bDarkOnly ? 8 : 0 );
            indexB = m_nCurrentBg; //+ (m_bAnsiBold ? 8 : 0 );
        
            pDC->SetTextColor(pDoc->m_ForeColors[indexF]);
            pDC->SetBkColor(pDoc->m_BackColors[indexB]);

            CRect myRect(0,0,0,0);
            int XShift;
            if ( TextLen) {
                pDC->DrawText(Text, TextLen, &myRect, DT_LEFT | DT_SINGLELINE | DT_NOCLIP | DT_CALCRECT | DT_NOPREFIX);
                XShift = myRect.Width();

            } else {
                XShift = 0;
            }
            OutRect = rect;
            OutRect.left += LeftSide;

            OutRect.right = OutRect.left + XShift;

            LeftSide += XShift;
            if ( XShift ) 
                pDC->ExtTextOut(OutRect.left, OutRect.top, ETO_OPAQUE, &OutRect, Text, TextLen, NULL);

/*            pDC->ExtTextOut(myRect.left, myRect.top, ETO_OPAQUE, &myRect, Text, TextLen, NULL);
        
            if ( TextLen) {
                pDC->DrawText(Text, TextLen, &myRect, DT_LEFT | DT_SINGLELINE | DT_NOCLIP | DT_CALCRECT);
                LeftSide += myRect.Width();
            }
*/
            // Now check for ANSI colors
            if ( !*src++ ) // if end of string - get out
                break;

            // check for [ command and digit after it. IF not - skip to end of ESC command
            if ( *src++ != '[' /*|| !isdigit(*src)*/ ) {
                while ( *src && *src != 'm' ) src++;
                if ( *src == 'm' )
                    src++;
                continue;
            }
            // now Get colors command and use it
            do {        
                // may be need skip to ; . But .... Speed
                Text[0] = 0;
                dest = Text;
                while ( isdigit(*src) ) 
                    *dest++ = *src++;
                *dest = 0;
                if ( Text[0] ) 
                    SetCurrentANSI(Text);
            } while ( *src && *src++ != 'm' );
        }while ( *src );
        OutRect = rect;
        OutRect.left += LeftSide;
        indexF = m_nCurrentFg + (m_bAnsiBold && !pDoc->m_bDarkOnly ? 8 : 0 );
        indexB = m_nCurrentBg; //+ (m_bAnsiBold ? 8 : 0 );
        pDC->SetTextColor(pDoc->m_ForeColors[indexF]);
        pDC->SetBkColor(pDoc->m_BackColors[indexB]);
        pDC->ExtTextOut(OutRect.left, OutRect.top, ETO_OPAQUE, &OutRect, "", 0, NULL);
    }
}
Exemplo n.º 15
0
void SeqPlot::showChouFasman ( wxDC &dc , int b , int tx , int ty , int lx )
    {
//	 mylog ( "SeqPlot::showChouFasman" , "1" ) ;
    int bottom = ty + lines * can->charheight ;
    int ch = can->charheight / 2 ;
    int cw = can->charwidth ;
    int u ;
//	 mylog ( "SeqPlot::showChouFasman" , "2" ) ;
    for ( u = 1 ; u < d1.GetCount() ; u++ )
        {
        wxPen *pen = wxRED_PEN ;
        if ( u == 2 ) pen = wxGREEN_PEN ;
        if ( u == 3 ) pen = MYPEN(_T("BLUE")) ;
        int tz = ty + (u-1) * ch + 1 ;
        int tw = ( tx + cw ) - lx ;
        
        if ( getMark ( b+1 ) > 0 )
           {
           dc.SetPen ( *wxGREY_PEN ) ;
           myRect ( dc , lx , tz , tw , ch*can->charheight - 2 ) ;
           }

        if ( d1[u][(uint)b] == 'X' )
           {
           dc.SetPen(*pen);
           myRect ( dc , lx , tz , tw , ch - 2 ) ;
           dc.SetPen(*wxBLACK_PEN);
           dc.DrawLine ( lx , tz , lx + tw , tz ) ;
           dc.DrawLine ( lx , tz + ch - 2 , lx + tw , tz + ch - 2 ) ;
           if ( b == 0 || d1[u][(uint)b-1] == ' ' )
              dc.DrawLine ( lx , tz , lx , tz + ch - 2 ) ;
           if ( b + 1 == s.length() || d1[u][(uint)b+1] == ' ' )
              dc.DrawLine ( lx + tw , tz , lx + tw , tz + ch - 2 ) ;
           }
        else
           {
           dc.SetPen(*wxBLACK_PEN);
           dc.DrawLine ( lx , ty + (u-1)*ch + ch/2 , 
                         tx + cw , ty + (u-1)*ch + ch/2 ) ;
           }
        if ( startOfLine )
           {
		   if ( type == CHOU_FASMAN )
		   	  {
//	 mylog ( "SeqPlot::showChouFasman" , "2a" ) ;
			  if ( u == 1 ) drawSymbol ( 'a' , dc , lx-cw , ty+(u-1)*ch , lx-2 , ty+(u-1)*ch+ch ) ; // Alpha
			  else if ( u == 2 ) drawSymbol ( 'b' , dc , lx-cw , ty+(u-1)*ch , lx-2 , ty+(u-1)*ch+ch ) ; // Beta
			  else drawSymbol ( 'T' , dc , lx-cw , ty+(u-1)*ch , lx-2 , ty+(u-1)*ch+ch ) ; // Turn
			  }
		   else if ( type == COILED_COIL )
		   	  {
//	 mylog ( "SeqPlot::showChouFasman" , "2b" ) ;
	   	   	  if ( u == 1 ) dc.DrawText ( _T("14") , lx-cw*2 , ty+(u-1)*ch-ch/2 ) ;
	   	   	  else if ( u == 2 ) dc.DrawText ( _T("21") , lx-cw*2 , ty+(u-1)*ch-ch/2 ) ;
	   	   	  else if ( u == 3 ) dc.DrawText ( _T("28") , lx-cw*2 , ty+(u-1)*ch-ch/2 ) ;
			  }
           }
        }
    
//	 mylog ( "SeqPlot::showChouFasman" , "3" ) ;
    showPlot ( dc , b , tx , ty , lx , bottom - d1.GetCount() * ch - ty ) ;
//	 mylog ( "SeqPlot::showChouFasman" , "4" ) ;
    }