×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    17

    Landscape/Portrait orientation

    Hi @ all,

    I have developed a small application, with some labels, which are drawn to the view. My problem is now, that if I change the view to Landscape, my lowermost label, is not anymore on the screen, because I have hardcoded the positions in pixel. I tried to figure out now, what view is activated and depending on it, draw the labels higher/more to the left, because now I have more room to fit 2 labels in one row, and wouldn't need to many rows, so everything fits on the screen again.

    I have read some wiki pages about it, and searched in the forum and knowlege base, but I didn't find a solution to my prob.

    I tried last the version with CCoeEnv, but this always returns me EAppUiOrientationUnspecified! :(

    Here is my code, I'll try to handle it in the SizeChanged() funktion (maybe it's the wrong place to do this?):

    Code:
    void CTestProgramAppView::SizeChanged()
    	{
    	TInt yOffset = 0;
    
    	CCoeEnv* env = CCoeEnv::Static();
    	if( env )
    	    {
    	    CAknAppUiBase* appUiBase = REINTERPRET_CAST( CAknAppUiBase*, env->AppUi() );
    	    if( appUiBase )
    	        {
    	        /* 
    	        * Possible values for TAppUiOrientation are :
    	        * EAppUiOrientationUnspecified,
    	        * EAppUiOrientationPortrait,
    	        * EAppUiOrientationLandscape,
    	        * EAppUiOrientationAutomatic
    	        **/
    	        CAknAppUiBase::TAppUiOrientation orientation = appUiBase->Orientation();
    	        if (orientation == CAknAppUiBase::EAppUiOrientationLandscape)
    	        	{
    	        	yOffset = 20;
    	        	}
    	        }
    	    }
    	
    	
    	iLabelHeading->SetExtent( TPoint(10,10), iLabelHeading->MinimumSize());
    	iLabelHeadingText->SetExtent( TPoint(10 + 4* yOffset ,30 -yOffset), iLabelHeadingText->MinimumSize());
    	
    	// ... more labels follow
    
    	iLabelAdditionalInformationText->SetExtent( TPoint(10,200 -yOffset), TSize(250,70));
    	 
    	DrawNow();
    	}
    What am I doing wrong? Thanks a lot in advance for your help!

    Cheers,
    Matt

    p.s. I also tried it with:

    Code:
    void CScalableScreenDrawingControl::HandleResourceChange(TInt aType)
        {
        CCoeControl::HandleResourceChange(aType);
        if(aType == KEikDynamicLayoutVariantSwitch)
           {
           // ...
           }
        }
    but here I just know, a view switch happened, and I still don't know if its portait or landscape...?!

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,144

    Re: Landscape/Portrait orientation

    You could try setting the new size in your HandleResourceChange() function..

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    17

    Re: Landscape/Portrait orientation

    thanks for you reply. :)

    two questions to that:

    I don't have implemented that function yet, I suppose it is called automatically? When?

    And then I still don't know how to check which view I've got? I think the TAppUiOrientation will still be containing "EAppUiOrientationUnspecified" ?

    Cheers, Matt

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    889

    Re: Landscape/Portrait orientation

    I don't have implemented that function yet, I suppose it is called automatically? When?
    It will be called by the framework whenever the layout switches.. You can now decide on the points to place the labels of your UI ...
    You can well go thru the Scalable screen drawing example from FN to know its usage..

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    17

    Re: Landscape/Portrait orientation

    Hi,

    I have implemented this HandleResourceChance() Function now in my AppUI class. It's like this:

    Code:
    void CAppUi::HandleResourceChangeL(TInt aType)
    {
    	CAknAppUi::HandleResourceChangeL(aType);
    
    	if ( aType==KEikDynamicLayoutVariantSwitch )
    		{		
                    // Check if we are switched to Landscape Orientation
    		if(this->Orientation() == CAknViewAppUi::EAppUiOrientationLandscape)
    			{
                            // Temp: Show InformationNote to see, that if statement is correct
    			HBufC* text = StringLoader::LoadLC(R_BLABLA_TEXT);
    			CAknInformationNote *myInformationNote = new (ELeave) CAknInformationNote;
    			myInformationNote->ExecuteLD(*text);
    			CleanupStack::PopAndDestroy(text);
    			}
    	    }
    }
    So, all I won by now is, that I find out WHEN the orientation is changed. The second if statement still doesn't work. this->Orientation() still has the EAppUiOrientationUnspecified value!

    I also checked out the Scalable_screen_drawing_how_to.pdf ... but all they say in this document is, how to find out WHEN the orientation is changed, and then they call

    SetExtentToWholeScreen();

    But full screen is not what I need... :(

    Thanks again,

    matt

  6. #6
    Registered User
    Join Date
    May 2008
    Posts
    17

    Re: Landscape/Portrait orientation

    Hey buddies,

    I have solved the problem now, by toggling a TBool variable everytime i get a orientation switch event, and adjust my view depending on it. But it's a really unsatisfactionary/bad solution, this Orientation() function has to be working somehow, hasn't it?!

    Cheers

    UPDATE: This problem is not solved when the app started already in Landscape mode! So any help about the Orientation() function is appreciated. Thanks!!
    Last edited by greumatt; 2009-01-07 at 02:32.

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: Landscape/Portrait orientation

    Orientation is simply not the way, see paralel thread http://discussion.forum.nokia.com/fo...d.php?t=154853 (by the way: feel free to look around a bit prior to starting a new thread).

Similar Threads

  1. Changing orientation does not work!
    By FrankTheFox in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-12-12, 10:55
  2. Replies: 6
    Last Post: 2008-11-10, 16:40
  3. Detect device orientation capabilities
    By adigadish in forum Symbian
    Replies: 3
    Last Post: 2008-02-01, 11:44
  4. Application/camera orientation
    By dudi in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2008-01-29, 16:52
  5. Landscape orientation without correct softkey support
    By olivier_randria in forum Symbian
    Replies: 8
    Last Post: 2007-02-24, 15:50

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •