|
|
|
|
|
|
|
|
|
|
|
|
|
|
PROGRAMMING POWER
Utility routines for programmers
By Alan Jay Weiner
We looked at resources last month, and started looking at forms and controls. This month, I'm going to skip ahead a bit and get some code into your hands. We can return to examine controls next month.
These are some of the routines from my personal library. They make working with buttons and text a bit easier.
Pointers to control objects Many of the APIs require pointers to various control objects rather than simply the identification number you've assigned them. The GetObjectPtr routine in Listing A (see http://www.component-net.com/pp-extras/utility1.html) takes the ID number and determines the pointer. It assumes that the control is on the currently displayed form.
This routine is straight out of the Palm examples. Many of the following routines use it to reference control objects.
Hiding buttons Sometimes we want to hide a button. For example, to make sure a particular feature isn't available until some other conditions occur. Or we want to make a button visible because those conditions have been met.
Making a control invisible when the form is displayed is easy. Simply mark it "not usable" when you design the form. Then, when the form is first displayed, the control won't be drawn.
Listing B (see http://www.component-net.com/pp-extras/utility2.html) shows two routines; MakeButtonInvisible hides a button. The other, MakeButtonVisible, unhides it.
Changing a button's text Listing C (see http://www.component-net.com/pp-extras/utility3.html), ChangeButtonText, changes the text on a button. Use this to make a button mean different things under different circumstances. It's easier to change the text on a single button than to have multiple buttons in the same place.
Centering a line of text on the screen This final routine, in Listing D (see http://www.component-net.com/pp-extras/utility4.html), centers a line of text. Actually, it's two routines; the first sets the font unless the new font is CURRENT_FONT, or the value -1. While this could be done in-line in the DisplayCentered routine, we'll see it in future text-display routines. It also updates the font value with the original font, so it can later be restored.
The regular fonts are defined in FONT.H; they are stdFont, boldFont, largeFont, symbolFont, symbol11Font, symbol7Font, and ledFont. The Palm III has added a new font called largeBoldFont.
DisplayCentered itself is fairly simple - it optionally changes to a new font, gets the width of the text string, and draws it in the right place.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Advertisement --
EASY DEDICATED AND VIRTUAL DEDICATED SERVERS FOR AS LOW AS $67.99 PER MONTH
Customize and configure your own dedicated server. Simply choose one of our popular plans or select your own Linux or Windows server and plan options.
NO LONG WAITS. Server provisioned within hours.
Tap here now and be up and running with your own server tonight. |
-- Advertisement --
Write for Computing Unplugged!
Share your experience and expertise with other handheld device users. There are new opportunities at ZATZ for contributing authors and editors.
Write about something you're an expert on and get your name in lights.
For Writers' Guidelines and to discuss topics, contact Staff Editor Steve Niles. This is your opportunity to shine in front of your peers, your clients, and friends.
Click for more info! |
|
|
|
|
|
|
|
|
|
|