void MapRect::ma_drawInactive(const GRect & pm_rect, const GP<GPixmap> & pm) // pm_rect is the rectangle of the pane in screen coordinates // where pm is supposed to go to { if (mapper && pm) { GRect border_rect=gmap_area->get_bound_rect(); mapper->map(border_rect); GRect irect; if (irect.intersect(border_rect, pm_rect)) { // Translate the intersection into the GPixmap's coordinate irect.translate(-pm_rect.xmin, -pm_rect.ymin); // Do hiliting first if (gmap_area->hilite_color!=0xffffffff) { if (gmap_area->hilite_color==0xff000000) { // Do XOR hiliting for(int y=irect.ymin;y<irect.ymax;y++) { GPixel * pix=(*pm)[pm->rows()-1-y]+irect.xmin; for(int x=irect.xmin;x<irect.xmax;x++, pix++) { pix->r^=0xff; pix->g^=0xff; pix->b^=0xff; } } } else { // Do COLOR hiliting int r=(gmap_area->hilite_color & 0xff0000) >> (16+2); int g=(gmap_area->hilite_color & 0xff00) >> (8+2); int b=(gmap_area->hilite_color & 0xff) >> 2; for(int y=irect.ymin;y<irect.ymax;y++) { GPixel * pix=(*pm)[pm->rows()-1-y]+irect.xmin; for(int x=irect.xmin;x<irect.xmax;x++, pix++) { pix->r=((((int) pix->r << 1)+(int) pix->r) >> 2)+r; pix->g=((((int) pix->g << 1)+(int) pix->g) >> 2)+g; pix->b=((((int) pix->b << 1)+(int) pix->b) >> 2)+b; } } } } }
void MapArea::draw(const GRect & bm_rect, const GP<GBitmap> & bm_in, GRect & pm_rect, GP<GPixmap> & pm_out, DRAW_MODE draw_mode) // Draws itself into the specified bitmap. The bm_rect should be // in the pane's coordinates. Since GBitmap may not contain color // information, we will create a color GPixmap patch (pm_out), where we // will actually be drawing. The pm_rect is a rectangle in // pane coordinates where this pm_out should go to. { DEBUG_MSG("MapArea::draw(): Highlighting " << gmap_area->url << ":" << gmap_area->target << "\n"); DEBUG_MAKE_INDENT(3); if (pane) { GRect brect=gmap_area->get_bound_rect(); mapper->map(brect); brect.inflate(3, 3); GRect irect; if (irect.intersect(bm_rect, brect)) { pm_rect=irect; irect.translate(-bm_rect.xmin, -bm_rect.ymin); pm_out=GPixmap::create(*bm_in, GRect(irect.xmin, bm_in->rows()-irect.ymax, irect.width(), irect.height())); if (!isInactiveOutlineMode()) if (draw_mode==DRAW_INACTIVE || draw_mode==DRAW_ACTIVE) ma_drawInactive(pm_rect, pm_out); if (!isActiveOutlineMode()) if (draw_mode==APPLY_ACTIVE || draw_mode==DRAW_ACTIVE) ma_applyActive(pm_rect, pm_out); } } }