当前位置: 首页>>代码示例>>C++>>正文


C++ wxMemoryDC::SetTextForeground方法代码示例

本文整理汇总了C++中wxMemoryDC::SetTextForeground方法的典型用法代码示例。如果您正苦于以下问题:C++ wxMemoryDC::SetTextForeground方法的具体用法?C++ wxMemoryDC::SetTextForeground怎么用?C++ wxMemoryDC::SetTextForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wxMemoryDC的用法示例。


在下文中一共展示了wxMemoryDC::SetTextForeground方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawCurrentValues

void StripChart::DrawCurrentValues(wxMemoryDC &dc){
	
	//see if data was logged for the mouse location
	int dataBufferSize = _dataBuffer.size();
	float zoomFactor = (float)_zoomPercentage / 100.0;
	int dataBufferIndex = dataBufferSize - (int)(((float)(_currentWidth - _mouseX)) / zoomFactor) - 1;
	//adjust for uboundoffset
	dataBufferIndex-=((dataBufferSize - 1) -_currentDataBufferUBound);
	if (dataBufferIndex < 0 || dataBufferIndex >= dataBufferSize) return;
	
	
	dc.SetPen(*wxThePenList->FindOrCreatePen(*wxWHITE, 1, wxSOLID));
	dc.DrawLine(_mouseX, 0, _mouseX, _currentHeight);

	int currentOffset = 0;
	StripChartLogItem logItem = _dataBuffer[dataBufferIndex];
	
	wxDateTime timestamp = logItem.GetTimestamp();
	
	wxDateTime fromTime;
	switch(_timespanMode){
		case TIMESPAN_FROM_LAST_LOG_ENTRY:
		{
			StripChartLogItem lastLogItem = _dataBuffer[dataBufferSize - 1];
			fromTime = lastLogItem.GetTimestamp();
			break;
		}
		case TIMESPAN_FROM_NOW:
			fromTime = wxDateTime::UNow();
			break;
	}
	wxTimeSpan span =  (fromTime - timestamp);
	wxString timeString = wxString::Format("%d seconds back",(int)span.GetSeconds().ToLong());
	
	
	wxFont labelFont = GetFont();
	int labelWidth,labelHeight,descent,externalLeading;
	dc.GetTextExtent(timeString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);
	dc.SetTextForeground(*wxWHITE);
	
	dc.DrawRotatedText(timeString, _mouseX - labelWidth, _mouseY,90);
	
	for (LogItemTypes::iterator it = _logItemTypes.begin(); it != _logItemTypes.end(); ++it){

		wxString key = it->first;		
		LogItemType *logItemType = it->second;
		ChartScale *scale = &_chartScales[logItemType->scaleId];
		
		dc.SetTextForeground(logItemType->lineColor);

		int value = logItem[logItemType->typeKey];
		wxString valueString = logItemType->typeLabel + ": " + wxString::Format("%d",value) + " " +scale->scaleLabel;

		dc.GetTextExtent(valueString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);
		
		currentOffset += labelWidth;
		dc.DrawRotatedText(valueString,_mouseX - labelHeight - 15, _mouseY - currentOffset,0);
	}
}
开发者ID:BMWPower,项目名称:gaugeWorks,代码行数:59,代码来源:StripChart.cpp

示例2: DrawCurrentValues

void LineChart::DrawCurrentValues(wxMemoryDC &dc, size_t dataIndex, int x, int y){
	int currentOffset = 0;
	wxFont labelFont = GetFont();
	int labelWidth,labelHeight,descent,externalLeading;

	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		Series *series = it->second;
		double dataValue = series->GetValueAtOrNear(dataIndex);
		wxString numberFormat = "% 2." + wxString::Format("%df", series->GetPrecision());
		wxString valueString = (DatalogValue::NULL_VALUE == dataValue ? "---" : wxString::Format(numberFormat.ToAscii(), dataValue)) + " " + series->GetLabel();
		dc.SetTextForeground(series->GetColor());
		dc.GetTextExtent(valueString, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);

		dc.DrawRotatedText(valueString, x + CURRENT_VALUES_RIGHT_OFFSET, y + currentOffset,0);
		currentOffset += labelWidth;
	}
}
开发者ID:BMWPower,项目名称:RaceAnalyzer,代码行数:18,代码来源:lineChart.cpp

示例3: drawTable


//.........这里部分代码省略.........
        bdc.GetTextExtent(queryTable->getName()+wxT(" (")+queryTable->getAlias()+wxT(")"),&w,&h);
    else
        bdc.GetTextExtent(queryTable->getName(),&w,&h);
    width= rowLeftMargin + w + rowRightMargin;

    // Get Columns Metrics
    bdc.SetFont(normalFont);

    // Don't use h value from font metrics to get consistency between columns vertical separation (height)
    height+=rowHeight*queryTable->parent->countCols()+rowTopMargin*queryTable->parent->countCols();
    gqbIteratorBase *iterator = queryTable->parent->createColumnsIterator();
    while(iterator->HasNext())
    {
        gqbColumn *tmp= (gqbColumn *)iterator->Next();
        bdc.GetTextExtent(tmp->getName(),&w,&h);
        if((rowLeftMargin + w + rowRightMargin) > width)
            width=rowLeftMargin + w + rowRightMargin;
    }

    //Don't delete iterator because will be use below;

	// Set table Size in ObjectModel (Temporary Values for object representation,
	// and for this reason the view can modified model without using the controller
	// because this values are used by controller when use object's size in internal operations)
    if( (height+2) < minTableHeight) // +2 from BackgroundLayers addition
    {
        queryTable->setHeight(minTableHeight);    
        height=minTableHeight;
    }
    else
        queryTable->setHeight(height+2);

    if( (width+2) < minTableWidth)
    {
        queryTable->setWidth(minTableWidth);
        width=minTableWidth;
    }
    else
        queryTable->setWidth(width+2);

    //Decorate Table
    bdc.SetPen(*wxTRANSPARENT_PEN);

    //draw second Layer
    bdc.SetBrush(BackgroundLayer2);
    bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width+2,height+2)));

    //draw third Layer
    bdc.SetBrush(BackgroundLayer1);
    bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width+1,height+1)));

    //draw real frame layer
    bdc.SetBrush(*wxWHITE_BRUSH);
    if(queryTable->getSelected())
    {
        bdc.SetPen(selectedPen);
    }
    else
    {
        bdc.SetPen(*wxBLACK_PEN);
    }
    bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width,height)));

    //draw title layer
    bdc.SetBrush(BackgroundTitle);
    bdc.DrawRectangle(wxRect(wxPoint(origin->x,origin->y), wxSize(width,rowHeight+rowTopMargin)));
    bdc.SetFont(TableTitleFont);
    if(queryTable->getAlias().length()>0)
        bdc.DrawText(queryTable->getName()+wxT(" (")+queryTable->getAlias()+wxT(")"),origin->x+margin,origin->y+rowTopMargin);
    else
        bdc.DrawText(queryTable->getName(),origin->x+margin,origin->y+rowTopMargin);
    bdc.SetFont(normalFont);

    // GQB-TODO: in a future reuse a little more the iterator creating it inside the Query or Table Object
    // and only delete it when delete the query object.

    // Draw Columns
    height=rowHeight+rowTopMargin;
    iterator->ResetIterator();
    while(iterator->HasNext())
    {
        gqbColumn *tmp= (gqbColumn *)iterator->Next();
        if(queryTable->existsColumn(tmp))
        {
            bdc.SetTextForeground(* wxRED);
            bdc.SetFont(normalFont);
            bdc.DrawBitmap(imgSelBoxSelected,origin->x+3,origin->y+height,true);
        }
        else
        {
            bdc.SetFont(normalFont);
            bdc.DrawBitmap(imgSelBoxEmpty,origin->x+3,origin->y+height,true);
        }
        bdc.DrawText(tmp->getName(),origin->x+rowLeftMargin,origin->y+height);
        bdc.SetTextForeground( *wxBLACK);
        height+=rowHeight+rowTopMargin;
    }
    delete iterator;                              //now if delete because it's not needed anymore

}
开发者ID:xiul,项目名称:Database-Designer-for-pgAdmin,代码行数:101,代码来源:gqbGraphSimple.cpp

示例4: OnTimer

void SjOscWindow::OnTimer(wxTimerEvent&)
{
	SJ_FORCE_IN_HERE_ONLY_ONCE;

	if( m_oscModule )
	{
		// volume stuff
		long                volume, maxVolume = 1;
		bool                volumeBeat;

		// other objects
		long                i;
		bool                titleChanged, forceOscAnim, forceSpectrAnim;
		wxString            newTitle;

		// get data
		g_mainFrame->m_player.GetVisData(m_bufferStart, m_sampleCount*SJ_WW_CH*SJ_WW_BYTERES, 0);

		// get window client size, correct offscreen DC if needed
		wxSize clientSize = m_oscModule->m_oscWindow->GetClientSize();
		if( clientSize.x != m_offscreenBitmap.GetWidth() || clientSize.y != m_offscreenBitmap.GetHeight() )
		{
			m_offscreenBitmap.Create(clientSize.x, clientSize.y);
			m_offscreenDc.SelectObject(m_offscreenBitmap);
		}

		// calculate the points for the lines, collect volume
		m_oscilloscope->Calc(clientSize, m_bufferStart, volume);
		if( m_oscModule->m_showFlags&SJ_OSC_SHOW_SPECTRUM )
		{
			m_spectrum->Calc(clientSize, m_bufferStart);
		}

		// get data that are shared between the threads
		{
			titleChanged = m_oscModule->m_titleChanged;
			m_oscModule->m_titleChanged = FALSE;
			if( titleChanged )
			{
				newTitle = m_oscModule->m_trackName;
				if( newTitle.IsEmpty() )
				{
					newTitle = SJ_PROGRAM_NAME;
				}
				else if( !m_oscModule->m_leadArtistName.IsEmpty() )
				{
					newTitle.Prepend(m_oscModule->m_leadArtistName + wxT(" - "));
				}
			}

			forceOscAnim = m_oscModule->m_forceOscAnim;
			m_oscModule->m_forceOscAnim = FALSE;

			forceSpectrAnim = m_oscModule->m_forceSpectrAnim;
			m_oscModule->m_forceSpectrAnim = FALSE;
		}

		// calculate volume, volume is theoretically max. 255, normally lesser
		if( titleChanged )              { maxVolume = 1;        }
		if( volume > maxVolume )        { maxVolume = volume;   }

		volumeBeat = (volume > maxVolume/2);

		// erase screen
		m_offscreenDc.SetPen(*wxTRANSPARENT_PEN);
		{
			// blue gradient background
			#define BG_STEPS 88
			int rowH = (clientSize.y/BG_STEPS)+1;
			for( i = 0; i < BG_STEPS; i++ )
			{
				m_bgBrush.SetColour(0, 0, i);
				m_offscreenDc.SetBrush(m_bgBrush);
				m_offscreenDc.DrawRectangle(0, i*rowH, clientSize.x, rowH);
			}
		}

		// draw text (very background)
		{
			m_offscreenDc.SetBackgroundMode(wxTRANSPARENT);
			m_offscreenDc.SetTextForeground(m_textColour);
			m_title->Draw(m_offscreenDc, clientSize, titleChanged, newTitle);
		}

		// draw figures (they lay in backgroud)
		if( m_oscModule->m_showFlags&SJ_OSC_SHOW_FIGURES )
		{
			long bgLight = 100;

			// draw hands (optional)
			m_hands->Draw(m_offscreenDc, clientSize, volume, bgLight, titleChanged);

			// draw rotor (optional)
			m_rotor->Draw(m_offscreenDc, clientSize, m_starfield->IsRunning(), titleChanged, volume, bgLight);

			// draw firework (optional)
			m_firework->Draw(m_offscreenDc, clientSize, titleChanged, m_starfield->IsRunning(), volumeBeat, bgLight);
		}

		// draw starfield (optional)
//.........这里部分代码省略.........
开发者ID:antonivich,项目名称:Silverjuke,代码行数:101,代码来源:vis_oscilloscope.cpp

示例5: DrawScale

int LineChart::DrawScale(wxMemoryDC &dc){
	int leftOrientationEdge = 0;
	int rightOrientationEdge = _currentWidth - 1;

	int scaleOrientation = LineChart::ORIENTATION_LEFT;

	wxFont labelFont = GetFont();



	int tickLabelWidth = 0;
	for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){

		int maxLabelWidth = 0;
		Series *series = it->second;
		Range * range = m_rangeArray[series->GetRangeId()];


		double minValue = range->GetMin();
		double maxValue = range->GetMax();
		double rangeSize = maxValue - minValue;
		double stepInterval = (maxValue - minValue) / 10;
		if (stepInterval == 0) stepInterval = 1;

		dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID));

		dc.SetTextForeground(series->GetColor());

		bool labelOn = false;
		int tickLabelHeight,tickDescent,tickExternalLeading;
		dc.DrawLine(leftOrientationEdge, 0, leftOrientationEdge, _currentHeight);

		for (double tick = minValue; tick <=maxValue; tick += stepInterval){

			int y = _currentHeight - (double)_currentHeight * ((tick - minValue) / rangeSize);
			int nextY = _currentHeight - (double)_currentHeight * ((tick + stepInterval - minValue) / rangeSize);

			if (labelOn){
				wxString numberFormat = "%." + wxString::Format("%df", range->GetPrecision());
				wxString tickLabel = wxString::Format(numberFormat, tick);
				dc.GetTextExtent(tickLabel, &tickLabelHeight, &tickLabelWidth, &tickDescent, &tickExternalLeading, &labelFont);
				if (tickLabelHeight > maxLabelWidth) maxLabelWidth = tickLabelHeight;

				if (tickLabelWidth < y - nextY ){
					switch (scaleOrientation){
						case LineChart::ORIENTATION_LEFT:
						{
							dc.DrawRotatedText(tickLabel, leftOrientationEdge, y, 0);
							break;
						}
						case LineChart::ORIENTATION_RIGHT:
						{
							dc.DrawRotatedText(tickLabel, rightOrientationEdge, y, 0);
							break;
						}
					}
				}
			}
			labelOn = !labelOn;
			dc.DrawLine(leftOrientationEdge, y, leftOrientationEdge + tickLabelWidth, y);
		}

		maxLabelWidth+=(tickLabelWidth / 2);
		switch (scaleOrientation){
			case LineChart::ORIENTATION_LEFT:
			{
				leftOrientationEdge += (maxLabelWidth);
				break;
			}
			case LineChart::ORIENTATION_RIGHT:
			{
				rightOrientationEdge -= (maxLabelWidth);
				break;
			}
		}
	}
	return leftOrientationEdge;
}
开发者ID:BMWPower,项目名称:RaceAnalyzer,代码行数:78,代码来源:lineChart.cpp

示例6: Paint

void wxListSelection::Paint(wxMemoryDC &dc)
{
	const StringArray &displayOrder = mParent->GetDisplayOrder();
	wxASSERT(false == displayOrder.empty());
	wxASSERT(displayOrder.size() == mpImpl->mPoints.size());

	wxSize size = GetSize();
	wxColour background = mpImpl->mBackground;

	// Set background color.
	if(mpImpl->mIsHighlight && mpImpl->mIsSelected)
	{
		background = mpImpl->mHighlightAndSelected;
	}
	else if(mpImpl->mIsHighlight)
	{
		background = mpImpl->mHighlight;
	}
	else if(mpImpl->mIsSelected)
	{
		background = mpImpl->mSelected;
	}

	dc.SetPen(wxPen(background));
	dc.SetBrush(wxBrush(background));
	dc.DrawRectangle(0, 0, size.x, size.y);

	// Bitmap (if any)
	if(true == mpImpl->mBitmap.Ok())
	{
		dc.DrawBitmap(mpImpl->mBitmap, sImageBufferX, mpImpl->mImageBufferY, true);
	}

	// Draw text.
	dc.SetFont(mpImpl->mMainFont);
	wxColour shadow = mpImpl->mMainTextShadow;
	wxColour main = IsEnabled() ? mpImpl->mMainText : 
		mpImpl->mMainTextDisabled;
	for(size_t i = 0; i < displayOrder.size(); ++i)
	{
		if(1 == i)
		{
			dc.SetFont(mpImpl->mSubFont);
			shadow = mpImpl->mSubTextShadow;
			main = mpImpl->mSubText;
		}

		const wxString &str = mpImpl->mFields[displayOrder[i]];

		if(false == str.IsEmpty())
		{
			const wxPoint &point = mpImpl->mPoints[i];

			if(shadow != mpImpl->mTransparent)
			{
				dc.SetTextForeground(shadow);
				dc.DrawText(str, point.x + 1, point.y + 1);
			}
			dc.SetTextForeground(main);
			dc.DrawText(str, point.x, point.y);
		}
	}
}
开发者ID:Dangr8,项目名称:Cities3D,代码行数:63,代码来源:ListSelection.cpp

示例7: DrawScale

void StripChart::DrawScale(wxMemoryDC &dc){
		
	int leftOrientationEdge = 0;
	int rightOrientationEdge = _currentWidth - 1;
	
	
	wxFont labelFont = GetFont();

	for (LogItemTypes::iterator it = _logItemTypes.begin(); it != _logItemTypes.end(); ++it){

		wxString key = it->first;		
		LogItemType *logItemType = it->second;
		ChartScale *scale = &_chartScales[logItemType->scaleId];
		
		ChartScale::UNITS_DISPLAY_ORIENTATION orientation = scale->displayOrientation;
		double stepInterval = scale->stepInterval;
		double minValue = scale->minValue;
		double maxValue = scale->maxValue;
		
		dc.SetPen(*wxThePenList->FindOrCreatePen(logItemType->lineColor, 1, wxSOLID));

		wxString chartLabel = logItemType->typeLabel + " ( " + scale->scaleLabel + " )";
		int labelWidth,labelHeight,descent,externalLeading;
		dc.GetTextExtent(chartLabel, &labelHeight, &labelWidth, &descent, &externalLeading, &labelFont);


		dc.SetTextForeground(logItemType->lineColor);
	
		int verticalMiddleOfChart = _currentHeight / 2;
		
		int tickFromX = 0;
		int tickToX = 0; 
		
		bool showLabels;
		showLabels = (_currentHeight > labelHeight * 2  );
		switch (orientation){
			case ChartScale::ORIENTATION_LEFT:
			{
				if (showLabels) dc.DrawRotatedText(chartLabel,leftOrientationEdge, verticalMiddleOfChart + (labelHeight / 2),90);
				leftOrientationEdge += labelWidth;
				tickFromX = leftOrientationEdge;
				leftOrientationEdge += 5;
				tickToX = leftOrientationEdge;
				dc.DrawLine(tickFromX, 0 , tickFromX, _currentHeight);
				break;
			}
			case ChartScale::ORIENTATION_RIGHT:
			{
				if (showLabels) dc.DrawRotatedText(chartLabel, rightOrientationEdge, verticalMiddleOfChart - (labelHeight / 2), 270);
				rightOrientationEdge -= labelWidth;
				tickToX = rightOrientationEdge;
				rightOrientationEdge -= 5;
				tickFromX = rightOrientationEdge;
				dc.DrawLine(tickToX, 0 , tickToX, _currentHeight);
				break;
			}	
		}
		
		
		bool labelOn = false;
		int tickLabelWidth,tickLabelHeight,tickDescent,tickExternalLeading;
		for (double tick = minValue; tick <=maxValue; tick = tick + stepInterval){
			
			double percentageOfMax = (tick - minValue) / (maxValue - minValue);
			int y = _currentHeight - (int)(((double)_currentHeight) * percentageOfMax);
			
			dc.DrawLine(tickFromX, y, tickToX, y);
			
			if (labelOn){
				wxString tickLabel;
				tickLabel.Printf("%d",(int)tick);
				dc.GetTextExtent(chartLabel, &tickLabelHeight, &tickLabelWidth, &tickDescent, &tickExternalLeading, &labelFont);
				if (showLabels){
					switch (orientation){
						case ChartScale::ORIENTATION_LEFT:
						{
							dc.DrawRotatedText(tickLabel, leftOrientationEdge, y + (tickLabelWidth / 2), 90);
							break;				
						}
						case ChartScale::ORIENTATION_RIGHT:
						{
							dc.DrawRotatedText(tickLabel, rightOrientationEdge, y - (tickLabelWidth / 2), 270);
							break;
						}	
					}
				}
			}
			labelOn = !labelOn;
		}
		switch (orientation){
			case ChartScale::ORIENTATION_LEFT:
			{
				leftOrientationEdge += (tickLabelWidth);
				break;	
			}
			case ChartScale::ORIENTATION_RIGHT:
			{
				rightOrientationEdge -= (tickLabelWidth);
				break;
			}
//.........这里部分代码省略.........
开发者ID:BMWPower,项目名称:gaugeWorks,代码行数:101,代码来源:StripChart.cpp


注:本文中的wxMemoryDC::SetTextForeground方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。