예제 #1
0
/*****************************************************************
 * 
 * method :void		WritePageHeader(CRect inRect)
 *
 * parameters : 
 *
 * returns : 
 *
 * description: Write the default page header. By default, this
 * contains the report title (centered) and date field, 
 * right aligned
 *
 ****************************************************************/
void	CEasyReport::WritePageHeader(CRect inRect)
{
	CRect		aRect(inRect);
	CTextBox	*aBox;

	aRect.bottom = aRect.top + GetHeadingFontSize().cy;
	aBox = new CTextBox(&aRect,m_ReportTitle,eColHeadingFont);
	aBox->SetDocPtr(this);
	m_ReportItems.Add(aBox);

	// make a text area 1/4 of the page width
	aRect.right = inRect.right;
	aRect.left = inRect.right - inRect.Width()/4;
	aBox = new CTextBox(&aRect, m_ReportDate, eColHeadingFont, DT_LEFT);
	aBox->SetDocPtr(this);
	m_ReportItems.Add(aBox);

	aRect.top = inRect.bottom-10;	// 1mm from the bottom
	aRect.bottom = inRect.bottom;
	aRect.left = inRect.left;
	aRect.right = inRect.right;
	CHline	*aLine = new CHline(&aRect,0);
	aLine->SetDocPtr(this);
	m_ReportItems.Add(aLine);
}
예제 #2
0
/*!
  \brief Draw the knob
  \param p painter
  \param r borders of the knob
*/
void QwtKnob::drawKnob(QPainter *p, const QRect &r)
{
    const int bw2 = d_borderWidth / 2;

    QRect aRect(r.x() + bw2, r.y() + bw2,
          r.width() - 2 * bw2, r.height() - 2 * bw2);

    //
    // draw button face
    //
    p->setBrush(colorGroup().brush(QColorGroup::Button));
    p->drawEllipse(aRect);

    //
    // draw button shades
    //
    QPen pn;
    pn.setWidth(d_borderWidth);

    pn.setColor(colorGroup().light());
    p->setPen(pn);
    p->drawArc(aRect, 45*16,180*16);

    pn.setColor(colorGroup().dark());
    p->setPen(pn);
    p->drawArc(aRect, 225*16,180*16);

    //
    // draw marker
    //
    if ( isValid() )
        drawMarker(p, d_angle, colorGroup().buttonText());
}
예제 #3
0
void CSketcherView::OnMouseMove(UINT nFlags, CPoint point)
{
  // TODO: 在此添加消息处理程序代码和/或调用默认值
  if (nFlags & MK_LBUTTON) {
    
    m_CalledTimes_OnMouseMove ++;

    CClientDC aDC(this);
    CRect aRect(m_StartPoint, m_EndPoint);

    switch (m_DrawTrigger) {
      case 1:
        m_DrawTrigger = 2;
        m_EndPoint = point;
        aRect.SetRect(m_StartPoint,m_EndPoint);
        aDC.Rectangle(aRect);
        break;

      case 2:
        aDC.SetROP2(R2_NOTXORPEN);
        aDC.Rectangle(aRect);
    
        m_EndPoint = point;
        aRect.SetRect(m_StartPoint, m_EndPoint);
        aDC.Rectangle(aRect); 
        break;

      default:
        break;
      }
  }
    
  CView::OnMouseMove(nFlags, point);
}
예제 #4
0
ArpAboutWindow::ArpAboutWindow(BWindow* inwin,
                               const char* appname, const char* verstr,
                               const char* build, const char* text)
    : BWindow(inwin ? inwin->Frame() : BScreen().Frame(), appname,
              B_MODAL_WINDOW_LOOK,
              B_NORMAL_WINDOW_FEEL,
              //inwin ? B_FLOATING_SUBSET_WINDOW_FEEL : B_FLOATING_APP_WINDOW_FEEL,
              B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS )
{
    if( inwin ) AddToSubset(inwin);

    ArpAboutView	*aView;
    // set up a rectangle and instantiate a new view
    BRect aRect( Bounds() );
    aView = new ArpAboutView(aRect, "AnimView", text,
                             appname, verstr, text);
    // add view to window
    AddChild(aView);

    BRect frm = Frame();
    float w=0, h=0;
    aView->GetPreferredSize(&w, &h);
    ResizeTo(w, h);
    BRect cfrm = Frame();
    ArpD(cdb << ADH << "Resized frame = " << cfrm << endl);
    MoveTo( frm.left
            + (frm.Width()-cfrm.Width())/2,
            frm.top
            + (frm.Height()-cfrm.Height())/2);
    ArpD(cdb << ADH << "Moved frame = " << Frame() << endl);
}
예제 #5
0
/*!
  \brief Draw the knob
  \param painter painter
  \param knobRect Bounding rectangle of the knob (without scale)
*/
void QwtKnob::drawKnob( QPainter *painter, 
    const QRectF &knobRect ) const
{
    double dim = qMin( knobRect.width(), knobRect.height() );
    dim -= d_data->borderWidth * 0.5;

    QRectF aRect( 0, 0, dim, dim );
    aRect.moveCenter( knobRect.center() );

    QPen pen( Qt::NoPen );
    if ( d_data->borderWidth > 0 )
    {
        QColor c1 = palette().color( QPalette::Light );
        QColor c2 = palette().color( QPalette::Dark );

        QLinearGradient gradient( aRect.topLeft(), aRect.bottomRight() );
        gradient.setColorAt( 0.0, c1 );
        gradient.setColorAt( 0.3, c1 );
        gradient.setColorAt( 0.7, c2 );
        gradient.setColorAt( 1.0, c2 );

        pen = QPen( gradient, d_data->borderWidth ); 
    }

    QBrush brush;
    switch( d_data->knobStyle )
    {
        case QwtKnob::Raised:
        {
            double off = 0.3 * knobRect.width();
            QRadialGradient gradient( knobRect.center(),
                knobRect.width(), knobRect.topLeft() + QPoint( off, off ) );
            
            gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) );
            gradient.setColorAt( 1.0, palette().color( QPalette::Button ) );

            brush = QBrush( gradient );

            break;
        }
        case QwtKnob::Sunken:
        {
            QLinearGradient gradient( 
                knobRect.topLeft(), knobRect.bottomRight() );
            gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) );
            gradient.setColorAt( 0.5, palette().color( QPalette::Button ) );
            gradient.setColorAt( 1.0, palette().color( QPalette::Midlight ) );
            brush = QBrush( gradient );

            break;
        }
        default:
            brush = palette().brush( QPalette::Button );
    }

    painter->setPen( pen );
    painter->setBrush( brush );
    painter->drawEllipse( aRect );
}
예제 #6
0
/*****************************************************************
 * 
 * method :void	CEasyReport::WritePageFooter(CRect inRect)
 *
 * parameters : 
 *
 * returns : 
 *
 * description: Write the page footer
 *
 ****************************************************************/
void	CEasyReport::WritePageFooter(CRect inRect)
{
	CRect	aRect(inRect);

	aRect.top = aRect.bottom = inRect.top +10;	// 1mm below 
	CHline	*aLine = new CHline(&aRect,0);
	aLine->SetDocPtr(this);
	m_ReportItems.Add(aLine);

	aRect.top += 10;	// 1mm
	aRect.bottom = aRect.top + GetHeadingFontSize().cy;
	CPageNum	*aPgNumField = new CPageNum(&aRect,eColHeadingFont);
	aPgNumField->SetDocPtr(this);
	m_ReportItems.Add(aPgNumField);
}
예제 #7
0
void CustomGrid::DrawRowLabel( wxDC& dc, int row )
{
    //init dc font and colours
    dc.SetFont( m_labelFont );
    dc.SetPen(GetDefaultGridLinePen());
	dc.SetBrush( wxBrush( m_labelBackgroundColour, wxBRUSHSTYLE_SOLID ) );
    int w = dc.GetTextExtent(_T("Speed")).x;
    wxString label1,label2;
    label1 = GetRowLabelValue(row).BeforeFirst(',', &label2);
    bool pline = true;
    //row is the first of 3 for the same parameter (wind ... waves ...)
    if(GetNumberRows() > row + 2 && label1 == GetRowLabelValue(row + 2).BeforeFirst(',')){
        pline = false;
        if(IsRowVisible(row + 2))
            label1 = _T(" ");
    }
    //row is the second of 3 or the first of 2
    else if(GetNumberRows() > row + 1 && label1 == GetRowLabelValue(row + 1).BeforeFirst(',')){
        pline = false;
        if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){    //second of 3
            if(!IsRowVisible(row + 1))
                label1 = _T(" ");
        }
    }
    //row is the last of 3
    else if(row > 1 && label1 == GetRowLabelValue(row - 2).BeforeFirst(',')){
        if(IsRowVisible(row - 1))
            label1 = _T(" ");
    }
    //row is the last of 2
    else if(row > 0 && label1 == GetRowLabelValue(row - 1).BeforeFirst(',')){
        if(IsRowVisible(row - 1))
            label1 = _T(" ");
    }
    //draw first part of the label
    wxRect aRect(5, GetRowTop(row), m_rowLabelWidth - w, GetRowHeight(row));
    dc.DrawLabel(label1, aRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
    //draw second part of the label
    wxRect bRect(m_rowLabelWidth - w, GetRowTop(row), w, GetRowHeight(row));
    dc.SetFont( wxFont(m_labelFont).Scale(0.85) );
    dc.DrawLabel(label2 , bRect, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL);
    //draw row lines around labels
    if(pline)
        dc.DrawLine(0, GetRowBottom(row) - 1, m_rowLabelWidth, GetRowBottom(row) - 1);
    dc.DrawLine(0, GetRowTop(row), 0, GetRowBottom(row) );
    dc.DrawLine(m_rowLabelWidth - 1, GetRowTop(row), m_rowLabelWidth - 1, GetRowBottom(row) );
}
예제 #8
0
bool World::checkCollision(std::weak_ptr<ICollideable> a, std::weak_ptr<ICollideable> b)
{
    sf::Vector2f a1 = a.lock()->getPhysicsPosition() + sf::Vector2f(a.lock()->getHitBox().left, a.lock()->getHitBox().top);
    sf::Vector2f a2 = sf::Vector2f(a.lock()->getHitBox().width, a.lock()->getHitBox().height);

    sf::Vector2f b1 = b.lock()->getPhysicsPosition() + sf::Vector2f(b.lock()->getHitBox().left, b.lock()->getHitBox().top);
    sf::Vector2f b2 = sf::Vector2f(b.lock()->getHitBox().width, b.lock()->getHitBox().height);

    //float rect = (left, top, width, height)
    sf::FloatRect aRect(a1, a2);
    sf::FloatRect bRect(b1, b2);

    if (aRect.intersects(bRect))
        return true;

    return false;
}
예제 #9
0
AwayEditorWindow::AwayEditorWindow( BRect frame )
	 				: SingleWindowBase(SW_AWAY_EDITOR, frame, "Away Message Editor",
	 				  B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE )
{
	// Set up the view
	BRect aRect( Bounds() );
	genView = new AwayEditorView( aRect );
	AddChild( genView );
	BuildList();
	
	// vars
	hasSelection = false;
	EnableMessageStuff(false);
	
	// prefs
	enterIsNewline = prefs->ReadBool( "EnterInsertsNewline", false );
	tabIsTab = prefs->ReadBool( "TabIsTab", false );	
	
	// load all the right language stuff
	RefreshLangStrings();
}
예제 #10
0
ScribbleWindow::ScribbleWindow() 
		: BWindow(BRect(100,100,300,400), "Scribble", B_TITLED_WINDOW, 0)
{
	BMenuBar *pMenuBar = new BMenuBar(BRect(), "Mainmenu");
	BMenu *pMenu = new BMenu("File");
	BMenuItem *pCloseItem = 
		new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED), 'q');	
	pMenu->AddItem(pCloseItem);
	pMenuBar->AddItem(pMenu);
	
	AddChild(pMenuBar);

	float menuHeight = pMenuBar->Bounds().Height();

	ScribbleView *aView;
	// set up a rectangle and instantiate a new view
	BRect aRect( Bounds() );
	aRect.top = aRect.top+menuHeight+1;
	aView = new ScribbleView(aRect);
	// add view to window
	AddChild(aView);
}
예제 #11
0
bool StGLFontEntry::renderGlyph(StGLContext&    theCtx,
                                const bool      theToDrawUndef,
                                const stUtf32_t theUChar,
                                const stUtf32_t theUCharNext,
                                StGLTile&       theGlyph,
                                StGLVec2&       thePen) {
    std::map<stUtf32_t, size_t>::const_iterator aTileIter = myGlyphMap->find(theUChar);
    size_t aTileId;
    if(aTileIter != myGlyphMap->end()) {
        aTileId = aTileIter->second;
    } else if(renderGlyph(theCtx, theUChar, false)) {
        aTileId = myLastTileId;
        (*myGlyphMap)[theUChar] = aTileId;
    } else if(!theToDrawUndef) {
        return false;
    } else {
        aTileIter = myGlyphMap->find(0);
        if(aTileIter != myGlyphMap->end()) {
            aTileId = aTileIter->second;
        } else if(renderGlyph(theCtx, theUChar, true)) {
            aTileId = myLastTileId;
            (*myGlyphMap)[theUChar] = aTileId;
        } else {
            thePen.x() += myFont->getAdvanceX(theUChar, theUCharNext);
            return false;
        }
    }

    const StGLTile& aTile = myTiles[aTileId];
    StGLRect aRect(thePen.y() + aTile.px.top(),  thePen.y() + aTile.px.bottom(),
                   thePen.x() + aTile.px.left(), thePen.x() + aTile.px.right());
    theGlyph.px      = aRect;
    theGlyph.uv      = aTile.uv;
    theGlyph.texture = aTile.texture;

    thePen.x() += myFont->getAdvanceX(theUChar, theUCharNext);
    return true;
}
예제 #12
0
ArpConfigureView::ArpConfigureView(BRect frame, const char* name,
								const ArpConfigureFile& config,
								BMessage* message,
								uint32 resizingMode,
								uint32 flags)
	: BView(frame, name, resizingMode, flags),
	  BInvoker(message, 0),
	  mPanel(0),
	  mRevertButton(0), mMakeDefaultButton(0), mDoneButton(0),
	  mPanelFrameWidth(0), mPanelFrameHeight(0),
	  mButtonsWidth(0), mButtonsHeight(0)
{
	const BFont* font = be_plain_font;
	
	font_height fh;
	font->GetHeight(&fh);
	const float spaceh = ceil((fh.ascent+fh.descent+fh.leading)/2);
	const float spacew = ceil(font->StringWidth("W")/2);
	mSpaceWidth = spacew;
	mSpaceHeight = spaceh;
	
	mPanelFrameWidth = spacew;
	mPanelFrameHeight = spaceh;
	
	try {
		float makedefWidth=0, makedefHeight=0;
		if( config.HasFile() ) {
			mMakeDefaultButton = new BButton(frame, "makedefault", "Make Default",
							new BMessage(MAKEDEFAULT_MSG), B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT);
			mMakeDefaultButton->GetPreferredSize(&makedefWidth,&makedefHeight);
			mMakeDefaultButton->ResizeToPreferred();
		}
		
		float revertWidth=0, revertHeight=0;
		mRevertButton = new BButton(frame, "revert", "Revert",
						new BMessage(REVERT_MSG), B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT);
		mRevertButton->GetPreferredSize(&revertWidth,&revertHeight);
		mRevertButton->ResizeToPreferred();
		
		float doneWidth=0, doneHeight=0;
		mDoneButton = new BButton(frame, "done", "Done",
						new BMessage(DONE_MSG), B_FOLLOW_BOTTOM|B_FOLLOW_RIGHT);
		mDoneButton->GetPreferredSize(&doneWidth,&doneHeight);
		mDoneButton->ResizeToPreferred();
		
		mButtonsWidth = revertWidth+makedefWidth+doneWidth+spacew*8;
		mButtonsHeight = revertHeight+spaceh*2;
		
		if( mMakeDefaultButton ) {
			mMakeDefaultButton->MoveTo(frame.right-doneWidth-makedefWidth-spacew*6
								  - (revertWidth>0 ? (revertWidth+spacew):0),
								  frame.bottom-revertHeight-spaceh);
		}
		mRevertButton->MoveTo(frame.right-doneWidth-revertWidth-spacew*4,
							  frame.bottom-revertHeight-spaceh);
		mDoneButton->MoveTo(frame.right-doneWidth-spacew*2,
							frame.bottom-revertHeight-spaceh);
							
		BRect aRect(frame.left, ceil(mPanelFrameHeight/2),
					frame.right,
					frame.Height()-mButtonsHeight-mPanelFrameHeight);
		mPanel = new ArpConfigurePanel(aRect, "Panels", config);
		
		AddChild(mPanel);
		AddChild(mRevertButton);
		if( mMakeDefaultButton ) AddChild(mMakeDefaultButton);
		AddChild(mDoneButton);
		
	} catch(...) {
		delete mRevertButton;
		delete mMakeDefaultButton;
		delete mDoneButton;
		delete mPanel;
	}
}
예제 #13
0
StOutAnaglyph::StOutAnaglyph(const StNativeWin_t theParentWindow)
: StWindow(theParentWindow),
  mySettings(new StSettings(ST_OUT_PLUGIN_NAME)),
  myFrBuffer(new StGLStereoFrameBuffer()),
  myStereoProgram(NULL),
  mySimpleAnaglyph("Anaglyph Simple"),
  myGrayAnaglyph("Anaglyph Gray"),
  myTrueAnaglyph("Anaglyph True"),
  myOptimAnaglyph("Anaglyph Optimized"),
  myYellowAnaglyph("Anaglyph Yellow"),
  myYellowDubiosAnaglyph("Anaglyph Yellow Dubios"),
  myGreenAnaglyph("Anaglyph Green"),
  myToSavePlacement(theParentWindow == (StNativeWin_t )NULL),
  myToCompressMem(myInstancesNb.increment() > 1),
  myIsBroken(false) {
    StTranslations aLangMap(ST_OUT_PLUGIN_NAME);

    myStereoProgram = &mySimpleAnaglyph;

    // about string
    StString& aTitle     = aLangMap.changeValueId(STTR_PLUGIN_TITLE,   "sView - Anaglyph Output module");
    StString& aVerString = aLangMap.changeValueId(STTR_VERSION_STRING, "version");
    StString& aDescr     = aLangMap.changeValueId(STTR_PLUGIN_DESCRIPTION,
        "(C) 2007-2014 Kirill Gavrilov <*****@*****.**>\nOfficial site: www.sview.ru\n\nThis library distributed under LGPL3.0");
    myAbout = aTitle + '\n' + aVerString + ": " + StVersionInfo::getSDKVersionString() + "\n \n" + aDescr;

    // devices list
    StHandle<StOutDevice> aDevice = new StOutDevice();
    aDevice->PluginId = ST_OUT_PLUGIN_NAME;
    aDevice->DeviceId = "Anaglyph";
    aDevice->Priority = ST_DEVICE_SUPPORT_LOW; // anaglyph could be run on every display...
    aDevice->Name     = aLangMap.changeValueId(STTR_ANAGLYPH_NAME, "Anaglyph glasses");
    aDevice->Desc     = aLangMap.changeValueId(STTR_ANAGLYPH_DESC, "Simple glasses with color-filters");
    myDevices.add(aDevice);

    // Glasses switch option
    StHandle<StEnumParam> aGlasses = new StEnumParam(GLASSES_TYPE_REDCYAN,
                                                     aLangMap.changeValueId(STTR_ANAGLYPH_GLASSES, "Glasses type"));
    aGlasses->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_REDCYAN, "Red-cyan"));
    aGlasses->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_YELLOW,  "Yellow-Blue"));
    aGlasses->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_GREEN,   "Green-Magenta"));
    aGlasses->signals.onChanged.connect(this, &StOutAnaglyph::doSetShader);
    params.Glasses = aGlasses;

    // Red-cyan filter switch option
    StHandle<StEnumParam> aFilterRC = new StEnumParam(REDCYAN_MODE_SIMPLE,
                                                      aLangMap.changeValueId(STTR_ANAGLYPH_REDCYAN_MENU, "Red-Cyan filter"));
    aFilterRC->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_REDCYAN_SIMPLE, "Simple"));
    aFilterRC->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_REDCYAN_OPTIM,  "Optimized"));
    aFilterRC->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_REDCYAN_GRAY,   "Grayed"));
    aFilterRC->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_REDCYAN_DARK,   "Dark"));
    aFilterRC->signals.onChanged.connect(this, &StOutAnaglyph::doSetShader);
    params.RedCyan = aFilterRC;

    // Amber-Blue filter switch option
    StHandle<StEnumParam> aFilterAB = new StEnumParam(AMBERBLUE_MODE_SIMPLE,
                                                      aLangMap.changeValueId(STTR_ANAGLYPH_AMBERBLUE_MENU, "Yellow filter"));
    aFilterAB->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_AMBERBLUE_SIMPLE, "Simple"));
    aFilterAB->changeValues().add(aLangMap.changeValueId(STTR_ANAGLYPH_AMBERBLUE_DUBIOS, "Dubios"));
    aFilterAB->signals.onChanged.connect(this, &StOutAnaglyph::doSetShader);
    params.AmberBlue = aFilterAB;

    // load window position
    StRect<int32_t> aRect(256, 768, 256, 1024);
    mySettings->loadInt32Rect(ST_SETTING_WINDOWPOS, aRect);
    StWindow::setPlacement(aRect, true);
    StWindow::setTitle("sView - Anaglyph Renderer");

    // load glasses settings
    mySettings->loadParam(ST_SETTING_GLASSES,   params.Glasses);
    mySettings->loadParam(ST_SETTING_REDCYAN,   params.RedCyan);
    mySettings->loadParam(ST_SETTING_AMBERBLUE, params.AmberBlue);
}
예제 #14
0
template<class ContainerT> void
ContainerRender(ContainerT* aContainer,
                LayerManagerComposite* aManager,
                const nsIntRect& aClipRect)
{
    /**
     * Setup our temporary surface for rendering the contents of this container.
     */
    RefPtr<CompositingRenderTarget> surface;

    Compositor* compositor = aManager->GetCompositor();

    RefPtr<CompositingRenderTarget> previousTarget = compositor->GetCurrentRenderTarget();

    nsIntRect visibleRect = aContainer->GetEffectiveVisibleRegion().GetBounds();

    aContainer->mSupportsComponentAlphaChildren = false;

    float opacity = aContainer->GetEffectiveOpacity();

    bool needsSurface = aContainer->UseIntermediateSurface();
    if (needsSurface) {
        SurfaceInitMode mode = INIT_MODE_CLEAR;
        bool surfaceCopyNeeded = false;
        gfx::IntRect surfaceRect = gfx::IntRect(visibleRect.x, visibleRect.y,
                                                visibleRect.width, visibleRect.height);
        gfx::IntPoint sourcePoint = gfx::IntPoint(visibleRect.x, visibleRect.y);
        // we're about to create a framebuffer backed by textures to use as an intermediate
        // surface. What to do if its size (as given by framebufferRect) would exceed the
        // maximum texture size supported by the GL? The present code chooses the compromise
        // of just clamping the framebuffer's size to the max supported size.
        // This gives us a lower resolution rendering of the intermediate surface (children layers).
        // See bug 827170 for a discussion.
        int32_t maxTextureSize = compositor->GetMaxTextureSize();
        surfaceRect.width = std::min(maxTextureSize, surfaceRect.width);
        surfaceRect.height = std::min(maxTextureSize, surfaceRect.height);
        if (aContainer->GetEffectiveVisibleRegion().GetNumRects() == 1 &&
                (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE))
        {
            // don't need a background, we're going to paint all opaque stuff
            aContainer->mSupportsComponentAlphaChildren = true;
            mode = INIT_MODE_NONE;
        } else {
            const gfx::Matrix4x4& transform3D = aContainer->GetEffectiveTransform();
            gfx::Matrix transform;
            // If we have an opaque ancestor layer, then we can be sure that
            // all the pixels we draw into are either opaque already or will be
            // covered by something opaque. Otherwise copying up the background is
            // not safe.
            if (HasOpaqueAncestorLayer(aContainer) &&
                    transform3D.Is2D(&transform) && !ThebesMatrix(transform).HasNonIntegerTranslation()) {
                surfaceCopyNeeded = gfxPlatform::ComponentAlphaEnabled();
                sourcePoint.x += transform._31;
                sourcePoint.y += transform._32;
                aContainer->mSupportsComponentAlphaChildren
                    = gfxPlatform::ComponentAlphaEnabled();
            }
        }

        sourcePoint -= compositor->GetCurrentRenderTarget()->GetOrigin();
        if (surfaceCopyNeeded) {
            surface = compositor->CreateRenderTargetFromSource(surfaceRect, previousTarget, sourcePoint);
        } else {
            surface = compositor->CreateRenderTarget(surfaceRect, mode);
        }

        if (!surface) {
            return;
        }

        compositor->SetRenderTarget(surface);
    } else {
        surface = previousTarget;
        aContainer->mSupportsComponentAlphaChildren = (aContainer->GetContentFlags() & Layer::CONTENT_OPAQUE) ||
                (aContainer->GetParent() && aContainer->GetParent()->SupportsComponentAlphaChildren());
    }

    nsAutoTArray<Layer*, 12> children;
    aContainer->SortChildrenBy3DZOrder(children);

    /**
     * Render this container's contents.
     */
    for (uint32_t i = 0; i < children.Length(); i++) {
        LayerComposite* layerToRender = static_cast<LayerComposite*>(children.ElementAt(i)->ImplData());

        if (layerToRender->GetLayer()->GetEffectiveVisibleRegion().IsEmpty() &&
                !layerToRender->GetLayer()->AsContainerLayer()) {
            continue;
        }

        if (i + 1 < children.Length() &&
                layerToRender->GetLayer()->GetEffectiveTransform().IsIdentity()) {
            LayerComposite* nextLayer = static_cast<LayerComposite*>(children.ElementAt(i + 1)->ImplData());
            nsIntRect nextLayerOpaqueRect;
            if (nextLayer && nextLayer->GetLayer()) {
                nextLayerOpaqueRect = GetOpaqueRect(nextLayer->GetLayer());
            }
            if (!nextLayerOpaqueRect.IsEmpty()) {
                nsIntRegion visibleRegion;
                visibleRegion.Sub(layerToRender->GetShadowVisibleRegion(), nextLayerOpaqueRect);
                layerToRender->SetShadowVisibleRegion(visibleRegion);
                if (visibleRegion.IsEmpty()) {
                    continue;
                }
            }
        }

        nsIntRect clipRect = layerToRender->GetLayer()->
                             CalculateScissorRect(aClipRect, &aManager->GetWorldTransform());
        if (clipRect.IsEmpty()) {
            continue;
        }

        if (layerToRender->HasLayerBeenComposited()) {
            // Composer2D will compose this layer so skip GPU composition
            // this time & reset composition flag for next composition phase
            layerToRender->SetLayerComposited(false);
            if (layerToRender->GetClearFB()) {
                // Clear layer's visible rect on FrameBuffer with transparent pixels
                gfx::Rect aRect(clipRect.x, clipRect.y, clipRect.width, clipRect.height);
                compositor->clearFBRect(&aRect);
                layerToRender->SetClearFB(false);
            }
        } else {
            layerToRender->RenderLayer(clipRect);
        }

        if (gfxPlatform::GetPrefLayersScrollGraph()) {
            DrawVelGraph(clipRect, aManager, layerToRender->GetLayer());
        }
        // invariant: our GL context should be current here, I don't think we can
        // assert it though
    }

    if (needsSurface) {
        // Unbind the current surface and rebind the previous one.
#ifdef MOZ_DUMP_PAINTING
        if (gfxUtils::sDumpPainting) {
            RefPtr<gfx::DataSourceSurface> surf = surface->Dump(aManager->GetCompositor());
            WriteSnapshotToDumpFile(aContainer, surf);
        }
#endif

        compositor->SetRenderTarget(previousTarget);
        EffectChain effectChain;
        LayerManagerComposite::AutoAddMaskEffect autoMaskEffect(aContainer->GetMaskLayer(),
                effectChain,
                !aContainer->GetTransform().CanDraw2D());

        effectChain.mPrimaryEffect = new EffectRenderTarget(surface);

        gfx::Rect rect(visibleRect.x, visibleRect.y, visibleRect.width, visibleRect.height);
        gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
        aManager->GetCompositor()->DrawQuad(rect, clipRect, effectChain, opacity,
                                            aContainer->GetEffectiveTransform());
    }

    if (aContainer->GetFrameMetrics().IsScrollable()) {
        const FrameMetrics& frame = aContainer->GetFrameMetrics();
        LayerRect layerBounds = ScreenRect(frame.mCompositionBounds) * ScreenToLayerScale(1.0);
        gfx::Rect rect(layerBounds.x, layerBounds.y, layerBounds.width, layerBounds.height);
        gfx::Rect clipRect(aClipRect.x, aClipRect.y, aClipRect.width, aClipRect.height);
        aManager->GetCompositor()->DrawDiagnostics(DIAGNOSTIC_CONTAINER,
                rect, clipRect,
                aContainer->GetEffectiveTransform());
    }
}
void CSketcherView::OnMouseMove(UINT nFlags, CPoint point)
{
  // Define a Device Context object for the view
  CClientDC aDC(this);                // DC is for this view
  OnPrepareDC(&aDC);                  // Get origin adjusted

    // If we are in move mode, move the selected element and return
  if(m_MoveMode)
  {
    aDC.DPtoLP(&point);                // Convert to logical coordinatess
    MoveElement(aDC, point);           // Move the element
    return;
  }

  aDC.SetROP2(R2_NOTXORPEN);          // Set the drawing mode
  if((nFlags&MK_LBUTTON)  && (this==GetCapture()))
  {
    aDC.DPtoLP(&point);              // convert point to Logical
    m_SecondPoint = point;           // Save the current cursor position

    if(m_pTempElement)
    {
      if(CURVE == GetDocument()->GetElementType())   // Is it a curve?
      {  // We are drawing a curve
         // so add a segment to the existing curve
         static_cast<CCurve*>(m_pTempElement)->AddSegment(m_SecondPoint);  
         m_pTempElement->Draw(&aDC);   // Now draw it
         return;                       // We are done
      }

      aDC.SetROP2(R2_NOTXORPEN);       // Set drawing mode
      // Redraw the old element so it disappears from the view
      m_pTempElement->Draw(&aDC);
      delete m_pTempElement;           // Delete the old element
      m_pTempElement = 0;              // Reset the pointer to 0
    }

    // Create a temporary element of the type and color that
    // is recorded in the document object, and draw it
    m_pTempElement = CreateElement();  // Create a new element
    m_pTempElement->Draw(&aDC);        // Draw the element
  }
  else
  { // We are not drawing an element so do highlighting...
    CSketcherDoc* pDoc=GetDocument();  // Get a pointer to the document
    CElement* pElement = 0;            // Store an element pointer
    CRect aRect(0,0,0,0);              // Store a rectangle
    POSITION aPos = pDoc->GetListHeadPosition();  // Get first element posn
    CElement* pOldSelection = m_pSelected;        // Save old selected element
    m_pSelected = 0;
    while(aPos)                        // Iterate through the list
    {
      pElement = pDoc->GetNext(aPos);
      aRect = pElement->GetBoundRect();
      aDC.LPtoDP(aRect);
      aRect.NormalizeRect();

      // Select the first element that appears under the cursor
      if(aRect.PtInRect(point))
      {
        m_pSelected = pElement;
        break;
      }
    }
    if(m_pSelected == pOldSelection)   // If new selection is same as old       
      return;                          // we are done

    // Unhighlight old selection if there is one
    if(pOldSelection != 0)             // Verify there is one
    {
      aRect = pOldSelection->GetBoundRect();
      aDC.LPtoDP(aRect);               // Convert to device coords
      aRect.NormalizeRect();           // Normalize
      InvalidateRect(aRect, FALSE);    // Invalidate area
    }

    // Highlight new selection if there is one
    if(m_pSelected != 0)               // Verify there is one
    {
      aRect = m_pSelected->GetBoundRect();
      aDC.LPtoDP(aRect);               // Convert to device coords
      aRect.NormalizeRect();           // Normalize
      InvalidateRect(aRect, FALSE);    // Invalidate area
    }
  }
}