void NativeButton::ButtonPressed() { RequestFocus(); // TODO(beng): obtain mouse event flags for native buttons someday. DWORD pos = GetMessagePos(); POINTS points = MAKEPOINTS(pos); gfx::Point cursor_point(points.x, points.y); view::MouseEvent event(view::Event::ET_MOUSE_RELEASED, cursor_point.x(), cursor_point.y(), view::Event::EF_LEFT_BUTTON_DOWN); NotifyClick(event); }
bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) { if(IsEnabled()) { DWORD pos = GetMessagePos(); POINTS points = MAKEPOINTS(pos); gfx::Point cursor_point(points.x, points.y); view::MouseEvent event(view::Event::ET_MOUSE_RELEASED, cursor_point.x(), cursor_point.y(), view::Event::EF_LEFT_BUTTON_DOWN); NotifyClick(event); return true; } return false; }
static HCURSOR qt_createPixmapCursor( const QCursor &cursor, const QPixmap &pixmap, const QPoint &hotspot ) { QSize size; /* calculate size of cursor */ QPoint pt = hotspot - cursor.hotSpot(); QPoint pixmap_point( 0, 0 ); QPoint cursor_point( 0, 0 ); if ( qWinVersion() <= Qt::WV_95 ) { /* Win95 can only fixed size */ size.setWidth( GetSystemMetrics ( SM_CXCURSOR ) ); size.setHeight ( GetSystemMetrics ( SM_CYCURSOR ) ); } else { /* calculate size (enlarge if needed) */ const QBitmap *tmp = cursor.bitmap(); /* Only bitmap cursors allowed... */ if ( tmp ) { QPoint point; // curent size size = pixmap.size(); // calc position of lower right cursor pos point.setX( pt.x() + tmp->size().width() ); point.setY( pt.y() + tmp->size().height() ); // resize when cursor to large if ( point.x() > pixmap.width() ) size.setWidth( point.x() ); if ( point.y() > pixmap.height() ) size.setHeight( point.y() ); // calc upper left corner where both pixmaps have to be drawn if ( pt.x() >= 0 ) { cursor_point.setX( pt.x() ); } else { pixmap_point.setX( -pt.x() ); // negative position -> resize size.setWidth( size.width() - pt.x() ); } if ( pt.y() >= 0 ) { cursor_point.setX( pt.x() ); } else { pixmap_point.setY( -pt.y() ); // negative position -> resize size.setHeight( size.height() - pt.y() ); } } } /* Mask */ QBitmap andMask( size ); BitBlt( andMask.handle(), 0, 0, size.width(), size.height(), NULL, 0, 0, WHITENESS ); if ( pixmap.mask() ) BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), pixmap.mask() ->handle(), 0, 0, SRCAND ); else BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), NULL, 0, 0, BLACKNESS ); const QBitmap *curMsk = cursor.mask(); if ( curMsk ) BitBlt( andMask.handle(), cursor_point.x(), cursor_point.y(), curMsk->width(), curMsk->height(), curMsk->handle(), 0, 0, SRCAND ); /* create Pixmap */ QPixmap xorMask( size ); xorMask.fill ( Qt::color1 ); QPainter paint2( &xorMask ); paint2.drawPixmap( pixmap_point, pixmap ); QPixmap pm; pm.convertFromImage( cursor.bitmap() ->convertToImage().convertDepth( 8 ) ); pm.setMask( *cursor.mask() ); paint2.drawPixmap ( cursor_point, pm ); paint2.end(); #ifdef DEBUG_QDND_SRC andMask.save ( "pand.png", "PNG" ); xorMask.save ( "pxor.png", "PNG" ); #endif HCURSOR cur = qt_createPixmapCursor ( qt_display_dc(), xorMask, andMask, hotspot, size ); if ( !cur ) { qWarning( "Error creating cursor: %d", GetLastError() ); } return cur; }