// Create desired fonts for draw legend in x axis and y axis. void CChart2D::_CreateFont() { //Create system font LOGFONT d_lf; // Init desired font memset(&d_lf, 0, sizeof(LOGFONT)); lstrcpy(d_lf.lfFaceName, _T("MS Sans Serif")); // Initial font size CWindowDC wdc(NULL); const int cyPixels = wdc.GetDeviceCaps(LOGPIXELSY); d_lf.lfHeight = -1 * MulDiv(7, cyPixels, 72); // Create a new font 7 pts mp_legendFontY = new CFont(); mp_legendFontY->CreateFontIndirect(&d_lf); d_lf.lfHeight = -1 * MulDiv(12, cyPixels, 72); d_lf.lfWeight = FW_BOLD; mp_titleFont = new CFont(); mp_titleFont->CreateFontIndirect(&d_lf); d_lf.lfWeight = 0 ; d_lf.lfOrientation = 900; // Rotate 90 degree for x axis d_lf.lfEscapement = 900; d_lf.lfHeight = -1 * MulDiv(7, cyPixels, 72); mp_legendFontX = new CFont(); mp_legendFontX->CreateFontIndirect(&d_lf); }
// /// Returns TEventStatus. // TEventStatus TTinyCaption::DoMouseMove(uint /*modKeys*/, const TPoint& pt) { if (TCEnabled && DownHit != HTNOWHERE) { uint hitTest; TPoint screenPt = pt; ClientToScreen(screenPt); // Cvt to screen coord DoNCHitTest(screenPt, hitTest); bool isNowPressed = hitTest == DownHit; if (isNowPressed != IsPressed) { IsPressed = isNowPressed; TWindowDC wdc(*this); switch (DownHit) { case HTSYSMENU: if (CloseBox) { TRect rect(GetSysBoxRect()); PaintCloseBox(wdc, rect, IsPressed); } return esComplete; case HTMINBUTTON: { TRect rect(GetMinBoxRect()); PaintMinBox(wdc, rect, IsPressed); } return esComplete; case HTMAXBUTTON: { TRect rect(GetMaxBoxRect()); PaintMaxBox(wdc, rect, IsPressed); } return esComplete; } } } return esPartial; }
////////////////////////////////////////////////////// // Create desired fonts for draw legend in x axis and // y axis . void CChart::CreateFont() { //Create system font .. LOGFONT d_lf ; // Init desired font memset(&d_lf, 0, sizeof(LOGFONT)); //lstrcpy(d_lf.lfFaceName, "Times New Roman") ; lstrcpy(d_lf.lfFaceName, "Arial") ; // Initial font size // Get a screen DC CWindowDC wdc(NULL) ; const int cyPixels = wdc.GetDeviceCaps(LOGPIXELSY); d_lf.lfHeight = -1 * MulDiv(7, cyPixels, 72); // Create a new font 7 pts. pLegendFontY = new CFont() ; pLegendFontY->CreateFontIndirect(&d_lf); d_lf.lfHeight = -1 * MulDiv(8, cyPixels, 72); d_lf.lfWeight = FW_BOLD ; pTitleFont = new CFont(); pTitleFont->CreateFontIndirect(&d_lf); d_lf.lfWeight = 0 ; d_lf.lfOrientation = 900 ; // Rotate font 90 degree for x axis d_lf.lfEscapement = 900 ; d_lf.lfHeight = -1 * MulDiv(7, cyPixels, 72); pLegendFontX = new CFont() ; pLegendFontX->CreateFontIndirect(&d_lf); }
/* * Here we do the actual rendering. I put it in a separate * method so that it can work no matter what type of DC * (e.g. wxPaintDC or wxClientDC) is used. */ void wxImagePanel::render(wxDC& dc) { int neww, newh; dc.GetSize(&neww, &newh); // Adjust aspect ratio. if (BackgroundWidth * newh > neww * BackgroundHeight) newh = (neww * BackgroundHeight) / BackgroundWidth; else neww = (newh * BackgroundWidth) / BackgroundHeight; if (neww != w || newh != h) { //static int Count = 0; //printf ("Rescale %d: %d %d -> %d %d\n", ++Count, w, h, neww, newh); w = neww; h = newh; resized = wxBitmap(image.Scale(neww, newh, wxIMAGE_QUALITY_HIGH)); int i; for (i = 1; i < NumGraphics; i++) // Skip initial dummy entry. Rescale(Graphics[i].UnscaledImage, Graphics[i].ScaledImage); for (i = 0; i < MAX_CLOCK_ANGLES; i++) { Rescale(HandsHours[i].UnscaledImage, HandsHours[i].ScaledImage); Rescale(HandsMinutes[i].UnscaledImage, HandsMinutes[i].ScaledImage); Rescale(HandsSeconds[i].UnscaledImage, HandsSeconds[i].ScaledImage); } } wxMemoryDC wdc(resized); wxBitmap Buffer(resized.GetWidth(), resized.GetHeight()); wxMemoryDC bdc(Buffer); bdc.DrawBitmap(resized, 0, 0, false); int i; for (i = 0; i < NumFields; i++) if (Fields[i].Type == FT_OUT && Fields[i].State != gi_none) BufferedComposite(&bdc, Graphics[Fields[i].State].ScaledImage, Fields[i].x, Fields[i].y); // Do the accutron clock hands. time_t t; struct tm *tm_struct; time(&t); tm_struct = gmtime(&t); /* printf("%d %d %d %d %d %p %p %p\n", Fields[trs_ac_hands].x, Fields[trs_ac_hands].y, tm_struct->tm_hour * 5, tm_struct->tm_min * 2, tm_struct->tm_sec * 2, HandsHours[tm_struct->tm_hour * 5].ScaledImage, HandsMinutes[tm_struct->tm_min * 2].ScaledImage, HandsSeconds[tm_struct->tm_sec * 2].ScaledImage); */ BufferedComposite(&bdc, HandsHours[tm_struct->tm_hour * 5].ScaledImage, Fields[trs_ac_hands].x, Fields[trs_ac_hands].y); BufferedComposite(&bdc, HandsMinutes[tm_struct->tm_min * 2].ScaledImage, Fields[trs_ac_hands].x, Fields[trs_ac_hands].y); BufferedComposite(&bdc, HandsSeconds[tm_struct->tm_sec * 2].ScaledImage, Fields[trs_ac_hands].x, Fields[trs_ac_hands].y); // Now actually write the buffer to the screen. dc.DrawBitmap(Buffer, 0, 0, false); }
void CameraDisplaySave::saveImage(wxString ss) { wxWindowDC wdc(render_panel_); wxSize s = render_panel_->GetSize() ; wxBitmap b(s.x, s.y); wxMemoryDC md; md.SelectObject(b) ; md.Blit(0, 0, s.x, s.y, &wdc, 0, 0) ; wxString filename = wxString::Format(wxT("/tmp/camera-%s-%05d.png"),ss.c_str(),texture_.getImageCount()); if ( !filename.empty() ) { b.SaveFile(filename,wxBITMAP_TYPE_PNG); } }
void CRaster::OnCopy() { CClientDC wdc(&c_Sample); // get static control that surrounds example CDC memDC; memDC.CreateCompatibleDC(&wdc); CBitmap bm; CRect r; c_Sample.GetClientRect(&r); CString s; c_Sample.GetWindowText(s); CFont * font = c_Sample.GetFont(); wdc.SelectObject(font); CSize sz = wdc.GetTextExtent(s); int scale = 1; // REQ #050 if(c_EnableScaling.GetCheck() == BST_CHECKED) // REQ #050 { /* scaled */ // REQ #050 scale = c_SpinMultiplier.GetPos32(); // REQ #050 } /* scaled */ // REQ #050 sz.cx *= scale; // REQ #050 sz.cy *= scale; // REQ #050 bm.CreateCompatibleBitmap(&wdc, sz.cx, sz.cy); CBitmap * oldbm = memDC.SelectObject(&bm); memDC.BitBlt(0, 0, sz.cx * scale, sz.cy * scale, &wdc, 0, 0, SRCCOPY);// REQ #050 OpenClipboard(); ::EmptyClipboard(); ::SetClipboardData(CF_BITMAP, bm.m_hObject); CloseClipboard(); memDC.SelectObject(oldbm); bm.Detach(); // make sure bitmap not deleted with CBitmap object }
// /// If the caption bar is not enabled, returns esPartial. Otherwise, determines if /// the user released the button outside or inside a menu, and returns esComplete. // TEventStatus TTinyCaption::DoNCLButtonDown(uint hitTest, const TPoint& screenPt) { if (!TCEnabled) return esPartial; TWindowDC wdc(*this); switch (hitTest) { case HTSYSMENU: DownHit = HTSYSMENU; if (CloseBox) { IsPressed = true; SetCapture(); TRect rect(GetSysBoxRect()); PaintCloseBox(wdc, rect, IsPressed); } else { TRect sysBoxRect = GetSysBoxRect().InflatedBy(-1,-1); sysBoxRect.right += 1; wdc.PatBlt(sysBoxRect, PATINVERT); // Display sys menu on button down // Need to lock sys menu until user clicks outside // Set flag to indicate we're expecting a sys command, & then send // message to popup sys menu // WaitingForSysCmd = true; SendMessage(WM_SYSCOMMAND, SC_MOUSEMENU|HTSYSMENU, MkParam2(screenPt.x,screenPt.y)); // If we didn't execute a command, user released btn outside of menu // If it was released in sys menu box, then redisplay menu as if it // were brought up with a keystroke // if (WaitingForSysCmd) { uint hitTest; TPoint pt; GetCursorPos(pt); DoNCHitTest(pt, hitTest); if (hitTest == HTSYSMENU) SendMessage(WM_SYSCOMMAND, SC_KEYMENU|HTSYSMENU); } if (GetHandle()) wdc.PatBlt(sysBoxRect, PATINVERT); } return esComplete; case HTMINBUTTON: { DownHit = HTMINBUTTON; IsPressed = true; SetCapture(); TRect rect(GetMinBoxRect()); PaintMinBox(wdc, rect, IsPressed); return esComplete; } case HTMAXBUTTON: { DownHit = HTMAXBUTTON; IsPressed = true; SetCapture(); TRect rect(GetMaxBoxRect()); PaintMaxBox(wdc, rect, IsPressed); return esComplete; } } DownHit = HTNOWHERE; return esPartial; }
void CameraDisplaySave::update(float wall_dt, float ros_dt) { updateStatus(); try { if (texture_.update() || force_render_) { float old_alpha = alpha_; if (texture_.getImageCount() == 0) { alpha_ = 1.0f; } // if(alpha_ != 0.49) { // updateCamera(); // render_panel_->getRenderWindow()->update(); // } else { alpha_ = 0.0; updateCamera(); render_panel_->getRenderWindow()->update(); // copy model image into md wxWindowDC wdc(render_panel_); wxSize s = render_panel_->GetSize() ; wxBitmap b(s.x, s.y,24); wxMemoryDC md; md.SelectObject(b) ; md.Blit(0, 0, s.x, s.y, &wdc, 0, 0) ; wxColour c; md.GetPixel(1,1,&c); // b.SetMask(new wxMask(b,c) ); alpha_ = 1.0; updateCamera(); render_panel_->getRenderWindow()->update(); // copy model image into md wxMemoryDC md2; wxBitmap b2(s.x, s.y,24); md2.SelectObject(b2); md2.Blit(0, 0, s.x, s.y, &wdc, 0, 0,wxCOPY,false) ; wxMemoryDC md3; wxBitmap b3(s.x, s.y,24); wxImage A = b.ConvertToImage(); wxImage B = b2.ConvertToImage(); wxImage C = b3.ConvertToImage(); unsigned char* pA = A.GetData(); unsigned char* pB = B.GetData(); unsigned char* pC = C.GetData(); for(int i=0;i<s.x*s.y;i++) { bool img = (pA[0]==0) && (pA[1]==0) && (pA[2]==0); if(!img) { *(pC++) = *(pA++); *(pC++) = *(pA++); *(pC++) = *(pA++); pB += 3; } else { *(pC++) = *(pB++); *(pC++) = *(pB++); *(pC++) = *(pB++); pA += 3; } } wxString filename = wxString::Format(wxT("/tmp/camera-%05d.png"),texture_.getImageCount()); if ( !filename.empty() ) { std::cout << "saving"<<filename.mb_str()<<std::endl; C.SaveFile(filename,wxBITMAP_TYPE_PNG); } // } alpha_ = old_alpha; force_render_ = false; } } catch (UnsupportedImageEncoding& e) { setStatus(status_levels::Error, "Image", e.what()); } }