July 25, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Screen Rotation in Qualcomm Brew

  • March 10, 2008
  • By Ray Rischpater
  • Send Email »
  • More Articles »

BREW sends you an event, EVT_SCR_ROTATE, whenever the user rotates the screen. When you get this event, you can determine the desired screen orientation using ISHELL_GetDeviceInfoEx, and then set the screen orientation using IDISPLAY_SetPrefs. So, if the preceding code listing was in a HandleRotate function, you would add something like the following to your top-level event handler before you pass events to other forms or application states:

Switch( evt )
{
   case EVT_APP_START:
      HandleRotate( p );
      ...
      return TRUE;

   case EVT_APP_STOP:
      ...
      return TRUE;

   case EVT_SCR_ROTATE:
      HandleRotate( p );
      return TRUE;
      ...    // other events follow
}

When handling the rotation event, you should return TRUE if you intend to change orientation, FALSE otherwise.

Strategies for Dealing with Rotated Layouts

So, what about your application screen layout and logic itself? If you're working with a legacy application, you've got some work ahead of you. You may well need to do some significant re-engineering, as you think best about how to lay out your application in multiple layouts. Even so, this approach can help you whether you're working with legacy or new code:

  • Store graphic assets for different screen orientations in different resource files, and select the resource file based on the current screen orientation when loading the assets.
  • Lay out your screen contents in thirds. When the screen rotates, move the top or bottom third of your screen up along either the left or right side of the first two-thirds of the screen (see Figure 2).



Click here for a larger image.

Figure 2: Managing screen rotation by dividing your UI into thirds.

The division-by-thirds trick is approximate, and of course requires some considerable thought in laying out your application. It works best with layouts that have a bar of widgets such as buttons or annunciators along one margin; this can be rotated 90° to fit in the remaining space. Of course, games and other applications may have their own unique requirements.

Conclusion

Supporting screen rotation in Qualcomm Brew isn't hard: It's a matter of listening for when the screen rotates, determining the desired orientation, and then telling the screen bitmap to orient in the desired way.

Acknowledgments

I'd like to thank Rashmi Garud at Rocket Mobile for her assistance with the article and work in adding screen rotation support to our applications.

About the Author

Ray Rischpater is the chief architect at Rocket Mobile, Inc., specializing in the design and development of messaging and information access applications for today's wireless devices. Ray Rischpater is the author of several books on software development, including eBay Application Development and Software Development for the QUALCOMM BREW Platform, both available from Apress, and is an active Amateur Radio operator. Contact Ray at kf6gpe@lothlorien.com.





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel