// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseMaskedBackgroundControlContextOpsL
// Masked background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseMaskedBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;

    CAknsMaskedLayerBackgroundControlContext* myCtx = CAknsMaskedLayerBackgroundControlContext::NewL(
        id, initialRect, EFalse, 2 );
    CleanupStack::PushL( myCtx );
    myCtx->SetLayerImage( 0, id2 );
    myCtx->SetLayerImage( 1, id3 );
    myCtx->SetLayerRect( 0, nextRect );
    myCtx->SetLayerRect(1, rect3 );
    // Skipped myCtx->SetLayerMaskAndSizeL() since we cannot get CEikEnv::Static()
    CleanupStack::PopAndDestroy( myCtx );
    
    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "MaskedBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseBasicBackgroundControlContextOpsL
// Basic background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseBasicBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;

    CAknsBasicBackgroundControlContext* myCtx =
        CAknsBasicBackgroundControlContext::NewL( id, initialRect, EFalse );
    CleanupStack::PushL( myCtx );

    myCtx->SetBitmap( id2 );
    myCtx->SetRect( nextRect );
    myCtx->SetParentPos( TPoint( 0,0 ) );
    myCtx->SetParentContext( NULL );

    if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame ))
        {
        err = KErrGeneral;
        }

    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "BasicBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
void QSpreadsheetHeaderView::drawNextButton(QPainter *painter, int logicalIndex) const
{
    QRect rect = nextRect(logicalIndex);

    painter->setPen(QColor(71,71,71));
    painter->drawLine(rect.right()-2, rect.center().y() - 3, rect.right()-2, rect.center().y() + 3);
    painter->drawLine(rect.right()-3, rect.center().y() - 2, rect.right()-3, rect.center().y() + 2);
    painter->drawLine(rect.right()-4, rect.center().y() - 1, rect.right()-4, rect.center().y() + 1);
    painter->drawPoint(rect.right()-5, rect.center().y());
}
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseCombinedBackgroundControlContextOpsL
// Combined background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseCombinedBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;

    CAknsCombinedBackgroundControlContext* myCtx = 
        CAknsCombinedBackgroundControlContext::NewL( EFalse );
    CleanupStack::PushL( myCtx );

    CAknsBasicBackgroundControlContext* mySubCtx1 = 
        CAknsBasicBackgroundControlContext::NewL( id, initialRect, EFalse );

    CAknsBasicBackgroundControlContext* mySubCtx2 = 
        CAknsBasicBackgroundControlContext::NewL( id3, rect3, EFalse );

    MAknsControlContext* retrievedCtx = myCtx->GetControlContext( 0 );
    if ( retrievedCtx )
        {
        // We haven't add anything to the combined context, so this should fail.
        err = KErrGeneral;
        }

    myCtx->AddControlContext( mySubCtx1 );
    retrievedCtx = myCtx->GetControlContext( 0 );
    if ( !retrievedCtx )
        {
        // We have added one context, so this should not fail.
        err = KErrGeneral;
        }
    myCtx->AddControlContext( mySubCtx2 );
    myCtx->RemoveControlContext( 0 );
    myCtx->GetControlContext( 0 );
    if ( !retrievedCtx )
        {
        // We added two contexts, then removed one, so this should not fail.
        err = KErrGeneral;
        }
    myCtx->RemoveControlContext( 0 ); // remove the last remaining one.
    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "CombinedBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
void QSpreadsheetHeaderView::mousePressEvent ( QMouseEvent * event )
{
    QHeaderView::mousePressEvent(event);

    int logicalIndex = logicalIndexAt(event->pos());

    if (buttonMenuRect(logicalIndex).contains(event->pos())) {
        QMenu menu(this);
        QAction *hideCol = menu.addAction("Hide column");
        QAction *sortAZ = menu.addAction("Sort sheet A->Z");
        QAction *sortZA = menu.addAction("Sort sheet Z->A");

        // Disable hide column if only one column remains. Otherwise
        // the gui is no more available to show them back.
        hideCol->setEnabled(hiddenSectionCount() < count() - 1);

        QAction *res = menu.exec(mapToGlobal(event->pos()));

        if (res == hideCol) {
            hideSection(logicalIndex);
            updateSection(logicalIndex-1);
        }
        if (res == sortAZ)
            model()->sort(logicalIndex, Qt::AscendingOrder);
        if (res == sortZA)
            model()->sort(logicalIndex, Qt::DescendingOrder);
    }

    // Catch previous arrow mouse click.
    if (prevRect(logicalIndex).contains(event->pos())) {
        showSection(logicalIndex - 1);
        updateSection(logicalIndex - 2);
    }

    // Catch next arrow mouse click.
    if (nextRect(logicalIndex).contains(event->pos())) {
        showSection(logicalIndex + 1);
        updateSection(logicalIndex + 2);
    }
}
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseListBoxBackgroundControlContextOpsL
// Listbox background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseListBoxBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TRect rect4( TSize( 200, 200 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;
    TAknsItemID id4 = KAknsIIDQsnBgColumn0;

    CAknsListBoxBackgroundControlContext* myCtx =
        CAknsListBoxBackgroundControlContext::NewL( id, initialRect, EFalse, id2, nextRect );
    CleanupStack::PushL( myCtx );

    myCtx->SetTiledBitmap( id3 );
    myCtx->SetTiledRect( rect3 );
    myCtx->SetBottomBitmap( id4 );
    myCtx->SetBottomRect( rect4 );

    if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame ))
        {
        err = KErrGeneral;
        }

    // Skipped case to update context since we cannot instantiate singleton.

    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "ListBoxBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }
// -----------------------------------------------------------------------------
// CSkinningModule::TestCaseLayeredBackgroundControlContextOpsL
// Layered background context operations.
// -----------------------------------------------------------------------------
//
TInt CSkinningModule::TestCaseLayeredBackgroundControlContextOpsL( TTestResult& aResult )
    {
    TInt err = KErrNone;

    TRect initialRect( TSize( 100, 100 ) );
    TRect nextRect( TSize( 50, 50 ) );
    TRect rect3( TSize( 20, 20 ) );
    TAknsItemID id = KAknsIIDQsnCpClockAnalogueFace1;
    TAknsItemID id2 = KAknsIIDQsnCpClockAnalogueFace2;
    TAknsItemID id3 = KAknsIIDQgnLogoEmpty;

    CAknsLayeredBackgroundControlContext* myCtx =
        CAknsLayeredBackgroundControlContext::NewL( id, initialRect, EFalse, 2 );
    CleanupStack::PushL( myCtx );

    myCtx->SetLayerImage( 0, id2 );
    myCtx->SetLayerImage( 1, id3 );
    myCtx->SetLayerRect( 0, nextRect );
    myCtx->SetLayerRect( 1, rect3 );

    if ( !myCtx->IsCompatibleWithType( EAknsControlContextTypeBasic ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeUnknown ) ||
         !myCtx->IsCompatibleWithType( EAknsControlContextTypeLayered ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeListBox ) ||
         myCtx->IsCompatibleWithType( EAknsControlContextTypeFrame ))
        {
        err = KErrGeneral;
        }

    CleanupStack::PopAndDestroy( myCtx );

    // Sets test case result and description(Maximum size is KStifMaxResultDes)
    _LIT( KDescription, "LayeredBackgroundControlContextOps finished" );
    aResult.SetResult( err, KDescription );
    return err;
    }