| 1391 | } |
| 1392 | |
| 1393 | void wxShape::OnSizingBeginDragLeft(wxControlPoint* pt, double x, double y, int keys, int WXUNUSED(attachment)) |
| 1394 | { |
| 1395 | m_canvas->CaptureMouse(); |
| 1396 | |
| 1397 | wxClientDC dc(GetCanvas()); |
| 1398 | GetCanvas()->PrepareDC(dc); |
| 1399 | /* |
| 1400 | if (pt->m_eraseObject) |
| 1401 | this->Erase(dc); |
| 1402 | */ |
| 1403 | |
| 1404 | dc.SetLogicalFunction(OGLRBLF); |
| 1405 | |
| 1406 | double bound_x; |
| 1407 | double bound_y; |
| 1408 | this->GetBoundingBoxMin(&bound_x, &bound_y); |
| 1409 | this->GetEventHandler()->OnBeginSize(bound_x, bound_y); |
| 1410 | |
| 1411 | // Choose the 'opposite corner' of the object as the stationary |
| 1412 | // point in case this is non-centring resizing. |
| 1413 | if (pt->GetX() < this->GetX()) |
| 1414 | pt->sm_controlPointDragStartX = (double)(this->GetX() + (bound_x/2.0)); |
| 1415 | else |
| 1416 | pt->sm_controlPointDragStartX = (double)(this->GetX() - (bound_x/2.0)); |
| 1417 | |
| 1418 | if (pt->GetY() < this->GetY()) |
| 1419 | pt->sm_controlPointDragStartY = (double)(this->GetY() + (bound_y/2.0)); |
| 1420 | else |
| 1421 | pt->sm_controlPointDragStartY = (double)(this->GetY() - (bound_y/2.0)); |
| 1422 | |
| 1423 | if (pt->m_type == CONTROL_POINT_HORIZONTAL) |
| 1424 | pt->sm_controlPointDragStartY = (double)(this->GetY() - (bound_y/2.0)); |
| 1425 | else if (pt->m_type == CONTROL_POINT_VERTICAL) |
| 1426 | pt->sm_controlPointDragStartX = (double)(this->GetX() - (bound_x/2.0)); |
| 1427 | |
| 1428 | // We may require the old width and height. |
| 1429 | pt->sm_controlPointDragStartWidth = bound_x; |
| 1430 | pt->sm_controlPointDragStartHeight = bound_y; |
| 1431 | |
| 1432 | wxPen dottedPen(*wxBLACK, 1, wxDOT); |
| 1433 | dc.SetPen(dottedPen); |
| 1434 | dc.SetBrush((* wxTRANSPARENT_BRUSH)); |
| 1435 | |
| 1436 | if (this->GetCentreResize()) |
| 1437 | { |
| 1438 | double new_width = (double)(2.0*fabs(x - this->GetX())); |
| 1439 | double new_height = (double)(2.0*fabs(y - this->GetY())); |
| 1440 | |
| 1441 | // Constrain sizing according to what control point you're dragging |
| 1442 | if (pt->m_type == CONTROL_POINT_HORIZONTAL) |
| 1443 | { |
| 1444 | if (GetMaintainAspectRatio()) |
| 1445 | { |
| 1446 | new_height = bound_y*(new_width/bound_x); |
| 1447 | } |
| 1448 | else |
| 1449 | new_height = bound_y; |
| 1450 | } |
no test coverage detected