void kwxAngularMeter::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC old_dc(this); int w,h ; GetClientSize(&w,&h); ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*membitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(m_cBackColour,wxSOLID)); dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cBackColour,wxSOLID)); dc.Clear(); if (m_pPreviewBmp && m_pPreviewBmp->Ok()) dc.DrawBitmap( *m_pPreviewBmp, 1, 1 ); /////////////////// //Rettangolo dc.SetPen(*wxThePenList->FindOrCreatePen(m_cBorderColour, 1, wxSOLID)); dc.DrawRectangle(0,0,w,h); //settori DrawSectors(dc) ; //tacche if (m_nTick > 0) DrawTicks(dc); //indicatore lancetta DrawNeedle(dc); //testo valore if (m_bDrawCurrent) { wxString valuetext; valuetext.Printf("%d",m_nRealVal); dc.SetFont(m_Font); dc.DrawText(valuetext, (w / 2) - 10, (h / 2) + 10); } // We can now draw into the memory DC... // Copy from this DC to another DC. old_dc.Blit(0, 0, w, h, &dc, 0, 0); }
void kwxAngularMeter::OnPaint(wxPaintEvent &WXUNUSED(event)) { wxPaintDC old_dc(this); int w,h ; GetClientSize(&w,&h); ///////////////// if (m_bNeedRedrawBackground) { ConstructBackground(); m_bNeedRedrawBackground = false; } // Create a memory DC wxMemoryDC dc; wxBitmap a(w,h); dc.SelectObject(a); // //dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(m_cBackColour,wxSOLID)); //dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(m_cBackColour,wxSOLID)); // dc.Clear(); /* if (m_pPreviewBmp && m_pPreviewBmp->Ok()) dc.DrawBitmap( *m_pPreviewBmp, 1, 1 ); */ dc.Blit(0, 0, w, h, &m_BackgroundDc, 0, 0); //Indicator needle DrawNeedle(dc); //Text value if (m_bDrawCurrent) { wxString valuetext; valuetext.Printf(wxT("%d"),m_nRealVal); dc.SetFont(m_Font); dc.DrawText(valuetext, (w / 2) - 10, (h / 2) + 10); } // We can now draw into the memory DC... // Copy from this DC to another DC. old_dc.Blit(0, 0, w, h, &dc, 0, 0); }
void AngularMeter::OnPaint(wxPaintEvent &event) { wxPaintDC old_dc(this); // wxPaintDC dc((wxWindow *) this); int w,h ; GetClientSize(&w,&h); if (w != _currentWidth || h != _currentHeight){ delete (_memBitmap); _currentWidth = w; _currentHeight = h; _memBitmap = new wxBitmap(_currentWidth, _currentHeight); } ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*_memBitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(_backgroundColor,wxSOLID)); dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(_backgroundColor,wxSOLID)); dc.Clear(); /////////////////// //Rettangolo dc.SetPen(*wxThePenList->FindOrCreatePen(_borderColor, 1, wxSOLID)); dc.DrawRectangle(0,0,w,h); //settori DrawSectors(dc) ; //tacche DrawTicks( dc ); //indicatore lancetta DrawLabel(dc); //testo valore if (_shouldDrawCurrent) DrawValue(dc); DrawNeedle(dc); //blit into the real DC old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0); }
void kwxBmpSwitcher::OnPaint(wxPaintEvent &WXUNUSED(event)) { wxPaintDC old_dc(this); int w,h; wxBitmap *pCurrent ; m_nCount = m_bmplist.GetCount() ; GetClientSize(&w,&h); ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*membitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(),wxSOLID)); dc.Clear(); double dx = 30.5, dy = 30.5, dr = 29.95; dc.SetPen( *wxBLACK_PEN ); dc.SetBrush( *wxBLACK_BRUSH ); dc.DrawCircle((int)dx, (int)dy, (int)dr); if (m_nCount == 1) { CBmpList::Node *node = m_bmplist.GetFirst(); pCurrent = node->GetData() ; } else { if (m_nState >= m_nCount ) m_nState = 0 ; CBmpList::Node *node = m_bmplist.Item(m_nState); pCurrent = node->GetData(); } if (pCurrent->IsOk()) dc.DrawBitmap(*pCurrent, 0, 0, TRUE); old_dc.Blit(0, 0, w, h, &dc, 0, 0); }
void kwxBitmapButton::OnPaint(wxPaintEvent& event) { wxPaintDC old_dc(this); int w,h; GetClientSize(&w,&h); ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*membitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(),wxSOLID)); dc.Clear(); /////////////////// // se impostato n bitmap lo disegno //if (mDefaultBitmap) if(m_stato == 0) dc.DrawBitmap(*mDefaultBitmap, 0, 0, TRUE); else if(m_stato == 1) dc.DrawBitmap(*mMoveMouseBitmap, 0, 0, TRUE); else if(m_stato == 2) dc.DrawBitmap(*mPressMouseBitmap, 0, 0, TRUE); // Cornice intorno dc.SetPen(*wxThePenList->FindOrCreatePen(*wxRED, 1, wxSOLID)); dc.DrawLine(0, 0, 0, h - 1); dc.DrawLine(0, 0, w, 0); dc.DrawLine(0, h - 1, w, h - 1); dc.DrawLine(w - 1, 0, w - 1, h - 1); // We can now draw into the memory DC... // Copy from this DC to another DC. old_dc.Blit(0, 0, w, h, &dc, 0, 0); }
void kwxBmpSwitcher::OnPaint(wxPaintEvent &event) { wxPaintDC old_dc(this); int w,h; wxBitmap *pCurrent ; m_nCount = m_bmplist.GetCount() ; GetClientSize(&w,&h); ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*membitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(),wxSOLID)); dc.Clear(); if (m_nCount == 1) { CBmpList::Node *node = m_bmplist.GetFirst(); pCurrent = node->GetData() ; dc.DrawBitmap(*pCurrent, 0, 0, TRUE); } else { if (m_nState >= m_nCount ) m_nState = 0 ; CBmpList::Node *node = m_bmplist.Item(m_nState); pCurrent = node->GetData() ; dc.DrawBitmap(*pCurrent, 0, 0, TRUE); } old_dc.Blit(0, 0, w, h, &dc, 0, 0); }
void kwxBmpCheckBox::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC old_dc(this); int w,h; int bdraw = 0 ; GetClientSize(&w,&h); ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*membitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(GetBackgroundColour(),wxSOLID)); dc.Clear(); /////////////////// // se impostato n bitmap lo disegno //if (mOffBitmap) if(m_stato == 0) { if(m_bPress) dc.DrawBitmap(*mOnBitmap, 0, 0, TRUE); else dc.DrawBitmap(*mOffBitmap, 0, 0, TRUE); bdraw = 0 ; } else if(m_stato == 1) { if(m_bPress) dc.DrawBitmap(*mOnSelBitmap, 0, 0, TRUE); else dc.DrawBitmap(*mOffSelBitmap, 0, 0, TRUE); bdraw = 1 ; } else if(m_stato == 2) { if(m_bPress) dc.DrawBitmap(*mOffSelBitmap, 0, 0, TRUE); else dc.DrawBitmap(*mOnSelBitmap, 0, 0, TRUE); bdraw = 1 ; } if(m_bBord) { if(bdraw) { // Cornice intorno dc.SetPen(*wxThePenList->FindOrCreatePen(*wxRED, 1, m_nStyle )); dc.DrawLine(0, 0, 0, h - 1); dc.DrawLine(0, 0, w, 0); dc.DrawLine(0, h - 1, w, h - 1); dc.DrawLine(w - 1, 0, w - 1, h - 1); } } // We can now draw into the memory DC... // Copy from this DC to another DC. old_dc.Blit(0, 0, w, h, &dc, 0, 0); }
void LineChart::OnPaint(wxPaintEvent &event){ wxPaintDC old_dc(this); float zoomFactor = (float)_zoomPercentage / 100; int w,h ; GetClientSize(&w,&h); if (w != _currentWidth || h != _currentHeight){ delete (_memBitmap); _currentWidth = w; _currentHeight = h; _memBitmap = new wxBitmap(_currentWidth, _currentHeight); } ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*_memBitmap); wxColor backColor = GetBackgroundColour(); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID)); dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID)); dc.Clear(); DrawGrid(dc); if (m_showScale){ m_leftEdge = DrawScale(dc); } else{ m_leftEdge = 0; } size_t largestBufferSize = GetMaxSeriesBufferSize(); double lastValue = 0; for (SeriesMap::iterator it = m_seriesMap.begin(); it != m_seriesMap.end(); ++it){ float currentX = (float)m_leftEdge; int lastX = (int)currentX; int lastY; Series *series = it->second; dc.SetPen(*wxThePenList->FindOrCreatePen(series->GetColor(), 1, wxSOLID)); size_t bufSize = series->GetBufferSize(); Range *range = m_rangeArray[series->GetRangeId()]; if (bufSize > 0){ double minValue = range->GetMin(); double maxValue = range->GetMax(); double loggedValue = series->GetValueAt(0); double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue); lastY = h - (int)(((double)h) * percentageOfMax); size_t i = (size_t)(((double)largestBufferSize) * m_viewOffsetFactor); while (i < bufSize && currentX < _currentWidth ){ if (i == m_markerIndex){ wxPen pen = dc.GetPen(); dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSOLID)); dc.DrawLine(currentX, 0, currentX, _currentHeight); DrawCurrentValues(dc, i, currentX, CURRENT_VALUES_TOP_OFFSET); dc.SetPen(pen); } loggedValue = series->GetValueAt(i); if (DatalogValue::NULL_VALUE == loggedValue){ loggedValue = lastValue; } else{ lastValue = loggedValue; } double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue); int y = h - (int)(((double)h) * percentageOfMax); dc.DrawLine(lastX, lastY, (int)currentX, y); lastX = (int)currentX; lastY = y; currentX += zoomFactor; i++; } } } if (m_showData) DrawMouseoverMarker(dc); //blit into the real DC old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0); }
void StripChart::OnPaint(wxPaintEvent &event){ wxPaintDC old_dc(this); int w,h ; GetClientSize(&w,&h); if (w != _currentWidth || h != _currentHeight){ delete (_memBitmap); _currentWidth = w; _currentHeight = h; _memBitmap = new wxBitmap(_currentWidth, _currentHeight); } ///////////////// // Create a memory DC wxMemoryDC dc; dc.SelectObject(*_memBitmap); wxColor backColor = GetBackgroundColour(); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID)); dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(backColor,wxSOLID)); dc.Clear(); DrawGrid(dc); if (_showScale) DrawScale(dc); unsigned int dataBufferSize = _dataBuffer.size(); float zoomFactor = (float)_zoomPercentage / 100; dc.SetPen(*wxThePenList->FindOrCreatePen(*wxLIGHT_GREY, 1, wxSHORT_DASH)); int dataBufferUBound = _currentDataBufferUBound; float currentX = (float)w; for (int i = dataBufferUBound; i >= 0; i--){ if (_dataBuffer[i].IsMarked()){ dc.DrawLine((int)currentX,0,(int)currentX,h); } currentX -= zoomFactor; } for (LogItemTypes::iterator it = _logItemTypes.begin(); it != _logItemTypes.end(); ++it){ wxString key = it->first; LogItemType *itemType = it->second; ChartScale scale = _chartScales[itemType->scaleId]; double minValue = scale.minValue; double maxValue = scale.maxValue; currentX = (float)w; dc.SetPen(*wxThePenList->FindOrCreatePen(itemType->lineColor, 1, wxSOLID)); int lastX = (int)currentX; int lastY; if (dataBufferSize > 0){ StripChartLogItem logItem = _dataBuffer[dataBufferUBound]; double loggedValue = logItem[key]; double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue); lastY = h - (int)(((double)h) * percentageOfMax); for (int i = dataBufferUBound; i >= 0; i--){ StripChartLogItem logItem = _dataBuffer[i]; double loggedValue = logItem[key]; double percentageOfMax = (loggedValue - minValue) / (maxValue - minValue); int y = h - (int)(((double)h) * percentageOfMax); dc.DrawLine(lastX, lastY, (int)currentX, y); lastX = (int)currentX; lastY = y; currentX -= zoomFactor; } } } if (_showData) DrawCurrentValues(dc); //blit into the real DC old_dc.Blit(0,0,_currentWidth,_currentHeight,&dc,0,0); }
void kwxLinearReg::OnPaint(wxPaintEvent &WXUNUSED(event)) { wxPaintDC old_dc(this); int w,h; int yPoint, rectHeight ; GetClientSize(&w,&h); wxMemoryDC dc; dc.SelectObject(*m_pMembitmap); dc.SetBackground(*wxTheBrushList->FindOrCreateBrush(*m_pPassiveBarColour,wxSOLID)); dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*m_pPassiveBarColour,wxSOLID)); dc.Clear(); /////////////////////////////////////////////////////////////////////////// dc.SetPen(*wxThePenList->FindOrCreatePen(*m_pBorderColour, 1, wxSOLID)); dc.DrawRectangle(0, 0, w, h); dc.SetPen(*wxThePenList->FindOrCreatePen(*m_pActiveBarColour, 1, wxSOLID)); dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(*m_pActiveBarColour,wxSOLID)); if((!(m_iStyle&STYLE_VERTICAL))) dc.DrawRectangle(1, 1, m_iScaledVal, h - 2); else { yPoint = h - m_iScaledVal ; if (m_iScaledVal == 0 ) rectHeight = m_iScaledVal ; else { if (m_iRealVal == m_iMax) { rectHeight = m_iScaledVal; yPoint -= 1 ; } else rectHeight = m_iScaledVal - 1 ; } dc.DrawRectangle(1, yPoint, w - 2, rectHeight); } if (m_iStyle & STYLE_METER) { DrawNeedle(dc); // draw needle } if (m_iStyle & STYLE_DRAW_CURRENT) DrawCurrent(dc); //valore attuale if (m_iStyle & STYLE_DRAW_LIMITS) DrawLimits(dc); //valore minimo e massimo if (m_iTagsCount > 0 ) DrawTags(dc) ; // draw tags // We can now draw into the memory DC... // Copy from this DC to another DC. old_dc.Blit(0, 0, w, h, &dc, 0, 0); }