|
||
The following examples give some suggestions on how to process events related to the whole system, rather than individual windows or window groups.
To detect if the window group with focus has changed, use the EEventFocusGroupChanged
event type.
You can get the handle of the window group with focus by calling the RWsSession::GetFocusWindowGroup()
function for the iWs
window server session.
// Window group with focus changes
case EEventFocusGroupChanged:
{
// Get the handle of the group with focus
TInt handle = iWs.GetFocusWindowGroup();
break;
}
To detect if the window group has been destroyed or changed name, use the EEventWindowGroupsChanged
event type.
You can get a a list of identifiers of window groups in the window server session by calling RWsSession::WindowGroupList()
. Call the RWsSession::GetWindowGroupNameFromIdentifier()
function to get the window group name passed to it in the windowName
buffer.
// Window group destroyed, or changes name
case EEventWindowGroupsChanged:
{
// Get a list of the names and IDs of the all the window groups
CArrayFixFlat<Tint>* windowList = new CArrayFixFlat<TInt>(4);
CleanupStack::PushL(windowList);
// Get a list of window group IDs
User::LeaveIfError(iWs.WindowGroupList(windowList));
TBuf<50>windowName;
for (TInt i = 0; i< windowList -> Count(); i++)
{
// Get the window name for each window group ID
iWs.GetWindowGroupNameFromIdentifier( (*windowList)[i], windowName );
// do something with windowName...
// ..
}
CleanupStack::PopAndDestroy(); // windowList
break;
}
To detect if screen size or mode changed event has been issued, use the EEventScreenDeviceChanged
event type.
You can get the screen rotation and size by calling CWsScreenDevice::GetScreenModeSizeAndRotation()
. Pass as parameters the current screen mode and a TPixelsTwipsAndRotation
object to get the orientation of the specified screen mode, and its size in both pixels and twips.
// Screen size mode changed
case EEventScreenDeviceChanged:
{
// Get the new screen mode and size
TInt newMode = iScreen.CurrentScreenMode();
TPixelsTwipsAndRotation sizeAndRotation;
iScreen.GetScreenModeSizeAndRotation(newMode, sizeAndRotation);
break;
}
Note that for screen size mode changed events, often after having got the new size and rotation you would set it back on your screen device.
To detect if power on/off events have been issued, use the EEventSwitchOn
, EEventSwitchOff
or EEventKeySwitchOff
event types.
// Power on/off events
case EEventSwitchOn:
case EEventSwitchOff:
case EEventKeySwitchOff:
{
break;
}
To detect if case open/closed events have been issued, use the EEventCaseOpened
, EEventCaseClosed
event types.
// Case open/closed events
case EEventCaseOpened:
case EEventCaseClosed:
{
break;
}
To detect if an error event message has been issued, use the EEventErrorMessage
event type.
You can get information about the error event by calling the TWsEvent::ErrorMessage()
function.
// A window server error event message
case EEventErrorMessage:
{
// Get error category and code
TWsErrorMessage* msg = iWsEvent.ErrorMessage();
TWsErrorMessage::TErrorCategory errorCategory = msg -> iErrorCategory;
TUint code = msg -> iError;
break;
}