void DisplayFemaleGlowCursor( void ) { // this procdure will draw the activation string cursor on the screen at position cursorx cursory UINT32 uiDestPitchBYTES; static UINT32 uiBaseTime = 0; UINT32 uiDeltaTime = 0; static UINT32 iCurrentState = 0; static BOOLEAN fIncrement = TRUE; UINT8 *pDestBuf; if(uiBaseTime == 0) { uiBaseTime = GetJA2Clock(); } // get difference uiDeltaTime = GetJA2Clock() - uiBaseTime; // if difference is long enough, rotate colors if(uiDeltaTime > MIN_GLOW_DELTA) { if( iCurrentState == 10) { // start rotating downward fIncrement = FALSE; } if( iCurrentState == 0) { // rotate colors upward fIncrement = TRUE; } // if increment upward, increment iCurrentState if(fIncrement) { iCurrentState++; } else { // else downwards iCurrentState--; } // reset basetime to current clock uiBaseTime = GetJA2Clock( ); } pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, SCREEN_BUFFER_WIDTH, SCREEN_BUFFER_HEIGHT ); // draw rectangle RectangleDraw( TRUE, FEMALE_BOX_X, MALE_BOX_Y, FEMALE_BOX_X + MALE_BOX_WIDTH, MALE_BOX_Y + MALE_BOX_HEIGHT, Get16BPPColor( FROMRGB( GlowColorsList[ iCurrentState ][ 0 ], GlowColorsList[ iCurrentState ][ 1 ], GlowColorsList[ iCurrentState ][ 2 ] ) ), pDestBuf ); InvalidateRegion((UINT16) FEMALE_BOX_X, MALE_BOX_Y, FEMALE_BOX_X + MALE_BOX_WIDTH + 1, MALE_BOX_Y + MALE_BOX_HEIGHT + 1); // unlock frame buffer UnLockVideoSurface( FRAME_BUFFER ); return; }
void RenderPopupMenu() { UINT16 usX, usY; UINT8 ubColumn, ubEntry, ubCounter; UINT8 *pDestBuf; UINT32 uiDestPitchBYTES; UINT16 usLineColor; UINT16 usStringWidth; UINT16 usStart; //Draw the menu ColorFillVideoSurfaceArea(FRAME_BUFFER, gPopup.usLeft, gPopup.usTop, gPopup.usRight, gPopup.usBottom, Get16BPPColor(FROMRGB(128, 128, 128) ) ); pDestBuf = LockVideoSurface( FRAME_BUFFER, &uiDestPitchBYTES ); SetClippingRegionAndImageWidth( uiDestPitchBYTES, 0, 0, 640, 480 ); usLineColor = Get16BPPColor( FROMRGB( 64, 64, 64 ) ); RectangleDraw( TRUE, gPopup.usLeft, gPopup.usTop, gPopup.usRight, gPopup.usBottom, usLineColor, pDestBuf ); if( gPopup.ubColumns > 1 ) { //draw a vertical line between each column usStart = gPopup.usLeft + gPopup.ubColumnWidth[ 0 ]; for( ubColumn = 1; ubColumn < gPopup.ubColumns; ubColumn++ ) { LineDraw( TRUE, usStart, gPopup.usTop, usStart, gPopup.usBottom, usLineColor, pDestBuf ); } usStart += (UINT16)gPopup.ubColumnWidth[ ubColumn ]; } UnLockVideoSurface( FRAME_BUFFER ); //Set up the text attributes. SetFont( gPopup.usFont); SetFontBackground( FONT_MCOLOR_BLACK ); SetFontForeground( FONT_MCOLOR_WHITE ); usX = gPopup.usLeft + 1; ubCounter = 0; usStart = gPopup.usLeft; for( ubColumn = 0; ubColumn < gPopup.ubColumns; ubColumn++ ) { for( ubEntry = 0; ubEntry < gPopup.ubMaxEntriesPerColumn; ubEntry++ ) { if( ubCounter >= gPopup.ubNumEntries ) return; //done //Calc current string's width in pixels. Adding 14 pixels which is the width of //two padded gPopup.usFont spaces not stored in the string. usStringWidth = 14 + StringPixLength( GetPopupMenuString( ubCounter ), gPopup.usFont ); //Horizontally center the string inside the popup menu usX = usStart + ( gPopup.ubColumnWidth[ ubColumn ] - usStringWidth ) / 2; usY = gPopup.usTop + 1 + ubEntry * gusEntryHeight; if( ubCounter == gPopup.ubSelectedIndex - 1 ) { //This is the highlighted menu entry. SetFontForeground( FONT_MCOLOR_LTBLUE ); mprintf( usX, usY, L" %s ", GetPopupMenuString( ubCounter ) ); SetFontForeground( FONT_MCOLOR_WHITE ); } else { mprintf( usX, usY, L" %s ", GetPopupMenuString( ubCounter ) ); } ubCounter++; } usStart += gPopup.ubColumnWidth[ ubColumn ]; } }
void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int /*flags*/) { #if wxUSE_GRAPHICS_CONTEXT wxGCDC dc(*(wxMemoryDC*)hdc); wxColour penColour(wxColourFromCAandAlpha(outline, alphaOutline)); wxColour brushColour(wxColourFromCAandAlpha(fill, alphaFill)); dc.SetPen(wxPen(penColour)); dc.SetBrush(wxBrush(brushColour)); dc.DrawRoundedRectangle(wxRectFromPRectangle(rc), cornerSize); return; #else #ifdef wxHAVE_RAW_BITMAP // TODO: do something with cornerSize wxUnusedVar(cornerSize); int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); wxAlphaPixelData pixData(bmp); pixData.UseAlpha(); // Set the fill pixels ColourDesired cdf(fill.AsLong()); int red = cdf.GetRed(); int green = cdf.GetGreen(); int blue = cdf.GetBlue(); wxAlphaPixelData::Iterator p(pixData); for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); for (x=0; x<r.width; x++) { p.Red() = wxPy_premultiply(red, alphaFill); p.Green() = wxPy_premultiply(green, alphaFill); p.Blue() = wxPy_premultiply(blue, alphaFill); p.Alpha() = alphaFill; ++p; } } // Set the outline pixels ColourDesired cdo(outline.AsLong()); red = cdo.GetRed(); green = cdo.GetGreen(); blue = cdo.GetBlue(); for (x=0; x<r.width; x++) { p.MoveTo(pixData, x, 0); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; p.MoveTo(pixData, x, r.height-1); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; } for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; p.MoveTo(pixData, r.width-1, y); p.Red() = wxPy_premultiply(red, alphaOutline); p.Green() = wxPy_premultiply(green, alphaOutline); p.Blue() = wxPy_premultiply(blue, alphaOutline); p.Alpha() = alphaOutline; } // Draw the bitmap hdc->DrawBitmap(bmp, r.x, r.y, true); #else wxUnusedVar(cornerSize); wxUnusedVar(alphaFill); wxUnusedVar(alphaOutline); RectangleDraw(rc, outline, fill); #endif #endif }
void SurfaceImpl::AlphaRectangle (PRectangle rc, int cornerSize, ColourAllocated fill, int alphaFill, ColourAllocated outline, int alphaOutline, int WXUNUSED(flags)) { #ifdef wxHAVE_RAW_BITMAP wxUnusedVar(cornerSize); int x, y; wxRect r = wxRectFromPRectangle(rc); wxBitmap bmp(r.width, r.height, 32); wxAlphaPixelData pixData(bmp); pixData.UseAlpha(); wxAlphaPixelData::Iterator p(pixData); // Set the fill pixels ColourDesired cdf(fill.AsLong()); int red = cdf.GetRed(); int green = cdf.GetGreen(); int blue = cdf.GetBlue(); #ifdef __WXMSW__ int aFill = alphaFill; #else int aFill = 0xff; #endif for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); for (x=0; x<r.width; x++) { p.Red() = red * aFill / 0xff; p.Green() = green * aFill / 0xff; p.Blue() = blue * aFill / 0xff; p.Alpha() = alphaFill; ++p; } } // Set the outline pixels ColourDesired cdo(outline.AsLong()); red = cdo.GetRed(); green = cdo.GetGreen(); blue = cdo.GetBlue(); #ifdef __WXMSW__ int aOutline = alphaOutline; #else int aOutline = 0xff; #endif for (x=0; x<r.width; x++) { p.MoveTo(pixData, x, 0); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; p.MoveTo(pixData, x, r.height-1); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; } for (y=0; y<r.height; y++) { p.MoveTo(pixData, 0, y); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; p.MoveTo(pixData, r.width-1, y); p.Red() = red * aOutline / 0xff; p.Green() = green * aOutline / 0xff; p.Blue() = blue * aOutline / 0xff; p.Alpha() = alphaOutline; } // Draw the bitmap hdc->DrawBitmap(bmp, r.x, r.y, true); #else wxUnusedVar(cornerSize); wxUnusedVar(alphaFill); wxUnusedVar(alphaOutline); RectangleDraw(rc, outline, fill); #endif }