static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas, alpm_list_t **data) { int errors = 0, ret = 0; alpm_list_t *i; alpm_trans_t *trans = handle->trans; if(!deltas) { return 0; } /* Check integrity of deltas */ EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_START, NULL, NULL); for(i = deltas; i; i = i->next) { alpm_delta_t *d = alpm_list_getdata(i); char *filepath = _alpm_filecache_find(handle, d->delta); if(test_md5sum(trans, filepath, d->delta_md5) != 0) { errors++; *data = alpm_list_add(*data, strdup(d->delta)); } FREE(filepath); } if(errors) { handle->pm_errno = ALPM_ERR_DLT_INVALID; return -1; } EVENT(trans, ALPM_TRANS_EVT_DELTA_INTEGRITY_DONE, NULL, NULL); /* Use the deltas to generate the packages */ EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_START, NULL, NULL); ret = apply_deltas(handle); EVENT(trans, ALPM_TRANS_EVT_DELTA_PATCHES_DONE, NULL, NULL); return ret; }
/*---------------------------------------------------------------------- * Class: AmayaEditShapeEvtHandler * Method: OnMouseMove * Description: handle mouse move events -----------------------------------------------------------------------*/ void AmayaEditShapeEvtHandler::OnMouseMove( wxMouseEvent& event ) { #define RATIO_EQUILATERAL sqrt((float)3)/2. ThotBool same_size; int rx, ry, lx, ly, x, y; int x1, y1, x2, y2, dx, dy; float ratio = 0.; if (IsFinish()) return; /* DELTA is the sensitivity toward mouse moves. */ #define DELTA 0 /* Update the current mouse coordinates */ mouse_x = event.GetX(); mouse_y = event.GetY(); if (!buttonDown) { lastX = mouse_x; lastY = mouse_y; buttonDown = true; } if ((abs(mouse_x -lastX) + abs(mouse_y - lastY) > DELTA)) { x1 = lastX; y1 = lastY; x2 = mouse_x; y2 = mouse_y; MouseCoordinatesToSVG (document, pFrame, x0, y0, width, height, inverse, TRUE, NULL, &x1, &y1, FALSE); MouseCoordinatesToSVG (document, pFrame, x0, y0, width, height, inverse, TRUE, NULL, &x2, &y2, FALSE); dx = x2 - x1; dy = y2 - y1; /* lx * <-------------> * * (x,y)------O-rx-. ^ * | | | * | ry | * | | | * | O | * | | | * | | |ly * | | | * | | | * | | | * | | | * .-------------. v */ lx = box->BxW; ly = box->BxH; x = x_org; y = y_org; /* 9 = Rx handle */ /* / */ /* 1-------------2------O------3 */ /* | O */ /* | |\ */ /* 8 4 \ */ /* | | 10 = Ry */ /* | | Handle */ /* 7-------------6-------------5 */ switch(shape) { case 1: /* square */ case 2: /* Parallelogram */ case 3: /* Trapezium */ case 'C': /* rectangle */ case 'a': /* circle */ case 'c': /* ellipse */ case 'L': /* diamond */ case 4: /* Equilateral triangle (ly = lx*R) */ case 5: /* Isosceles triangle */ case 6: /* Rectangle triangle */ case 7: /* square */ case 8: /* rectangle */ if (shape == 1 || shape == 'C') /* square and rectangle with rounded corner */ { rx = box->BxRx; ry = box->BxRy; if (rx != -1 && ry == -1) ry = rx; else if (rx == -1 && ry != -1) rx = ry; } else if (shape == 2) /* parallelogram */ rx = box->BxRx; else if (shape == 3) /* trapezium */ { rx = box->BxRx; ry = box->BxRy; } if (1 <= point && point <= 8) { same_size = (shape == 1 || shape == 7 || shape == 'a'); if (same_size)ratio = 1.; } else same_size = (box->BxRx == -1 || box->BxRy == -1); if (shape == 4) ratio = RATIO_EQUILATERAL; if (shape == 6 && point == 5) { /* The point is actually the middle of the hypot */ dx *= 2; dy *= 2; } switch(point) { case 1: apply_deltas(&x, &y, &lx, &ly, dx, dy, -1, -1, ratio); break; case 2: apply_deltas(&x, &y, &lx, &ly, dx, dy, 0, -1, ratio); break; case 3: apply_deltas(&x, &y, &lx, &ly, dx, dy, +1, -1, ratio); break; case 4: apply_deltas(&x, &y, &lx, &ly, dx, dy, +1, 0, ratio); break; case 5: apply_deltas(&x, &y, &lx, &ly, dx, dy, +1, +1, ratio); break; case 6: apply_deltas(&x, &y, &lx, &ly, dx, dy, 0, +1, ratio); break; case 7: apply_deltas(&x, &y, &lx, &ly, dx, dy, -1, +1, ratio); break; case 8: apply_deltas(&x, &y, &lx, &ly, dx, dy, -1, 0, ratio); break; case 9: // change the arc size if (shape == 1 || shape == 'C') /* Square Rectangle */ { rx -= dx; if (rx > lx/2) rx = lx/2; if (same_size) { if (rx > ly/2) rx = ly/2; ry = rx; } } else if (shape == 2) /* Parallelogram */ rx += dx; break; case 10: // change the arc size if (shape == 1 || shape == 'C') /* Square Rectangle */ { ry += dy; if (ry > ly/2) ry = ly/2; if (same_size || Angle_ratio) { if (ry > lx/2) ry = lx/2; rx = ry; } } else if (shape == 2) /* Parallelogram */ rx -= dx; break; } if (lx < 0){lx = 0; x = x_org;} if (ly < 0){ly = 0; y = y_org;} if (shape == 1 || shape == 'C') /* Square Rectangle */ { if (rx > lx/2) rx = lx/2; if (ry > ly/2) ry = ly/2; if (box->BxRx != -1) box->BxRx = rx; if (box->BxRy != -1) box->BxRy = ry; } else if (shape == 2) /* Parallelogram */ { if (rx < 0)rx = 0; if (rx > lx)rx = lx; box->BxRx = rx; } else if (shape == 3) /* Trapezium */ { if (x+abs(rx) > x+lx-abs(ry)) { box->BxRx = (rx < 0 ? -1 : 1)*(lx/2); box->BxRy = (ry < 0 ? -1 : 1)*(lx/2); } else { box->BxRx = rx; box->BxRy = ry; } } break; default: break; } if (shape != 1 && shape != 'C' && shape != 'a' && shape != 'c' && shape != 'g' && shape != 7 && shape != 8) { TtaAppendMatrixTransform (document, el, 1, 0, 0, 1, x - x_org, y - y_org); box->BxXOrg = 0; box->BxYOrg = 0; } else if (point != 9 && point != 10) { box->BxXOrg = x; box->BxYOrg = y; } x_org = x; y_org = y; box->BxW = lx; box->BxH = ly; box->BxWidth = lx; box->BxHeight = ly; e_box->BxW = lx; e_box->BxH = ly; e_box->BxWidth = lx; e_box->BxHeight = ly; /* Redisplay the GRAPHICS leaf */ RedisplayLeaf ((PtrElement) leaf, document, 0); /* Update the previous mouse coordinates */ lastX = mouse_x; lastY = mouse_y; *hasBeenEdited = TRUE; } }