void gr_bitmapm( int x, int y, grs_bitmap *bm ) { int dx1=x, dx2=x+bm->bm_w-1; int dy1=y, dy2=y+bm->bm_h-1; int sx=0, sy=0; if ((dx1 >= grd_curcanv->cv_bitmap.bm_w ) || (dx2 < 0)) return; if ((dy1 >= grd_curcanv->cv_bitmap.bm_h) || (dy2 < 0)) return; if ( dx1 < 0 ) { sx = -dx1; dx1 = 0; } if ( dy1 < 0 ) { sy = -dy1; dy1 = 0; } if ( dx2 >= grd_curcanv->cv_bitmap.bm_w ) { dx2 = grd_curcanv->cv_bitmap.bm_w-1; } if ( dy2 >= grd_curcanv->cv_bitmap.bm_h ) { dy2 = grd_curcanv->cv_bitmap.bm_h-1; } // Draw bitmap bm[x,y] into (dx1,dy1)-(dx2,dy2) if ( (bm->bm_type == BM_LINEAR) && (grd_curcanv->cv_bitmap.bm_type == BM_LINEAR )) { if ( bm->bm_flags & BM_FLAG_RLE ) gr_bm_ubitblt00m_rle(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); else gr_bm_ubitblt00m(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); return; } gr_bm_ubitbltm(dx2-dx1+1,dy2-dy1+1, dx1, dy1, sx, sy, bm, &grd_curcanv->cv_bitmap ); }
void ui_mouse_show() { if (Mouse.hidden==1 ) { Mouse.hidden = 0; // Save the background under new pointer Mouse.bg_saved=1; Mouse.bg_x = Mouse.x; Mouse.bg_y = Mouse.y; gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, 0, 0, Mouse.bg_x, Mouse.bg_y, &(grd_curscreen->sc_canvas.cv_bitmap),Mouse.background ); // Draw the new pointer gr_bm_ubitbltm( Mouse.pointer->bm_w, Mouse.pointer->bm_h, Mouse.x, Mouse.y, 0, 0, Mouse.pointer, &(grd_curscreen->sc_canvas.cv_bitmap) ); } }
void ui_mouse_process() { int buttons,w,h; //if (Mouse.hidden==0) // mouse_get_pos( &Mouse.x, &Mouse.y ); //else // mouse_set_pos( Mouse.x, Mouse.y ); Mouse.dx = Mouse.new_dx; Mouse.dy = Mouse.new_dy; buttons = Mouse.new_buttons; Mouse.x += Mouse.dx; Mouse.y += Mouse.dy; w = grd_curscreen->sc_w; h = grd_curscreen->sc_h; if (Mouse.x < 0 ) Mouse.x = 0; if (Mouse.y < 0 ) Mouse.y = 0; // if (Mouse.x > w-Mouse.pointer->bm_w ) Mouse.x = w - Mouse.pointer->bm_w; // if (Mouse.y > h-Mouse.pointer->bm_h ) Mouse.y = h - Mouse.pointer->bm_h; if (Mouse.x > w-3 ) Mouse.x = w - 3; if (Mouse.y > h-3 ) Mouse.y = h - 3; if ( (Mouse.bg_x!=Mouse.x) || (Mouse.bg_y!=Mouse.y) ) Mouse.moved = 1; if ( (Mouse.bg_x!=Mouse.x) || (Mouse.bg_y!=Mouse.y) || (Mouse.bg_saved==0) ) { // Restore the background under old pointer if (Mouse.bg_saved==1) { gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, Mouse.bg_x, Mouse.bg_y, 0, 0, Mouse.background, &(grd_curscreen->sc_canvas.cv_bitmap) ); } Mouse.bg_saved = 0; if (!Mouse.hidden) { // Save the background under new pointer Mouse.bg_saved=1; Mouse.bg_x = Mouse.x; Mouse.bg_y = Mouse.y; gr_bm_ubitblt( Mouse.background->bm_w, Mouse.background->bm_h, 0, 0, Mouse.bg_x, Mouse.bg_y, &(grd_curscreen->sc_canvas.cv_bitmap),Mouse.background ); // Draw the new pointer gr_bm_ubitbltm( Mouse.pointer->bm_w, Mouse.pointer->bm_h, Mouse.x, Mouse.y, 0, 0, Mouse.pointer, &(grd_curscreen->sc_canvas.cv_bitmap) ); } } Mouse.b1_last_status = Mouse.b1_status; Mouse.b2_last_status = Mouse.b2_status; if ( Mouse.backwards== 0 ) { if (buttons & MOUSE_LBTN ) Mouse.b1_status = BUTTON_PRESSED; else Mouse.b1_status = BUTTON_RELEASED; if (buttons & MOUSE_RBTN ) Mouse.b2_status = BUTTON_PRESSED; else Mouse.b2_status = BUTTON_RELEASED; } else { if (buttons & MOUSE_LBTN ) Mouse.b2_status = BUTTON_PRESSED; else Mouse.b2_status = BUTTON_RELEASED; if (buttons & MOUSE_RBTN ) Mouse.b1_status = BUTTON_PRESSED; else Mouse.b1_status = BUTTON_RELEASED; } if ((Mouse.b1_status & BUTTON_PRESSED) && (Mouse.b1_last_status & BUTTON_RELEASED) ) { if ( (TICKER <= Mouse.time_lastpressed+5) ) //&& (Mouse.moved==0) Mouse.b1_status |= BUTTON_DOUBLE_CLICKED; Mouse.moved = 0; Mouse.time_lastpressed = TICKER; Mouse.b1_status |= BUTTON_JUST_PRESSED; } else if ((Mouse.b1_status & BUTTON_RELEASED) && (Mouse.b1_last_status & BUTTON_PRESSED) ) Mouse.b1_status |= BUTTON_JUST_RELEASED; if ((Mouse.b2_status & BUTTON_PRESSED) && (Mouse.b2_last_status & BUTTON_RELEASED) ) Mouse.b2_status |= BUTTON_JUST_PRESSED; else if ((Mouse.b2_status & BUTTON_RELEASED) && (Mouse.b2_last_status & BUTTON_PRESSED) ) Mouse.b2_status |= BUTTON_JUST_RELEASED; }