advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 2/5 | Rate this item | 1 user has rated this item.
Email this articleEmail this article
 
Build Better Mobile UIs with a New Brew Framework, Part II
Build on what you learned in Part I of this series, and learn how to create multi-screen user interfaces, manage applications using forms, and work with the model-view-controller paradigm in BREW. 

advertisement
n my last article, I showed you how to get started with the QUALCOMM BREW UI toolkit and introduced BREW's notion of forms and widgets. In this article, you'll build on that knowledge and look at an entire multi-screen application to see how forms, widgets, models, and listeners fit together.

The IOU application (see Figure 1 and Figure 2) consists of three screens: one to list the money you owe people and money they owe you, and two to let you enter in IOUs and debts owed to you (referred to as "UOMe's" in the source code). It's not a commercial application, but serves two very real purposes: it lets us track our "coffee debts" around the office where I work, and it provided me with a playground in which to work with the BREW UI Toolkit before using what I learn in commercial applications.

Constructing a List of Items
The previous article demonstrated how to set up a simple form and populate it with widgets. Listing 1 shows you how to do this same thing for a form with a menu. However, using the UI Toolkit's support for lists and menus (vertical and horizontal lists are provided, as is a grid list) is a bit trickier.


Figure 1. IOUs and UOMes: This screen lists the money you owe people and money they owe you.
 
Figure 2. Entering The Debts: This screen shows where you enter in IOUs and UOMes.

Listing 1 follows the same basic structure to create a form as in the first article's example:

  • Create a form
  • Create a container
  • Bind the container to the form
  • Create some widgets
  • Add the widgets to the container
  • Configure the widgets so they appear the way you want
There are a few key differences between initializing a form with static or text widgets and initializing a form with menu widgets.

When configuring the list widget itself, I provide an explicit model for the list widget. This model (created at startup) is responsible for containing the list of items in the list. Listing 1 uses a simplistic data model, keeping each IOU as a name and an amount in a wide character string. More importantly, however, is that the list widget is actually a decorator—a widget that wraps the behavior of another widget, in essence decorating it. In the UI Toolkit, many widgets, such as those providing menus and scrollbars, are actually decorators, that modify the behavior of the widgets they contain through their handling of events and the data stored in their models. The list widget takes another widget (in Listing 1, it's a static text widget), and uses that widget to draw each element of the list given information from the list widget's own data model, the IMenuModel set using IWIDGET_SetModel.

In addition to setting the list widget's data model, you must also configure the height of a list widget's individual item. Do this by obtaining the decorator interface to the list widget, and then setting its item height to the preferred height of the contained widget. Before releasing the decorator interface, set the decorator's widget to be the contained static text widget.

Finally, Listing 1 shows how to intercept events going to a specific widget or to a form. This is essential for large applications, because it lets you keep form-specific event handling in separate methods, which prevents you from cluttering up your event handler. If you're writing in C++, you can think of this as the means by way you provide an event handler method for a specific form class. Listing 1 does this in two ways: it creates a handler for the form containing the list (called the MenuForm), and it also creates a focus listener for the list which will receive notifications whenever the list changes state as a result of user action.

  Next Page: Handling Events on Behalf of Forms
Page 1: IntroductionPage 3: Listening to Model Changes
Page 2: Handling Events on Behalf of Forms 
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
Avaya Article: Call Control XML - Powerful, Standards-Based Call Control
Internet.com eBook: The Pros and Cons of Outsourcing
Go Parallel Article: Scalable Parallelism with Intel(R) Threading Building Blocks
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
Go Parallel Article: James Reinders on the Intel Parallel Studio Beta Program
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Go Parallel Article: Getting Started with TBB on Windows
HP eBook: Storage Networking , Part 1
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Go Parallel Video: Intel(R) Threading Building Blocks: A New Method for Threading in C++
HP Video: Is Your Data Center Ready for a Real World Disaster?
Microsoft Partner Portal Video: Microsoft Gold Certified Partners Build Successful Practices
HP On Demand Webcast: Virtualization in Action
Go Parallel Video: Performance and Threading Tools for Game Developers
Rackspace Hosting Center: Customer Videos
Intel vPro Developer Virtual Bootcamp
HP Disaster-Proof Solutions eSeminar
HP On Demand Webcast: Discover the Benefits of Virtualization
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Microsoft Download: Silverlight 2 Software Development Kit Beta 2
30-Day Trial: SPAMfighter Exchange Module
Red Gate Download: SQL Toolbelt
Iron Speed Designer Application Generator
Microsoft Download: Silverlight 2 Beta 2 Runtime
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
IBM IT Innovation Article: Green Servers Provide a Competitive Advantage
Microsoft Article: Expression Web 2 for PHP Developers--Simplify Your PHP Applications
Featured Algorithm: Intel Threading Building Blocks - parallel_reduce
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES