Linking in the Cards Class
We are now ready to link in the cards class. Copy the header file into the source directory and the include directory. We use a deck of cards in the AppUi class. Include the cards.h file into the header file of the Container and add a pointer to a deck of cards into the Container class as below The deck needs to be instantiated. We can add a new method, StartGame , to initialize the card game iPlayerWins iPhoneWins 0 iDeckOfCards CCards NewL 2 Here we see the addition of two new variables,...
Key Presses
To get the chance to handle key presses, we need to derive a class from CoeControl, which provides a virtual method, OfferKeyEventL . This should be implemented to match handled key presses and is called by the framework when an event occurs. You must inherit the class from CoeControl and define the OfferKeyEventL method. class CKeyPressContainer public CCoeControl, MCoeControlObserver TKeyResponse OfferKeyEventL const TKeyEvent amp aKeyEvent, When this method is called by the framework, it can...
Advertising a Service
Now that we can detect other Bluetooth devices we need a means of checking each of these devices to find out which are running our specific application. The server will advertise the service for the client to detect. The service discovery protocol SDP provides a simple mechanism for communicating between Bluetooth devices. The SDP uses a simple request-response model, which enables the client device to query the server. In this example, the client requests the service record from the server...
eikappinfo Resource
The final part of the header is the definition of the EIK_APP_INFO resource. This is the standard resource that the application user interface will use. Not all of the fields are required in fact there are only two main fields in the structure that are commonly used menubar and CBA. Menubar defines the menu structure to use it is handled by Han-dleCommandL in the AppUi. We take a closer look at the menu structure in the next section. CBA is an abbreviation for Control Button Array, in other...
Data Query Dialog
A data query dialog see Figure 5.8 asks for input from the user. It has the functionality of a standard dialog, with the layout of a query. The data query dialog is handled in the same way as the other dialogs we have looked at. First we create a resource and set all the appropriate fields flags EGeneralQueryFlags EEikDialogFlagNotifyEsc buttons R_AVKON_SOFTKEYS_OK_CANCEL type EAknCtQuery id EGeneralQuery layout EDataLayout label Enter Name EGeneralQueryFlags is a combination of defined flags...
DeieiVg please uait
dynamically change the text by using either single or plural fields. Set-TextPluralityL ETrue is called to ensure that the plural_label is used. Finally, RunLD executes the resource and deletes the note object once the note is dismissed. If a process takes a noticeable time to complete, a wait note, as illustrated in Figure 5.6, is a good way of informing the user that the program is still executing and has not crashed . This is a deterrent, keeping the impatient user from pressing keys. It...
CBA Buttons
CBA buttons define the labels for the left and right softkeys. There are a number of pre-defined softkeys in avkon.hrh, see Table 5.1 for a full list. It is useful to customize applications by defining specific softkeys using the CBA resource structure. It contains a buttons field that takes two CBA_BUTTON definitions. The CBA_BUTTON structure takes an ID for the button and a text-based name. The ID can be used to refer to the button in your code, as we show later. The following code...
DkCanci
The following code example creates a dialog with one EDWIN control line. It may be useful to add another line that has a LABEL control to indicate to the user what they need to enter. flags EEikDialogFlagNoDrag EEikDialogFlagCbaButtons buttons R_AVKON_SOFTKEYS_OK_CANCEL maxlength KMaxNameLength width KMaxNameLength The DIALOG structure uses a number of fields, such as flags, buttons and items. These are the minimum required to define the dialog. There are, however, other fields to define icons...
ClientServer Communication
We are finally ready to link the client and server. The application is controlled from the HandleCommandL method of the AppUI void CBTExampleAppUi HandleCommandL Tint aCommand case EEikCmdExit case EAknSoftkeyExit LIT8 KMessage, Message The application exits on the Exit command or when the Exit softkey is pressed begins the connection process by initiating the device-discovery process when the Connect menu option is selected and sends a message, using a new SendMessageL method which has been...
Note Dialog
A note dialog is a pop-up message that informs the user of an event that has occurred. For instance, if memory is running low on the phone, a warning note appears. A note contains text and can also contain an icon. It can sound an audible tone on activation. The note destroys itself after a period of time. Notes do not require user input, however, if the user causes a key press event, then it cancels the note. As user input is not required, a note does not display softkey labels the wait note...
