MCPcopy Create free account
hub / github.com/GeoDaCenter/geoda / OnSizingDragLeft

Method OnSizingDragLeft

ogl/basic2.cpp:1286–1391  ·  view source on GitHub ↗

Control points ('handles') redirect control to the actual shape, to make it easier to override sizing behaviour.

Source from the content-addressed store, hash-verified

1284// Control points ('handles') redirect control to the actual shape, to make it easier
1285// to override sizing behaviour.
1286void wxShape::OnSizingDragLeft(wxControlPoint* pt, bool WXUNUSED(draw), double x, double y, int keys, int WXUNUSED(attachment))
1287{
1288 double bound_x;
1289 double bound_y;
1290 this->GetBoundingBoxMin(&bound_x, &bound_y);
1291
1292 wxClientDC dc(GetCanvas());
1293 GetCanvas()->PrepareDC(dc);
1294
1295 dc.SetLogicalFunction(OGLRBLF);
1296
1297 wxPen dottedPen(*wxBLACK, 1, wxDOT);
1298 dc.SetPen(dottedPen);
1299 dc.SetBrush((* wxTRANSPARENT_BRUSH));
1300
1301 if (this->GetCentreResize())
1302 {
1303 // Maintain the same centre point.
1304 double new_width = (double)(2.0*fabs(x - this->GetX()));
1305 double new_height = (double)(2.0*fabs(y - this->GetY()));
1306
1307 // Constrain sizing according to what control point you're dragging
1308 if (pt->m_type == CONTROL_POINT_HORIZONTAL)
1309 {
1310 if (GetMaintainAspectRatio())
1311 {
1312 new_height = bound_y*(new_width/bound_x);
1313 }
1314 else
1315 new_height = bound_y;
1316 }
1317 else if (pt->m_type == CONTROL_POINT_VERTICAL)
1318 {
1319 if (GetMaintainAspectRatio())
1320 {
1321 new_width = bound_x*(new_height/bound_y);
1322 }
1323 else
1324 new_width = bound_x;
1325 }
1326 else if (pt->m_type == CONTROL_POINT_DIAGONAL && (keys & KEY_SHIFT))
1327 new_height = bound_y*(new_width/bound_x);
1328
1329 if (this->GetFixedWidth())
1330 new_width = bound_x;
1331
1332 if (this->GetFixedHeight())
1333 new_height = bound_y;
1334
1335 pt->sm_controlPointDragEndWidth = new_width;
1336 pt->sm_controlPointDragEndHeight = new_height;
1337
1338 this->GetEventHandler()->OnDrawOutline(dc, this->GetX(), this->GetY(),
1339 new_width, new_height);
1340 }
1341 else
1342 {
1343 // Don't maintain the same centre point!

Callers 1

OnDragLeftMethod · 0.45

Calls 15

GetMaintainAspectRatioFunction · 0.85
SetXMethod · 0.80
SetYMethod · 0.80
CalculateBoundingBoxMethod · 0.80
CalculateNewSizeMethod · 0.80
GetCanvasFunction · 0.70
GetYFunction · 0.70
GetBoundingBoxMinMethod · 0.45
SetPenMethod · 0.45
SetBrushMethod · 0.45
GetXMethod · 0.45

Tested by

no test coverage detected