void orb_mapctrl::draw() { // Resize the viewport before drawing m_viewport->w(w()); m_viewport->h(h()); if ((damage() & FL_DAMAGE_ALL) == 0) return; // Fill the area which the viewport does not cover fl_rectf(x(), y(), w(), h(), 80, 80, 80); // Create an offscreen drawing buffer and send all subsequent commands there Fl_Offscreen offscreen; offscreen = fl_create_offscreen(m_viewport->w(), m_viewport->h()); fl_begin_offscreen(offscreen); fl_rectf(0, 0, m_viewport->w(), m_viewport->h(), 80, 80, 80); // Draw all the layers for (std::vector<orb_layer*>::iterator iter=m_layers.begin();iter!=m_layers.end();++iter) (*iter)->draw(*m_viewport); fl_end_offscreen(); // Blit the generated viewport bitmap onto the widget (centered) int dpx = 0, dpy = 0; if (w() > (int)m_viewport->w()) dpx = (w() - (int)m_viewport->w())/2; if (h() > (int)m_viewport->h()) dpy = (h() - (int)m_viewport->h())/2; fl_copy_offscreen(x()+dpx, y()+dpy, m_viewport->w(), m_viewport->h(), offscreen, 0, 0); fl_delete_offscreen(offscreen); }
void CImgWidget::partDraw(iBox2 r) { if (!_initdraw) { draw(); return; } else { std::lock_guard<std::recursive_mutex> lock(_mutim); iBox2 rr = mtools::intersectionRect(r, iBox2(0, _ox - 1, 0, _oy - 1)); if ((_offbuf == ((Fl_Offscreen)0))||(rr.lx() < 0) || (rr.ly() < 0)) return; fl_copy_offscreen((int)rr.min[0], (int)rr.min[1], (int)rr.lx() + 1, (int)rr.ly() + 1, (Fl_Offscreen)_offbuf, (int)rr.min[0], (int)rr.min[1]); } }
void CImgWidget::draw() { if ((!_initdraw) || (w() > ((int)_ox)) || (h() > ((int)_oy))) { Fl_Window::draw(); } // first time or base widget showing : redraw it. { std::lock_guard<std::recursive_mutex> lock(_mutim); if (!_initdraw) { _initdraw = true; if (_saved_im != nullptr) { setImage(_saved_im); delete _saved_im; _saved_im = nullptr; } if (_saved_im32 != nullptr) { setImage32(_saved_im32,_saved_nbRounds); delete _saved_im32; _saved_im32 = nullptr; } } int lx = ((int)_ox > w()) ? w() : (int)_ox; int ly = ((int)_oy > h()) ? h() : (int)_oy; if ((_offbuf == ((Fl_Offscreen)0)) || (_ox <= 0) || (_oy <= 0)) { return; } fl_copy_offscreen(0, 0, lx, ly, (Fl_Offscreen)_offbuf, 0, 0); } }
void draw() { static int oX=0, oY=0; if(!tW) { fl_font(FL_HELVETICA_BOLD, 14); tW = int(fl_width(str)); } if(!backing->get_offscreen()) backing->draw(0,0); Pixmap id = backing->get_offscreen(); int tX = (w()/2)-(tW/2); int bW = ball->width(); int bH = ball->height(); if(damage()!=FL_DAMAGE_VALUE) { fl_copy_offscreen(0, 0, w(), h(), id, 0, 0); } else { // Erase bg under text fl_copy_offscreen(tX, tY, tW, int(fl_height()), id, tX, tY); // Erase only area affected, by moving ball! int DX = dX>0 ? dX : -dX; int DY = dY>0 ? dY : -dY; DX+=2; DY+=2; // X axis if(dX>0) fl_copy_offscreen(oX, Y-DY, dX, bH+(DY*2), id, oX, Y-DY); else fl_copy_offscreen(X+bW, Y-DY, -dX, bH+(DY*2), id, X+bW, Y-DY); // Y axis if(dY>0) fl_copy_offscreen(oX, oY, bW+DX, dY, id, oX, oY); else fl_copy_offscreen(oX, Y+bH, bW+DX, -dY, id, oX, Y+bH); } if(blended) delete blended; // Do alphablend and draw it to screen if( (blended = ball->blend(backing, X,Y)) ) { blended->draw(X, Y); } // Draw string fl_draw(str, float(tX), float(tY+int(fl_height()))); oX=X; oY=Y; }
void WPaper::_draw(int dx, int dy, int dw, int dh, int sx, int sy, int sw, int sh, Fl_Flags f) { if(!id) Fl_Image::_draw(dx,dy,dw,dh,sx,sy,sw,sh,f); if(id && m_data) { delete m_data; m_data=0; } if(id) { // convert to Xlib coordinates: Pixmap pix = (Pixmap) id; fl_transform(dx,dy); fl_copy_offscreen(dx,dy,dw,dh,pix,0,0); // Set X root (used by terms for 'transparency') Atom prop_root = XInternAtom(fl_display, "_XROOTPMAP_ID", False); XChangeProperty(fl_display, RootWindow(fl_display, fl_screen), prop_root, XA_PIXMAP, 32, PropModeReplace, (unsigned char *) &pix, 1); } }
FL_EXPORT_C(void ,flc_copy_offscreen)(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy){ fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy); };