Example #1
0
void CSliderControl::ShrinkRects(TRect aRect,TInt aDir)
	{
	SetExtent(aRect.iTl,aRect.Size());
	CCoeControlArray::TCursor cursor = Components().Begin();
	CCoeControl* ctrl = NULL;
	TInt i=0;
	TRect r;
	while ((ctrl = cursor.Control<CCoeControl>()) != NULL)
	    {
		if (aDir==EDirectionHorizontal)
			{
			TInt w=aRect.Size().iWidth/Components().Count();
			TInt h=aRect.Size().iHeight;
			r=TRect(i*w,0,(i+1)*w,aRect.Height());
			}
		else if (aDir==EDirectionVertical)
			{
			TInt w=aRect.Size().iWidth;
			TInt h=aRect.Size().iHeight/Components().Count();
			r=TRect(0,h*i,aRect.Width(),h*(i+1));
			}		
		ctrl->SetRect(r);
	    cursor.Next();
	    i++;
	    }
	}
Example #2
0
void QCursor::setPos(int x, int y)
{
    //clip to screen size (window server allows a sprite hotspot to be outside the screen)
    if (x < 0)
        x=0;
    else if (x >= S60->screenWidthInPixels)
        x = S60->screenWidthInPixels - 1;
    if (y < 0)
        y = 0;
    else if (y >= S60->screenHeightInPixels)
        y = S60->screenHeightInPixels - 1;

#ifndef QT_NO_CURSOR
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
    if (S60->brokenPointerCursors && cursorSpriteVisible)
        cursorSprite.d->scurs.SetPosition(TPoint(x,y));
    else
#endif
        S60->wsSession().SetPointerCursorPosition(TPoint(x, y));
#endif
    S60->lastCursorPos = QPoint(x, y);
    //send a fake mouse move event, so that enter/leave events go to the widget hierarchy
    QWidget *w = QApplication::topLevelAt(S60->lastCursorPos);
    if (w) {
        CCoeControl* ctrl = w->effectiveWinId();
        TPoint epos(x, y);
        TPoint cpos = epos - ctrl->PositionRelativeToScreen();
        TPointerEvent fakeEvent;
        fakeEvent.iType = TPointerEvent::EMove;
        fakeEvent.iModifiers = 0U;
        fakeEvent.iPosition = cpos;
        fakeEvent.iParentPosition = epos;
        ctrl->HandlePointerEventL(fakeEvent);
    }
}
// ---------------------------------------------------------------------------
// CAknPointerEventModifier::Push
// ---------------------------------------------------------------------------
//
EXPORT_C void CAknPointerEventModifier::Push( CCoeControl& aControl, 
    const TRect& aRect )
    {
    // Figure out aControl's window-owning parent. This will also work as a
    // sanity check for the aControl argument.
    CCoeControl* parent = aControl.Parent();
    
    while ( parent && !parent->OwnsWindow() )
        {
        parent = parent->Parent();
        }
        
    if ( !parent )
        {
        return;
        }
    
    if ( !ControlIsInStack( aControl ) )
        {
        TStackItem item;
        item.iControl = &aControl;
        item.iParent = parent;
        item.iExtensionArea = aRect;
        
        if ( iStack.Insert( item, 0 ) == KErrNone )
            {
            iIsValid = EFalse;
            }
        }
    }
Example #4
0
/**
   @SYMTestCaseID UIF-TCone7Step-TestBackedUpExtentNotSetL
  
   @SYMDEF DEF123521 - Fix for PDEF116704 has been removed 
  
   @SYMTestCaseDesc Tests fix for PDEF116704 has not regressed.
	
   @SYMTestPriority High
  
   @SYMTestStatus Implemented
   
   @SYMTestActions : Creates a CCoeControl and a RBackedUpWindow. Sets the RBackupWindow as the container
    window for the CCoeControl.
	  
   @SYMTestExpectedResults The RBackedUpWindow's position and size should not change.

   @SYMTestType : CIT 
 */
TBool CCone7TestAppUi::TestBackedUpExtentNotSetL()
	{
	
	// Create a window
	RBackedUpWindow window(iCoeEnv->WsSession());
	TEST(window.Construct((RWindowTreeNode&)iCoeEnv->RootWin(), EGray4, TUint32(this))==KErrNone);
	
	// Create a control
	CCoeControl* ctrl = new (ELeave) CCoeControl;
	CleanupStack::PushL(ctrl);
	ctrl->SetExtent(TPoint(20,20), TSize(40,40));

	// Get extent of window
	TPoint position1 = window.Position();
	TSize size1 = window.Size();

	// Set control's container window
	ctrl->SetContainerWindowL(window);

	// Check extent not changed
	TPoint position2 = window.Position();
	TSize size2 = window.Size();

	TEST((size1==size2)&&(position1==position2)); 

	// Cleanup
	CleanupStack::PopAndDestroy(ctrl);
	window.Close();

	return ETrue;
	} 
Example #5
0
void CWindowMover::toZero()
{
    CCoeControl* control =(viewer->winId());
    RDrawableWindow* rWindow=(control->DrawableWindow());
    control->SetPosition(TPoint(0,0));
    prevY=0;
}
Example #6
0
/**
  Handles destruction of any control. It is called by framework if any control is destroyed.\n
  Accesses the component controls to make sure the components are not removed from
  CCoeControlArray before notifying the observer.\n
*/
void CTestMCoeFocusObserver::HandleDestructionOfFocusedItem()
	{
	TInt cnt = iCtlContainer.CountComponentControls();
	while(cnt--)
		{
		CCoeControl* child = iCtlContainer.ComponentControl(cnt);
		child->SetFocus(ETrue); // use control to make sure its not deleted
		}
	}
Example #7
0
void CWindowMover::finished()
{
    qDebug()<<"finished anim";
    CCoeControl* control =(viewer->winId());
    TPoint p=control->Position();
    int val=0;
    if (p.iX==0) val=p.iY;
    else if (p.iY==0) val=p.iX;
    if ((abs(val)==control->Size().iHeight||abs(val)==control->Size().iWidth)&&iCallBack) iCallBack->Hide();
}
Example #8
0
/**
 * Draws the joints between menu pane and menu pane title into the graphics
 * context aGc, in the rectangle aRect.
 */
EXPORT_C void LafMenuPane::DrawTitlePaneJoint(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc, const CCoeControl* aMenuPaneTitle, const TRect& aInnerRect)
	{
	PrepareGcForDrawingItems(aLafEnv, aMenuPane, aGc);
    aGc.SetPenStyle(CGraphicsContext::ENullPen);
    aGc.DrawRect(aInnerRect);
	if (aMenuPaneTitle)
		{// pane has title, so make sure they are joined up correctly
		const TPoint titlePos = aMenuPaneTitle->Position();
		const TInt width = aMenuPaneTitle->Size().iWidth;
		const TPoint position = aMenuPane.Position();

		// left straight join
		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
		aGc.SetPenColor(aLafEnv.ControlColor(EColorMenuPaneBackground, aMenuPane));
		// get rid of the gray bit of border
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+5,4),TPoint(titlePos.iX-position.iX+width-5,4));
		// get rid of the black bit of border
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+4,0),TPoint(titlePos.iX-position.iX+width-4,0));
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+4,1),TPoint(titlePos.iX-position.iX+width-4,1));

		aGc.DrawLine(TPoint(titlePos.iX-position.iX+5,4),TPoint(titlePos.iX-position.iX+width-5,4));
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,0),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),0));
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,1),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),1));
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,2),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),2));
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+MenuPaneSeparatorMargin() ,3),TPoint(titlePos.iX-position.iX+width-MenuPaneSeparatorMargin(),3));

		// draw in black line seperator
		aGc.SetPenColor(KRgbBlack);
		aGc.DrawLine(TPoint(titlePos.iX-position.iX +MenuPaneSeparatorMargin(),0),TPoint(titlePos.iX-position.iX+width-3-MenuPaneSeparatorMargin(),0));

		TGulBorder::TColors borderColors;
		GetBorderColors(borderColors, aLafEnv, *aMenuPaneTitle);

		aGc.SetPenColor(borderColors.iMidlight);
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+1,0),TPoint(titlePos.iX-position.iX+4,0));
		aGc.DrawLine(TPoint(titlePos.iX-position.iX+1,1),TPoint(titlePos.iX-position.iX+4,1));

		if (aMenuPaneTitle->Rect().iBr.iX==aMenuPane.Rect().iBr.iX)
			{// right straight join
			aGc.SetPenColor(borderColors.iMid);
			aGc.DrawLine(TPoint(aInnerRect.iBr.iX,0),TPoint(aInnerRect.iBr.iX,5));
			aGc.DrawLine(TPoint(aInnerRect.iBr.iX+1,0),TPoint(aInnerRect.iBr.iX+1,4));
			aGc.DrawLine(TPoint(aInnerRect.iBr.iX+2,0),TPoint(aInnerRect.iBr.iX+2,3));
			}
		else
			{// right corner join
			TInt xPos=titlePos.iX-position.iX+width-4;
			aGc.SetPenColor(borderColors.iMid);
			aGc.DrawLine(TPoint(xPos,0),TPoint(xPos,4));
			aGc.DrawLine(TPoint(xPos+1,0),TPoint(xPos+1,3));
			aGc.DrawLine(TPoint(xPos+2,0),TPoint(xPos+2,2));
			}
		}
	}
Example #9
0
RWindowBase* MMF::AbstractVideoOutput::videoWindow() const
{
    CCoeControl *control = internalWinId();
    if (!control)
        control = effectiveWinId();

    RWindowBase *window = 0;
    if (control)
        window = control->DrawableWindow();

    return window;
}
Example #10
0
void CWindowMover::yAnimChanged(const QVariant &value)
{
    bool ok;
    int val=value.toInt(&ok);
     CCoeControl* control =(viewer->winId());
     control->SetPosition(TPoint(0,val));
     int loop=yAnim->currentLoop();
     TSize s=TSize(control->Size().iWidth,abs(yAnim->keyValueAt(loop).toInt()-val));
     control->DrawBackground(TRect(TPoint(0,val),s));
     //if ((abs(val)==control->Size().iHeight)&&iCallBack) iCallBack->Hide();
     //qDebug()<<"y anim"<<val;
}
Example #11
0
/**
   Auxiliary function for all Test Cases
  
   The method is an override from CTestAppUi. The method initiates border
   drawing tests.
   
 */
void CSimpleParentAppUi::RunTestStepL(TInt aNextStep)
	{
	switch(aNextStep)
		{
		case 1:	
			{
			INFO_PRINTF1(_L("Test Parent - does the control have the view as its parent?"));
			
			// Get the control on the appview
			CCoeControl *control = iParentAppView->GetControl();
			
			if (control == NULL)
				{
				TEST(control != NULL); // generates a fail automatically
				INFO_PRINTF1(_L("Could not get control from appview - test failed"));
				break;
				}
				
			// Get the parent of that control
			CCoeControl *parent = control->Parent();
			
			// Check that there is a parent to begin with
			if (parent==NULL)
				{
				TEST(parent != NULL); // generates a fail automatically
				INFO_PRINTF1(_L("Control does not have a parent - test failed"));
				break;
				}
				
			// Check that the parent is the same as the view
			TEST(parent == iParentAppView);
				
			if (parent != iParentAppView)
				{
				INFO_PRINTF1(_L("View is not parent of Control - test failed"));
				}
				else
				{
				INFO_PRINTF1(_L("View is parent of Control - test PASSED"));
				}
				
			}
			break;
			
		case 2:
			AutoTestManager().FinishAllTestCases(CAutoTestManager::EPass);
			break;
		default:
			break;
		}
	}
Example #12
0
// ---------------------------------------------------------------------------
// CAknSignalPane::SetContainerWindowNonFading
// Allows/disallows fading of signal pane.
// ---------------------------------------------------------------------------
//
void CAknSignalPane::SetContainerWindowNonFading( TBool aNonFading )
    {
    CEikStatusPaneBase* statusPane = CEikStatusPaneBase::Current();
    if ( statusPane )
        {
        CCoeControl* control = NULL;
        TRAP_IGNORE(
            control = statusPane->ContainerControlL(
                TUid::Uid( EEikStatusPaneUidSignal ) ) );
        if ( control )
            {
            control->DrawableWindow()->SetNonFading( aNonFading );
            }
        }
    }
Example #13
0
void CWindowMover::checkLaunchArea()
{
    CCoeControl* control =(viewer->winId());
    int y=control->Position().iY;
    int x=control->Position().iX;
    float verSense=settings->value("settings/versense",0.5).toFloat();
    int height=control->Size().iHeight;
    if (x==0&&abs(y-prevY)<40&&y>(-height*verSense)&&y<-40)
    {
        qDebug()<<"will show launch area";
        emit showLaunchArea();
        startAnim(EYAxis,0);
    }
    prevY=y;
}
Example #14
0
/**
 * Prepares the graphics context aGc according of aHighlightType before drawing an item. At the
 * same time it determines and returns the text color to be used during the drawing of all components
 * of an item.
 */
EXPORT_C void LafMenuPane::PrepareGcForHighlight(const MLafEnv& aLafEnv, const CCoeControl& aMenuPane, CWindowGc& aGc, const TItemAttributes& aItemAttributes)
	{
	TRgb textColor = aLafEnv.ControlColor(EColorMenuPaneText, aMenuPane); //KEikMenuPaneTextColor;
	switch (aItemAttributes.iHighlightType)
		{
	case SLafMenuPane::EDrawHighlight:
		aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		textColor = aLafEnv.ControlColor(EColorMenuPaneTextHighlight, aMenuPane);
		if (aMenuPane.IsFocused())
			{
			aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneHighlight, aMenuPane));
			if (aItemAttributes.iFlags&EEikMenuItemDimmed)
				textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedTextHighlight, aMenuPane);
			}
		else
			{
			aGc.SetBrushColor(aLafEnv.ControlColor(EColorMenuPaneDimmedHighlight, aMenuPane));
			textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedTextHighlight, aMenuPane);
			}
		break;
	case SLafMenuPane::ERemoveHighlight:
	aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
		if (aItemAttributes.iFlags&EEikMenuItemDimmed)
			textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedText, aMenuPane);
		break;
	case SLafMenuPane::ENoHighlight:
		aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
		if (aItemAttributes.iFlags&EEikMenuItemDimmed)
			textColor = aLafEnv.ControlColor(EColorMenuPaneDimmedText, aMenuPane);
		break;
	default:
		break;
		}
	aGc.SetPenColor(textColor);
	}
//Background drawing function
void CTestRectGc::Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const
	{		
		if (iBmpBackground) 
		{
						
			TPoint a = PositionRelativeToScreen();
			TPoint b = aControl.PositionRelativeToScreen();

			//The source rect of the background is the relationship between this control and the control being drawn (child)
			//plus the subrect (aRect) to be drawn.
			TRect SourceRect(b-a+aRect.iTl, aRect.Size());

			aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
			aGc.BitBlt(aRect.iTl, iBmpBackground, SourceRect);			
			aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
		}
		else
		{
			TRect rc;
			aGc.SetClippingRect(aRect);
			aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
    		aGc.SetBrushColor(iBrushColor);
    		aGc.SetBrushStyle(iBrushStyle);
			aGc.DrawRect(rc);
			aGc.CancelClippingRect();

		}		
	}
Example #16
0
void CCustomWrapAppControl::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
	{
	if (aEventType==EEventRequestFocus)
		{
		iFocusControl=aControl;
		iFocusControl->SetFocus(ETrue,EDrawNow);
		}
	} 
Example #17
0
void CWindowMover::startAnim(CWindowMover::TAnimationAxis axis, int to)
{
    CCoeControl* control =(viewer->winId());
    if (axis==EXAxis)
    {
    xAnim->setStartValue(QVariant(control->Position().iX));
    xAnim->setEndValue(QVariant(to));
    xAnim->start();
    qDebug()<<"start x anim"<<to;

    }
    else
    {
        yAnim->setStartValue(QVariant(control->Position().iY));
        yAnim->setEndValue(QVariant(to));
        yAnim->start();
        qDebug()<<"start y anim"<<to;
    }
}
Example #18
0
void CCustomWrapAppControl::ConstructL()
	{
	CreateWindowL();
    Window().SetShadowDisabled(ETrue);
	CreateEdwinL();
	iStandardCustomWrap = iEdwin->TextLayout()->CustomWrap();
	iFocusControl=iEdwin;
	SetExtentToWholeScreen();
	ActivateL();
	iFocusControl->SetFocus(ETrue);
	}
void CNewDestDialog::RemoveInputFocus()
{
   CCoeControl* control = ControlOrNull( EWayFinderCtrlNewDestCityEdwin );
   if( control ) {
      control->SetFocus( EFalse );
   }
   control = ControlOrNull( EWayFinderCtrlNewDestHouseNumEdwin);
   if( control ) {
      control->SetFocus( EFalse );
   }
   control = ControlOrNull( EWayFinderCtrlNewDestStringEdwin );
   if( control ) {
      control->SetFocus( EFalse );
   }
   control = ControlOrNull( EWayFinderCtrlNewDestCountryEdwin );
   if( control ) {
      control->SetFocus( EFalse );
   }
   iHasFocus = EFalse;
}
void CMMADisplay::SetWindowResources(QWidget* qtWidget)
{
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetWindowResources +");
    CCoeControl* control = 0;
    if (qtWidget && qtWidget ->winId())
    {
        control = reinterpret_cast<CCoeControl*>(qtWidget->winId());
    }

    CCoeEnv *coeEnv = control->ControlEnv();
    RWsSession * iWs = &(coeEnv->WsSession());
    CWsScreenDevice* iScreenDevice = coeEnv->ScreenDevice();
    RWindowBase* window = static_cast<RWindowBase*>(control->DrawableWindow());
    if (!iWindow)
    {
        return;
    }
    iWindow->ProcureWindowResourcesFromQWidget(iWs,iScreenDevice,window);
    iWindow->SetVisible(ETrue,ETrue);
    LOG(EJavaMMAPI,EInfo,"CMMADisplay::SetWindowResources -");
}
/**
  @SYMTestCaseID UIF-TConeBackground-Test1L
 
  @SYMPREQ
 
  @SYMTestCaseDesc 
 
  @SYMTestPriority High
 
  @SYMTestStatus Implemented
  
  @SYMTestActions : Sets the background brush style to EVerticalHatchBrush.\n
  Instantiates a parent control (CConeBackgroundTestParent) which has capability of background drawing.\n
  Activates the Parent control.\n
  Invokes the DrawNow function for the View class which calls Draw() on the control itself,\n
  and also on all its component controls.\n.
  
  @SYMTestExpectedResults : The draw should complete with out any error.\n
 
  @SYMTestType : CIT
*/
void CConeBackgroundTestView::Test1L()
	{
	delete iControl;
	iControl = 0;

	iBgDrawer->SetBgStyle(1);
	iControl = CConeBackgroundTestParentWithBg::NewL(*this, Rect(),
				CConeBackgroundTestDrawer1::NewL(), ETrue);
	
	iControl->ActivateL();
	DrawNow();
	}
Example #22
0
/**
  Auxilliary Function performing the layout for a control.\n
  Checks if the used up width and height are less that than the available width and height respectively.\n
  If yes, initializes the top left and bottom right coordinates of the control 
  and assigns the same to the control's extent.\n
  
  @return KErrNone if successful else KErrTooBig
*/
TInt CLayoutTest::LayoutControl(TUint aCurCtrlIndex, TSize aCtrlSize)
	{
	TInt layoutSuccess = KErrNone;
	// check that we haven't used all the space left on the screen
	if (((iSizeUsed.iWidth + aCtrlSize.iWidth + KHorizontalBorder) <= iLayoutRect.Width()) &&
		((iSizeUsed.iHeight + aCtrlSize.iHeight + KVerticalBorder) <= iLayoutRect.Height()))
		{
		TPoint topLeft(iSizeUsed.iWidth + KHorizontalBorder, iSizeUsed.iHeight + KVerticalBorder);
		TPoint bottomRight(iSizeUsed.iWidth + aCtrlSize.iWidth + KHorizontalBorder, 
						   iSizeUsed.iHeight + aCtrlSize.iHeight + KVerticalBorder);
		TRect ctrlRect(topLeft, bottomRight);
		CCoeControl* ctrl = iCtrlArray[aCurCtrlIndex];
		ctrl->SetRect(ctrlRect);
		iControlsCompleted++;
		}
	else
		{
		layoutSuccess = KErrTooBig;
		}
	return layoutSuccess;
	}
Example #23
0
/**
  Sets the size of the component objects based on the present size of the container window.\n
  Calculates the present size of the container control and also the number of component objects.\n
  Sets the component object dimensions accordingly.\n
*/	
void CCtlContainer::SizeChanged() 
	{
	// set the size of the children
	TRect rect = Rect() ;
	TSize size = rect.Size() ;
	TPoint tl = rect.iTl ;
	TInt childCount = CountComponentControls() ;
	if ( childCount > 0 )
		{
		size.iWidth = size.iWidth/childCount ;
		size.iHeight = size.iHeight/childCount ;
		CCoeControl* child ;
		for ( TInt ii = 0; ii < childCount ; ++ii )
			{
			child = ComponentControl( ii ) ;
			child->SetRect( TRect( tl, size ) ) ;
			tl.iX += size.iWidth ;
			tl.iY += size.iHeight ;
			}
		}
	}
/**
  @SYMTestCaseID UIF-TConeBackground-Test4L
 
  @SYMDEF PDEF112327
 
  @SYMTestCaseDesc Tests MCoeControlBackground, when a parent window owning control has one 
  child control not supporting background drawing and non window owning.\n
 
  @SYMTestPriority Critical
 
  @SYMTestStatus Implemented
  
  @SYMTestActions : Sets the background draw style.\n
  Instantiates a parent control (CConeBackgroundTestParent) which has capability of background drawing.\n
  After a new screen device has been instantiated,instantiates a second graphics context and assigns it to the child control.\n
  Thus a scenario of parent control and child control with different graphics context is created and tested.\n
  Activates the parent and child control\n
  Invokes the DrawNow function for the NonWindowOwningControl class which results in calling Draw() and DrawComponets() on the parent control itself.\n 
  
  @SYMTestType Manual
  @SYMTestExpectedResults : The background drawing should use the parent graphics context. \n
  All the test code does is to exercise the defect fix and thus the draw should complete without any error.\n
  */
void CConeBackgroundTestView::Test4L()
	{
	delete iControl;
	iControl = 0;
	
	iBgDrawer->SetBgStyle(1);
	iControl = CConeBackgroundTestParentWindowOwning::NewL(*this, Rect(),
				CConeBackgroundTestDrawer2::NewL());
	
	// create a new Gc
	CWsScreenDevice* screenDevice = new (ELeave) CWsScreenDevice((iControl->ControlEnv())->WsSession()); 
	CleanupStack::PushL(screenDevice);
	User::LeaveIfError(screenDevice->Construct());
	
	CWindowGc* gc=new(ELeave) CWindowGc(screenDevice);
	CleanupStack::PushL(gc);
	User::LeaveIfError(gc->Construct());
	
	gc->Activate(Window());
	(iControl->ComponentControl(0))->SetCustomGc(gc);
	gc->Deactivate();
	
	TSize rectSize(90,200);
	iControl->SetSize(rectSize);
	(iControl->ComponentControl(0))->SetSize(rectSize);
	
	iControl->ActivateL();
	(iControl->ComponentControl(0))->ActivateL();
	(iControl->ComponentControl(0))->DrawNow(); 
	
	CleanupStack::PopAndDestroy(gc);
	CleanupStack::PopAndDestroy(screenDevice);
	}
Example #25
0
/*
 * Makes the specified cursor appear everywhere.
 * Called from QApplication::setOverrideCursor
 */
void qt_symbian_setGlobalCursor(const QCursor &cursor)
{
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
    if (S60->brokenPointerCursors) {
        qt_symbian_set_pointer_sprite(cursor);
    } else
#endif
    {
        //because of the internals of window server, we need to force the cursor
        //to be set in all child windows too, otherwise when the cursor is over
        //the child window it may show a widget cursor or arrow cursor instead,
        //depending on construction order.
        QListIterator<WId> iter(QWidgetPrivate::mapper->uniqueKeys());
        while(iter.hasNext())
        {
            CCoeControl *ctrl = iter.next();
            if(ctrl->OwnsWindow()) {
                RWindowTreeNode *node = ctrl->DrawableWindow();
                qt_symbian_setWindowGroupCursor(cursor, *node);
            }
        }
    }
}
// -----------------------------------------------------------------------------
// CTestSDKTouchPane::TestTPReduceRectL
// ReduceRect test method function.
// -----------------------------------------------------------------------------
//
TInt CTestSDKTouchPane::TestTPReduceRectL( CStifItemParser& /*aItem*/ )
    {

    // Print to UI
    _LIT( Ktestsdksearchfield, "testsdktouchpane" );
    _LIT( KTestSFSetSkinEnabledL, "In TestTPReduceRectL" );
    TestModuleIf().Printf( 0, Ktestsdksearchfield, KTestSFSetSkinEnabledL );
    // Print to log file
    iLog->Log( KTestSFSetSkinEnabledL );

    CAknTouchPane* touchPane = CAknTouchPane::NewL( R_TOUCHPANE );
    CleanupStack::PushL( touchPane );
    
    CCoeControl* container = new( ELeave ) CCoeControl();
    CleanupStack::PushL( container );
    TRect rect = container->Rect();
    touchPane->ReduceRect( rect );
    
    CleanupStack::Pop( container );
    CleanupStack::PopAndDestroy( touchPane );

    return KErrNone;
    }
/**
  @SYMTestCaseID UIF-TConeBackground-Test3L
 
  @SYMPREQ
 
  @SYMTestCaseDesc Tests MCoeControlBackground when a parent control has two 
  child controls,one supporting background drawing and the other without that support.\n
 
  @SYMTestPriority High
 
  @SYMTestStatus Implemented
  
  @SYMTestActions : Sets the background brush style to EVerticalHatchBrush.\n
  Instantiates a parent control (CConeBackgroundTestParent) which has capability of background drawing.\n
  Activates the Parent control.\n
  Also instantiates a secondary control of class CConeBackgroundTestParentWithBg.\n
  Later a third control without background drawing is instantiated.\n
  Thus a scenario of parent control containing child controls with and without background drawing support
  is created and tested.\n
  Invokes the DrawNow function for the View class which calls Draw() on the control itself,\n
  and also on all its component controls.\n
  
  @SYMTestExpectedResults : The draw should complete with out any error.\n
 
  @SYMTestType : CIT
*/
void CConeBackgroundTestView::Test3L()
	{
	delete iControl;
	iControl = 0;

	iBgDrawer->SetBgStyle(3);
	iControl = CConeBackgroundTestParentWithBg::NewL(*this, Rect(),
				CConeBackgroundTestDrawer1::NewL(), ETrue);
	TRect rect = Rect();
	rect.Shrink(rect.Width()/8, rect.Height()/8);
	CCoeControl* temp = CConeBackgroundTestParentWithBg::NewL(*iControl, rect, CConeBackgroundTestDrawer2::NewL());
	static_cast<CConeBackgroundTestParentWithBg*>(iControl)->SetSecondary(temp);
	iControl->ActivateL();
	DrawNow();
	}
Example #28
0
/**
 * Draws the thumb of the scrollbar. The thumb can be drawn in pressed colors if aIsDragged is true, or in normal
 * colors otherwise. The scrollbar is horizontal if aHorizontal is true and vertical otherwise.
 */
EXPORT_C void LafScrollThumb::DrawDragState(const MLafEnv& aLafEnv,CWindowGc& aGc,const CCoeControl& aScrollThumb,TBool aIsDragged, const TRect& aRect, TBool aHorizontal)
    {
    TRgb bgColor;
    if (aScrollThumb.IsDimmed())
        {
        bgColor=aLafEnv.ControlColor((aIsDragged? EColorScrollButtonThumbBackgroundPressed : EColorScrollThumbDimmed),aScrollThumb);
        }
    else
        {
        bgColor=aLafEnv.ControlColor((aIsDragged? EColorScrollButtonThumbBackgroundPressed : EColorScrollButtonThumbBackground),aScrollThumb);
        }
    
    aGc.SetBrushColor(bgColor);
    aGc.Clear(aRect);
    
    TRect gripRect=aRect;
    TInt length=(aHorizontal)? gripRect.Size().iWidth : gripRect.Size().iHeight;
    TInt gripStart=((length*(KLafScrollThumbGripProportion-1))/KLafScrollThumbGripProportion)/2;
    TInt horizBorder=(aHorizontal)? gripStart : KLafScrollThumbGripMargin;
    TInt vertBorder=(aHorizontal)? KLafScrollThumbGripMargin : gripStart;
    
    gripRect.Shrink(horizBorder,vertBorder);
    // TLafGrip::TOrientation gripOrientation=(aHorizontal)? TLafGrip::EVertical : TLafGrip::EHorizontal;
    }
void CTConeInvalidateAppUi::RunTestStepL(TInt aStepNum)
	{
		#define DRAW_SIZE   48
		#define DRAW_BORDER 8
		#define PARENT_HALF_WIDTH 64
		
		//Clear the offscreen bitmap to solid black, so that at each iteration we can see what is drawn during that frame.
		CTransGc *pOffGc = ((CTransGc*)iViewControl->iOffScreen->OffScreenGc());
		pOffGc->SetOrigin(TPoint(0,0));
		pOffGc->SetAlphaLevel(KAlphaOpaque);
		pOffGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		pOffGc->SetBrushColor(TRgb(0,0,0,0));
		pOffGc->Clear();		

		//1/4 transparent (or 3/4 opaque).
		pOffGc->SetAlphaLevel(192);

		//Clear the 2nd offscreen bitmap 
		pOffGc = ((CTransGc*)iViewControl->iOffScreen2->OffScreenGc());
		pOffGc->SetOrigin(TPoint(0,0));
		pOffGc->SetAlphaLevel(KAlphaOpaque);
		pOffGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
		pOffGc->SetBrushColor(TRgb(0,0,0,0));
		pOffGc->Clear();		
		//1/4 transparent (or 3/4 opaque).
		pOffGc->SetAlphaLevel(192);

		TPoint drawOffset;		
		
		TInt Phase = aStepNum - 1;
				
		if (Phase<KNumTestSteps)
		{			
			//Create the control and setup its parameters. The top 2 bits of Phase define window ownership combination for 
			//the 2 sub levels of the animated control. 
			TInt OwnerMask = (Phase>>2);
			//The LSB is set to 1 (the parent which is always window owning). 
			iViewControl->CreateComponentControlL(1, OwnerMask<<1|1);
			
			//Set backgrounds for the original control and the overlayed controls.
	    	iViewControl->iControl->SetBackground(iViewControl->iControl);
	    	iViewControl->iControlImage->SetBackground(iViewControl->iControlImage);
	    	iViewControl->iControlImage2->SetBackground(iViewControl->iControlImage2);

			//The lower two bits of Phase define the redraw rectangle position in the sequence (tl, tr, br, bl) and repeats this cycle.		
			
			TInt Region = Phase & 3;
																						
			switch (Region)
				{
				case 0: drawOffset = TPoint(DRAW_BORDER,    			   DRAW_BORDER); 					break;
				case 1: drawOffset = TPoint(PARENT_HALF_WIDTH+DRAW_BORDER, DRAW_BORDER);					break;
				case 2: drawOffset = TPoint(PARENT_HALF_WIDTH+DRAW_BORDER, PARENT_HALF_WIDTH+DRAW_BORDER);	break;
				case 3: drawOffset = TPoint(DRAW_BORDER,    			   PARENT_HALF_WIDTH+DRAW_BORDER);	break;
				default : break;
				}
	
	
			INFO_PRINTF6(_L("Invalidate rect: Step=%2d, OwnerMask=%1d%1d%1d, Region=%1d"), aStepNum, OwnerMask>>1&1, OwnerMask&1, 1, Region);

			//Set up the redraw rectangle for this test run																		
			TRect redrawRect(drawOffset, TSize(DRAW_SIZE,DRAW_SIZE));
			
			//Draw the main control, before we set any special Gcs
			iViewControl->iControl->DrawNow();
								
			//Now set each control to an offscreen Gc in "chequer board fashion"
			
			for (TInt j=0; j<4; j++)
				for (TInt k=0; k<4; k++)
				{
					CCoeControl *pControl = iViewControl->iControl-> ComponentControl(j)->
																   ComponentControl(k);
												
					if ((k==0)||(k==3)) //is the chequer pattern
						pControl->SetGc(iViewControl->iOffScreen->OffScreenGc());
					else																												
						pControl->SetGc(iViewControl->iOffScreen2->OffScreenGc());														
					

				}

			
			//and set the control without a background, for the subrect redraw
			iViewControl->iControl->SetBackground(NULL);			
																
			for (TInt i=0; i<50; i++) //Animation cycle whilst the rectangular region is being updated
				{
				
				//Reset the Gcs' window cache variable, required every redraw cycle so the Gc knows when a clear is required
				((CTransGc*)iViewControl->iOffScreen->OffScreenGc())->iWin = NULL;
				((CTransGc*)iViewControl->iOffScreen2->OffScreenGc())->iWin = NULL;
				
				//Animate the controls
				iViewControl->iControl->AnimateComponents();		

				//Instruct the control the redraw the desired rectangle
				iViewControl->iControl->DrawNow(redrawRect);						

				//Draw the whole offscreen image so that we can check the correct part of the rectangle was drawn
				iViewControl->iControlImage->DrawNow();
				
				//Draw the offscreen image blended over background.
				iViewControl->iControlImage2->DrawNow();
				
				User::After(TTimeIntervalMicroSeconds32(1000));			
				}
		}
Example #30
0
void CWindowMover::HandlePointerEventL(const TPointerEvent& aPointerEvent)
    {
    CCoeControl* control =(viewer->winId());
    if (aPointerEvent.iType == TPointerEvent::EButton1Down)
        {
        iPointerPoint1=aPointerEvent.iPosition;
        iPointerPoint2=aPointerEvent.iPosition;
        MovingChanged(true);

        QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress);
        pressEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX, iPointerPoint1.iY-control->Position().iY));
        qDebug()<<pressEvent.scenePos().x()<<pressEvent.scenePos().y();
        pressEvent.setButton(Qt::LeftButton);
        pressEvent.setButtons(Qt::LeftButton);
        QApplication::sendEvent(viewer->scene(), &pressEvent);
        }
    else if (aPointerEvent.iType == TPointerEvent::EDrag)
        {
        iDragged=ETrue;
        TInt dx=aPointerEvent.iPosition.iX-iPointerPoint1.iX;
        TInt dy=aPointerEvent.iPosition.iY-iPointerPoint1.iY;
        if (!axisSet)
        {
            if (abs(dy)>abs(dx)) {axisX=0; axisY=1;}
            else {axisX=1;axisY=0;}
            axisSet=true;
        }
        RWindow rWindow=(control->Window());
        control->SetPosition(TPoint(dx*axisX,dy*axisY));
        control->DrawBackground(TRect(control->Position(),control->Size()));
        }
    else if (aPointerEvent.iType==TPointerEvent::EButton1Up)
        {
        iPointerPoint2=aPointerEvent.iPosition;
        //MakeVisible(EFalse);
        int gest=settings->value("settings/gesture").toInt();
        if (gest==0) axisSet=false;

        float horSense=settings->value("settings/horsense",0.5).toFloat();
        float verSense=settings->value("settings/versense",0.5).toFloat();
        int width=control->Size().iWidth;
        int height=control->Size().iHeight;
        int x=control->Position().iX;
        int y=control->Position().iY;
        qDebug()<<"("<<x<<","<<y<<")"<<horSense<<verSense;
        if (x>(horSense)*width)
           {startAnim(EXAxis,width);}
        else if (x<(-horSense)*width)
           {startAnim(EXAxis,-width);}
        else if (x!=0)
           {startAnim(EXAxis,0);}
        if (y>(verSense)*height)
           {startAnim(EYAxis,height);}
        else if (y<(-verSense)*height)
           {startAnim(EYAxis,-height);}
        else if (y!=0)
           {startAnim(EYAxis,0);}
        if (abs(iPointerPoint1.iX-iPointerPoint2.iX)<20&&abs(iPointerPoint1.iY-iPointerPoint2.iY)<20)
        {
            QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
            releaseEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX, iPointerPoint1.iY-control->Position().iY));
            releaseEvent.setButton(Qt::LeftButton);
            releaseEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &releaseEvent);
        }
        else
        {
            QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove);
            moveEvent.setScenePos(QPointF(iPointerPoint1.iX-control->Position().iX-10,iPointerPoint1.iY-control->Position().iY-10));
            moveEvent.setButton(Qt::LeftButton);
            moveEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &moveEvent);
            QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease);
            releaseEvent.setScenePos(QPointF(0,0));
            releaseEvent.setButton(Qt::LeftButton);
            releaseEvent.setButtons(Qt::LeftButton);
            QApplication::sendEvent(viewer->scene(), &releaseEvent);

        }
        MovingChanged(false);
        }
    CCoeControl::HandlePointerEventL(aPointerEvent);
    }