×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    6

    UI Scaling problem

    Hi,

    I have make a simple AKnQueryDialog,where I have a editor. I want to display a image and string in the centre of the screen. When i change the orientation from potrait to landscape, the editor does not cover the whole area, a part of it is left out. I am enclosing the code , I could not find any mistake in it. I have tried display ing the string in the middle, but it always comes at the startign point. Thanks in advance

    rssfiles
    Code:
    RESOURCE DIALOG r_example_dialog_first_screen
    	{
    	flags = EEikDialogFlagNoDrag  | EEikDialogFlagFillAppClientRect
    	        | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
    
    	buttons = R_AVKON_SOFTKEYS_EMPTY;
    	items =
    			{
    			DLG_LINE
    				{
    				id=EExampleAboutDlgEditor;
    				type=EEikCtEdwin;
    				control= EDWIN
    								{
    								flags = EEikEdwinDisplayOnly | EEikEdwinResizable |
    								        EEikEdwinNoAutoSelection
    								| EEikEdwinAvkonDisableCursor | EEikEdwinAllowPictures ;
    					};
    				}
    			};
    	}
    Src file

    Code:
    ExampleFirstScreen::ExampleFirstScreen(
    				CAknsBasicBackgroundControlContext &aBgContext) :
    		 iBgContext(aBgContext)
    			{
    			
    			}
    
    		TTypeUid::Ptr ExampleFirstScreen::MopSupplyObject(TTypeUid aId)
    			{
    			if ( &iBgContext)
    				{
    				return MAknsControlContext::SupplyMopObject ( aId, &iBgContext);
    				}
    			return CAknDialog::MopSupplyObject (aId);
    
    			}
    
    		// Draw this application's view to the screen
    		void ExampleFirstScreen::Draw(const TRect& aRect) const
    			{
    		
    			CWindowGc& gc = SystemGc();
    							
    			// Redraw the background using the default skin
    			MAknsSkinInstance* skin = AknsUtils::SkinInstance ();
    			MAknsControlContext* cc = AknsDrawUtils::ControlContext ( this);
    			AknsDrawUtils::Background ( skin, cc, this, gc, aRect);
    			gc.Clear (); 
    			}
    		void ExampleFirstScreen::PreLayoutDynInitL()
    			{
    			TBuf<300> labelText;
    				labelText.Copy(_L("Hai..."));
    			 const CFont* editorFont = AknLayoutUtils::FontFromId( EAknLogicalFontSecondaryFont, NULL );
    
    				TCharFormat charFormat;
    				TCharFormatMask charFormatMask;
    				charFormat.iFontSpec = editorFont->FontSpecInTwips();
    				charFormatMask.SetAll();
    				iEditor = static_cast<CEikEdwin*>(ControlOrNull(EExampleAboutDlgEditor));
    				TRect aCurrLayoutRect;
    							
    							// Get Rect for 'MainPane' for current layout
    							AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane,
    									aCurrLayoutRect);
    				iEditor->SetTextL(&labelText);
    				/** Get the text */
    				CGlobalText* globalText = (CGlobalText*)iEditor->Text();
                    
    				/** Apply the charector formatting */
    				globalText->ApplyCharFormatL(charFormat,charFormatMask,0,
    											 iEditor->TextLength());
    			}
    		void CExampleFirstScreen::HandleResourceChange( TInt aType)
    			{
    			CAknDialog::HandleResourceChange( aType );
    				//do re-layout
    				TRect aCurrLayoutRect;
    				
    				// Get Rect for 'MainPane' for current layout
    				AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane,
    						aCurrLayoutRect);
    
    				// Set this control's rect
    				this->SetSize( aCurrLayoutRect.Size() );
    				   TInt a  = aCurrLayoutRect.Height() + 8;//I got it to cover the whole area after adding this line( when the orientation changed from potrait to landscape.)
    				        aCurrLayoutRect.SetHeight( a );
    				iEditor->SetSize( aCurrLayoutRect.Size());
    				       // iEditor->SetExtent( TPoint( aCurrLayoutRect.iTl),aCurrLayoutRect.Size());
    			}
    		void ExampleFirstScreen::SetSizeAndPosition ( const TSize& aSize )
    			{
    			CAknDialog::SetSizeAndPosition( aSize );
    			TRect aCurrLayoutRect;
    			AknLayoutUtils::LayoutMetricsRect (AknLayoutUtils::EMainPane,
    				aCurrLayoutRect);
    			this->SetSize( aCurrLayoutRect.Size() );
    			   TInt a  = aCurrLayoutRect.Height() + 8;//I got it to cover the whole area after adding this line( when the orientation changed from potrait to landscape.)
    							        aCurrLayoutRect.SetHeight( a );
    			iEditor->SetSize( aCurrLayoutRect.Size());
    
    			}
    Last edited by ltomuta; 2008-07-06 at 15:08. Reason: Use [code] [/code] to make your code easier to read

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

    Re: UI Scaling problem

    Hi,
    I have got rid of the scaling problem I had. Now I am worried is:

    How to place the text in the Middle of the screen. I want to place a string i.e Hai..
    in the middle of the editor... and want to have different font and sizes for both the strings I want to display

    I am displaying the text in this way now:

    Code:
    #define example_text_one "Hai.."
    #define example_text_two "Morning"
    Code:
    TRect aCurrLayoutRect;
    			HBufC* buf = StringLoader::LoadL( R_HOME_SCREEN_TEXT );
    			HBufC* copyBuf = StringLoader::LoadL( R_EXAMPLE_TEXT);
    			CleanupStack::PushL( copyBuf );
    			CleanupStack::PushL( buf );
    			HBufC* newBuf = buf->ReAllocL( buf->Des().Length() + 256 );
    			CleanupStack::Pop( buf );
    			buf = newBuf;
    			CleanupStack::PushL( buf );
    			TPtr bufPtr = buf->Des();
    			bufPtr.Append( copyBuf->Des() );
    			const CFont *font= AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont);  
    			const CFont *titleFont = AknLayoutUtils::FontFromId(EAknLogicalFontTitleFont);   
    			TCharFormat charFormat;
    			TCharFormatMask charFormatMask;
    			TCharFormatMask titleFormatMask;
    			TCharFormat titleFormat;
    			charFormat.iFontSpec = font->FontSpecInTwips();
    			charFormat.iFontPresentation.iTextColor = KRgbBlack;
    			charFormatMask.SetAttrib( EAttFontHeight );
    			charFormatMask.SetAttrib( EAttColor ); 
    			titleFormat.iFontSpec = titleFont->FontSpecInTwips();
    			titleFormat.iFontPresentation.iTextColor = KRgbBlue;
    			titleFormatMask.SetAll();
    			iEditor = static_cast<CEikEdwin*>(ControlOrNull(EExampleAboutDlgEditor));						
    		    iEditor->SetSize( aCurrLayoutRect.Size());	
    			iEditor->SetTextL( buf );
    			CleanupStack::PopAndDestroy( 2, copyBuf ); // buf
    				/** Get the text */
    			CGlobalText* globalText = (CGlobalText*)iEditor->Text();
    				/** Apply the charector formatting */
    			globalText->ApplyCharFormatL( charFormat,charFormatMask,0,
    										  5 );
    			globalText->ApplyCharFormatL( titleFormat,titleFormatMask,6,
    												  globalText->DocumentLength()-8 );
    Last edited by Symbian_newbee; 2008-07-07 at 21:52.

Similar Threads

  1. GIF Scaling problem in MMS
    By stephensson in forum General Messaging
    Replies: 0
    Last Post: 2008-06-09, 17:48
  2. scaling problem
    By Nitesh Bhardwaj in forum Symbian Media (Closed)
    Replies: 5
    Last Post: 2008-06-02, 14:10
  3. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  4. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  5. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

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