本文整理汇总了C++中OSFactory::createOSGraphics方法的典型用法代码示例。如果您正苦于以下问题:C++ OSFactory::createOSGraphics方法的具体用法?C++ OSFactory::createOSGraphics怎么用?C++ OSFactory::createOSGraphics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSFactory
的用法示例。
在下文中一共展示了OSFactory::createOSGraphics方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CtrlGeneric
CtrlButton::CtrlButton( intf_thread_t *pIntf, const GenericBitmap &rBmpUp,
const GenericBitmap &rBmpOver,
const GenericBitmap &rBmpDown, CmdGeneric &rCommand,
const UString &rTooltip, const UString &rHelp,
VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rCommand( rCommand ), m_tooltip( rTooltip ),
m_cmdUpOverDownOver( this, &transUpOverDownOver ),
m_cmdDownOverUpOver( this, &transDownOverUpOver ),
m_cmdDownOverDown( this, &transDownOverDown ),
m_cmdDownDownOver( this, &transDownDownOver ),
m_cmdUpOverUp( this, &transUpOverUp ),
m_cmdUpUpOver( this, &transUpUpOver ),
m_cmdDownUp( this, &transDownUp ),
m_cmdUpHidden( this, &transUpHidden ),
m_cmdHiddenUp( this, &transHiddenUp )
{
// Build the images of the button
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pImgUp = pOsFactory->createOSGraphics( rBmpUp.getWidth(),
rBmpUp.getHeight() );
m_pImgUp->drawBitmap( rBmpUp, 0, 0 );
m_pImgDown = pOsFactory->createOSGraphics( rBmpDown.getWidth(),
rBmpDown.getHeight() );
m_pImgDown->drawBitmap( rBmpDown, 0, 0 );
m_pImgOver = pOsFactory->createOSGraphics( rBmpOver.getWidth(),
rBmpOver.getHeight() );
m_pImgOver->drawBitmap( rBmpOver, 0, 0 );
// States
m_fsm.addState( "up" );
m_fsm.addState( "down" );
m_fsm.addState( "upOver" );
m_fsm.addState( "downOver" );
m_fsm.addState( "hidden" );
// Transitions
m_fsm.addTransition( "upOver", "mouse:left:down", "downOver",
&m_cmdUpOverDownOver );
m_fsm.addTransition( "upOver", "mouse:left:dblclick", "downOver",
&m_cmdUpOverDownOver );
m_fsm.addTransition( "downOver", "mouse:left:up", "upOver",
&m_cmdDownOverUpOver );
m_fsm.addTransition( "downOver", "leave", "down", &m_cmdDownOverDown );
m_fsm.addTransition( "down", "enter", "downOver", &m_cmdDownDownOver );
m_fsm.addTransition( "upOver", "leave", "up", &m_cmdUpOverUp );
m_fsm.addTransition( "up", "enter", "upOver", &m_cmdUpUpOver );
m_fsm.addTransition( "down", "mouse:left:up", "up", &m_cmdDownUp );
// XXX: It would be easy to use a "ANY" initial state to handle these
// four lines in only one. But till now it isn't worthwhile...
m_fsm.addTransition( "up", "special:hide", "hidden", &m_cmdUpHidden );
m_fsm.addTransition( "down", "special:hide", "hidden", &m_cmdUpHidden );
m_fsm.addTransition( "upOver", "special:hide", "hidden", &m_cmdUpHidden );
m_fsm.addTransition( "downOver", "special:hide", "hidden", &m_cmdUpHidden );
m_fsm.addTransition( "hidden", "special:show", "up", &m_cmdHiddenUp );
// Initial state
m_fsm.setState( "up" );
m_pImg = m_pImgUp;
}
示例2: CtrlGeneric
CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
const GenericBitmap &rBmpUp,
const GenericBitmap &rBmpOver,
const GenericBitmap &rBmpDown,
const Bezier &rCurve,
VarPercent &rVariable,
VarBool *pVisible,
const UString &rTooltip,
const UString &rHelp ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rVariable( rVariable ), m_tooltip( rTooltip ),
m_width( rCurve.getWidth() ), m_height( rCurve.getHeight() ),
m_cmdOverDown( this, &transOverDown ),
m_cmdDownOver( this, &transDownOver ), m_cmdOverUp( this, &transOverUp ),
m_cmdUpOver( this, &transUpOver ), m_cmdMove( this, &transMove ),
m_cmdScroll( this, &transScroll ),
m_lastPercentage( 0 ), m_xOffset( 0 ), m_yOffset( 0 ),
m_pEvt( NULL ), m_rCurve( rCurve )
{
// Build the images of the cursor
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImgUp = pOsFactory->createOSGraphics( rBmpUp.getWidth(),
rBmpUp.getHeight() );
m_pImgUp->drawBitmap( rBmpUp, 0, 0 );
m_pImgDown = pOsFactory->createOSGraphics( rBmpDown.getWidth(),
rBmpDown.getHeight() );
m_pImgDown->drawBitmap( rBmpDown, 0, 0 );
m_pImgOver = pOsFactory->createOSGraphics( rBmpOver.getWidth(),
rBmpOver.getHeight() );
m_pImgOver->drawBitmap( rBmpOver, 0, 0 );
// States
m_fsm.addState( "up" );
m_fsm.addState( "over" );
m_fsm.addState( "down" );
// Transitions
m_fsm.addTransition( "over", "mouse:left:down", "down",
&m_cmdOverDown );
m_fsm.addTransition( "down", "mouse:left:up", "over",
&m_cmdDownOver );
m_fsm.addTransition( "over", "leave", "up", &m_cmdOverUp );
m_fsm.addTransition( "up", "enter", "over", &m_cmdUpOver );
m_fsm.addTransition( "down", "motion", "down", &m_cmdMove );
m_fsm.addTransition( "over", "scroll", "over", &m_cmdScroll );
// Initial state
m_fsm.setState( "up" );
m_pImg = m_pImgUp;
// Observe the position variable
m_rVariable.addObserver( this );
// Initial position of the cursor
m_lastPercentage = m_rVariable.get();
}
示例3: CtrlGeneric
CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
const GenericBitmap &rBmpSeq, int numImg,
VarPercent &rVariable, float minAngle,
float maxAngle, const UString &rHelp,
VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_numImg( numImg ),
m_rVariable( rVariable ), m_minAngle( minAngle ), m_maxAngle( maxAngle ),
m_cmdUpDown( this ), m_cmdDownUp( this ),
m_cmdMove( this )
{
// Build the images of the sequence
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImgSeq = pOsFactory->createOSGraphics( rBmpSeq.getWidth(),
rBmpSeq.getHeight() );
m_pImgSeq->drawBitmap( rBmpSeq, 0, 0 );
m_width = rBmpSeq.getWidth();
m_height = rBmpSeq.getHeight() / numImg;
// States
m_fsm.addState( "up" );
m_fsm.addState( "down" );
// Transitions
m_fsm.addTransition( "up", "mouse:left:down", "down", &m_cmdUpDown );
m_fsm.addTransition( "down", "mouse:left:up", "up", &m_cmdDownUp );
m_fsm.addTransition( "down", "motion", "down", &m_cmdMove );
// Initial state
m_fsm.setState( "up" );
// Observe the variable
m_rVariable.addObserver( this );
}
示例4: CtrlFlat
CtrlImage::CtrlImage( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
CmdGeneric &rCommand, resize_t resizeMethod,
const UString &rHelp, VarBool *pVisible ):
CtrlFlat( pIntf, rHelp, pVisible ), m_rBitmap( rBitmap ),
m_rCommand( rCommand ), m_resizeMethod( resizeMethod )
{
OSFactory *pOsFactory = OSFactory::instance( pIntf );
// Create an initial unscaled image in the buffer
m_pImage = pOsFactory->createOSGraphics( rBitmap.getWidth(),
rBitmap.getHeight() );
m_pImage->drawBitmap( m_rBitmap );
}
示例5: draw
void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest )
{
const Position *pPos = getPosition();
if( pPos )
{
int width = pPos->getWidth();
int height = pPos->getHeight();
if( m_resizeMethod == kScale )
{
// Use scaling method
if( width > 0 && height > 0 )
{
if( width != m_pImage->getWidth() ||
height != m_pImage->getHeight() )
{
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Rescale the image with the actual size of the control
ScaledBitmap bmp( getIntf(), m_rBitmap, width, height );
SKINS_DELETE( m_pImage );
m_pImage = pOsFactory->createOSGraphics( width, height );
m_pImage->drawBitmap( bmp, 0, 0 );
}
rImage.drawGraphics( *m_pImage, 0, 0, xDest, yDest );
}
}
else
{
// Use mosaic method
while( width > 0 )
{
int curWidth = __MIN( width, m_pImage->getWidth() );
height = pPos->getHeight();
int curYDest = yDest;
while( height > 0 )
{
int curHeight = __MIN( height, m_pImage->getHeight() );
rImage.drawGraphics( *m_pImage, 0, 0, xDest, curYDest,
curWidth, curHeight );
curYDest += curHeight;
height -= m_pImage->getHeight();
}
xDest += curWidth;
width -= m_pImage->getWidth();
}
}
}
}
示例6: SkinObject
AnimBitmap::AnimBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap ):
SkinObject( pIntf ), m_pImage( NULL ), m_curFrame( 0 ), m_pTimer( NULL ),
m_cmdNextFrame( this ), m_rBitmap( rBitmap )
{
// Build the graphics
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pImage = pOsFactory->createOSGraphics( rBitmap.getWidth(),
rBitmap.getHeight() );
m_pImage->drawBitmap( rBitmap, 0, 0 );
m_nbFrames = rBitmap.getNbFrames();
m_frameRate = rBitmap.getFrameRate();
// Create the timer
m_pTimer = pOsFactory->createOSTimer( m_cmdNextFrame );
}
示例7: resize
void VoutWindow::resize( int width, int height )
{
// Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Recreate the image
if( m_pImage )
{
delete m_pImage;
}
m_pImage = pOsFactory->createOSGraphics( width, height );
// Draw a black rectangle
m_pImage->fillRect( 0, 0, width, height, 0 );
// Resize the window
GenericWindow::resize( width, height );
}
示例8: getIntf
const OSGraphics *GenericBitmap::getGraphics() const
{
if( m_pGraphics )
return m_pGraphics;
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
int width = getWidth();
int height = getHeight();
if( width > 0 && height > 0 )
{
m_pGraphics = pOsFactory->createOSGraphics( width, height );
m_pGraphics->drawBitmap( *this, 0, 0 );
return m_pGraphics;
}
msg_Err( getIntf(), "failed to create a graphics, please report" );
return NULL;
}
示例9: resize
void GenericLayout::resize( int width, int height )
{
// check real resize
if( width == m_rect.getWidth() && height == m_rect.getHeight() )
return;
// Update the window size
m_rect = SkinsRect( 0, 0 , width, height );
// Recreate a new image
if( m_pImage )
{
delete m_pImage;
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImage = pOsFactory->createOSGraphics( width, height );
}
// Notify all the controls that the size has changed and redraw them
std::list<LayeredControl>::const_iterator iter;
for( iter = m_controlList.begin(); iter != m_controlList.end(); ++iter )
{
iter->m_pControl->onResize();
}
}
示例10: draw
void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest, int w, int h )
{
const Position *pPos = getPosition();
if( !pPos )
return;
int width = pPos->getWidth();
int height = pPos->getHeight();
if( width <= 0 || height <= 0 )
return;
rect region( pPos->getLeft(), pPos->getTop(),
pPos->getWidth(), pPos->getHeight() );
rect clip( xDest, yDest, w, h );
rect inter;
if( !rect::intersect( region, clip, &inter ) )
return;
if( m_resizeMethod == kScale )
{
// Use scaling method
if( width != m_pImage->getWidth() ||
height != m_pImage->getHeight() )
{
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
// Rescale the image with the actual size of the control
ScaledBitmap bmp( getIntf(), *m_pBitmap, width, height );
delete m_pImage;
m_pImage = pOsFactory->createOSGraphics( width, height );
m_pImage->drawBitmap( bmp, 0, 0 );
}
rImage.drawGraphics( *m_pImage,
inter.x - pPos->getLeft(),
inter.y - pPos->getTop(),
inter.x, inter.y,
inter.width, inter.height );
}
else if( m_resizeMethod == kMosaic )
{
int xDest0 = pPos->getLeft();
int yDest0 = pPos->getTop();
// Use mosaic method
while( width > 0 )
{
int curWidth = __MIN( width, m_pImage->getWidth() );
height = pPos->getHeight();
int curYDest = yDest0;
while( height > 0 )
{
int curHeight = __MIN( height, m_pImage->getHeight() );
rect region1( xDest0, curYDest, curWidth, curHeight );
rect inter1;
if( rect::intersect( region1, clip, &inter1 ) )
{
rImage.drawGraphics( *m_pImage,
inter1.x - region1.x,
inter1.y - region1.y,
inter1.x, inter1.y,
inter1.width, inter1.height );
}
curYDest += curHeight;
height -= m_pImage->getHeight();
}
xDest0 += curWidth;
width -= m_pImage->getWidth();
}
}
else if( m_resizeMethod == kScaleAndRatioPreserved )
{
int w0 = m_pBitmap->getWidth();
int h0 = m_pBitmap->getHeight();
int scaled_height = width * h0 / w0;
int scaled_width = height * w0 / h0;
// new image scaled with aspect ratio preserved
// and centered inside the control boundaries
int w, h;
if( scaled_height > height )
{
w = scaled_width;
h = height;
m_x = ( width - w ) / 2;
m_y = 0;
}
else
{
w = width;
h = scaled_height;
m_x = 0;
m_y = ( height - h ) / 2;
}
// rescale the image if size changed
if( w != m_pImage->getWidth() ||
h != m_pImage->getHeight() )
{
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
ScaledBitmap bmp( getIntf(), *m_pBitmap, w, h );
//.........这里部分代码省略.........
示例11: makeImage
void CtrlTree::makeImage()
{
stats_TimerStart( getIntf(), "[Skins] Playlist image",
STATS_TIMER_SKINS_PLAYTREE_IMAGE );
delete m_pImage;
// Get the size of the control
const Position *pPos = getPosition();
if( !pPos )
{
stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
return;
}
int width = pPos->getWidth();
int height = pPos->getHeight();
int i_itemHeight = itemHeight();
// Create an image
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImage = pOsFactory->createOSGraphics( width, height );
VarTree::Iterator it = m_firstPos;
if( m_pBgBitmap )
{
// Draw the background bitmap
if( !m_pScaledBitmap ||
m_pScaledBitmap->getWidth() != width ||
m_pScaledBitmap->getHeight() != height )
{
delete m_pScaledBitmap;
m_pScaledBitmap =
new ScaledBitmap( getIntf(), *m_pBgBitmap, width, height );
}
m_pImage->drawBitmap( *m_pScaledBitmap, 0, 0 );
for( int yPos = 0; yPos < height; yPos += i_itemHeight )
{
if( it != m_rTree.end() )
{
if( it->isSelected() )
{
int rectHeight = __MIN( i_itemHeight, height - yPos );
m_pImage->fillRect( 0, yPos, width, rectHeight,
m_selColor );
}
do
{
it = m_flat ? m_rTree.getNextLeaf( it )
: m_rTree.getNextVisibleItem( it );
} while( it != m_rTree.end() && it->isDeleted() );
}
}
}
else
{
// FIXME (TRYME)
// Fill background with background color
uint32_t bgColor = m_bgColor1;
m_pImage->fillRect( 0, 0, width, height, bgColor );
for( int yPos = 0; yPos < height; yPos += i_itemHeight )
{
int rectHeight = __MIN( i_itemHeight, height - yPos );
if( it == m_rTree.end() )
m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
else
{
uint32_t color = ( it->isSelected() ? m_selColor : bgColor );
m_pImage->fillRect( 0, yPos, width, rectHeight, color );
do
{
it = m_flat ? m_rTree.getNextLeaf( it )
: m_rTree.getNextVisibleItem( it );
} while( it != m_rTree.end() && it->isDeleted() );
}
bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
}
}
int bitmapWidth = itemImageWidth();
int yPos = 0;
it = m_firstPos;
while( it != m_rTree.end() && yPos < height )
{
const GenericBitmap *m_pCurBitmap;
UString *pStr = it->getString();
uint32_t color = ( it->isPlaying() ? m_playColor : m_fgColor );
// Draw the text
if( pStr != NULL )
{
int depth = m_flat ? 1 : it->depth();
GenericBitmap *pText = m_rFont.drawString( *pStr, color, width - bitmapWidth * depth );
if( !pText )
{
stats_TimerStop( getIntf(), STATS_TIMER_SKINS_PLAYTREE_IMAGE );
return;
}
//.........这里部分代码省略.........
示例12: makeImage
void CtrlList::makeImage()
{
delete m_pImage;
// Get the size of the control
const Position *pPos = getPosition();
if( !pPos )
{
return;
}
int width = pPos->getWidth();
int height = pPos->getHeight();
int itemHeight = m_rFont.getSize() + LINE_INTERVAL;
// Create an image
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImage = pOsFactory->createOSGraphics( width, height );
VarList::ConstIterator it = m_rList[m_lastPos];
// Draw the background
if( m_pBitmap )
{
// A background bitmap is given, so we scale it, ignoring the
// background colors
ScaledBitmap bmp( getIntf(), *m_pBitmap, width, height );
m_pImage->drawBitmap( bmp, 0, 0 );
// Take care of the selection color
for( int yPos = 0; yPos < height; yPos += itemHeight )
{
int rectHeight = __MIN( itemHeight, height - yPos );
if( it != m_rList.end() )
{
if( (*it).m_selected )
{
m_pImage->fillRect( 0, yPos, width, rectHeight,
m_selColor );
}
++it;
}
}
}
else
{
// No background bitmap, so use the 2 background colors
// Current background color
uint32_t bgColor = m_bgColor1;
for( int yPos = 0; yPos < height; yPos += itemHeight )
{
int rectHeight = __MIN( itemHeight, height - yPos );
if( it != m_rList.end() )
{
uint32_t color = ( (*it).m_selected ? m_selColor : bgColor );
m_pImage->fillRect( 0, yPos, width, rectHeight, color );
++it;
}
else
{
m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
}
// Flip the background color
bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
}
}
// Draw the items
int yPos = 0;
for( it = m_rList[m_lastPos]; it != m_rList.end() && yPos < height; ++it )
{
UString *pStr = (UString*)(it->m_cString.get());
uint32_t color = ( it->m_playing ? m_playColor : m_fgColor );
// Draw the text
GenericBitmap *pText = m_rFont.drawString( *pStr, color, width );
if( !pText )
{
return;
}
yPos += itemHeight - pText->getHeight();
int ySrc = 0;
if( yPos < 0 )
{
ySrc = - yPos;
yPos = 0;
}
int lineHeight = __MIN( pText->getHeight() - ySrc, height - yPos );
m_pImage->drawBitmap( *pText, 0, ySrc, 0, yPos, pText->getWidth(),
lineHeight, true );
yPos += (pText->getHeight() - ySrc );
delete pText;
}
}
示例13: makeImage
void CtrlTree::makeImage()
{
delete m_pImage;
// Get the size of the control
const Position *pPos = getPosition();
if( !pPos )
return;
int width = pPos->getWidth();
int height = pPos->getHeight();
int i_itemHeight = itemHeight();
// Create an image
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImage = pOsFactory->createOSGraphics( width, height );
Iterator it = m_firstPos;
if( m_pBgBitmap )
{
// Draw the background bitmap
if( !m_pScaledBitmap ||
m_pScaledBitmap->getWidth() != width ||
m_pScaledBitmap->getHeight() != height )
{
delete m_pScaledBitmap;
m_pScaledBitmap =
new ScaledBitmap( getIntf(), *m_pBgBitmap, width, height );
}
m_pImage->drawBitmap( *m_pScaledBitmap, 0, 0 );
for( int yPos = 0;
yPos < height && it != m_rTree.end();
yPos += i_itemHeight, ++it )
{
if( it->isSelected() )
{
int rectHeight = __MIN( i_itemHeight, height - yPos );
m_pImage->fillRect( 0, yPos, width, rectHeight, m_selColor );
}
}
}
else
{
// Fill background with background color
uint32_t bgColor = m_bgColor1;
m_pImage->fillRect( 0, 0, width, height, bgColor );
// Overwrite with alternate colors (bgColor1, bgColor2)
for( int yPos = 0; yPos < height; yPos += i_itemHeight )
{
int rectHeight = __MIN( i_itemHeight, height - yPos );
if( it == m_rTree.end() )
m_pImage->fillRect( 0, yPos, width, rectHeight, bgColor );
else
{
uint32_t color = ( it->isSelected() ? m_selColor : bgColor );
m_pImage->fillRect( 0, yPos, width, rectHeight, color );
++it;
}
bgColor = ( bgColor == m_bgColor1 ? m_bgColor2 : m_bgColor1 );
}
}
int bitmapWidth = itemImageWidth();
it = m_firstPos;
for( int yPos = 0; yPos < height && it != m_rTree.end(); ++it )
{
const GenericBitmap *m_pCurBitmap;
UString *pStr = it->getString();
if( pStr != NULL )
{
uint32_t color = it->isPlaying() ? m_playColor : m_fgColor;
int depth = m_flat ? 1 : it->depth();
GenericBitmap *pText =
m_rFont.drawString( *pStr, color, width-bitmapWidth*depth );
if( !pText )
{
return;
}
if( it->size() )
m_pCurBitmap =
it->isExpanded() ? m_pOpenBitmap : m_pClosedBitmap;
else
m_pCurBitmap = m_pItemBitmap;
if( m_pCurBitmap )
{
// Make sure we are centered on the line
int yPos2 = yPos+(i_itemHeight-m_pCurBitmap->getHeight()+1)/2;
if( yPos2 >= height )
{
delete pText;
break;
}
// Draw the icon in front of the text
m_pImage->drawBitmap( *m_pCurBitmap, 0, 0,
bitmapWidth * (depth - 1 ), yPos2,
m_pCurBitmap->getWidth(),
//.........这里部分代码省略.........