MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / onProcessMessage

Method onProcessMessage

src/ui/widget.cpp:1334–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1332}
1333
1334bool Widget::onProcessMessage(Message* msg)
1335{
1336 ASSERT(msg != NULL);
1337
1338 switch (msg->type()) {
1339
1340 case kOpenMessage:
1341 case kCloseMessage:
1342 case kWinMoveMessage:
1343 // Broadcast the message to the children.
1344 for (auto child : m_children)
1345 child->sendMessage(msg);
1346 break;
1347
1348 case kPaintMessage: {
1349 const PaintMessage* ptmsg = static_cast<const PaintMessage*>(msg);
1350 ASSERT(ptmsg->rect().w > 0);
1351 ASSERT(ptmsg->rect().h > 0);
1352
1353 GraphicsPtr graphics = getGraphics(toClient(ptmsg->rect()));
1354 return paintEvent(graphics.get());
1355 }
1356
1357 case kKeyDownMessage:
1358 case kKeyUpMessage:
1359 if (static_cast<KeyMessage*>(msg)->propagateToChildren()) {
1360 // Broadcast the message to the children.
1361 for (auto child : m_children)
1362 if (child->sendMessage(msg))
1363 return true;
1364 }
1365
1366 // Propagate the message to the parent.
1367 if (static_cast<KeyMessage*>(msg)->propagateToParent() &&
1368 parent()) {
1369 return parent()->sendMessage(msg);
1370 }
1371 break;
1372
1373 case kDoubleClickMessage: {
1374 // Convert double clicks into mouse down
1375 MouseMessage* mouseMsg = static_cast<MouseMessage*>(msg);
1376 MouseMessage mouseMsg2(kMouseDownMessage,
1377 mouseMsg->pointerType(),
1378 mouseMsg->buttons(),
1379 mouseMsg->modifiers(),
1380 mouseMsg->position(),
1381 mouseMsg->wheelDelta());
1382
1383 sendMessage(&mouseMsg2);
1384 break;
1385 }
1386
1387 case kMouseDownMessage:
1388 case kMouseUpMessage:
1389 case kMouseMoveMessage:
1390 case kMouseWheelMessage:
1391 // Propagate the message to the parent.

Callers

nothing calls this directly

Calls 12

set_mouse_cursorFunction · 0.85
sendMessageMethod · 0.80
rectMethod · 0.80
propagateToChildrenMethod · 0.80
propagateToParentMethod · 0.80
buttonsMethod · 0.80
typeMethod · 0.45
getMethod · 0.45
pointerTypeMethod · 0.45
modifiersMethod · 0.45
positionMethod · 0.45
wheelDeltaMethod · 0.45

Tested by

no test coverage detected