| 发表于:2007-11-30 08:44:591楼 得分:0 |
procedure tc_reportf.drawshape(topleft, bottomright: tpoint; amode: tpenmode); begin with scrn_rect do begin pen.mode := amode; rectangle(topleft.x, topleft.y, bottomright.x, bottomright.y); end; end; procedure tc_reportf.imagemousedown(sender: tobject; button: tmousebutton; shift: tshiftstate; x, y: integer; layer: tcustomlayer); begin if button = mbright then begin mousedragging := true; image.cursor := crhandpoint; oldmousepos := point(x, y); end; mx := mouse.cursorpos.x; my := mouse.cursorpos.y; bx := x; by := y; if (not picdraging) and (button = mbleft) then begin mouse2down := true; origin := mouse.cursorpos; // clienttoscreen(point(x, y)); movept := origin; end; end; procedure tc_reportf.imagemousemove(sender: tobject; shift: tshiftstate; x, y: integer; layer: tcustomlayer); begin if mouse2down then begin if (x > bx) and (y > by) then scrn_rect.pen.color := color_kuang_big else scrn_rect.pen.color := color_kuang_auto; drawshape(origin, movept, pmnotxor); origin := mouse.cursorpos; drawshape(origin, movept, pmnotxor); end; if mousedragging or picdraging then begin image.scroll(oldmousepos.x - x, oldmousepos.y - y); oldmousepos := point(x, y); image.update; end; end; procedure tc_reportf.imagemouseup(sender: tobject; button: tmousebutton; shift: tshiftstate; x, y: integer; layer: tcustomlayer); var dx, dy : integer; rx, ry, r : single; ux, uy : integer; cw, ch, pw, ph : integer; nowscale : single; begin if mouse2down then begin mouse2down := false; drawshape(origin, movept, pmnotxor); end; if button = mbright then begin mousedragging := false; if picdraging then image.cursor := crhandpoint else image.cursor := crdefault end; if (not picdraging) and (button = mbleft) and (image.bitmap.width > 10) then begin nowscale := image.scale; ux := mouse.cursorpos.x; uy := mouse.cursorpos.y; if (ux > mx) and (uy > my) then //向右下脚划,放大图片。 begin dx := ux - mx; dy := uy - my; rx := image.width / dx; ry := image.height / dy; if rx <= ry then r := rx else r := ry; nowscale := image.scale * r; scalebar.repaint; if (nowscale < power(10, scalebar.maxvalue / 100)) then begin //image.scale := nowscale; scalebar.position := round(logn(10, nowscale) * 100); end; image.scroll(round(((bx + dx div 2) - image.width div 2) * r), round(((by + dy div 2) - image.height div 2) * r)); end else begin nowscale := image.width / image.bitmap.width; if nowscale > (image.height / image.bitmap.height) then nowscale := (image.height / image.bitmap.height); image.scale := nowscale; scalebar.position := round(logn(10, image.scale) * 100); end; end; end; | | |
|