////////////////////////////////////////////////////////////////////// // gfx_Direct3D8::CreatePalette() // Author: Logan "Burn" Jones /////////////////////////////////// Date: 10/8/2001 // //==================================================================== // Parameters: // PALETTEENTRY* pPaletteEntries - // LPPALETTE* ppPalette - // BOOL bSetAsCurrent - // // Return: BOOL - // BOOL gfx_Direct3D8::CreatePalette( PALETTEENTRY* pPaletteEntries, LPPALETTE* ppPalette, BOOL bSetAsCurrent ) { Palette_t newPal; // Copy the entries and the new index memcpy( newPal.Entries, pPaletteEntries, sizeof(PALETTEENTRY) * 256 ); newPal.Index = m_NumPalettes; // Copy the entries to the D3D palette index if( FAILED(m_pD3DDevice->SetPaletteEntries( m_NumPalettes, newPal.Entries )) ) { ErrorComment( "Failed to set palette entries." ); return FALSE; } // Add the structure to the list m_Palettes.push_front( newPal ); (*ppPalette) = &m_Palettes.front(); m_NumPalettes++; // Set the new palette as the current one if desired if( bSetAsCurrent ) return SetCurrentPalette( *ppPalette ); return TRUE; }
void WMFUpdateState::SelectObject(int nIndex) { ASSERT(nIndex < m_cpaGdiObjects.GetSize()); if (nIndex != -1 && nIndex < m_cpaGdiObjects.GetSize()) { CWMFGdiObject* pObject = (CWMFGdiObject*)m_cpaGdiObjects.GetAt(nIndex); ASSERT(pObject != NULL); if (pObject != NULL) { // We have an object. switch (pObject->m_nType) { case CWMFGdiObject::Brush: { m_DCState.m_nCurrentBrush = nIndex; CWMFBrushObject* pBrush = (CWMFBrushObject*)pObject; // Handle the interior style. switch (pBrush->m_LogBrush.lbStyle) { case BS_NULL: { set_interior_style(STYLE_Empty); break; } case BS_HATCHED: { set_interior_style(STYLE_Hatch); // set_hatch_index(?); break; } case BS_PATTERN: { set_interior_style(STYLE_Pattern); break; } default: case BS_SOLID: { set_interior_style(STYLE_Solid); break; } } // Handle the interior color. set_fill_color(RGBToOutlineColor(pBrush->m_LogBrush.lbColor)); break; } case CWMFGdiObject::Pen: { m_DCState.m_nCurrentPen = nIndex; CWMFPenObject* pPen = (CWMFPenObject*)pObject; // Handle the edge visibility. set_edge_visibility(pPen->m_LogPen.lopnStyle != PS_NULL); // Handle the line/edge color. OUTLINE_COLOR Color = RGBToOutlineColor(pPen->m_LogPen.lopnColor); set_line_color(Color); set_edge_color(Color); // TRACE("Select Pen - Style: %u; Width: %d, %d; Color: %08lx\n", // pPen->m_LogPen.lopnStyle, // pPen->m_LogPen.lopnWidth.x, // pPen->m_LogPen.lopnWidth.y, // pPen->m_LogPen.lopnColor); // Handle the line/edge width. int nWidth = (pPen->m_LogPen.lopnWidth.y > pPen->m_LogPen.lopnWidth.x) ? pPen->m_LogPen.lopnWidth.y : pPen->m_LogPen.lopnWidth.x; set_edge_width((short)nWidth); set_line_width((short)nWidth); break; } case CWMFGdiObject::Font: { m_DCState.m_nCurrentFont = nIndex; SetCurrentFont(((CWMFFontObject*)pObject)->m_LogFont); break; } case CWMFGdiObject::Palette: { m_DCState.m_nCurrentPalette = nIndex; SetCurrentPalette(((CWMFPaletteObject*)pObject)->m_pPalette); break; } default: { // Invalid GDI object type. ASSERT(FALSE); break; } } } } }