void RenderableEffect::initBitmaps(const char **data16, const char **data24, const char **data32, const char **data48, const char **data64) { wxImage image16(data16); wxImage image24(data24); wxImage image32(data32); wxImage image48(data48); wxImage image64(data64); AdjustAndSetBitmap(16, image16, image32, icon16); AdjustAndSetBitmap(24, image24, image48, icon24); AdjustAndSetBitmap(32, image32, image64, icon32); AdjustAndSetBitmap(48, image48, icon48); AdjustAndSetBitmap(64, image64, icon64); #ifdef __WXOSX__ AdjustAndSetBitmap(16, image16, icon16e); AdjustAndSetBitmap(24, image24, icon24e); AdjustAndSetBitmap(32, image32, icon32e); #endif }
void wxCursor::CreateFromImage(const wxImage & image) { m_refData = new wxCursorRefData; int w = 16; int h = 16; int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); int image_w = image.GetWidth(); int image_h = image.GetHeight(); wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w && hotSpotY >= 0 && hotSpotY < image_h, _T("invalid cursor hot spot coordinates") ); wxImage image16(image); // final image of correct size // if image is too small then place it in the center, resize it if too big if ((w > image_w) && (h > image_h)) { wxPoint offset((w - image_w)/2, (h - image_h)/2); hotSpotX = hotSpotX + offset.x; hotSpotY = hotSpotY + offset.y; image16 = image.Size(wxSize(w, h), offset); } else if ((w != image_w) || (h != image_h)) { hotSpotX = int(hotSpotX * double(w) / double(image_w)); hotSpotY = int(hotSpotY * double(h) / double(image_h)); image16 = image.Scale(w, h); } unsigned char * rgbBits = image16.GetData(); bool bHasMask = image16.HasMask() ; #if 0 // monochrome implementation M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ; M_CURSORDATA->m_disposeHandle = true ; HLock( (Handle) M_CURSORDATA->m_hCursor ) ; CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ; memset( cp->data , 0 , sizeof( Bits16 ) ) ; memset( cp->mask , 0 , sizeof( Bits16 ) ) ; unsigned char mr = image16.GetMaskRed() ; unsigned char mg = image16.GetMaskGreen() ; unsigned char mb = image16.GetMaskBlue() ; for ( int y = 0 ; y < h ; ++y ) { short rowbits = 0 ; short maskbits = 0 ; for ( int x = 0 ; x < w ; ++x ) { long pos = (y * w + x) * 3; unsigned char r = rgbBits[pos] ; unsigned char g = rgbBits[pos+1] ; unsigned char b = rgbBits[pos+2] ; if ( bHasMask && r==mr && g==mg && b==mb ) { // masked area, does not appear anywhere } else { if ( (int)r + (int)g + (int)b < 0x0200 ) { rowbits |= ( 1 << (15-x) ) ; } maskbits |= ( 1 << (15-x) ) ; } } cp->data[y] = rowbits ; cp->mask[y] = maskbits ; } if ( !bHasMask ) { memcpy( cp->mask , cp->data , sizeof( Bits16) ) ; } cp->hotSpot.h = hotSpotX ; cp->hotSpot.v = hotSpotY ; HUnlock( (Handle) M_CURSORDATA->m_hCursor ) ; #else PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap)) ; short extent = 16 ; short bytesPerPixel = 1 ; short depth = 8 ; Rect bounds = { 0 , 0 , extent , extent } ; CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ; CTabHandle newColors = GetCTable( 8 ) ; HandToHand((Handle *) &newColors); // set the values to the indices for ( int i = 0 ; i < (**newColors).ctSize ; ++i ) { (**newColors).ctTable[i].value = i ; } HLock( (Handle) ch) ; (**ch).crsrType = 0x8001 ; // color cursors (**ch).crsrMap = pm ; short bytesPerRow = bytesPerPixel * extent ; (**pm).baseAddr = 0; (**pm).rowBytes = bytesPerRow | 0x8000; (**pm).bounds = bounds; (**pm).pmVersion = 0; (**pm).packType = 0; (**pm).packSize = 0; (**pm).hRes = 0x00480000; /* 72 DPI default res */ (**pm).vRes = 0x00480000; /* 72 DPI default res */ (**pm).pixelSize = depth; (**pm).pixelType = 0; (**pm).cmpCount = 1; (**pm).cmpSize = depth; (**pm).pmTable = newColors; (**ch).crsrData = NewHandleClear( extent * bytesPerRow ) ; (**ch).crsrXData = NULL ; (**ch).crsrXValid = 0; (**ch).crsrXHandle = NULL; (**ch).crsrHotSpot.h = hotSpotX ; (**ch).crsrHotSpot.v = hotSpotY ; (**ch).crsrXTable = NULL ; (**ch).crsrID = GetCTSeed() ; memset( (**ch).crsr1Data , 0 , sizeof( Bits16 ) ) ; memset( (**ch).crsrMask , 0 , sizeof( Bits16 ) ) ; unsigned char mr = image16.GetMaskRed() ; unsigned char mg = image16.GetMaskGreen() ; unsigned char mb = image16.GetMaskBlue() ; for ( int y = 0 ; y < h ; ++y ) { short rowbits = 0 ; short maskbits = 0 ; for ( int x = 0 ; x < w ; ++x ) { long pos = (y * w + x) * 3; unsigned char r = rgbBits[pos] ; unsigned char g = rgbBits[pos+1] ; unsigned char b = rgbBits[pos+2] ; RGBColor col = { 0xFFFF ,0xFFFF, 0xFFFF } ; if ( bHasMask && r==mr && g==mg && b==mb ) { // masked area, does not appear anywhere } else { if ( (int)r + (int)g + (int)b < 0x0200 ) { rowbits |= ( 1 << (15-x) ) ; } maskbits |= ( 1 << (15-x) ) ; col = *((RGBColor*) wxColor( r , g , b ).GetPixel()) ; } *((*(**ch).crsrData) + y * bytesPerRow + x) = GetCTabIndex( newColors , &col) ; } (**ch).crsr1Data[y] = rowbits ; (**ch).crsrMask[y] = maskbits ; } if ( !bHasMask ) { memcpy( (**ch).crsrMask , (**ch).crsr1Data , sizeof( Bits16) ) ; } HUnlock((Handle) ch) ; M_CURSORDATA->m_hCursor = ch ; M_CURSORDATA->m_isColorCursor = true ; #endif }
/* * Constructs a Smilies which is a child of 'parent', with the * name 'name' and widget flags set to 'f' */ Smilies::Smilies( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QPixmap image0( SmallIcon("face_smile") ); QPixmap image1( SmallIcon("face_angel") ); QPixmap image2( SmallIcon("face_embarrassed") ); QPixmap image3( SmallIcon("face_yell") ); QPixmap image4( SmallIcon("face_wink") ); QPixmap image5( SmallIcon("face_glasses") ); QPixmap image6( SmallIcon("face_moneymouth") ); QPixmap image7( SmallIcon("face_crossedlips") ); QPixmap image8( SmallIcon("face_sad") ); QPixmap image9( SmallIcon("face_scream") ); QPixmap image10( SmallIcon("face_cry") ); QPixmap image11( SmallIcon("face_burp") ); QPixmap image12( SmallIcon("face_kiss") ); QPixmap image13( SmallIcon("face_think") ); QPixmap image14( SmallIcon("face_tongue") ); QPixmap image15( SmallIcon("face_luke") ); QPixmap image16( SmallIcon("face_bigsmile") ); QPixmap image17( SmallIcon("face_oneeye") ); if ( !name ) setName( "Smilies" ); resize( 124, 139 ); setCaption( tr( "kaim-smiles" ) ); SmiliesLayout = new QGridLayout( this ); SmiliesLayout->setSpacing( 0 ); SmiliesLayout->setMargin( 0 ); smile = new QToolButton( this, "smile" ); smile->setText( tr( " " ) ); smile->setPixmap( image0 ); SmiliesLayout->addWidget( smile, 0, 0 ); angel = new QToolButton( this, "angel" ); angel->setText( tr( " " ) ); angel->setPixmap( image1 ); SmiliesLayout->addWidget( angel, 2, 3 ); embarrassed = new QToolButton( this, "embarrassed" ); embarrassed->setText( tr( " " ) ); embarrassed->setPixmap( image2 ); SmiliesLayout->addWidget( embarrassed, 2, 2 ); yell = new QToolButton( this, "yell" ); yell->setText( tr( " " ) ); yell->setPixmap( image3 ); SmiliesLayout->addWidget( yell, 1, 2 ); wink = new QToolButton( this, "wink" ); wink->setText( tr( " " ) ); wink->setPixmap( image4 ); SmiliesLayout->addWidget( wink, 0, 3 ); glasses = new QToolButton( this, "glasses" ); glasses->setText( tr( " " ) ); glasses->setPixmap( image5 ); SmiliesLayout->addWidget( glasses, 2, 0 ); moneymouth = new QToolButton( this, "moneymouth" ); moneymouth->setText( tr( " " ) ); moneymouth->setPixmap( image6 ); SmiliesLayout->addWidget( moneymouth, 3, 3 ); crossedlips = new QToolButton( this, "crossedlips" ); crossedlips->setText( tr( " " ) ); crossedlips->setPixmap( image7 ); SmiliesLayout->addWidget( crossedlips, 3, 2 ); sad = new QToolButton( this, "sad" ); sad->setText( tr( " " ) ); sad->setPixmap( image8 ); SmiliesLayout->addWidget( sad, 0, 2 ); scream = new QToolButton( this, "scream" ); scream->setText( tr( " " ) ); scream->setPixmap( image9 ); SmiliesLayout->addWidget( scream, 1, 1 ); cry = new QToolButton( this, "cry" ); cry->setText( tr( " " ) ); cry->setPixmap( image10 ); SmiliesLayout->addWidget( cry, 3, 1 ); burp = new QToolButton( this, "burp" ); burp->setText( tr( " " ) ); burp->setPixmap( image11 ); SmiliesLayout->addWidget( burp, 2, 1 ); kiss = new QToolButton( this, "kiss" ); kiss->setText( tr( " " ) ); kiss->setPixmap( image12 ); SmiliesLayout->addWidget( kiss, 1, 3 ); think = new QToolButton( this, "think" ); think->setText( tr( " " ) ); think->setPixmap( image13 ); SmiliesLayout->addWidget( think, 3, 0 ); tongue = new QToolButton( this, "tongue" ); tongue->setText( tr( " " ) ); tongue->setPixmap( image14 ); SmiliesLayout->addWidget( tongue, 1, 0 ); luke = new QToolButton( this, "luke" ); luke->setText( tr( " " ) ); luke->setPixmap( image15 ); SmiliesLayout->addWidget( luke, 4, 2 ); bigsmile = new QToolButton( this, "bigsmile" ); bigsmile->setText( tr( " " ) ); bigsmile->setPixmap( image16 ); SmiliesLayout->addWidget( bigsmile, 0, 1 ); oneeye = new QToolButton( this, "oneeye" ); oneeye->setText( tr( " " ) ); oneeye->setPixmap( image17 ); SmiliesLayout->addWidget( oneeye, 4, 1 ); QObject::connect( smile, SIGNAL(clicked()), SLOT(smileClicked()) ); QObject::connect( angel, SIGNAL(clicked()), SLOT(angelClicked()) ); QObject::connect( embarrassed, SIGNAL(clicked()), SLOT(embarrassedClicked()) ); QObject::connect( yell, SIGNAL(clicked()), SLOT(yellClicked()) ); QObject::connect( wink, SIGNAL(clicked()), SLOT(winkClicked()) ); QObject::connect( glasses, SIGNAL(clicked()), SLOT(glassesClicked()) ); QObject::connect( moneymouth, SIGNAL(clicked()), SLOT(moneymouthClicked()) ); QObject::connect( crossedlips, SIGNAL(clicked()), SLOT(crossedlipsClicked()) ); QObject::connect( sad, SIGNAL(clicked()), SLOT(sadClicked()) ); QObject::connect( scream, SIGNAL(clicked()), SLOT(screamClicked()) ); QObject::connect( cry, SIGNAL(clicked()), SLOT(cryClicked()) ); QObject::connect( burp, SIGNAL(clicked()), SLOT(burpClicked()) ); QObject::connect( kiss, SIGNAL(clicked()), SLOT(kissClicked()) ); QObject::connect( think, SIGNAL(clicked()), SLOT(thinkClicked()) ); QObject::connect( tongue, SIGNAL(clicked()), SLOT(tongueClicked()) ); QObject::connect( luke, SIGNAL(clicked()), SLOT(lukeClicked()) ); QObject::connect( bigsmile, SIGNAL(clicked()), SLOT(bigsmileClicked()) ); QObject::connect( oneeye, SIGNAL(clicked()), SLOT(oneeyeClicked()) ); }