ebmDevMag.com home
ebm Developer's Magazine
links

developer's mag
main page

article
part 1
part 2
part 3
part 4
part 5
part 6


3 - Tinkering On Our Own

Although GUI_Alert() is a flexible dialog, we often need something a little different (such as Yes/No/Cancel), and for that we must create our own. The source code for the alert dialog can be seen at /franklin/SDK/samples/gui/calert.cpp, and shows the techniques used to create a general-purpose dialog. Although we could simply copy and modify that code to create a variation (subject to any Franklin licensing restrictions), it's quite straightforward to create a completely new one of our own, and we can consult the calert.cpp file to get tips on good dialog construction.

Primarily, a good dialog adjusts to its environment. For instance, imagine if a dialog popped up in portrait mode while the program was in landscape. In addition, screen sizes on the ebm will quite likely increase, affecting dialog size and placement (such as centering). To avoid this, a dialog should format to the current screen size, available from the functions LCD_QueryWidth() and LCD_QueryHeight().

Once created, the window will also need to adjust the internal objects, moving and resizing controls to fit. Although the code in calert.cpp makes use of GetWidth() and GetHeight() for sizes, these return the outside window size, including the frame. For more accurate results, use the GetUsableRect() function, which returns the internal window size.

Previous Section
Next Section

Copyright © 2001-2006 ebmDevMag.com - Legal Notice