sl@0: // Copyright (c) 1994-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Shells for window server window functions.
sl@0: // 
sl@0: //
sl@0: 
sl@0: #include <e32std.h>
sl@0: #include "../SERVER/w32cmd.h"
sl@0: #include "CLIENT.H"
sl@0: #include "w32comm.h"
sl@0: 
sl@0: RWindowTreeNode::RWindowTreeNode()
sl@0: /** Protected default constructor.
sl@0: 
sl@0: This creates a sessionless, uninitialised window tree node handle. This class 
sl@0: is not for user derivation; however derived classes form part of the Window 
sl@0: Server API.
sl@0: 
sl@0: Because RWindowTreeNode and its derived classes are lightweight handles, if 
sl@0: your class contains an object of such a class, the object should be an inline 
sl@0: member rather than a pointer member.
sl@0: 
sl@0: This default constructor allows you to instantiate such an inline member before 
sl@0: the class that contains it has created a window server session. If you do this, 
sl@0: you will need to call the RWindowTreeNode constructor that takes an RWsSession 
sl@0: parameter before you can use the member, because RWindowTreeNode-derived objects 
sl@0: must have a reference to a window server session in order to be valid. */
sl@0: 	{}
sl@0: 
sl@0: RWindowTreeNode::RWindowTreeNode(RWsSession &aWs) : MWsClientClass(aWs.iBuffer)
sl@0: /** Protected constructor which creates an uninitialised window tree node handle 
sl@0: within a server session. 
sl@0: 
sl@0: This class is not for user derivation; however derived classes form part of 
sl@0: the standard Window Server API, and are constructed with a public 
sl@0: constructor with the same signature as this one.
sl@0: 
sl@0: @param aWs Window server session. */
sl@0: 	{}
sl@0: 
sl@0: RWindowBase::RWindowBase() : RWindowTreeNode()
sl@0: /** Protected default constructor; creates an uninitialised, sessionless window 
sl@0: handle.
sl@0: 
sl@0: Handles to server-side objects must be created in a session in order to be 
sl@0: operational; this constructor is merely a convenience to allow the handle 
sl@0: to be stored as a data member. See RWindowTreeNode::RWindowTreeNode() for 
sl@0: details of how the complete setup of a handle field may be deferred until 
sl@0: the window server session is known. */
sl@0: 	{}
sl@0: 
sl@0: RWindowBase::RWindowBase(RWsSession &aWs) : RWindowTreeNode(aWs)
sl@0: /** Protected constructor; creates an uninitialised window handle within a session.
sl@0: 
sl@0: @param aWs Window server session. */
sl@0: 	{}
sl@0: 
sl@0: RDrawableWindow::RDrawableWindow() : RWindowBase()
sl@0: /** Protected default constructor which creates a sessionless, uninitialised drawable-window 
sl@0: handle.
sl@0: 
sl@0: Handles to server-side objects must be created in a session in order to be 
sl@0: operational; this constructor is merely a convenience to allow the handle 
sl@0: to be stored as a data member. See RWindowTreeNode::RWindowTreeNode() for 
sl@0: details of how the complete setup of a handle field may be deferred until 
sl@0: the window server session is known */
sl@0: 	{}
sl@0: 
sl@0: RDrawableWindow::RDrawableWindow(RWsSession &aWs) : RWindowBase(aWs)
sl@0: /** Protected default constructor which creates an initialised drawable-window 
sl@0: handle within a server session.
sl@0: 
sl@0: @param aWs Window server session. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RWindow::RWindow() : RDrawableWindow()
sl@0: /** Default constructor which creates a sessionless, uninitialised window handle. 
sl@0: 
sl@0: Handles to server-side objects must be created in a session in order to be 
sl@0: operational; this constructor is merely a convenience to allow the handle 
sl@0: to be stored as a data member. See RWindowTreeNode::RWindowTreeNode() for 
sl@0: details of how the complete setup of a handle field may be deferred until 
sl@0: the window server session is known. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RWindow::RWindow(RWsSession &aWs) : RDrawableWindow(aWs)
sl@0: /** Constructor which creates an initialised window handle within a server session.
sl@0: 
sl@0: @param aWs Window server session to use. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RBackedUpWindow::RBackedUpWindow() : RDrawableWindow()
sl@0: /** Default C++ constructor which creates a sessionless backed-up window handle.
sl@0: 
sl@0: Handles to server-side objects must be created in a session in order to be 
sl@0: operational; this constructor is merely a convenience to allow the handle 
sl@0: to be stored as a data member. See RWindowTreeNode::RWindowTreeNode() for 
sl@0: details of how the complete setup of a handle field may be deferred until 
sl@0: the window server session is known. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RBackedUpWindow::RBackedUpWindow(RWsSession &aWs) : RDrawableWindow(aWs)
sl@0: /** Constructor which creates an uninitialised backed-up window handle within a 
sl@0: session.
sl@0: 
sl@0: @param aWs The window server session that owns the window. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RBlankWindow::RBlankWindow() : RWindowBase()
sl@0: /** Default C++ constructor which creates an invalid blank-window handle. 
sl@0: 
sl@0: See RWindowTreeNode::RWindowTreeNode() for details of how the complete setup 
sl@0: of a handle field may be deferred until the window server session is known. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RBlankWindow::RBlankWindow(RWsSession &aWs) : RWindowBase(aWs)
sl@0: /** Default C++ constructor which creates a valid but uninitialised blank-window 
sl@0: handle. 
sl@0: 
sl@0: This constructor does not create a window in the window server: client programs 
sl@0: must do this by calling RBlankWindow::Construct() before any operations can 
sl@0: be carried out on the window.
sl@0: 
sl@0: @param aWs The window server session that owns the window. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RWindowGroup::RWindowGroup() : RWindowTreeNode()
sl@0: /** Creates a sessionless, uninitialised window group handle.
sl@0: 
sl@0: Handles to server-side objects must be created in a session in order to be 
sl@0: operational; this constructor is merely a convenience to allow the handle 
sl@0: to be stored as a data member. See RWindowTreeNode::RWindowTreeNode() for 
sl@0: details of how the complete setup of a handle field may be deferred until 
sl@0: the window server session is known. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C RWindowGroup::RWindowGroup(RWsSession &aWs) : RWindowTreeNode(aWs)
sl@0: /** Creates an initialised window group handle within a server session.
sl@0: 
sl@0: @param aWs The window server session owning the window group. */
sl@0: 	{}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::Close()
sl@0: /** Closes the node. 
sl@0: 
sl@0: This function should be called on all windows once they are no longer needed. 
sl@0: It causes the window server to destroy the server-side window, and frees client-side 
sl@0: resources owned by the window.
sl@0: 
sl@0: Note: When Close() is called on a parent window, its children are disconnected 
sl@0: from the window tree and are hence removed from the screen. However, any client-side 
sl@0: resources owned by its children are not freed. To free these resources, Close() 
sl@0: (or Destroy()) must be called on all its children individually. */
sl@0: 	{
sl@0: 	if (iBuffer && iWsHandle)
sl@0: 		Write(EWsWinOpFree);
sl@0: 	iWsHandle=NULL;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::Destroy()
sl@0: /** Closes and deletes the node. 
sl@0: 
sl@0: This function calls Close() followed by delete on the window. Use this function 
sl@0: only when the window is allocated in its own heap cell. */
sl@0: 	{
sl@0: 	Close();
sl@0: 	delete this;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TUint32 RWindowTreeNode::ClientHandle() const
sl@0: /** Gets the window's client handle
sl@0: 
sl@0: The return value is the client's integer handle that was passed as an argument
sl@0: to the window's Construct() function: see RWindow::Construct()
sl@0: for a description of the client handle.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Handle ID for the window.
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpClientHandle));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TUint32 RWindowTreeNode::Parent() const
sl@0: /** Gets the node's parent. 
sl@0: 
sl@0: The return value is the client's integer handle that was passed as an argument 
sl@0: to the parent window tree node's Construct() function: see RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: If called on a window group, this function returns 0, as window groups have 
sl@0: no parent.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Handle ID for the parent, or zero for window groups. 
sl@0: @see Child() 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpParent));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TUint32 RWindowTreeNode::PrevSibling() const
sl@0: /** Gets the node before this one in the sibling list. 
sl@0: 
sl@0: The return value is the client handle that was passed in the previous sibling window's 
sl@0: Construct() function: see RWindow::Construct() for a description of the client handle.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Handle ID for the previous sibling, or zero if no previous sibling exists. 
sl@0: @see NextSibling() 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpPrevSibling));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TUint32 RWindowTreeNode::NextSibling() const
sl@0: /** Gets the next window after this one in its sibling list. 
sl@0: 
sl@0: The return value is the client handle that was passed in the next sibling 
sl@0: window's Construct() function: see RWindow::Construct() for a description of the 
sl@0: client handle.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Window handle of next sibling, or 0 if no next sibling exists. 
sl@0: @see PrevSibling()
sl@0: @see Child()
sl@0: @see Parent() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpNextSibling));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TUint32 RWindowTreeNode::Child() const
sl@0: /** Gets the first child of the node.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The client handle of the child node that currently has ordinal position 
sl@0: 0. This is 0 if there isn't a child. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpChild));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::__DbgTestInvariant() const
sl@0: /** In debug builds, this function always causes a flush of the window 
sl@0: server buffer. */
sl@0: 	{
sl@0: #if defined(_DEBUG)
sl@0: 	if (WriteReply(EWsWinOpTestInvariant))
sl@0: 		User::Invariant();
sl@0: #endif
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::SetOrdinalPosition(TInt aPos)
sl@0: /** Sets the ordinal position of a window. 
sl@0: 
sl@0: A window's ordinal position is relative to its siblings with the same 
sl@0: ordinal priority. The ordinal priority of displayable windows (in other words, 
sl@0: not window groups) is almost always zero (the default). To set the ordinal priority 
sl@0: as well as the ordinal position, use the other overload of this function. 
sl@0: 
sl@0: The lower the ordinal position, the nearer the window will be to the front of the z-order. 
sl@0: The frontmost window has ordinal position zero. Specifying a negative value has the effect 
sl@0: of sending the window to the back of the z-order.
sl@0: 
sl@0: Note: If this window is a window group in a chain, then all other window groups in the chain will be moved also.
sl@0: When this function is called on Group Window with aPos set to KOrdinalPositionSwitchToOwningWindow then the 
sl@0: function doesn't change the ordinal position of the group window, if instead it has focus then the window group 
sl@0: that would come to the forground if it died will be moved to the foreground.
sl@0: 
sl@0: @param aPos The window's new ordinal position. The lower the ordinal, the closer to the 
sl@0: front of the z-order the window will be. Specifying any negative value however, sends 
sl@0: the window to the back of the z-order. */
sl@0: 	{
sl@0: 	WriteInt(aPos,EWsWinOpSetOrdinalPosition);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::SetOrdinalPosition(TInt aPos,TInt aOrdinalPriority)
sl@0: /** Sets the ordinal position and ordinal priority of a window. 
sl@0: 
sl@0: Ordinal priority is a number assigned to a window that determines its position in the z-order. 
sl@0: For sibling windows or group windows, the higher the priority, the closer it will be to the 
sl@0: front. Ordinal priority overrides ordinal position, so that the ordinal position 
sl@0: is only taken into account for sibling windows or window groups with the same ordinal priority. 
sl@0: For a description of ordinal position, see the other overload of this function.
sl@0: 
sl@0: Most windows have an ordinal priority of zero. Only window groups are normally 
sl@0: given non-default ordinal priorities.
sl@0: 
sl@0: To set priority of KPasswordWindowGroupPriority or greater on a window group, client will require 
sl@0: SwEvent capability. If client does not have SwEvent capability then priority will be reduced 
sl@0: to KPasswordWindowGroupPriority-1. This function doesn't return an error thus the client cannot 
sl@0: tell if the priority is reduced, however, there is another function that can be used if the client 
sl@0: does require an error, this is RWindowGroup::SetOrdinalPositionErr.
sl@0: 
sl@0: Note: If this window is a window group in a chain, then all other window groups in the chain will be moved also. 
sl@0: And further they will all have their ordinal priority set to the specified value.
sl@0: When this function is called on Group Window with aPos set to KOrdinalPositionSwitchToOwningWindow then the 
sl@0: function doesn't change the ordinal position of the group window, if instead it has focus then the window group 
sl@0: that would come to the forground if it died will be moved to the foreground.
sl@0: 
sl@0: @param aPos The window's new ordinal position. The lower the ordinal, the closer to the 
sl@0: front of the z-order the window will be. Specifying any negative value however, sends 
sl@0: the window to the back of the z-order.
sl@0: @param aOrdinalPriority The window's new ordinal priority. */
sl@0: 	{
sl@0: 	TWsWinCmdOrdinalPos ordinalPos;
sl@0: 	ordinalPos.pos=aPos;
sl@0: 	ordinalPos.ordinalPriority=aOrdinalPriority;
sl@0: 	Write(&ordinalPos,sizeof(ordinalPos),EWsWinOpSetOrdinalPositionPri);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::OrdinalPriority() const
sl@0: /** Gets the ordinal priority of the specified window.
sl@0: 
sl@0: This function was added for FEPs that need to know the priority in their dialogues. 
sl@0: 
sl@0: This function and RWsSession::GetWindowGroupOrdinalPriority() may return different 
sl@0: values because this function isn't subject to any ordinal priority adjustment, 
sl@0: while the window group ordinal priority may be.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The ordinal priority of the specified window */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpOrdinalPriority));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::OrdinalPosition() const
sl@0: /** Gets the current ordinal position of the window tree node. 
sl@0: 
sl@0: The ordinal position returned is the window's position amongst windows with 
sl@0: the same parent (an with the same priority). Displayable windows almost always 
sl@0: have the same priority, but window groups might typically have different priorities. 
sl@0: If a window group's ordinal position among window groups of all priorities 
sl@0: is required, use FullOrdinalPosition().
sl@0: 
sl@0: Note: all group windows (across all clients) have the same parent.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The window's ordinal position. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpOrdinalPosition));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::FullOrdinalPosition() const
sl@0: /** Get the current full ordinal position of a window. 
sl@0: 
sl@0: This function normally returns a useful value only when called on a window 
sl@0: group, because only window groups are normally given different priorities. 
sl@0: For other types of window the value returned is usually the same as that returned 
sl@0: by OrdinalPosition().
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The window's full ordinal position. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpFullOrdinalPosition));
sl@0: 	}
sl@0: 
sl@0: /**Get the screen number that a window is located on
sl@0: 
sl@0: @return The screen number that the window is located on
sl@0:  */
sl@0: EXPORT_C TInt RWindowTreeNode::ScreenNumber() const
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpScreenNumber));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::WindowGroupId() const
sl@0: /** Returns the window group Id of the parent window group
sl@0: 
sl@0: If the window is a window group it will return it's Id. If it is not it scans 
sl@0: up the window tree to find the group window from which this window is descended 
sl@0: and returns it's Id.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The window group Id of the window group from which this window is descended. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpWindowGroupId));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableOnEvents(TEventControl aCircumstances)
sl@0: /** Requests notification of 'on' events. 'On' events are of type EEventSwitchOn.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aCircumstances The circumstances in which 'on' events are to be reported. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see DisableOnEvents() */
sl@0: 	{
sl@0: 	return(WriteReplyInt(aCircumstances,EWsWinOpEnableOnEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableOnEvents()
sl@0: /** Cancels notification of 'on' events. 
sl@0: 
sl@0: This function instructs the server to stop reporting 'on' events to this window. 
sl@0: If the window server has not previously been instructed to report 'on' events, 
sl@0: this method has no effect (i.e. the default is that windows do not get the 
sl@0: events).
sl@0: 
sl@0: @see EnableOnEvents() */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableOnEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableGroupChangeEvents()
sl@0: /** Requests notification of group-change events.
sl@0: 
sl@0: Use this function to instruct the window server to report group-change events 
sl@0: to this window. These events will typically be of interest to a shell or similar 
sl@0: application, for example to notify it that it should update its list of running 
sl@0: applications. Window group changed events are of type EEventWindowGroupsChanged.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see DisableGroupChangeEvents() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpEnableGroupChangeEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableGroupChangeEvents()
sl@0: /** Cancels notification of group changed events. 
sl@0: 
sl@0: Use this function to instruct the server to stop reporting window group changed 
sl@0: events to this window. If the window server has not previously been instructed 
sl@0: to report window group changed events, this function has no effect (i.e. the 
sl@0: default is that windows do not get the events).
sl@0: 
sl@0: @see EnableGroupChangeEvents() */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableGroupChangeEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableFocusChangeEvents()
sl@0: /** Enables focus changed events.
sl@0: 
sl@0: After this function is called, the EEventFocusGroupChanged event is delivered 
sl@0: to the window server message queue every time the focus window group changes. 
sl@0: The handle of the event is set to the client handle of the window that this 
sl@0: function is called on.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes. 
sl@0: @see DisableFocusChangeEvents() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpEnableFocusChangeEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableFocusChangeEvents()
sl@0: /** Disables delivery of focus changed events.
sl@0: 
sl@0: Use this function to instruct the server to stop reporting window group focus 
sl@0: changed events to this window. If the window server has not previously been 
sl@0: instructed to report window group changed events, this function has no effect 
sl@0: (i.e. the default is that windows do not get the events).
sl@0: 
sl@0: @see EnableFocusChangeEvents() */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableFocusChangeEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableGroupListChangeEvents()
sl@0: /** Enables reporting of window group list change events.
sl@0: 
sl@0: The window group list is a list of all window groups and their z-order. Calling 
sl@0: this function will cause notification events (of type EEventWindowGroupListChanged) 
sl@0: for any change in the window group list: additions, removals and reorderings.
sl@0: 
sl@0: This function is useful when you need to know about changes to window groups 
sl@0: beneath the focused one, for instance when the screen is showing windows from 
sl@0: more than one window group at the same time.
sl@0: 
sl@0: The handle of the event is set to the client handle of the window that this 
sl@0: function is called on.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpEnableGroupListChangeEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableGroupListChangeEvents()
sl@0: /** Disables reporting of window group list change events.
sl@0: 
sl@0: This function instructs the window server to stop sending window group list 
sl@0: change events to this window. If the window server has not previously been 
sl@0: instructed to report window group list change events, this function has no 
sl@0: effect (i.e. the default is that windows do not receive group list change 
sl@0: events). */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableGroupListChangeEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableVisibilityChangeEvents()
sl@0: /** Enables reporting of window visibility change events.
sl@0: 
sl@0: The window visibility is based on whether or not any area of the window can be seen
sl@0: on the screen.  This can be affected by SetVisible(), but also by other windows in
sl@0: front of this one, and by the presence of transparent windows which it can be seen
sl@0: through.  Calling this function will cause notification events (of type
sl@0: EEventWindowVisibilityChanged) for any change in the window's visibility.
sl@0: 
sl@0: This function is useful when you are performing graphical processing such as animations
sl@0: and would like to stop them while they cannot be seen, for efficiency reasons.
sl@0: 
sl@0: The handle of the event is set to the client handle of the window that this 
sl@0: function is called on.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpEnableVisibilityChangeEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableVisibilityChangeEvents()
sl@0: /** Disables reporting of window visibility change events.
sl@0: 
sl@0: This function instructs the window server to stop sending window visibility 
sl@0: change events to this window. If the window server has not previously been 
sl@0: instructed to report window visibility change events, this function has no 
sl@0: effect (i.e. the default is that windows do not receive visibility change 
sl@0: events). */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableVisibilityChangeEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableErrorMessages(TEventControl aCircumstances)
sl@0: /** Requests notification of error message events. 
sl@0: 
sl@0: Use this function to instruct the window server to report error message events 
sl@0: (of type EEventErrorMessage).
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aCircumstances The circumstances in which error message events are 
sl@0: to be reported. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see DisableErrorMessages() */
sl@0: 	{
sl@0: 	return(WriteReplyInt(aCircumstances,EWsWinOpEnableErrorMessages));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableErrorMessages()
sl@0: /** Cancels notification of error message events. 
sl@0: 
sl@0: Use this function to instruct the server to stop reporting error message events 
sl@0: to this window. If the window server has not previously been instructed to 
sl@0: report error message events, this function has no effect (i.e. the default 
sl@0: is that windows do not get error messages).
sl@0: 
sl@0: @see EnableErrorMessages() */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableErrorMessages);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::EnableModifierChangedEvents(TUint aModifierMask, TEventControl aCircumstances)
sl@0: /** Requests notification of modifier changed events. 
sl@0: 
sl@0: Use this function to instruct the window server to report modifier changed 
sl@0: events to this window. Values for the modifier keys are defined in TEventModifier. 
sl@0: If more than one modifier key is to be monitored, their values should be combined 
sl@0: using a bit-wise OR operation. Modifier changed events are of type EEventModifiersChanged.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aModifierMask The modifiers to be reported. May be a combination of 
sl@0: values defined in TEventModifier 
sl@0: @param aCircumstances The circumstances in which modifier changed events are 
sl@0: to be reported. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see DisableModifierChangedEvents() */
sl@0: 	{
sl@0: 	TWsWinCmdEnableModifierChangedEvents params(aModifierMask, aCircumstances);
sl@0: 	return(WriteReply(&params,sizeof(params),EWsWinOpEnableModifierChangedEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::DisableModifierChangedEvents()
sl@0: /** Cancels notification of modifier changed events. 
sl@0: 
sl@0: Use this function to instruct the server to stop reporting modifier changed 
sl@0: events to this window. If the window server has not previously been instructed 
sl@0: to report modifier changed events, this function has no effect (i.e. the default 
sl@0: is that windows do not get the events).
sl@0: 
sl@0: @see EnableModifierChangedEvents() */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableModifierChangedEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowTreeNode::SetPointerCursor(TInt aCursorNumber)
sl@0: /** Sets the pointer cursor from the system pointer cursor list. 
sl@0: 
sl@0: Use this function to set the current cursor to one contained in the system 
sl@0: pointer cursor list. If the list does not contain a cursor with an index of 
sl@0: aCursorNumber, the function will attempt to set the cursor to the default 
sl@0: system pointer cursor, which has an index of 0 in the list.
sl@0: 
sl@0: The RWsSession class provides functions for setting and controlling the system 
sl@0: pointer cursor list.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aCursorNumber The cursor index in the system pointer cursor list. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see ClearPointerCursor() */
sl@0: 	{
sl@0: 	return(WriteReplyInt(aCursorNumber,EWsWinOpSetPointerCursor));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::SetCustomPointerCursor(const RWsPointerCursor &aPointerCursor)
sl@0: /** Sets the pointer cursor to an application-defined cursor.
sl@0: 
sl@0: @param aPointerCursor The cursor to use. */
sl@0: 	{
sl@0: 	WriteInt(aPointerCursor.WsHandle(),EWsWinOpSetCustomPointerCursor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::SetNonFading(TBool aNonFading)
sl@0: /** Sets whether a window is non-fading.
sl@0: 
sl@0: When the non-fading flag is set the window will unfade if needed and remain 
sl@0: unfaded until this flag is removed. This is useful for toolbars etc. which 
sl@0: must never be faded.
sl@0: 
sl@0: @param aNonFading ETrue to set the non-fading flag, EFalse (the default) to 
sl@0: re-set it. */
sl@0: 	{
sl@0: 	WriteInt(aNonFading,EWsWinOpSetNonFading);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::SetFaded(TBool aFaded,TFadeControl aIncludeChildren)
sl@0: /** Sets the window as faded or unfaded.
sl@0: 
sl@0: This function allows a single window to be faded or unfaded. The function 
sl@0: also allows the same action to be applied to all of the window's children.
sl@0: 
sl@0: Notes:
sl@0: 
sl@0: A redraw is required to un-fade a window because information is lost during 
sl@0: fading (blank and backup windows deal with this themselves). Areas in shadow 
sl@0: when the window is faded also require a redraw. 
sl@0: 
sl@0: While a window is faded, all drawing to that window will be adjusted appropriately 
sl@0: by the window server.
sl@0: 
sl@0: @param aFaded ETrue to fade the window, EFalse to un-fade it. 
sl@0: @param aIncludeChildren Fade control flags. These set whether fading/un-fading 
sl@0: also apply to child windows. */
sl@0: 	{
sl@0: 	TWsWinCmdSetFaded params(aFaded,aIncludeChildren);
sl@0: 	Write(&params,sizeof(params),EWsWinOpSetFade);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::SetFaded(TBool aFaded,TFadeControl aIncludeChildren,TUint8 aBlackMap,TUint8 aWhiteMap)
sl@0: /** Sets one or more windows as faded or unfaded, specifying a fading map. 
sl@0: 
sl@0: Fading is used to change the colour of a window to make other windows stand 
sl@0: out. For example, you would fade all other windows when displaying a dialogue. 
sl@0: 
sl@0: Fading makes a window closer to white or closer to black.
sl@0: Setting the fading map allows you to over-ride the default fading parameters 
sl@0: set in RWsSession::SetDefaultFadingParameters(). 
sl@0: 
sl@0: The white and black fading values define the range over which colours are 
sl@0: re-mapped when a window is faded. As the values get closer together, all colours 
sl@0: in the faded window becomes more similar, creating the fading effect. 
sl@0: When the numbers cross over (so that the black value is greater than the white 
sl@0: value) the colours in the faded window start to invert, i.e. colours that 
sl@0: were closer to white in the unfaded window are mapped to a darker colour when 
sl@0: the window is faded.
sl@0: 
sl@0: The function also allows the fading action applied to this window to be applied 
sl@0: to all of its children.
sl@0: 
sl@0: Notes:
sl@0: 
sl@0: Fading a window for a 2nd time will not change the fading map used. 
sl@0: 
sl@0: A redraw is required to un-fade a window because information is lost during 
sl@0: fading. Note that blank (RBlankWindow) and backup (RBackedUpWindow) windows 
sl@0: deal with this themselves. Areas in shadow when the window is faded also require 
sl@0: a redraw. 
sl@0: 
sl@0: While a window is faded all drawing to that window will be adjusted appropriately 
sl@0: by the window server.
sl@0: 
sl@0: @param aFaded ETrue to fade the window, EFalse to un-fade it. 
sl@0: @param aIncludeChildren Fade control flags. This sets whether fading/un-fading 
sl@0: is also to apply to all child windows. 
sl@0: @param aBlackMap Black map fading parameter.
sl@0: @param aWhiteMap White map fading parameter. 
sl@0: @see RWsSession::SetDefaultFadingParameters()
sl@0: @see CWindowGc::SetFadingParameters() */
sl@0: 	{
sl@0: 	TWsWinCmdSetFaded params(aFaded,aIncludeChildren,EFalse,aBlackMap,aWhiteMap);
sl@0: 	Write(&params,sizeof(params),EWsWinOpSetFade);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowTreeNode::ClearPointerCursor()
sl@0: /** Clears pointer cursor settings.
sl@0: 
sl@0: These are the settings made by calling SetPointerCursor(). */
sl@0: 	{
sl@0: 	Write(EWsWinOpClearPointerCursor);
sl@0: 	}
sl@0: 
sl@0: /** Returns the window server session that is used to create this window handle. 
sl@0: 
sl@0: This functions returns null if the window handle is not initialised.
sl@0: 
sl@0: @see RWindowTreeNode(RWsSession &aWs)
sl@0: */
sl@0: EXPORT_C RWsSession* RWindowTreeNode::Session() const
sl@0: 	{
sl@0: 	return iBuffer? iBuffer->Session() : NULL;
sl@0: 	}
sl@0: 
sl@0: /** @panic TW32Panic 17 in debug builds if called on an already constructed object.*/
sl@0: TInt RWindowBase::construct(const RWindowTreeNode &parent,TUint32 aClientHandle, TInt aType, TDisplayMode aDisplayMode)
sl@0: 	{
sl@0: 	__ASSERT_DEBUG(iWsHandle == KNullHandle, Panic(EW32PanicGraphicDoubleConstruction));
sl@0: 	TWsClCmdCreateWindow createWindow;
sl@0: 	createWindow.parent=parent.WsHandle();
sl@0: 	createWindow.clientHandle=aClientHandle;
sl@0: 	createWindow.type=(TWinTypes)aType;
sl@0: 	createWindow.displayMode=aDisplayMode;
sl@0: 	TInt ret=iBuffer->WriteReplyWs(&createWindow,sizeof(createWindow),EWsClOpCreateWindow);
sl@0: 	if (ret<0)
sl@0: 		return(ret);
sl@0: 	iWsHandle=ret;
sl@0: 	return(KErrNone);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::Activate()
sl@0: /** Displays the window and enables it to receive events. 
sl@0: 
sl@0: Calling this method on a window causes it to receive a redraw event 
sl@0: if it is a non-backed-up window, and should be called after a window has 
sl@0: been constructed and initialised.
sl@0: 
sl@0: Windows are not displayed automatically when they are constructed. This allows 
sl@0: them to be customised using SetPosition(), SetOrdinalPosition(), SetExtent(), 
sl@0: etc., before they are displayed. */
sl@0: 	{
sl@0: 	Write(EWsWinOpActivate);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TPoint RWindowBase::Position() const
sl@0: /** Gets a window's position relative to its parent.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Position of this window's origin relative to the origin of its parent. */
sl@0: 	{
sl@0: 	TPckgBuf<TPoint> pntPkg;
sl@0:   	WriteReplyP(&pntPkg,EWsWinOpPosition);
sl@0: 	return(pntPkg());
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TPoint RWindowBase::AbsPosition() const
sl@0: /** Gets a window's absolute position - ie the windows position relative 
sl@0: to the current screen size mode.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Position of this window's origin relative to the screen. */
sl@0: 	{
sl@0: 	TPckgBuf<TPoint> pntPkg;
sl@0:   	WriteReplyP(&pntPkg,EWsWinOpAbsPosition);
sl@0: 	return(pntPkg());
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TSize RWindowBase::Size() const
sl@0: /** Gets the window's current size.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return Current size of window. */
sl@0: 	{
sl@0: 	TPckgBuf<TSize> sizePkg;
sl@0:   	WriteReplyP(&sizePkg,EWsWinOpSize);
sl@0: 	return(sizePkg());
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @internalAll
sl@0: Disclaimer - this API is internal and is subject to change
sl@0: @deprecated */
sl@0: EXPORT_C TSize RWindowBase::SizeForEgl() const
sl@0:     {
sl@0:     return Size();
sl@0:     }
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetPosition(const TPoint &aPos)
sl@0: /** Sets the position of a window relative to its parent. 
sl@0: 
sl@0: The co-ordinates given in aPos specify the position of the top left-hand 
sl@0: corner of the window, relative to the top left-hand corner of its parent. 
sl@0: A positive value indicates a direction to the right and down. Negative values 
sl@0: are valid but will cause part of the window to be outside its parent's extent, 
sl@0: and therefore clipped.
sl@0: 
sl@0: This function may be called at any time after the window's Construct() function: 
sl@0: the window's position will change dynamically.
sl@0: 
sl@0: A window's position can also be set using the RWindow::SetExtent() and RWindowBase::SetExtentErr() 
sl@0: functions.
sl@0: 
sl@0: Note: upon creation, a window's extent is the same as its parent’s. In other words 
sl@0: it has the same origin and size. If the window’s parent is a group window, it is 
sl@0: initialised to be full screen.
sl@0: 
sl@0: @param aPos The position of the window's origin, relative to its parent */
sl@0: 	{
sl@0: 	WritePoint(aPos,EWsWinOpSetPos);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::SetSizeErr(const TSize &aSize)
sl@0: /** Sets the size of a backed-up window. 
sl@0: 
sl@0: A window's size is not constrained by the size of its parent. However, its 
sl@0: visible region is, and the child window's visible region will always be clipped 
sl@0: to the parent's visible region.
sl@0: 
sl@0: Avoid using this function for a window known to be of type RBlankWindow or 
sl@0: RWindow (i.e. not a backed-up window). Instead, use SetSize(), which is more 
sl@0: efficient as it does not return a value. However, if the window is a backed-up 
sl@0: window, or of unknown type, SetSizeErr() should be used, because 
sl@0: setting the size of a backed-up window may cause an out-of-memory error.
sl@0: 
sl@0: This function may be called at any time after the window's Construct() function: 
sl@0: the window's size will change dynamically.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aSize Window size.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see RWindow::SetSize()
sl@0: @see RWindow::SetExtent()
sl@0: @see RWindowBase::SetExtentErr() */
sl@0: 	{
sl@0: 	return(WriteReply(&aSize,sizeof(aSize),EWsWinOpSetSizeErr));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::SetExtentErr(const TPoint &pos,const TSize &size)
sl@0: /** Sets a backed-up window's extent, relative to its parent, and returns an error 
sl@0: code from the server. 
sl@0: 
sl@0: See SetPosition() and SetSizeErr() for a description of the rules applying 
sl@0: to aPoint and aSize respectively.
sl@0: 
sl@0: Avoid using this function for a window of type RBlankWindow or RWindow (in other words, 
sl@0: not a backed-up window). Instead, use SetExtent(), which is more efficient 
sl@0: as it does not return a value. However, if the window is a backed-up window, 
sl@0: or of unknown type, SetExtentErr() should be used, because setting 
sl@0: the extent of a backed-up window may cause an out-of-memory error.
sl@0: 
sl@0: This function may be called at any time after the window's Construct() function: 
sl@0: the window's extent will change dynamically.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param pos The position of the window's origin, relative to its parent. 
sl@0: @param size Window size. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	TWsWinCmdSetExtent setExtent(pos,size);
sl@0: 	return(WriteReply(&setExtent,sizeof(setExtent),EWsWinOpSetExtentErr));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TPoint RWindowBase::InquireOffset(const RWindowTreeNode &aWindow) const
sl@0: /** Enquires the offset between this and another window. 
sl@0: 
sl@0: A positive value indicates a position to the right and down from aWindow, 
sl@0: a negative value indicates a position to the left and up.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aWindow Another window tree node. 
sl@0: @return The offset of this window relative to aWindow. */
sl@0: 	{
sl@0: 	TPckgBuf<TPoint> pkgPoint;
sl@0: 	TUint32 handle=aWindow.WsHandle();
sl@0: 	WriteReplyP(&handle,sizeof(handle),&pkgPoint,EWsWinOpInquireOffset);
sl@0: 	return(pkgPoint());
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::PointerFilter(TUint32 aFilterMask, TUint32 aFilter)
sl@0: /** Sets the filter which controls which pointer events are sent to the client 
sl@0: session. 
sl@0: 
sl@0: A pointer filter can be defined for each window separately, and changed dynamically. 
sl@0: The default behaviour when a window is created is that move, drag, enter and 
sl@0: exit events are filtered out and not delivered to the client.
sl@0: 
sl@0: @param aFilterMask Bitwise OR of values from TPointerFilter masking event 
sl@0: types which will be updated. 
sl@0: @param aFilter Bits containing new values for the masked event types. A 1 bit 
sl@0: causes the corresponding event to be filtered out, a 0 bit lets through the 
sl@0: corresponding event. 
sl@0: @see TPointerFilter */
sl@0: 	{
sl@0: 	TWsWinCmdPointerFilter params;
sl@0: 	params.mask=aFilterMask;
sl@0: 	params.flags=aFilter;
sl@0: 	Write(&params,sizeof(params),EWsWinOpPointerFilter);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetPointerCapture(TInt aFlags)
sl@0: /** Sets the pointer capture state.
sl@0: 
sl@0: A window which has called this function can capture events that would otherwise 
sl@0: go to other windows. Normally, pointer events are sent to the window at 
sl@0: the co-ordinates where the event occurs. Capturing only works on windows which 
sl@0: are behind the capturing window in the z order. 
sl@0: 
sl@0: Capture can be enabled or disabled. If capturing is enabled a window will, 
sl@0: by default, capture events only from windows in the same window group. A flag 
sl@0: can be specified to allow it to capture events across all window groups.
sl@0: 
sl@0: Another flag can be used to specify drag-drop capture. This causes a drag-drop 
sl@0: message to be sent to the window within which the pen was lifted. Drag-drop 
sl@0: with a pen is a tap-drag-lift sequence.
sl@0: 
sl@0: Capture functionality is useful in situations where only the foreground window 
sl@0: should receive events, e.g. in a modal dialogue.
sl@0: 
sl@0: @param aFlags Bitwise OR of flag values from TCaptureFlags. 
sl@0: @see TCaptureFlags */
sl@0: 	{
sl@0: 	WriteInt(aFlags,EWsWinOpSetPointerCapture);		//The data is actually interpreted as a TUint
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetPointerGrab(TBool aState)
sl@0: /** Allows or disallows pointer grabs in a window. 
sl@0: 
sl@0: If the pointer grab is set, any down event in this window will cause 
sl@0: a pointer grab, terminated by the next corresponding up event. All pointer 
sl@0: events up to and including the next up event will be sent to that window.
sl@0: 
sl@0: Pointer grab can be used for drag-and-drop or other situations when you want 
sl@0: the events delivered to the same window even though the pen will be dragged 
sl@0: outside that window. This function is typically called during window construction 
sl@0: so that pointer grab is enabled for the lifetime of the window.
sl@0: 
sl@0: Pointer grab is disabled by default.
sl@0: 
sl@0: @param aState New state for the pointer grab setting. 
sl@0: @see ClaimPointerGrab() */
sl@0: 	{
sl@0: 	WriteInt(aState,EWsWinOpSetPointerGrab);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::ClaimPointerGrab(const TUint8, const TBool)
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */ 
sl@0: 	{
sl@0: 	ASSERT(EFalse);
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::ClaimPointerGrab(TBool aSendUpEvent)
sl@0: /** Claims the pointer grab from another window. 
sl@0: 
sl@0: If a pointer grab is already in effect in another window, a window can claim 
sl@0: the pointer grab from that window by calling this function. All subsequent 
sl@0: events will be delivered to this window, up to and including the next "up" 
sl@0: event. This next up event terminates the pointer grab.
sl@0: 
sl@0: This function would typically be used where clicking in a window pops up another 
sl@0: window, and where the popped-up window wishes to grab the pointer as though 
sl@0: the original click had been in that window.
sl@0: 
sl@0: Note:
sl@0: 
sl@0: If aSendUpEvent is set to ETrue, the window losing the grab is immediately 
sl@0: sent an up event, signalling the end of its pointer grab.
sl@0: 
sl@0: @param aSendUpEvent Whether to deliver an up event to the window that previously 
sl@0: had the grab. 
sl@0: @see SetPointerGrab() */
sl@0: 	{
sl@0: 	WriteInt(aSendUpEvent,EWsWinOpClaimPointerGrab);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetPointerCapturePriority(TInt aPriority)
sl@0: /** Sets the window's pointer capture priority.
sl@0: 
sl@0: To allow window gain a property that allows them to be clicked on even when they are behind a modal
sl@0: window. The priority will be 0 by default. Windows that need to stop modal window in front of them, 
sl@0: should set this value to positive. Window can only capture pointer events from another window 
sl@0: of same group, if it has at least the same pointer capture priority.
sl@0: 
sl@0: @param aPriority Pointer capture priority */
sl@0: 	{
sl@0: 	WriteInt(aPriority,EWsWinOpSetPointerCapturePriority);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::GetPointerCapturePriority() const
sl@0: /** Gets the windows's pointer capture priority
sl@0: 
sl@0: @return Window's pointer capture priority 
sl@0: @see SetPointerCapturePriority() */
sl@0: 	{
sl@0: 	return WriteReply(EWsWinOpGetPointerCapturePriority);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetVisible(TBool aState)
sl@0: /** Sets the window's visibility. 
sl@0: 
sl@0: This function can be called after the window has been created to dynamically 
sl@0: change its visibility.
sl@0: 
sl@0: Notes:
sl@0: 
sl@0: When a window is invisible, it receives no events from the window server.
sl@0: 
sl@0: A window is invisible before it is activated, irrespective of the state of 
sl@0: its visibility flag.
sl@0: 
sl@0: @param aState New value for the visibility. */
sl@0: 	{
sl@0: 	WriteInt(aState,EWsWinOpSetVisible);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetShadowHeight(TInt aHeight)
sl@0: /** Sets a window's shadow height.
sl@0: 
sl@0: This is the height that this window is above the window immediately behind 
sl@0: it. The offset of the shadow's bottom right corner from the window's bottom 
sl@0: right corner is the product of the window's shadow height and the system shadow 
sl@0: vector. 
sl@0: 
sl@0: A shadow is only displayed on top-level windows.
sl@0: 
sl@0: @param aHeight Shadow height. The default is 0. */
sl@0: 	{
sl@0: 	WriteInt(aHeight,EWsWinOpSetShadowHeight);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::SetShadowDisabled(TBool aState)
sl@0: /** Enables or disables whether a window casts a shadow. 
sl@0: 
sl@0: By default, when a window is created, its shadow is not disabled. (But note 
sl@0: that a shadow is only cast by top-level windows.)
sl@0: 
sl@0: @param aState ETrue if the shadow is to be disabled (not displayed). EFalse 
sl@0: if the shadow is to be displayed */
sl@0: 	{
sl@0: 	WriteInt(aState,EWsWinOpShadowDisabled);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::SetCornerType(TCornerType aCornerType, TInt aCornerFlags)
sl@0: /** Sets the shape of a window's corners.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aCornerType Corner type to apply. 
sl@0: @param aCornerFlags Bitwise OR of flags indicating corners to exclude. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see TCornerFlags 
sl@0: @deprecated */
sl@0: 	{
sl@0: 	TWsWinCmdSetCornerType params;
sl@0: 	params.type=aCornerType;
sl@0: 	params.flags=aCornerFlags;
sl@0: 	return(WriteReply(&params,sizeof(params),EWsWinOpSetCornerType));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::SetShape(const TRegion &aRegion)
sl@0: /** Sets a window's shape arbitrarily, if rectangular windows are not required.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aRegion Region defining window shape. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @deprecated */
sl@0: 	{
sl@0: 	__ASSERT_DEBUG(!aRegion.CheckError(),Panic(EW32PanicInvalidRegion));
sl@0: 	const TInt regionCount=aRegion.Count();
sl@0: 	TPtrC8 ptrRect(reinterpret_cast<const TUint8*>(aRegion.RectangleList()),regionCount*sizeof(TRect));
sl@0: 	return(WriteReplyByProvidingRemoteReadAccess(&regionCount,sizeof(regionCount),&ptrRect,EWsWinOpSetShape));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::SetRequiredDisplayMode(TDisplayMode aMode)
sl@0: /** Sets the window's display mode. 
sl@0: 
sl@0: Each window can be given an individual display mode because some windows may 
sl@0: require a greater number of different colours than others.
sl@0: 
sl@0: The default display mode of a window is dependent on the individual target 
sl@0: device. The default mode may not reflect the full capabilities of the display. 
sl@0: On some devices a simpler colour mode may be used as the default in order 
sl@0: to save battery power. In these cases, this method may be used to request 
sl@0: a different display mode on a per-window basis.
sl@0: 
sl@0: At any given time, the window server uses the highest display mode of the 
sl@0: windows currently visible, and switches the hardware into that mode. Therefore, 
sl@0: if an application contains a window with display mode EGray16, but only EGray4 
sl@0: windows are visible, the screen hardware will use EGray4 until the EGray16 
sl@0: window becomes visible.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aMode The display mode: can have any TDisplayMode value except TDisplayMode::ERgb 
sl@0: (since this isn't a mode that screen hardware can ever take). 
sl@0: @return The display mode to which the window has been set. This is the closest 
sl@0: display mode to aMode supported by the hardware. */
sl@0: 	{
sl@0: 	return(WriteReplyInt(aMode,EWsWinOpRequiredDisplayMode));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TDisplayMode RWindowBase::DisplayMode() const
sl@0: /** Gets the window's current display mode.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The window's current display mode. */
sl@0: 	{
sl@0: 	return((TDisplayMode)WriteReply(EWsWinOpGetDisplayMode));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::EnableBackup(TUint aBackupType/*=EWindowBackupAreaBehind*/)
sl@0: /** Requests that this window backs up all or part of the screen's contents. There 
sl@0: are two backup possibilities:- just the area behind this window (the default), 
sl@0: or the whole screen. Backing up the whole screen is useful for windows that 
sl@0: require the rest of the screen to fade when they are displayed. In this case, 
sl@0: the full screen backup is of the unfaded content of the screen.
sl@0: 
sl@0: It is possible to specify both types of backup at the same time. This may 
sl@0: be used by fade behind windows that can be dragged across the screen, e.g. 
sl@0: a dialog. This is done by calling this function with the parameter EWindowBackupAreaBehind|EWindowBackupFullScreen.
sl@0: 
sl@0: When backing up the whole screen, this function should be called before the 
sl@0: window is activated, and before you call fade behind on it (RWindowBase::FadeBehind()).
sl@0: 
sl@0: Backing up a window is an optimisation feature that is honoured only if there 
sl@0: is enough memory to do so, (it requires bitmaps and a region to be created 
sl@0: and maintained). If there is not enough memory, all or part of the backup 
sl@0: will be lost. In this case, a redraw will be issued at the relevant point 
sl@0: just as if the window had not been backed up.
sl@0: 
sl@0: The backup bitmap is made and is claimed by the window not when EnableBackup() 
sl@0: is called, but when the window becomes visible (this is normally when the 
sl@0: window is activated).
sl@0: 
sl@0: Only one backed up window of the same type can exist at any one time (although 
sl@0: the same window can have both types of backup at the same time). If a window 
sl@0: requests a backup of type EWindowBackupAreaBehind, any window that has already 
sl@0: claimed a backup of this type will lose it. If a window requests a backup 
sl@0: of type EWindowBackupFullScreen, this request will fail if another window 
sl@0: has already claimed a backup of this type.
sl@0: 
sl@0: @param aBackupType The type of backed up window. See the TWindowBackupType 
sl@0: enum for possible values.
sl@0: @see TWindowBackupType */
sl@0: 	{
sl@0: 	WriteInt(aBackupType,EWsWinOpEnableBackup);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32 aTime,const TRect &aRect)
sl@0: /** Requests a pointer repeat event. 
sl@0: 
sl@0: This function instructs the window server to send a single pointer repeat event if 
sl@0: the pointer state that caused the last event (e.g. EButton1Down) has not changed 
sl@0: within aTime and the pointer has not moved outside aRect. Pointer repeat events 
sl@0: are pointer events of type TPointerEvent::EButtonRepeat.
sl@0: 
sl@0: While the repeat is in operation all move and drag events within the rectangle 
sl@0: are filtered out. The repeat is cancelled if the pointer moves outside the 
sl@0: rectangle or generates any other pointer event.
sl@0: 
sl@0: A typical use of this function would be for a scrollbar, so that holding down 
sl@0: the pointer results in a continuous scroll.
sl@0: 
sl@0: @param aTime Time interval before pointer repeat event should be sent. 
sl@0: @param aRect Repeat event occurs only if pointer is within this rectangle. 
sl@0: @see CancelPointerRepeatEventRequest() */
sl@0: 	{
sl@0: 	TWsWinCmdRequestPointerRepeatEvent params(aTime,aRect);
sl@0: 	Write(&params,sizeof(params),EWsWinOpRequestPointerRepeatEvent);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::CancelPointerRepeatEventRequest()
sl@0: /** Cancels a request for a pointer repeat event.
sl@0: 
sl@0: @see RequestPointerRepeatEvent() */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpCancelPointerRepeatEventRequest);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::RequestPointerRepeatEvent(TTimeIntervalMicroSeconds32 /*aTime*/,const TRect &/*aRect*/, const TUint8 /*aPointerNumber*/)
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */ 
sl@0: 	{
sl@0: 	// No multipointer in WSERV NONNGA, so ignore pointer number by redirecting to appropriate API
sl@0: 	ASSERT(0);
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::CancelPointerRepeatEventRequest(const TUint8 /*aPointerNumber*/)
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */ 
sl@0: 	{
sl@0: 	// No multipointer in WSERV NONNGA, so ignore pointer number by redirecting to appropriate API
sl@0: 	ASSERT(0);	
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::EnableAdvancedPointers()
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */ 
sl@0: 	{
sl@0: 	ASSERT(0);	
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: @internalAll
sl@0: Disclaimer - this API is internal and is subject to change
sl@0: @deprecated */
sl@0: EXPORT_C TInt RWindowBase::FixNativeOrientation()
sl@0:     {
sl@0:     return KErrNotSupported;
sl@0:     }
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::AllocPointerMoveBuffer(TInt aMaxNumPoints, TUint aFlags)
sl@0: /** Allocates a buffer for storing pointer movements. 
sl@0: 
sl@0: The pointer move buffer is used by applications that need to process every 
sl@0: single pointer move or drag event: for example, a freehand drawing application.
sl@0: 
sl@0: Normally, multiple drag events which the window server receives from the pointer 
sl@0: device driver are translated into a single drag event. The single drag event 
sl@0: incorporates all pointer events that occurred while the client was processing 
sl@0: the previous pointer event. If the pointer move buffer is used, the window 
sl@0: server stores all pointer events in a pointer buffer, and then delivers the 
sl@0: entire buffer when it is full.
sl@0: 
sl@0: AllocPointerMoveBuffer() must be called before the pointer move buffer can 
sl@0: be used. It would typically be called during window construction.
sl@0: 
sl@0: After the pointer move buffer has been allocated, the window server does not 
sl@0: start putting pointer events into it until EnablePointerMoveBuffer() is called.
sl@0: 
sl@0: Note: move events are not available on all hardware.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aMaxPoints Maximum number of pointer events the buffer can hold. This 
sl@0: affects the frequency at which the buffer is flushed. 
sl@0: @param aFlags Obsolete argument: set to zero always. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	TWsWinCmdAllocPointerMoveBuffer params;
sl@0: 	params.maxNumPoints=aMaxNumPoints;
sl@0: 	params.flags=aFlags;
sl@0: 	return(WriteReply(&params,sizeof(params),EWsWinOpAllocPointerMoveBuffer));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::FreePointerMoveBuffer()
sl@0: /** Frees the pointer move buffer. 
sl@0: 
sl@0: This function should be called on a window which calls AllocPointerMoveBuffer(). */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpFreePointerMoveBuffer);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::EnablePointerMoveBuffer()
sl@0: /** Enables the pointer move buffer for receiving pointer move events. 
sl@0: 
sl@0: This function instructs the window server to begin putting pointer events 
sl@0: into the pointer move buffer. AllocPointerMoveBuffer() must have previously 
sl@0: been called, or a panic will occur.
sl@0: 
sl@0: As soon as the pointer buffer has at least one point in it, the window server 
sl@0: sends an event of type EEventPointerBufferReady to the client, and the events 
sl@0: can be retrieved from the pointer move buffer using RetrievePointerMoveBuffer().
sl@0: 
sl@0: Note: pointer move, drag and enter/exit events are not delivered to a window 
sl@0: by default. An application using the pointer move buffer should use PointerFilter() 
sl@0: to request that these events be delivered.
sl@0: 
sl@0: @see DisablePointerMoveBuffer() */
sl@0: 	{
sl@0: 	Write(EWsWinOpEnablePointerMoveBuffer);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::DisablePointerMoveBuffer()
sl@0: /** Instructs the window server to stop adding pointer events to the pointer move 
sl@0: buffer. */
sl@0: 	{
sl@0: 	Write(EWsWinOpDisablePointerMoveBuffer);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::RetrievePointerMoveBuffer(TDes8 &aBuf) const
sl@0: /** Retrieves events from the pointer move buffer. 
sl@0: 
sl@0: Use this function to get pointer events from the pointer move buffer. This 
sl@0: function should be called when an event has occurred of type EEventPointerBufferReady 
sl@0: (defined in TEventCode).
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aBuf Buffer to store events retrieved from pointer move buffer 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	TInt maxPoints=aBuf.MaxSize()/sizeof(TPoint);
sl@0: 	return(WriteReplyP(&maxPoints,sizeof(maxPoints),&aBuf,EWsWinOpRetrievePointerMoveBuffer));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::DiscardPointerMoveBuffer()
sl@0: /** Discards all events in the pointer move buffer. 
sl@0: 
sl@0: The window server subsequently continues to put new pointer events into the 
sl@0: pointer move buffer as usual (if the buffer is enabled). */
sl@0: 	{
sl@0: 	Write(EWsWinOpDiscardPointerMoveBuffer);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::AddKeyRect(const TRect &aRect, TInt aScanCode, TBool aActivatedByPointerSwitchOn)
sl@0: /** Adds an on-screen key rectangle. 
sl@0: 
sl@0: This function configures an area of the screen, given by aRect, to act as 
sl@0: an on-screen key. Any subsequent pointer events within this area will be translated 
sl@0: by the window server into key events with a scan code of aScanCode.
sl@0: 
sl@0: aActivatedByPointerSwitchOn indicates whether or not to generate a key event 
sl@0: as a result of a pointer event that acts to switch the machine on.
sl@0: 
sl@0: Before v7.0, calling this function stopped the window from receiving pointer 
sl@0: events (they were received as key events) and pointer events outside the specified 
sl@0: key rectangle were discarded. From v7.0, pointer events outside the key rectangles 
sl@0: are not discarded and may be handled.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aRect Rectangle to act as an on-screen key, relative to the window 
sl@0: origin 
sl@0: @param aScanCode Scan code of key events generated by this on-screen key 
sl@0: @param aActivatedByPointerSwitchOn If ETrue, a switch-on pointer event will 
sl@0: produce a key event. If EFalse, a switch-on pointer event will not produce 
sl@0: a key event. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see RemoveAllKeyRects() */
sl@0: 	{
sl@0: 	TWsWinCmdAddKeyRect params(aRect, aScanCode, aActivatedByPointerSwitchOn);
sl@0: 	return(WriteReply(&params,sizeof(params),EWsWinOpAddKeyRect));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::RemoveAllKeyRects()
sl@0: /** Removes all the on-screen keys that have been added to this window.
sl@0: 
sl@0: After this function has been called, all pointer events are delivered to the window, 
sl@0: reversing the effect of AddKeyRect().
sl@0: 
sl@0: @see AddKeyRect() */
sl@0: 	{
sl@0: 	Write(EWsWinOpRemoveAllKeyRects);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::PasswordWindow(TPasswordMode aPasswordMode)
sl@0: /** Makes this window the password window.
sl@0: 
sl@0: Only one password window can exist concurrently. Another window may take over 
sl@0: as the password window if either (a) the current password window calls this 
sl@0: function with aPasswordMode=EPasswordCancel, or (b) the current password window 
sl@0: is destroyed.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aPasswordMode The type of password handling required. 
sl@0: @return KErrNone if successful, KErrInUse if this function is called when another 
sl@0: password window already exists, otherwise another of the system-wide error 
sl@0: codes. 
sl@0: 
sl@0: @deprecated */
sl@0: 	{
sl@0: 	return(WriteReplyInt(aPasswordMode,EWsWinOpPasswordWindow));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowBase::FadeBehind(TBool aFade)
sl@0: /** Sets whether or not all windows behind the current window, in the same window 
sl@0: group, should be faded or unfaded. 
sl@0: 
sl@0: This function can be used to fade all windows used by an application when 
sl@0: a dialogue is displayed.
sl@0: 
sl@0: Fading works on a count basis. Fading increases the fade count, while unfading 
sl@0: decreases it. If the fade count is greater than zero the window will be drawn 
sl@0: faded. Only when it drops back to zero will it stop being faded.
sl@0: 
sl@0: This functionality is used to support nested dialogues. When bringing up a 
sl@0: dialogue the rest of the application windows are faded. If an option is selected 
sl@0: to launch another dialogue, the original dialogue is faded (fade count 1) 
sl@0: and the remaining windows have their fade count increased to 2. When the dialogue 
sl@0: is closed the fade count is reduced by one, which displays the original dialogue, 
sl@0: but the remaining windows remain faded. They are only displayed when the other 
sl@0: dialogue is closed and their fade count is reduced to zero.
sl@0: 
sl@0: Note:
sl@0: 
sl@0: Information is lost when a window is faded, so a redraw is required to restore 
sl@0: the window content when it is unfaded (blank and backup windows deal with 
sl@0: this themselves). A redraw is also required for the areas that were in shadow 
sl@0: when the window was faded, since the shadowing also causes information loss. 
sl@0: While a window is faded all drawing to that window will be adjusted appropriately 
sl@0: by the window server.
sl@0: 
sl@0: @param aFade ETrue to increase the fade count of all windows behind the current 
sl@0: window (within the current window group), EFalse to reduce the fade count. 
sl@0: @see RWindowTreeNode::SetFaded()
sl@0: @see RWindowTreeNode::SetNonFading() */
sl@0: 	{
sl@0: 	WriteInt(aFade,EWsWinOpFadeBehind);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TBool RWindowBase::IsFaded() const
sl@0: /** Tests whether the current window is faded.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return ETrue if the current window is faded, otherwise EFalse. */
sl@0: 	{
sl@0: 	return WriteReply(EWsWinOpGetIsFaded);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TBool RWindowBase::IsNonFading() const
sl@0: /** Tests whether the current window is non-fading.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return ETrue if the current window is non-fading, otherwise EFalse. 
sl@0: @see RWindowTreeNode::SetNonFading() */
sl@0: 	{
sl@0: 	return WriteReply(EWsWinOpGetIsNonFading);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowBase::MoveToGroup(TInt aIdentifier)
sl@0: /** Moves this window to another window group. 
sl@0: 
sl@0: This function allows a window with a window group as its immediate parent 
sl@0: to be moved from one window group to another one. The two window groups must 
sl@0: be owned by the same client. The new parent window group is specified by its 
sl@0: identifier.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aIdentifier The identifier of the target window group. This is the 
sl@0: value returned by RWindowGroup::Identifier(). 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes. An error is returned if an attempt is made to move the window between 
sl@0: window groups in different clients. */
sl@0: 	{
sl@0: 	return WriteReplyInt(aIdentifier,EWsWinOpMoveToGroup);
sl@0: 	}
sl@0: 
sl@0: /** This sets the background of the window to be the given surface.
sl@0: 
sl@0: The surface will be stretched or compressed to fill the extent of the window.
sl@0: The background is updated on screen when the window is next redrawn.
sl@0: 
sl@0: When the window is moved, the surface will move with it. If the window is
sl@0: resized, the surface will be similarly scaled. If a 1-1 pixel mapping is
sl@0: required and the window size changes, the function will need to be called
sl@0: again with a different TSurfaceId for a surface with the new size of the
sl@0: window.
sl@0: 
sl@0: The key color to use in chroma key composition mode is defined by the system,
sl@0: for all TSurfaceId background windows to use. In alpha composition mode,
sl@0: transparent black is used. The composition mode is determined by the screen
sl@0: display mode: if the mode supports an alpha channel, alpha composition is used;
sl@0: otherwise chroma key composition is used.
sl@0: 
sl@0: @param aSurface  The surface to act as the background of the window
sl@0: @return KErrNone on success or a system-wide error code.
sl@0: @pre aSurface has been initialized.
sl@0: @pre The window is either an RWindow or an RBlankWindow, or the client is
sl@0: panicked with the code EWservPanicDrawable.
sl@0: @pre The surface must be compatible with being composited on the screen this
sl@0: window appears on; otherwise the client thread is panicked with code
sl@0: EWservPanicIncompatibleSurface.
sl@0: @post The window has its background set to be the surface.
sl@0: @post The window is opaque.
sl@0: @post The base area of the window is the full extent of the window.
sl@0: @post A GCE surface layer has been created to associate the surface with a
sl@0: location on screen.
sl@0: @post The surface's content is in an undefined state, but the surface remains
sl@0: initialized.
sl@0: @post This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @publishedPartner
sl@0: @prototype
sl@0: */
sl@0: EXPORT_C TInt RWindowBase::SetBackgroundSurface(const TSurfaceId& aSurface)
sl@0: 	{
sl@0: 	(void) aSurface;	//avoid unreferenced warning
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /**
sl@0: This sets a surface to appear in front of the window's background within a 
sl@0: given area of that window. 
sl@0: 
sl@0: Any rendering performed by CWindowGc operations will appear in front of surface 
sl@0: for the window. The TSurfaceConfiguration object contains the Surface ID and 
sl@0: allows various surface presentation attributes to be specified. This describes 
sl@0: the mapping from surface co-ordinates to screen co-ordinates, allowing for scaling, 
sl@0: cropping, and rotation. 
sl@0: 
sl@0: For details on the attributes see TSurfaceConfiguration.
sl@0: 
sl@0: The composition mode is determined by the screen display mode: if the mode supports an 
sl@0: alpha channel, alpha composition is used; otherwise chroma key composition is used. 
sl@0: In chroma key composition mode, the key color used is defined by the system, for all 
sl@0: TSurfaceId background windows to use. In alpha composition mode, transparent 
sl@0: black is used.
sl@0: 
sl@0: If the same surface ID is already set as the window background surface, then only 
sl@0: the configuration parameters will be updated. 
sl@0: 
sl@0: If the window already has a background surface (that is not same as the new surface) 
sl@0: or then that surface will be removed and the new 
sl@0: background surface will be set. The Surface ID will be registered while attached 
sl@0: to this window. This is in addition to any call to RWsSession::RegisterSurface.
sl@0: 
sl@0: @param aConfiguration The set of configuration that applies to the surface.
sl@0: @param aTriggerRedraw If set causes WServ to repaint any affected portions of the display.
sl@0: @return KErrNone on success or any system-wide error code
sl@0: 	- KErrNotSupported if surface support is not available
sl@0: 	- KErrNoMemory If a memory allocation fault occurs
sl@0: 	- KErrArgument If the surface ID is not accepted by the GCE 
sl@0: @pre The window is either a RWindow or an RBlankWindow, or the client is panicked 
sl@0: with the code EWservPanicDrawable.
sl@0: @pre The surface is opaque; otherwise results are not defined.
sl@0: @pre All members of the TSurfaceConfiguration recognised by the server must have valid 
sl@0: values. If not, the client is panicked with code EWservPanicInvalidSurfaceConfiguration.
sl@0: @pre The surface must not be the UI surface; otherwise the client thread is panicked 
sl@0: with code EWservPanicInvalidSurface.
sl@0: @pre The surface must not be the null surface ID; otherwise the client thread is 
sl@0: panicked with code EWservPanicInvalidSurface.
sl@0: @post The window has a new background surface set to be within the given area. Outside 
sl@0: the area, the window’s background color will be visible.
sl@0: @post The window must be redrawn before the surface becomes visible, and the surface's 
sl@0: content will be visible after the composition and refresh. Composition of the surface 
sl@0: will be automatically triggered if required. The aTriggerRedraw flush parameter will 
sl@0: cause this redraw, or the client should cause a redraw after this call.
sl@0: @post This function always causes a flush of the WServ session buffer.
sl@0: @see RemoveBackgroundSurface
sl@0: @see GetBackgroundSurface
sl@0: 
sl@0: @publishedPartner
sl@0: @prototype
sl@0: */
sl@0: EXPORT_C TInt RWindowBase::SetBackgroundSurface(const TSurfaceConfiguration& aConfiguration, TBool aTriggerRedraw)
sl@0: 	{
sl@0: 	(void) aConfiguration;	//avoid unreferenced warning
sl@0: 	(void) aTriggerRedraw;	//avoid unreferenced warning
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /**
sl@0: This removes any background surface that has been set to the window.
sl@0: 
sl@0: The surface ID registration associated with the window will be released. 
sl@0: This is independent of any outstanding calls to RWsSession::RegisterSurface, 
sl@0: which should be completed with a corresponding call to UnregisterSurface.
sl@0: 
sl@0: The aTriggerRedraw parameter triggers a redraw of at least the affected 
sl@0: areas of the window at the end of this method. 
sl@0: 
sl@0: @param aTriggerRedraw If set causes WServ to repaint any affected portions of the display.
sl@0: @post Any background surface associated with this window has been removed. The 
sl@0: appearance on screen may not change until the window is redrawn and the next 
sl@0: refresh occurs. The aTriggerRedraw parameter can be set to trigger this redrawing.
sl@0: @post This function does not explicitly force a flush of the WServ session buffer. 
sl@0: Internal reference counting will keep the Surface ID "live" until the client code 
sl@0: has released any handles and provisioners, and WServ processes the buffered remove 
sl@0: command, and the final frame containing this surface has finished being displayed.
sl@0: @see SetBackgroundSurface
sl@0: @see GetBackgroundSurface
sl@0: 
sl@0: @publishedPartner
sl@0: @prototype
sl@0: */
sl@0: EXPORT_C void RWindowBase::RemoveBackgroundSurface(TBool aTriggerRedraw)
sl@0: 	{
sl@0: 	(void) aTriggerRedraw;	//avoid unreferenced warning
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /**
sl@0: Retrieves a copy of the current configuration for background surface attached to the window.
sl@0: 
sl@0: The client must present a properly initialized TSurfaceConfiguration on entry – in 
sl@0: particular the size field must be valid before the call. The server will then fill 
sl@0: the object with the available data.
sl@0: 
sl@0: If the server supports more fields it will truncate the returned data to the size the 
sl@0: client has requested. If the server has fewer fields it will set the returned size 
sl@0: field to the lower value. 
sl@0: 
sl@0: Note that the returned attribute values will only be guaranteed equivalent to the 
sl@0: input values, not exact copies, as the values may be calculated from internal flags 
sl@0: rather than reported from a cached exact copy.
sl@0: 
sl@0: @param aConfiguration
sl@0: 	- On entry the Size field specifies the maximum size of the object.
sl@0: 	- On return fields up to this size are filled in.
sl@0: @return KErrNone on success or any system-wide error code
sl@0: 	- KErrNotFound The window does not have a background surface attached.
sl@0: 	- KErrNoMemory If a memory allocation fault occurs.
sl@0: @pre The window is either a RWindow or an RBlankWindow, or the client is panicked 
sl@0: with the code EWservPanicDrawable.
sl@0: @pre The window has not been set as transparent, or the client is panicked with 
sl@0: the code EWservPanicTransparencyMisuse.
sl@0: @pre The Size member of the configuration must be an acceptable value. The size 
sl@0: must match the Size() member of a defined TSurfaceConfiguration variant, or be 
sl@0: larger than all variants known to the server. If not, the client is panicked with 
sl@0: code EWservPanicInvalidSurfaceConfiguration.
sl@0: @post aConfiguration object filled to specified size.
sl@0: @post This function always causes a flush of the WServ session buffer.
sl@0: @see SetBackgroundSurface
sl@0: @see RemoveBackgroundSurface
sl@0: 
sl@0: @publishedPartner
sl@0: @prototype
sl@0: */
sl@0: EXPORT_C TInt RWindowBase::GetBackgroundSurface(TSurfaceConfiguration& aConfiguration) const
sl@0: 	{
sl@0: 	(void) aConfiguration;	//avoid unreferenced warning
sl@0: 	return KErrNotSupported;
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: Not supported in non-NGA
sl@0:  */
sl@0: EXPORT_C void RWindowBase::SetSurfaceTransparency(TBool aSurfaceTransparency)
sl@0:     {
sl@0:     (void) aSurfaceTransparency;
sl@0:     }
sl@0: 
sl@0: /** This function returns the key color for the window, if used.
sl@0: 
sl@0: In chroma key composition mode, this will be an opaque color; in alpha
sl@0: composition mode, it will be transparent black, i.e. TRgb(0, 0, 0, 0). If the
sl@0: window does not have a surface or overlay background, the return value is
sl@0: transparent black.
sl@0: 
sl@0: The value of a chroma key color depends on the background type. Windows with
sl@0: surface backgrounds return the system defined key color, whereas windows with
sl@0: overlay backgrounds return the color passed in.
sl@0: 
sl@0: If the return value is opaque, the client should take care to avoid using the
sl@0: color when rendering further content in the window, since it may cause that
sl@0: content to become invisible.
sl@0: 
sl@0: @return The key color used in this window, or transparent black.
sl@0: @post This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @publishedPartner
sl@0: @prototype
sl@0: */
sl@0: EXPORT_C TRgb RWindowBase::KeyColor() const
sl@0: 	{
sl@0: 	return KRgbBlack;
sl@0: 	}
sl@0: 
sl@0: /**	Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0: 	@internalComponent*/
sl@0: EXPORT_C void RWindowBase::SetPurpose(TInt /*aPurpose*/)
sl@0: 	{
sl@0: 	ASSERT(0);
sl@0: 	}
sl@0: 
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */
sl@0: EXPORT_C void RWindowBase::SendEffectCommand(TInt /*aTfxCmd*/,const TDesC8& /*aTfxCmdData*/)
sl@0:     {
sl@0: 	ASSERT(0);
sl@0:     }
sl@0: 
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */
sl@0: EXPORT_C void RWindowBase::OverrideEffects(TInt /*aAction*/, const TFileName& /*aResourceDir*/, const TFileName& /*aFilenameOutgoing*/, const TFileName& /*aFilenameIncoming*/, TBitFlags /*aFlags*/)
sl@0:     {
sl@0: 	ASSERT(0);
sl@0:     }
sl@0: 
sl@0: //////////////////////////// RDrawableWindow ////////////////////////////////
sl@0: 
sl@0: void RDrawableWindow::doScroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect, TInt aOpcode)
sl@0: 	{
sl@0: 	TWsWinCmdScroll scroll(aClipRect,aOffset,aRect);
sl@0: 	Write(&scroll,sizeof(scroll),aOpcode);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RDrawableWindow::Scroll(const TPoint &aOffset)
sl@0: /** Scrolls the window contents by an offset. 
sl@0: 
sl@0: All parts of an RWindow are either drawn with content copied from another 
sl@0: part of the window or are invalidated. Areas are invalidated when the source 
sl@0: content of the scroll would be outside the window or obscured behind another 
sl@0: window. The areas that are invalidated are not blanked off.
sl@0: 
sl@0: For example, if the window is scrolled towards the right, then there is no 
sl@0: content (from outside the window) to move into area on the left hand side. 
sl@0: This area is invalidated. Similarly, no content can be scrolled out from under 
sl@0: an obscuring window, so the area from beneath the obscuring window is also 
sl@0: invalidated.
sl@0: 
sl@0: Note that for an RBackedUpWindow, the contents of areas obscured by other windows 
sl@0: are stored. In this case the window contents are scrolled out from "underneath" 
sl@0: the obscuring window. In the example above the area on the left was invalidated 
sl@0: but for this type of window the area simply contains its old pre-scroll contents.
sl@0: 
sl@0: @param aOffset Scroll offset, in pixels. Positive values cause the window 
sl@0: contents to move downwards/right. Negative values cause contents to move upwards/left. */
sl@0: 	{
sl@0: 	doScroll(TRect(), aOffset, TRect(), EWsWinOpScroll);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RDrawableWindow::Scroll(const TRect &aClipRect,const TPoint &aOffset)
sl@0: /** Scrolls the contents of a clip rectangle, independently of the other contents 
sl@0: of the window.
sl@0: 
sl@0: This function behaves in exactly the same way as the single parameter overload, 
sl@0: except that the scroll region is a clipping rectangle rather than the whole window. 
sl@0: All parts of the clipping rectangle are either drawn with content copied from 
sl@0: another part of the rectangle or are invalidated.
sl@0: 
sl@0: The RBackedUpWindow behaviour is also similar to the behaviour in the function 
sl@0: above.
sl@0: 
sl@0: @param aClipRect Rectangle to which scrolling is to be clipped 
sl@0: @param aOffset Scroll offset, in pixels. Positive values cause the window contents 
sl@0: to move downwards and right. Negative values cause contents to move upwards 
sl@0: and left. */
sl@0: 	{
sl@0: 	doScroll(aClipRect, aOffset, TRect(), EWsWinOpScrollClip);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RDrawableWindow::Scroll(const TPoint &aOffset, const TRect &aRect)
sl@0: /** Scrolls a rectangle within a window.
sl@0: 
sl@0: This function effectively moves the specified rectangle by the given offset 
sl@0: with respect to the window. The destination rectangle may overlap and cover 
sl@0: the old rectangle.
sl@0: 
sl@0: Note that if the source of this rectangle is an invalid area, ie it is obscured 
sl@0: or lies outside the window, then this area in the destination rectangle will 
sl@0: be invalidated.
sl@0: 
sl@0: @param aOffset Scroll offset, in pixels. Positive values cause the window 
sl@0: contents to move downwards and right. Negative values cause contents to move 
sl@0: upwards and left. 
sl@0: @param aRect The source rectangle for the scroll. */
sl@0: 	{
sl@0: 	doScroll(TRect(), aOffset, aRect, EWsWinOpScrollRect);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RDrawableWindow::Scroll(const TRect &aClipRect, const TPoint &aOffset, const TRect &aRect)
sl@0: /** Scrolls the contents of a source rectangle within a clipping rectangle.
sl@0: 
sl@0: The source rectangle is effectively copied from one position to another, with 
sl@0: both the source and destination clipped to the clipping rectangle. Hence if 
sl@0: the source and destination rectangles are inside the clipping region then 
sl@0: this function behaves exactly like the Scroll(const TPoint &aOffset, const TRect &aRect) 
sl@0: overload. However if the source or destination for the scrolled rectangle intersect 
sl@0: the clipping rectangle then the function behaves similarly to the 
sl@0: Scroll(const TRect &aClipRect,const TPoint &aOffset) overload, with regards to 
sl@0: invalidated regions etc.
sl@0: 
sl@0: @param aClipRect Rectangle to which scrolling is to be clipped.
sl@0: @param aOffset Scroll offset, in pixels. Positive values cause the window contents 
sl@0: to move downwards and right. Negative values cause contents to move upwards 
sl@0: and left. 
sl@0: @param aRect Source rectangle for the scroll. */
sl@0: 	{
sl@0: 	doScroll(aClipRect, aOffset, aRect, EWsWinOpScrollClipRect);
sl@0: 	}
sl@0: 
sl@0: /**Protected system function.
sl@0: 
sl@0: Sets the current redraw reference rectangle that is being drawn. 
sl@0: This is called between a BeingRedraw() / EndRedraw() pair by the system.
sl@0: 
sl@0: @param aRect Rectangle reference area that is currently being drawn.
sl@0: @see GetDrawRect() */
sl@0: void RDrawableWindow::SetDrawRect(const TRect &aRect)
sl@0: 	{
sl@0: 	iDrawRect = aRect;
sl@0: 	}
sl@0: 
sl@0: /**Obtains the current rectangle being drawn to this window, during a window redraw cycle.
sl@0: 
sl@0: This function can be called between a BeginRedraw() / EndRedraw() pair to obtain 
sl@0: the current window redraw reference rectangle.
sl@0: 
sl@0: @return The current reference rectangle that is being redrawn*/
sl@0: EXPORT_C TRect RDrawableWindow::GetDrawRect() const
sl@0: 	{
sl@0: 	return iDrawRect;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::BeginRedraw(const TRect &aRect)
sl@0: /** Begins the redraw of a rectangle within the window's invalid region.
sl@0: 
sl@0: This method tells the window server that the window is about to respond to the 
sl@0: last redraw event by redrawing the specified rectangle. This causes the window 
sl@0: server to clear the rectangle, and remove it from the invalid region. 
sl@0: 
sl@0: After the redraw is complete the window should call EndRedraw().
sl@0: 
sl@0: Note:
sl@0: 
sl@0: When handling a redraw event, this rectangle would typically be the rectangle 
sl@0: returned by TWsRedrawEvent::Rect().
sl@0: 
sl@0: The redraw is clipped to the area that is validated, i.e. the intersection 
sl@0: of the rectangle with the previously invalid region.
sl@0: 
sl@0: If you only validate part of the rectangle given in the redraw event then, 
sl@0: after EndRedraw() is called, drawing will be clipped to the visible area which 
sl@0: is not invalid. This is because drawing (that is non-redrawing) is always 
sl@0: clipped to the visible region less the invalid region. You will get another 
sl@0: message telling you to redraw the area that is still invalid. 
sl@0: 
sl@0: @param aRect The rectangle to be redrawn. 
sl@0: @see EndRedraw() */
sl@0: 	{
sl@0: 	WriteRect(aRect,EWsWinOpBeginRedraw);
sl@0: 	SetDrawRect(aRect);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::BeginRedraw()
sl@0: /** Begins redrawing the window's invalid region. 
sl@0: 
sl@0: This method tells the window server that the window is about to respond to 
sl@0: the last redraw event by redrawing the entire invalid region. This causes 
sl@0: the window server to validate the entire invalid region. 
sl@0: 
sl@0: After the redraw is complete the entire region that was previously invalid 
sl@0: is validated. The window should then call EndRedraw().
sl@0: 
sl@0: Note: the redraw is clipped to the region that was previously invalid.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @see EndRedraw() */
sl@0: 	{
sl@0: 	Write(EWsWinOpBeginRedrawFull);
sl@0: 	SetDrawRect(TRect(Size()));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::EndRedraw()
sl@0: /** Ends the current redraw. 
sl@0: 
sl@0: This function should be called when redrawing is complete. */
sl@0: 	{
sl@0: 	Write(EWsWinOpEndRedraw);
sl@0: 	SetDrawRect(TRect::EUninitialized);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::Invalidate(const TRect &aRect)
sl@0: /** Invalidates an area within the window. 
sl@0: 
sl@0: This function invalidates the specified rectangle, which causes the window 
sl@0: to get a redraw message. This allows an application-initiated redraw of a 
sl@0: specified rectangle.
sl@0: 
sl@0: @param aRect Area to invalidate. */
sl@0: 	{
sl@0: 	WriteRect(aRect,EWsWinOpInvalidate);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::Invalidate()
sl@0: /** Invalidates the entire window. 
sl@0: 
sl@0: This function causes the window to get a redraw message specifying its entire 
sl@0: visible area, allowing an application-initiated redraw. */
sl@0: 	{
sl@0: 	Write(EWsWinOpInvalidateFull);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::GetInvalidRegion(RRegion &aRegion) const
sl@0: /** Gets the invalid region.
sl@0: 
sl@0: Note: if there is not enough memory to create the region, the region's error flag 
sl@0: will be set.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aRegion On return, contains the invalid region. */
sl@0: 	{
sl@0: 	aRegion.Clear();
sl@0: retry:
sl@0: 	TInt count=WriteReply(EWsWinOpGetInvalidRegionCount);
sl@0: 	if (count>0)
sl@0: 		{
sl@0: 		HBufC8 *rectBuf=NULL;
sl@0: 		TRAPD(err,rectBuf=HBufC8::NewMaxL(count*sizeof(TRect)));
sl@0: 		if (err==KErrNone)
sl@0: 			{
sl@0: 			TPtr8 des=rectBuf->Des();
sl@0: 			if (WriteReplyP(&count,sizeof(count),&des,EWsWinOpGetInvalidRegion))
sl@0: 				{
sl@0: 				User::Free(rectBuf);
sl@0: 				goto retry;
sl@0: 				}
sl@0: 			for(TInt index=0;index<count;index++)
sl@0: 				aRegion.AddRect(((TRect *)rectBuf->Ptr())[index]);
sl@0: 			User::Free(rectBuf);
sl@0: 			}
sl@0: 		else
sl@0: 			aRegion.ForceError();
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::SetBackgroundColor(TRgb aColor)
sl@0: /** Sets the background colour used for clearing in server-initiated redraws. 
sl@0: 
sl@0: The window will be cleared to its background colour when a window server-initiated 
sl@0: redraw occurs. Background colour can be changed dynamically after a window 
sl@0: has been created and activated, however, the new background colour will not 
sl@0: be visible until the window has been redrawn.
sl@0: 
sl@0: @param aColor Background colour to be used during redraws. */
sl@0: 	{
sl@0: 	WriteInt(aColor.Internal(),EWsWinOpSetBackgroundColor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::SetBackgroundColor()
sl@0: /** Sets the background colour used for clearing in server-initiated redraws to 
sl@0: none. 
sl@0: 
sl@0: The window will not be cleared to its background colour when a window server-initiated 
sl@0: redraw occurs. 
sl@0: 
sl@0: For a window on which SetTransparencyAlphaChannel() has been called, this function means
sl@0: that the transparent window has no background.
sl@0: 
sl@0: If a client calls this function for an opaque window, it is their responsibility to provide
sl@0: opaque drawing to every pixel in the window (for example, a background bitmap). Otherwise,
sl@0: undefined behaviour will result. */
sl@0: 	{
sl@0: 	Write(EWsWinOpSetNoBackgroundColor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindow::Construct(const RWindowTreeNode &parent,TUint32 aClientHandle)
sl@0: /** Completes the construction of the window handle. 
sl@0: 
sl@0: This method should be called after the RWindow() constructor, before any other 
sl@0: functions are performed on the window. It creates a window in the window server 
sl@0: corresponding to the RWindow object. The window is initialised to inherit 
sl@0: the size and extent of its parent window, given by the first parameter. If its 
sl@0: parent is a group window then it will be full screen.
sl@0:  
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param parent The window's parent. 
sl@0: @param aClientHandle Client handle for the window. This is an integer value 
sl@0: chosen by the client that must be unique within the current server session. The 
sl@0: usual way of doing this is to cast the address of the object that owns the window 
sl@0: to a TUint32; this allows event handlers which are given a window handle to obtain 
sl@0: a reference to the window an event is intended for. For example, CCoeControl uses 
sl@0: this technique when it constructs a window. Note that in GUI applications, every 
sl@0: window is created and owned by a control. Therefore it is rare for 3rd party code 
sl@0: to ever need to call a window's Construct() function directly.
sl@0: 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	return(construct(parent,aClientHandle,EWinRedraw,ENone));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::SetSize(const TSize &size)
sl@0: /** Sets the size of a window. 
sl@0: 
sl@0: This function may be called at any time after the window's Construct() function: 
sl@0: the window's size will change dynamically.
sl@0: 
sl@0: If the window size is increased, any new area will be cleared to the background 
sl@0: colour and a redraw event will be generated for it.
sl@0: 
sl@0: @param size The window size. */
sl@0: 	{
sl@0: 	WriteSize(size,EWsWinOpSetSize);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindow::SetExtent(const TPoint &pos,const TSize &size)
sl@0: /** Sets the size and position of a window. 
sl@0: 
sl@0: This function may be called at any time after the window's Construct() function: 
sl@0: the window's extent will change dynamically.
sl@0: 
sl@0: If the window size is increased, any new area will be cleared to the background 
sl@0: colour and a redraw event will be generated for it.
sl@0: 
sl@0: @param pos The position of the window's origin, relative to its parent. 
sl@0: @param size The window size. 
sl@0: @see RBackedUpWindow */
sl@0: 	{
sl@0: 	TWsWinCmdSetExtent setExtent(pos,size);
sl@0: 	Write(&setExtent,sizeof(setExtent),EWsWinOpSetExtent);
sl@0: 	}
sl@0: 
sl@0: /** Enables or Disables the storing of redraw operations that do not 
sl@0: intersect the viewport for a window.
sl@0: 
sl@0: The window server stores operations required to redraw a window in a redraw 
sl@0: store. Calling this function with ETrue causes all such drawing operations 
sl@0: to be stored. The EnableRedrawStore(EFalse) call serves as a hint to store 
sl@0: only the subset of draw commands which intersect the viewport.
sl@0: 
sl@0: @param aEnabled Indicates whether the redraw store should be enabled or disabled. */
sl@0: EXPORT_C void RWindow::EnableRedrawStore(TBool aEnabled)
sl@0: 	{
sl@0: 	WriteInt(aEnabled, EWsWinOpStoreDrawCommands);
sl@0: 	}
sl@0: 
sl@0: /** Enables/Disables the WSERV to use its OSB
sl@0: @param bool value that dertermines whether to trun OSB on or off
sl@0: */
sl@0: EXPORT_C void RWindow::EnableOSB(TBool aStatus)
sl@0: 	{
sl@0: 	if(aStatus)
sl@0: 		{
sl@0: 		Write(EWsWinOpEnableOSB);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		Write(EWsWinOpDisableOSB);
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: /** Clears the draw commands that are stored for this window from the redraw store.
sl@0: 	Windows that have had their redraw store cleared are not ready to draw again until 
sl@0: 	a new set of draw commands enclosed by BeginRedraw/EndRedraw have been issued.
sl@0: */	
sl@0: EXPORT_C void RWindow::ClearRedrawStore()
sl@0: 	{
sl@0: 	Write(EWsWinOpClearRedrawStore);
sl@0: 	}
sl@0: 	
sl@0: EXPORT_C void RWindowGroup::SetOrdinalPriorityAdjust(TInt aAdjust)
sl@0: /** Sets the window group's priority adjust value. 
sl@0: 
sl@0: This function is primarily designed for sessions that own multiple window 
sl@0: groups. After this function has been called by a window group, that window 
sl@0: group's priority will be adjusted by the amount given by aAdjust whenever 
sl@0: another window group owned by the same session gains keyboard focus.
sl@0: 
sl@0: When the session loses focus, the priority returns to its original value.
sl@0: 
sl@0: Note: This is ignored for window groups in chains.
sl@0: 
sl@0: @param aAdjust Value to be added to window group's existing priority. */
sl@0: 	{
sl@0: 	WriteInt(aAdjust,EWsWinOpSetOrdinalPriorityAdjust);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::SetOrdinalPositionErr(TInt aPos,TInt aOrdinalPriority)
sl@0: /** Sets the ordinal position and ordinal priority of a window.
sl@0:  
sl@0: Ordinal priority is a number assigned to a window that determines its position in the z-order. 
sl@0: For a description of ordinal priority, see the RWindowTreeNode::SetOrdinalPosition function.
sl@0: To set a priority of KPasswordWindowGroupPriority or greater, client will require 
sl@0: SwEvent capability. If client does not have SwEvent capability then it will return error 
sl@0: code.
sl@0: 
sl@0: Note: If this window is a window group in a chain, then all other window groups in the chain will be moved also. 
sl@0: And further they will all have their ordinal priority set to the specified value.
sl@0: When this function is called on Window with aPos set to KOrdinalPositionSwitchToOwningWindow then the function 
sl@0: doesn't change the ordinal position of the window, if instead it has focus then the window that would come to 
sl@0: the forground if it died will be moved to the foreground.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aPos The window's new ordinal position. The lower the ordinal, the closer to the 
sl@0: front of the z-order the window will be. Specifying any negative value however, sends 
sl@0: the window to the back of the z-order.
sl@0: @param aOrdinalPriority The window's new ordinal priority.
sl@0: @return	if not successful, one of the system-wide error codes. */
sl@0: 	{
sl@0: 	TWsWinCmdOrdinalPos ordinalPos;
sl@0: 	ordinalPos.pos=aPos;
sl@0: 	ordinalPos.ordinalPriority=aOrdinalPriority;
sl@0: 	return(WriteReply(&ordinalPos,sizeof(ordinalPos),EWsWinOpSetOrdinalPositionErr));
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: Window transparency based on the use of a separate window mask bitmap has been 
sl@0: deprecated. Calling this method method has no effect. For window transparency 
sl@0: see the the support for window alpha channel.
sl@0: 
sl@0: @see RWindow::SetTransparencyAlphaChannel() 
sl@0: @deprecated
sl@0: */
sl@0: EXPORT_C void RWindow::HandleTransparencyUpdate()
sl@0: 	{
sl@0: 	// deprecated. this call does nothing. always return KErrNone.
sl@0: 	Write(EWsWinOpHandleTransparencyUpdate);
sl@0: 	}
sl@0: 
sl@0: /**
sl@0: The support for window transparency factor has been deprecated. Calling this 
sl@0: method has no effect. For window transparency see the the support for window 
sl@0: alpha channel.
sl@0: 
sl@0: @param aTransparencyFactor Ignored.
sl@0: @return	Always KErrNone.
sl@0: @see RWindow::SetTransparencyAlphaChannel() 
sl@0: @deprecated
sl@0: */
sl@0: EXPORT_C TInt RWindow::SetTransparencyFactor(const TRgb& aTransparencyFactor)
sl@0: 	{
sl@0: 	// deprecated. this call does nothing. always return KErrNone.
sl@0: 	return WriteReplyInt(aTransparencyFactor.Internal(), EWsWinOpSetTransparencyFactor);
sl@0: 	}
sl@0: 	
sl@0: /**
sl@0: Window transparency based on the use of a separate window mask bitmap has been 
sl@0: deprecated. Calling this method method has no effect. For window transparency 
sl@0: see the the support for window alpha channel.
sl@0: 
sl@0: @param aTransparencyBitmap Ignored.
sl@0: @return	Always KErrNone.
sl@0: @see RWindow::SetTransparencyAlphaChannel() 
sl@0: @deprecated
sl@0: */
sl@0: EXPORT_C TInt RWindow::SetTransparencyBitmap(const CFbsBitmap& aTransparencyBitmap)
sl@0: 	{
sl@0: 	// deprecated. this call does nothing. always return KErrNone.
sl@0: 	return WriteReplyInt(aTransparencyBitmap.Handle(), EWsWinOpSetTransparencyBitmap);	
sl@0: 	}
sl@0: 	
sl@0: /**
sl@0: Window transparency based on the use of a separate window mask bitmap has been 
sl@0: deprecated. Calling this method method has no effect. For window transparency 
sl@0: see the the support for window alpha channel.
sl@0: 
sl@0: @param aTransparencyBitmap Ignored.
sl@0: @return	Always KErrNone.
sl@0: @see RWindow::SetTransparencyAlphaChannel() 
sl@0: @deprecated
sl@0: */
sl@0: EXPORT_C TInt RWindow::SetTransparencyWsBitmap(const CWsBitmap& aTransparencyBitmap)
sl@0: 	{
sl@0: 	// deprecated. this call does nothing. always return KErrNone.
sl@0: 	return WriteReplyInt(aTransparencyBitmap.WsHandle(), EWsWinOpSetTransparencyBitmapCWs);
sl@0: 	}	
sl@0: 
sl@0: /**
sl@0: Window transparency based on the use of a separate window mask bitmap has been 
sl@0: deprecated. Calling this method method has no effect. To guarantee a window being
sl@0: opaque; see SetTransparentRegion().
sl@0: 
sl@0: @see RWindow::SetTransparentRegion()
sl@0: @deprecated
sl@0: */
sl@0: EXPORT_C void RWindow::SetNonTransparent()
sl@0: 	{}
sl@0: 
sl@0: /**
sl@0: Enables the use of an alpha channel to control the window's transparency.
sl@0: 
sl@0: Note that the window's invalid area will be cleared using the window's 
sl@0: background color before any drawing commence. Thus setting the background 
sl@0: color to fully transparent is essential in most use cases.
sl@0:    
sl@0: @see RWindow::SetBackgroundColor()
sl@0: @return	KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: EXPORT_C TInt RWindow::SetTransparencyAlphaChannel()
sl@0: 	{
sl@0: 	return WriteReply(EWsWinOpSetTransparencyAlphaChannel);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindow::SetTransparentRegion(const TRegion& aRegion)
sl@0: /** Sets the user-defined transparent region of a window.
sl@0: 
sl@0: This will replace the default transparent region in a transparent window which is normally the full window 
sl@0: base area.
sl@0: The area outside of the transparent region will be treated by window server as being opaque. The client
sl@0: is responsible for ensuring that opaque drawing is present in all pixels of this area. If the client 
sl@0: fails to do this, undefined behaviour will result.
sl@0: It is possible to make the transparent window completely opaque by passing an empty region. Passing a region
sl@0: equal to the window base area or larger will revert the window to its default behaviour (i.e. full window
sl@0: transparency).
sl@0: No screen content changes will occur immediately as a result of calling this function.
sl@0:  
sl@0: This function applies to transparent window only and always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aRegion User defined windows's transparent region. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see RWindow::SetTransparencyAlphaChannel() */
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(!aRegion.CheckError(),Panic(EW32PanicInvalidRegion));
sl@0: 	const TInt regionCount=aRegion.Count();
sl@0: 	TPtrC8 ptrRect(reinterpret_cast<const TUint8*>(aRegion.RectangleList()),regionCount*sizeof(TRect));
sl@0: 	return WriteReplyByProvidingRemoteReadAccess(&regionCount,sizeof(regionCount),&ptrRect,EWsWinOpSetTransparentRegion);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindow::SetTransparencyPolicy(TWsTransparencyPolicy aPolicy)
sl@0: /** Sets the transparency policy of a window.
sl@0: 
sl@0: No screen content changes will occur immediately as a result of calling this function.
sl@0:  
sl@0: This function applies to transparent window only.
sl@0: 
sl@0: @param aPolicy Transparent window policy. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. 
sl@0: @see TWsTransparencyPolicy */
sl@0: 	{
sl@0: 	return WriteReplyInt(aPolicy,EWsWinOpSetTransparencyPolicy);
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /** Returns whether the window uses a redraw store to store drawing commands.
sl@0: 
sl@0: The current WServ implementation always uses a redraw store. Therefore this function always returns ETrue.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return ETrue 
sl@0: @see RWindow::EnableRedrawStore()
sl@0: @deprecated */
sl@0: EXPORT_C TBool RWindow::IsRedrawStoreEnabled() const
sl@0: 	{
sl@0: 	return WriteReply(EWsWinOpIsRedrawStoreEnabled);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::Construct(TUint32 aClientHandle)
sl@0: /** Completes construction of a window group. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be 
sl@0: called.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the most likely 
sl@0: of which is KErrNoMemory. 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(ConstructChildApp(0,aClientHandle,ETrue));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::Construct(TUint32 aClientHandle,CWsScreenDevice* aScreenDevice) 
sl@0: /** Completes construction of a window group on a screen. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be 
sl@0: called.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aScreenDevice A screen device is used to specify on which screen the window should be. The screen device must exist for as long as the window 
sl@0: is in use. Different screen devices for two different window groups in an application allow the windows to have different screen size modes and WSERV 
sl@0: will automatically switch from one to the other when there is a screen size mode change.
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the most likely 
sl@0: of which is KErrNoMemory. 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return (Construct(0,aClientHandle,ETrue,aScreenDevice));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::Construct(TUint32 aClientHandle,TBool aIsFocusable,CWsScreenDevice* aScreenDevice)
sl@0: /** Completes construction of a window group on a screen. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be called.
sl@0: 
sl@0: The purpose of this Construct function for RWindowGroup is that it allows chains of window groups to be created on a specific screen. When one of 
sl@0: the window groups in a chain is moved with SetOrdinalPosition then all window groups in that chain will be moved to be consecutative, 
sl@0: with the parent being at the back in the Z-order. The purpose of this feature is to allow embedding of applications.
sl@0: 
sl@0: Note: The term parent should not be confused with the paremeter used in the function RWindow::Construct.  There it means that this window 
sl@0: is a child of that window in the tree.  Here is just means that the two window groups involved will have an extra association.
sl@0: Note: This window group will be given the same ordinal priority as it's parent window group.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aScreenDevice A screen device is used to specify on which screen the window should be. The screen device must exist for as long as the window 
sl@0: is in use. Different screen devices for two different window groups in an application allow the windows to have different screen size modes and WSERV 
sl@0: will automatically switch from one to the other when there is a screen size mode change.
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @param aIdOfParentWindowGroup The Identifier of the parent window group.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the most likely of which is KErrNoMemory. 
sl@0: It will return KErrPermissionDenied if the requested parent has not allowed this window group to be its child, 
sl@0: and it will return KErrInUse if the parent already has a child.
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(Construct(0,aClientHandle,aIsFocusable,aScreenDevice));	
sl@0: 	}
sl@0: 	
sl@0: EXPORT_C TInt RWindowGroup::Construct(TUint32 aClientHandle,TBool aIsFocusable)
sl@0: /** Completes the construction of a window group, setting its initial focus state. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be 
sl@0: called.
sl@0: 
sl@0: aInitialFocusState can be specified in order to prevent a window group from 
sl@0: automatically taking the keyboard focus when it is created. If specified, 
sl@0: it sets the initial focus state of the window group. If a window group has 
sl@0: a focus state of ETrue (the default), it can receive keyboard focus; if EFalse, 
sl@0: it is prevented from receiving keyboard focus until this setting is changed. 
sl@0: If a window group is constructed without specifying an initial focus state, 
sl@0: keyboard focus will be enabled by default and the window group will receive 
sl@0: keyboard focus automatically when it is created. To prevent this, set aInitialFocusState 
sl@0: to EFalse.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aClientHandle The client's integer handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @param aIsFocusable Whether the window is focusable. Set ETrue for it to 
sl@0: be able to receive focus, EFalse otherwise. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, 
sl@0: the most likely of which is KErrNoMemory.
sl@0: @see EnableReceiptOfFocus() 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(ConstructChildApp(0,aClientHandle,aIsFocusable));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::ConstructChildApp(TInt aIdOfParentWindowGroup,TUint32 aClientHandle)
sl@0: /** Completes construction of a window group. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be called.
sl@0: 
sl@0: The purpose of this Construct function for RWindowGroup is that it allows chains of window groups to be created. When one of 
sl@0: the window groups in a chain is moved with SetOrdinalPosition then all window groups in that chain will be moved to be consecutative, 
sl@0: with the parent being at the back in the Z-order. The purpose of this feature is to allow embedding of applications.
sl@0: 
sl@0: Note: The term parent should not be confused with the paremeter used in the function RWindow::Construct.  There it means that this window 
sl@0: is a child of that window in the tree.  Here is just means that the two window groups involved will have an extra association.
sl@0: Note: This window group will be given the same ordinal priority as it's parent window group.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @param aIdOfParentWindowGroup The Identifier of the parent window group.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the most likely of which is KErrNoMemory. 
sl@0: It will return KErrPermissionDenied if the requested parent has not allowed this window group to be its child, 
sl@0: and it will return KErrInUse if the parent already has a child.
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(ConstructChildApp(aIdOfParentWindowGroup,aClientHandle,ETrue));
sl@0: 	}
sl@0: 
sl@0: TInt RWindowGroup::Construct(TInt aIdOfParentWindowGroup,TUint32 aClientHandle,TBool aIsFocusable, CWsScreenDevice* aScreenDevice)
sl@0: /** Completes construction of a window group on a screen. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be called.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aScreenDevice A screen device is used to specify on which screen the window should be. The screen device must exist for as long as the window 
sl@0: is in use. Different screen devices for two different window groups in an application allow the windows to have different screen size modes and WSERV 
sl@0: will automatically switch from one to the other when there is a screen size mode change.
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() for a description of the client handle.
sl@0: @param aIdOfParentWindowGroup The Identifier of the parent window group.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the most likely of which is KErrNoMemory. 
sl@0: It will return KErrPermissionDenied if the requested parent has not allowed this window group to be its child, 
sl@0: and it will return KErrInUse if the parent already has a child.
sl@0: @param aIsFocusable Whether the window is focusable. Set ETrue for it to be able to receive focus, EFalse otherwise. 
sl@0: @panic TW32Panic 17 in debug builds if called on an already constructed object.
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	__ASSERT_DEBUG(iWsHandle == KNullHandle, Panic(EW32PanicGraphicDoubleConstruction));
sl@0: 	TWsClCmdCreateWindowGroup create;
sl@0: 	create.clientHandle=aClientHandle;
sl@0: 	create.focus=aIsFocusable;
sl@0: 	create.parentId=aIdOfParentWindowGroup;
sl@0: 	create.screenDeviceHandle = (aScreenDevice) ? aScreenDevice->WsHandle() : 0;
sl@0: 	
sl@0: 	TInt ret;
sl@0: 	if ((ret=iBuffer->WriteReplyWs(&create,sizeof(create),EWsClOpCreateWindowGroup))<0)
sl@0: 		{
sl@0: 		return ret;
sl@0: 		}
sl@0: 	iWsHandle=ret;
sl@0: 	return KErrNone;
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::ConstructChildApp(TInt aIdOfParentWindowGroup,TUint32 aClientHandle,TBool aIsFocusable)
sl@0: /** Completes construction of a window group. 
sl@0: 
sl@0: Construction must be complete before any other window group methods can be called.
sl@0: 
sl@0: This Construct function of RWindowGroup allows both the creation of the group window in a chain and for and for it not to recieve focus.  
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @param aIdOfParentWindowGroup The Identifier of the parent window group.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the most likely of which is KErrNoMemory. 
sl@0: It will return KErrPermissionDenied if the requested parent has not allowed this window group to be its child, 
sl@0: and it will return KErrInUse if the parent already has a child.
sl@0: @param aIsFocusable Whether the window is focusable. Set ETrue for it to be able to receive focus, EFalse otherwise. 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return (Construct(aIdOfParentWindowGroup,aClientHandle,aIsFocusable,NULL));
sl@0: 	}
sl@0:     
sl@0: EXPORT_C void RWindowGroup::AllowProcessToCreateChildWindowGroups(TUid aProcessSID)
sl@0: /** Allows a Window Group in the specified process to be be a child of this one
sl@0: 
sl@0: This function will need to be called to allow another window group to become a child window group of this one.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aProcessSID This is the process security Id of the process that will be allowed to make child window groups*/
sl@0: 	{
sl@0: 	WriteReplyInt(aProcessSID.iUid,EWsWinOpAllowChildWindowGroup);		//Use WriteReply to cause it to flush
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::EnableReceiptOfFocus(TBool aState)
sl@0: /** Enables or disables receipt of keyboard focus.
sl@0: 
sl@0: The front most focusable window has keyboard focus. This function sets whether 
sl@0: or not the window can receive keyboard focus.
sl@0: 
sl@0: @param aState Whether this window group can accept keyboard focus. */
sl@0: 	{
sl@0: 	WriteInt(aState,EWsWinOpReceiveFocus);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::AutoForeground(TBool aState)
sl@0: /** Sets or disables auto-foreground behaviour. 
sl@0: 
sl@0: If this behaviour is set for a window, it will automatically be given ordinal 
sl@0: position zero whenever a pointer event of type EButton1Down occurs in any 
sl@0: of its child windows. This will cause it to be brought to the foreground, 
sl@0: unless another window group exists with a higher priority.
sl@0: 
sl@0: A window group that is moved to the foreground will automatically get keyboard 
sl@0: focus unless it has explicitly had receipt-of-focus disabled or there is a 
sl@0: focusable window group of higher priority. See EnableReceiptOfFocus().
sl@0: 
sl@0: @param aState Whether this group should be automatically brought to the foreground 
sl@0: on an EButton1Down. */
sl@0: 	{
sl@0: 	WriteInt(aState,EWsWinOpAutoForeground);
sl@0: 	}
sl@0: 
sl@0: TInt32 RWindowGroup::doCaptureKey(TUint aKey, TUint aModifierMask, TUint aModifiers, TInt aPriority, TInt aOpcode)
sl@0: 	{
sl@0: 	TWsWinCmdCaptureKey captureKey;
sl@0: 
sl@0: 	captureKey.key=aKey;
sl@0: 	captureKey.modifiers=aModifiers;
sl@0: 	captureKey.modifierMask=aModifierMask;
sl@0: 	captureKey.priority=aPriority;
sl@0: 
sl@0: 	return(WriteReply(&captureKey,sizeof(captureKey),aOpcode));
sl@0: 	}
sl@0: 
sl@0: void RWindowGroup::doCancelCaptureKey(TInt32 aCaptureKeyHandle, TInt aOpcode)
sl@0: 	{
sl@0: 	if (iWsHandle && aCaptureKeyHandle)
sl@0: 		WriteReplyInt(aCaptureKeyHandle,aOpcode);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt32 RWindowGroup::CaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers)
sl@0: /** Requests key capture.
sl@0: 
sl@0: This function instructs the window server to send key events (of type EEventKey) 
sl@0: with the specified key code and modifier state to this window group, regardless 
sl@0: of which window group currently has the keyboard focus. 
sl@0: 
sl@0: Key events for the key given by aKeyCode are captured only when the modifier keys 
sl@0: specified by aModifierMask are in the states specified by aModifier. For example, 
sl@0: calling  
sl@0: @code
sl@0: wsGroup->CaptureKey(EKeyDevice2, EModifierAlt|EModifierCtrl, EModifierCtrl); 
sl@0: @endcode
sl@0: will capture the EKeyDevice2 key only if Ctrl is pressed and Alt is not.
sl@0: 
sl@0: Normally, keyboard key presses result in three events being delivered to the client: 
sl@0: EEventKeyDown, EEventKey and EEventKeyUp. However, CaptureKey() results in only 
sl@0: the EEventKey being delivered to the window group that called it: the EEventKeyUp 
sl@0: and EEventKeyDown events are sent to the window group that has focus. If a window 
sl@0: group wishes to capture the EEventKeyUp and EEventKeyDown events as well as the 
sl@0: EEventKey, it should call CaptureKeyUpAndDowns().
sl@0: 
sl@0: Note that a window group can call this function more than once (to request capture 
sl@0: for more than one key), and more than one window group may have requested key 
sl@0: capture. If multiple window groups have requested to capture the same key using 
sl@0: this function, the key is sent to the window group that most recently requested 
sl@0: the key capture.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aKeyCode The key code for the key to be captured. Key codes for special 
sl@0: keys are defined in TKeyCode. 
sl@0: @param aModifierMask Bitmask that identifies the modifier keys of interest. 
sl@0: Possible values are defined in TEventModifier.
sl@0: @param aModifiers Bitmask that identifies which of the modifier keys in 
sl@0: aModifierMask need to be set and which need to be unset. For example, see the 
sl@0: description above. 
sl@0: @return A handle identifying the capture key, or one of the system-wide error 
sl@0: codes (if <0). KErrPermissionDenied indicates that the requested key cannot be 
sl@0: captured by this window group, because it has been protected by another window group. 
sl@0: For more information, see the PROTECTEDKEY parameter in wsini.ini. 
sl@0: Handles should be kept in order to be passed to CancelCaptureKey() 
sl@0: later. KErrPermissionDenied, if 
sl@0: @capability SwEvent */
sl@0: 	{
sl@0: 	return(doCaptureKey(aKeyCode, aModifierMask, aModifiers, 0, EWsWinOpCaptureKey));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt32 RWindowGroup::CaptureKey(TUint aKeyCode, TUint aModifierMask, TUint aModifiers, TInt aPriority)
sl@0: /** Requests key capture, with a priority.
sl@0: 
sl@0: This function instructs the window server to send key events (of type EEventKey) 
sl@0: with the specified key code and modifier state to this window group, regardless 
sl@0: of which window group currently has the keyboard focus. 
sl@0: 
sl@0: Key events for the key given by aKeyCode are captured only when the modifier keys 
sl@0: specified by aModifierMask are in the states specified by aModifier. For example, 
sl@0: calling  
sl@0: @code
sl@0: wsGroup->CaptureKey(EKeyDevice2, EModifierAlt|EModifierCtrl, EModifierCtrl, priority); 
sl@0: @endcode
sl@0: will capture the EKeyDevice2 key only if Ctrl is pressed and Alt is not.
sl@0: 
sl@0: Normally, keyboard key presses result in three events being delivered to the client: 
sl@0: EEventKeyDown, EEventKey and EEventKeyUp. However, CaptureKey() results in only 
sl@0: the EEventKey being delivered to the window group that called it: the EEventKeyUp 
sl@0: and EEventKeyDown events are sent to the window group that has focus. If a window 
sl@0: group wishes to capture the EEventKeyUp and EEventKeyDown events as well as the 
sl@0: EEventKey, it should call CaptureKeyUpAndDowns().
sl@0: 
sl@0: Note that a window group can call this function more than once (to request capture 
sl@0: for more than one key), and more than one window group may have requested key 
sl@0: capture. If multiple window groups have requested to capture the same key at the 
sl@0: same priority, the key is sent to the window group that most recently requested 
sl@0: the key capture.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aKeyCode The key code for the key to be captured. Key codes for special 
sl@0: keys are defined in TKeyCode. 
sl@0: @param aModifierMask Bitmask that identifies the modifier keys of interest. 
sl@0: Possible values are defined in TEventModifier.
sl@0: @param aModifiers Bitmask that identifies which of the modifier keys in 
sl@0: aModifierMask need to be set and which need to be unset. For example, see the 
sl@0: description above. 
sl@0: @param aPriority A priority value - if more than one window group has requested 
sl@0: capture for the same key event, the one with the highest priority will capture it.
sl@0: @return A handle identifying the capture key, or one of the system-wide error 
sl@0: codes (if <0). KErrPermissionDenied indicates that the requested key cannot be 
sl@0: captured by this window group, because it has been protected by another window group. 
sl@0: For more information, see the PROTECTEDKEY parameter in wsini.ini. Handles should be 
sl@0: kept in order to be passed to CancelCaptureKey() later. 
sl@0: @capability SwEvent */	{
sl@0: 	return(doCaptureKey(aKeyCode, aModifierMask, aModifiers, aPriority, EWsWinOpCaptureKey));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::CancelCaptureKey(TInt32 aHotKey)
sl@0: /** Cancels a request for key capture. 
sl@0: 
sl@0: Use this function to cancel a request to capture a key previously made with 
sl@0: CaptureKey(). If the value passed in aHotKey is not a valid capture key 
sl@0: handle, this function will cause a panic.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aHotKey The key for which the capture request is cancelled. */
sl@0: 	{
sl@0: 	doCancelCaptureKey(aHotKey, EWsWinOpCancelCaptureKey);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt32 RWindowGroup::CaptureKeyUpAndDowns(TUint aScanCode, TUint aModifierMask, TUint aModifiers)
sl@0: /** Requests the capture of key-up and key-down events on behalf of a window group.
sl@0: 
sl@0: This function requests the window server to send EEventKeyUp and EEventKeyDown 
sl@0: key events from the specified key to this window group, regardless of which 
sl@0: window group currently has the keyboard focus. This contrasts with CaptureKey(), 
sl@0: which causes the window server to send the EEventKey event.
sl@0: 
sl@0: Key events for the key given by aScanCode are captured only when the modifier 
sl@0: keys specified by aModifierMask are in the states specified by aModifiers. 
sl@0: See RWsSession::SetHotKey() for examples of how to set aModifierMask and aModifiers.
sl@0: 
sl@0: Note: in general, keyboard key presses result in three events being delivered to 
sl@0: the client: EEventKeyDown, EEventKey and EEventKeyUp.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aScanCode Scan code for the key to be captured. Scan codes are defined 
sl@0: in TStdScanCode. 
sl@0: @param aModifierMask Bitmask that identifies the modifier keys of interest. 
sl@0: Possible values are defined in TEventModifier. 
sl@0: @param aModifiers Bitmask that identifies which of the modifier keys in 
sl@0: aModifierMask need to be set and which need to be unset. 
sl@0: @return A handle identifying the capture key, or one of the system-wide error 
sl@0: codes (if < 0). KErrPermissionDenied indicates that the requested key cannot be 
sl@0: captured by this window group, because it has been protected by another window group. 
sl@0: For more information, see the PROTECTEDKEY parameter in wsini.ini. Handles should be 
sl@0: kept in order to be passed to CancelCaptureKeyUpAndDowns() later.
sl@0: @capability SwEvent */
sl@0: 	{
sl@0: 	return(doCaptureKey(aScanCode, aModifierMask, aModifiers, 0, EWsWinOpCaptureKeyUpsAndDowns));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt32 RWindowGroup::CaptureKeyUpAndDowns(TUint aScanCode, TUint aModifierMask, TUint aModifiers, TInt aPriority)
sl@0: /** Requests the capture of key-up and key-down events on behalf of a window group.
sl@0: This function is identical to the other overload, except that it allows a priority to be specified.
sl@0: This function always causes a flush of the window server buffer.
sl@0: @param aScanCode Scan code for the key to be captured. Scan codes are defined 
sl@0: in TStdScanCode. 
sl@0: @param aModifierMask Bitmask that identifies the modifier keys of interest. 
sl@0: Possible values are defined in TEventModifier. 
sl@0: @param aModifiers Bitmask that identifies which of the modifier keys in 
sl@0: aModifierMask need to be set and which need to be unset. 
sl@0: @param aPriority A priority value - if more than one window group has requested 
sl@0: capture for the same key event, the one with the highest priority will capture it.
sl@0: @return A handle identifying the capture key, or one of the system-wide error 
sl@0: codes (if < 0). KErrPermissionDenied indicates that the requested key cannot be captured by this 
sl@0: window group, because it has been protected by another window group. For more information, see 
sl@0: the PROTECTEDKEY parameter in wsini.ini. Handles should be kept in order to be passed to 
sl@0: CancelCaptureKeyUpAndDowns() later.
sl@0: @capability SwEvent */
sl@0: 	{
sl@0: 	return(doCaptureKey(aScanCode, aModifierMask, aModifiers, aPriority, EWsWinOpCaptureKeyUpsAndDowns));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::CancelCaptureKeyUpAndDowns(TInt32 aHotKey)
sl@0: /** Cancels a capture request for a key up or key down event. 
sl@0: 
sl@0: Use this function to cancel a request to capture a key, previously made with 
sl@0: CaptureKeyUpAndDowns(). If the value passed in aHotKey is not a valid 
sl@0: capture key handle, this function will cause a panic.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aHotKey Cancels the request to capture this key. */
sl@0: 	{
sl@0: 	doCancelCaptureKey(aHotKey, EWsWinOpCancelCaptureKeyUpsAndDowns);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt32 RWindowGroup::CaptureLongKey(TUint aInputKeyCode,TUint aOutputKeyCode,TUint aModifierMask,TUint aModifiers
sl@0: 																											,TInt aPriority,TUint aFlags)
sl@0: /** Requests capture of long key presses.
sl@0: 
sl@0: This function causes the window server to send a long key event (which 
sl@0: is generated when the key has been held down for the initial keyboard 
sl@0: repeat time), to this window group, regardless of whether it currently has 
sl@0: keyboard focus. The key that is output can have a different key code to the 
sl@0: key that was captured.
sl@0: 
sl@0: Key events for the key given by aInputKeyCode are captured only when the modifier 
sl@0: keys specified by aModifierMask are in the states specified by aModifiers.
sl@0: 
sl@0: A priority can be specified to resolve any conflicts that arise when multiple 
sl@0: window groups attempt to capture the same long key event.
sl@0: 
sl@0: Normal key press behaviour (where no long key press capture requests have been 
sl@0: made) is as follows. When a key is pressed, a key down event occurs, followed by 
sl@0: one or more standard (short) key events, followed by a key up event. All of 
sl@0: these key events are sent to the application in the foreground.
sl@0: 
sl@0: Key press behaviour when an application has made a long key press capture request 
sl@0: is as follows. When the key is pressed and held down, a long key event is generated 
sl@0: in addition to the events described above (although if a long key event occurs, 
sl@0: then there will never be more than one standard key event) and this is sent to the 
sl@0: application that made the request, even if it is not in the foreground. 
sl@0: 
sl@0: If that application also wants to capture the up and down key events then it needs to call 
sl@0: CaptureKeyUpAndDowns(). If it wants to capture the standard key event, then it needs to 
sl@0: call CaptureKey(). Depending on flags (enumerated in TLongCaptureFlags) specified when making 
sl@0: the long key capture request, the standard key event can either be generated when the key is 
sl@0: pressed, as it would be if no long key capture request had been made, or it can be generated 
sl@0: when the key is released. In the latter case, the standard key event is only generated if the 
sl@0: key was not held down long enough to generate a long key event.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aInputKeyCode The key code for the key to be captured. Key codes for 
sl@0: special keys are defined in TKeyCode.
sl@0: @param aOutputKeyCode The key code that will be output.
sl@0: @param aModifierMask Only the modifier keys in this mask are tested against 
sl@0: the states specified in aModifier.
sl@0: @param aModifiers The key is captured only when the modifier keys specified 
sl@0: in aModifierMask match these states, where 1 = modifier set, and 0 = modifier 
sl@0: not set. Modifier key states are defined in TEventModifier. 
sl@0: @param aPriority If more than one window group has requested capture for the 
sl@0: same long key event, the one with the highest priority will capture the event.
sl@0: @param aFlags Configures the long key capture behaviour. See the TLongCaptureFlags 
sl@0: enum.
sl@0: @return Identifying value for the long key capture. For use with the CancelCaptureLongKey() 
sl@0: function.
sl@0: @see TLongCaptureFlags 
sl@0: @capability SwEvent */
sl@0: 	{
sl@0: 	return(CaptureLongKey(TTimeIntervalMicroSeconds32(-1),aInputKeyCode,aOutputKeyCode,aModifierMask,aModifiers,aPriority,aFlags));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt32 RWindowGroup::CaptureLongKey(TTimeIntervalMicroSeconds32 aRepeatTime,TUint aInputKeyCode,TUint aOutputKeyCode
sl@0: 																	,TUint aModifierMask,TUint aModifiers,TInt aPriority,TUint aFlags)
sl@0: /** Requests capture of long key presses.
sl@0: 
sl@0: This function causes the window server to send a long key event (which 
sl@0: is generated when the key has been held down for the specified time), 
sl@0: to this window group, regardless of whether it currently has 
sl@0: keyboard focus.
sl@0: 
sl@0: For more information on this function, see the other CaptureLongKey() overload.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aRepeatTime The time interval in microseconds between the initial 
sl@0: key event and the first auto repeat.
sl@0: @param aInputKeyCode The key code for the key to be captured. Key codes for 
sl@0: special keys are defined in TKeyCode.
sl@0: @param aOutputKeyCode The key code that will be output.
sl@0: @param aModifierMask Only the modifier keys in this mask are tested against 
sl@0: the states specified in aModifier.
sl@0: @param aModifiers The key is captured only when the modifier keys specified 
sl@0: in aModifierMask match these states, where 1 = modifier set, and 0 = modifier 
sl@0: not set. Modifier key states are defined in TEventModifier. 
sl@0: @param aPriority If more than one window group has requested capture for the 
sl@0: same long key event, the one with the highest priority will capture the event.
sl@0: @param aFlags Configures the long key capture behaviour. See the TLongCaptureFlags 
sl@0: enum.
sl@0: @return Identifying value for the long key capture. For use with the CancelCaptureLongKey() 
sl@0: function.
sl@0: @see TLongCaptureFlags
sl@0: @capability SwEvent */
sl@0: 	{
sl@0: 	TWsWinCmdCaptureLongKey captureKey(aModifiers,aModifierMask,aInputKeyCode,aOutputKeyCode,aRepeatTime,aPriority,aFlags);
sl@0: 	return(WriteReply(&captureKey,sizeof(captureKey),EWsWinOpCaptureLongKey));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::CancelCaptureLongKey(TInt32 aCaptureKey)
sl@0: /** Cancels a previous long key capture request.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aCaptureKey The value returned by the previous call to CaptureLongKey(). 
sl@0: Identifies which long key capture request to cancel. */
sl@0: 	{
sl@0: 	doCancelCaptureKey(aCaptureKey, EWsWinOpCancelCaptureLongKey);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::AddPriorityKey(TUint aKeycode, TUint aModifierMask, TUint aModifiers)
sl@0: /** Adds a priority key. 
sl@0: 
sl@0: Priority key events are typically used for providing "Abort" or "Escape" keys 
sl@0: for an application. For priority key events to occur they must first be configured 
sl@0: using this function. Functions provided by RWsSession can then be used to 
sl@0: get priority key events. Note that unlike other events, the Control Framework 
sl@0: does not get priority key events for you.
sl@0: 
sl@0: Priority key events for the key given by aKeyCode are only delivered when 
sl@0: the modifier keys specified by aModifierMask are in the states specified by 
sl@0: aModifiers. See RWsSession::SetHotKey() for examples of how to use aModifierMask 
sl@0: and aModifiers.
sl@0: 
sl@0: More than one priority key can be added for each keycode, each having a different 
sl@0: set of modifier requirements.
sl@0: 
sl@0: Note: if you press a priority key while another is waiting to be sent to the client 
sl@0: then the first key is lost.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aKeycode The priority key to be added. 
sl@0: @param aModifierMask Only the modifier keys in this mask are tested against 
sl@0: the states specified in aModifiers. 
sl@0: @param aModifiers Key is captured only when modifier keys specified in aModifierMask 
sl@0: match these states, where 1 = modifier key on, and 0 = modifier key off. Modifier 
sl@0: key states are defined in TEventModifier. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	TWsWinCmdPriorityKey priorityKey;
sl@0: 
sl@0: 	priorityKey.keycode=aKeycode;
sl@0: 	priorityKey.modifiers=aModifiers;
sl@0: 	priorityKey.modifierMask=aModifierMask;
sl@0: 	return(WriteReply(&priorityKey,sizeof(priorityKey),EWsWinOpAddPriorityKey));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::RemovePriorityKey(TUint aKeycode, TUint aModifierMask, TUint aModifier)
sl@0: /** Removes a priority key. 
sl@0: 
sl@0: Use this function to remove a priority key that was added using AddPriorityKey(). 
sl@0: If the specified priority key does not exist, this function does nothing.
sl@0: 
sl@0: Note: all 3 parameters must match exactly for a successful removal.
sl@0: 
sl@0: @param aKeycode Key code for the priority key to be removed 
sl@0: @param aModifierMask Modifier mask for the priority key to be removed 
sl@0: @param aModifier Modifier states for the priority key to be removed */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		{
sl@0: 		TWsWinCmdPriorityKey priorityKey;
sl@0: 
sl@0: 		priorityKey.keycode=aKeycode;
sl@0: 		priorityKey.modifiers=aModifier;
sl@0: 		priorityKey.modifierMask=aModifierMask;
sl@0: 		Write(&priorityKey,sizeof(priorityKey),EWsWinOpRemovePriorityKey);
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::SetTextCursor(RWindowBase &aWin, const TPoint &aPos, const TTextCursor &aCursor, const TRect &aClipRect)
sl@0: /** Sets the text cursor and its clipping rectangle. 
sl@0: 
sl@0: Use this function to set a text cursor for this window group, or to change 
sl@0: the existing text cursor's position or appearance.
sl@0: 
sl@0: The cursor is clipped to aClipRect. This allows, for example, the window 
sl@0: to have a border region in which the cursor is not displayed.
sl@0: 
sl@0: @param aWin The text cursor is in this window, and is hence clipped to it 
sl@0: and positioned relative to it. 
sl@0: @param aPos Position of the text cursor's origin, relative to the origin of 
sl@0: aWin. 
sl@0: @param aCursor The cursor to set. This may be a standard rectangular cursor, 
sl@0: of type TTextCursor::ETypeRectangle or TTextCursor::ETypeHollowRectangle, 
sl@0: or it may be a custom cursor, in which case it should have previously been 
sl@0: added to the window server using RWsSession::SetCustomTextCursor().
sl@0: @param aClipRect The cursor is clipped to this rectangle. Rectangle co-ordinates 
sl@0: are relative to the origin of aWin. */
sl@0: 	{
sl@0: 	TWsWinCmdSetTextCursor SetTextCursor(aWin.WsHandle(),aPos,aCursor,aClipRect);
sl@0: 	Write(&SetTextCursor,sizeof(SetTextCursor),EWsWinOpSetTextCursorClipped);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::SetTextCursor(RWindowBase &aWin, const TPoint &aPos, const TTextCursor &aCursor)
sl@0: /** Sets the text cursor.
sl@0: 
sl@0: Use this function to set a text cursor for this window group, or to change 
sl@0: the existing text cursor's position or appearance.
sl@0: 
sl@0: @param aWin The text cursor is in this window, and is hence clipped to it 
sl@0: and positioned relative to it.
sl@0: @param aPos Position of the text cursor's origin, relative to the origin of 
sl@0: aWin.
sl@0: @param aCursor The cursor to set. This may be a standard rectangular cursor, 
sl@0: of type TTextCursor::ETypeRectangle or TTextCursor::ETypeHollowRectangle, 
sl@0: or it may be a custom cursor, in which case it should have previously been 
sl@0: added to the window server using RWsSession::SetCustomTextCursor(). */
sl@0: 	{
sl@0: 	TWsWinCmdSetTextCursor SetTextCursor(aWin.WsHandle(),aPos,aCursor);
sl@0: 	Write(&SetTextCursor,sizeof(SetTextCursor),EWsWinOpSetTextCursor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::CancelTextCursor()
sl@0: /** Removes the text cursor. 
sl@0: 
sl@0: Use this function to remove the current text cursor from this window group. 
sl@0: This function does nothing if the cursor is currently in another window group. */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpCancelTextCursor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::SetName(const TDesC &aName)
sl@0: /** Sets the window group's name. 
sl@0: 
sl@0: Use this function to set the name of a window group. Window group names are 
sl@0: arbitrary and can contain any data that can be stored in a descriptor 
sl@0: of type TDesC.
sl@0: 
sl@0: Note: if this function is successful, a window group change event is sent to everything 
sl@0: that is set up to receive these events.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aName The name for the window group. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	const TInt nameLength=aName.Length();
sl@0: 	return WriteReplyByProvidingRemoteReadAccess(&nameLength,sizeof(TInt),&aName,EWsWinOpSetName);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::Name(TDes &aWindowName) const
sl@0: /** Gets the window group's name, as set by SetName().
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aWindowName On return, contains the name of this window group. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes. */
sl@0: 	{
sl@0: 	return(WriteReplyIntP(aWindowName.MaxLength(),&aWindowName,EWsWinOpName));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::SetOwningWindowGroup(TInt aIdentifier)
sl@0: /** Sets the owning window group for this window group.
sl@0: 
sl@0: The owning window group is the group that is brought to the foreground when 
sl@0: the window group which has keyboard focus (the foreground application) dies.
sl@0: 
sl@0: If the owning window group is not set, then the window group brought to the 
sl@0: foreground when the application dies will be the default owning window group.
sl@0: 
sl@0: @param aIdentifier The window group's identifier. */
sl@0: 	{
sl@0: 	WriteInt(aIdentifier,EWsWinOpSetOwningWindowGroup);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::DefaultOwningWindow()
sl@0: /** 
sl@0: @publishedPartner
sl@0: @released
sl@0: 
sl@0: Makes this window group the default owning window group.
sl@0: 
sl@0: The default owning window group is the group that is brought to the foreground 
sl@0: when the window group which has keyboard focus (the foreground application) 
sl@0: dies, if no other window has been set up as the owning group.
sl@0: 
sl@0: This window group will take over as the default owning window group even if 
sl@0: another window group has previously called this function. However, if this 
sl@0: window group is subsequently destroyed, the default owning window group will 
sl@0: revert to being the previous window group.
sl@0: 
sl@0: @see SetOwningWindowGroup() 
sl@0: @capability WriteDeviceData */
sl@0: 	{
sl@0: 	Write(EWsWinOpDefaultOwningWindow);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::Identifier() const
sl@0: /** Gets the identifier of the window group.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The window group identifier. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpIdentifier));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::DisableKeyClick(TBool aState)
sl@0: /** Disables key clicks.
sl@0: 
sl@0: If a window group calls this function with aState=ETrue, key clicks (i.e. 
sl@0: the sound generated when keys are pressed) will be disabled whenever this 
sl@0: window group has the keyboard focus. Key clicks for this window group can be 
sl@0: re-enabled by calling this function with aState=EFalse. 
sl@0: 
sl@0: Note that this function doesn't do anything in v6.0 and v6.1.
sl@0: 
sl@0: @param aState If ETrue, no key clicks occur when this window group has keyboard focus. 
sl@0: If EFalse, key clicks are enabled when this window group has keyboard focus. */
sl@0: 	{
sl@0: 	WriteInt(aState,EWsWinOpDisableKeyClick);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::EnableScreenChangeEvents()
sl@0: /** Enables screen change event sending.
sl@0: 
sl@0: This function ensures that window groups are sent screen change events, which 
sl@0: are sent, for example, when the cover on a phone that supports screen flipping 
sl@0: is opened or closed.
sl@0: 
sl@0: Note that not getting screen change events is the default behaviour.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return KErrNone if successful, otherwise another of the system-wide error 
sl@0: codes. 
sl@0: @see DisableScreenChangeEvents() */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpEnableScreenChangeEvents));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::DisableScreenChangeEvents()
sl@0: /** Disables screen change event sending.
sl@0: 
sl@0: This function prevents window groups from getting screen change events, which 
sl@0: are sent, for example, when the cover on a phone that supports screen flipping is 
sl@0: opened or closed.
sl@0: 
sl@0: Note that not getting screen change events is the default behaviour.
sl@0: 
sl@0: See EnableScreenChangeEvents(). */
sl@0: 	{
sl@0: 	if (iWsHandle)
sl@0: 		Write(EWsWinOpDisableScreenChangeEvents);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::SimulatePointerEvent(TRawEvent aEvent)
sl@0: /** Simulates a pointer event.
sl@0: 
sl@0: This function sends a pointer event to the window as if it had come 
sl@0: from the kernel, except that it will be sent to a window which is a child 
sl@0: of the window group it is called on. 
sl@0: 
sl@0: Notes:
sl@0: 
sl@0: The function can be used to send a pointer event to an application when 
sl@0: it is in the background.
sl@0: 
sl@0: The function is supported for testing purposes only.
sl@0: 
sl@0: @param aEvent The simulated raw event. */
sl@0: 	{
sl@0: 	Write(&aEvent,sizeof(aEvent),EWsWinOpSendPointerEvent);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RWindowGroup::SimulateAdvancedPointerEvent(TRawEvent /*aEvent*/)
sl@0: /** Dummy implementation in order to preserve compatibility with WSERV NGA.
sl@0:     @internalComponent */ 
sl@0: 	{
sl@0: 	ASSERT(0);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RWindowGroup::ClearChildGroup()
sl@0: /** Clears all children of the current window group.
sl@0: 
sl@0: The window group chain is broken directly after the current window group. In the 
sl@0: general case (consider clearing the child group of a window group in the middle of a 
sl@0: long chain), this results in two distinct chains. In the special cases where either
sl@0: the parent window group or the child window group ends up as the only member of a 
sl@0: resultant chain, it is removed from that chain.
sl@0: 
sl@0: @return KErrArgument if trying to clear the child window group of a window group that
sl@0: has no children; KErrNoMemory if, when splitting into 2 chains, there is insufficient
sl@0: memory to create the second chain (in this case the child window groups are all cleared
sl@0: from the current chain, then the error is returned). Otherwise KErrNone or one of the 
sl@0: system-wide error codes.
sl@0: 
sl@0: @see SetChildGroup() */
sl@0: 	{
sl@0: 	return WriteReply(EWsWinOpClearChildGroup);
sl@0: 	}
sl@0: 	
sl@0: EXPORT_C TInt RWindowGroup::SetChildGroup(TInt aId)
sl@0: /** Sets a window group chain onto the current window group.
sl@0: 
sl@0: Appends all the window groups chained to the child window group onto the chain
sl@0: containing the current window group. 
sl@0: 
sl@0: @param aId. ID of the child window group that is head of the chain
sl@0: 
sl@0: @return KErrArgument if any of these are true:
sl@0: - child group referred to by aId does not exist
sl@0: - the current window group already has a child 
sl@0: - the window group requested to be the child is already a child of another window group
sl@0: - the window group requested to the child is already the parent or grand parent etc. of the current window group
sl@0: KErrNoMemory: If the group and it's child are not currently in a chain then a new chain needs to be created
sl@0: which can fail due to lack of memory;
sl@0: otherwise one of the system-wide error codes is returned.
sl@0: 
sl@0: @see ClearChildGroup() */
sl@0: 	{
sl@0: 	return WriteReplyInt(aId,EWsWinOpSetChildGroup);
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // Backed up window
sl@0: //
sl@0: 
sl@0: EXPORT_C TInt RBackedUpWindow::Construct(const RWindowTreeNode &parent, TDisplayMode aDisplayMode, TUint32 aClientHandle)
sl@0: /** Completes the construction of a backed up window. 
sl@0: 
sl@0: This method should be called after the RBackedUpWindow(RWsSession&) constructor, 
sl@0: and before any other functions are performed on the window. It creates a window 
sl@0: in the window server corresponding to the RBackedUpWindow object, and allocates 
sl@0: a bitmap with which to perform the window backup.
sl@0: 
sl@0: Unlike non backed up windows, the size of a backed up window is not inherited 
sl@0: from its parent. The window will be created with an initial size of zero, 
sl@0: but this can be altered. The display mode must be specified because it determines 
sl@0: the amount of memory required to store the backup bitmap.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param parent The window's parent. 
sl@0: @param aDisplayMode The display mode for the window. 
sl@0: @param aClientHandle The client's handle for the window. See RWindow::Construct() 
sl@0: for a description of the client handle.
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, the 
sl@0: most likely of which is KErrNoMemory. 
sl@0: @see RWindowBase::SetSizeErr()
sl@0: @see RWindowBase::SetExtentErr() 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(construct(parent,aClientHandle,EWinBackedUp,aDisplayMode));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C TInt RBackedUpWindow::BitmapHandle() const
sl@0: /** Gets a handle to the backup bitmap. 
sl@0: 
sl@0: This handle can then be passed to CFbsBitmap::Duplicate() to gain access 
sl@0: to the bitmap. Once the bitmap has been obtained, it can be drawn to or read 
sl@0: from by the application.
sl@0: 
sl@0: Notes: in most circumstances this function should be used only after MaintainBackup() 
sl@0: has been called. Otherwise, the content of the backup bitmap will be unpredictable.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @return The handle of the backup bitmap. */
sl@0: 	{
sl@0: 	return(WriteReply(EWsWinOpBitmapHandle));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBackedUpWindow::UpdateScreen(const TRegion &aRegion)
sl@0: /** Copies a part of the backup bitmap to the on-screen bitmap. 
sl@0: 
sl@0: This function behaves in the same way as UpdateScreen(), but copies only the 
sl@0: specified region of the backup bitmap to the window on screen.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param aRegion Area of the backup bitmap to copy. */
sl@0: 	{
sl@0: 	const TInt regionCount=aRegion.Count();
sl@0: 	TPtrC8 ptrRect(reinterpret_cast<const TUint8*>(aRegion.RectangleList()),regionCount*sizeof(TRect));
sl@0: 	WriteReplyByProvidingRemoteReadAccess(&regionCount,sizeof(regionCount),&ptrRect,EWsWinOpUpdateScreenRegion);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBackedUpWindow::UpdateScreen()
sl@0: /** Copies the backup bitmap's image to the on-screen bitmap. 
sl@0: 
sl@0: This function should be used if the application draws directly to the backup 
sl@0: bitmap. Any changes made to the backup bitmap will not be reflected on the 
sl@0: screen until this function is called. */
sl@0: 	{
sl@0: 	Write(EWsWinOpUpdateScreen);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBackedUpWindow::UpdateBackupBitmap()
sl@0: /** Copies to the backup bitmap any areas of the window which are not currently 
sl@0: stored in the bitmap.
sl@0: 
sl@0: This method does not need to be called if the server has not been instructed 
sl@0: to maintain the backup buffer constantly
sl@0: 
sl@0: @see MaintainBackup() */
sl@0: 	{
sl@0: 	Write(EWsWinOpUpdateBackupBitmap);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBackedUpWindow::MaintainBackup()
sl@0: /** Tells the window server to start maintaining a backup bitmap with the entire 
sl@0: window contents. 
sl@0: 
sl@0: By default, the window only backs up the non-visible and shadowed part of the 
sl@0: window. Calling this function makes drawing to the window much faster.
sl@0: 
sl@0: Once this function has been called, it cannot be reversed. */
sl@0: 	{
sl@0: 	Write(EWsWinOpMaintainBackup);
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // Blank window
sl@0: //
sl@0: 
sl@0: EXPORT_C TInt RBlankWindow::Construct(const RWindowTreeNode &parent, TUint32 aClientHandle)
sl@0: /** Completes the construction of a valid blank-window handle. 
sl@0: 
sl@0: This function should be called after the RBlankWindow(RWsSession&) constructor, 
sl@0: and before any other functions are performed on the window. It creates a window 
sl@0: in the window server corresponding to the RBlankWindow object. The window 
sl@0: is initialised to inherit the size and extent of its parent window, or to be full 
sl@0: screen if its parent is a group window.
sl@0: 
sl@0: This function always causes a flush of the window server buffer.
sl@0: 
sl@0: @param parent The window's parent. 
sl@0: @param aClientHandle Client handle for the window. See RWindow::Construct() for a 
sl@0: description of the client handle. 
sl@0: @return KErrNone if successful, otherwise one of the system-wide error codes, 
sl@0: the most likely of which is KErrNoMemory.
sl@0: @see TWsEvent::Handle()
sl@0: @see TWsPriorityKeyEvent::Handle() 
sl@0: @see RWindow::Construct() */
sl@0: 	{
sl@0: 	return(construct(parent,aClientHandle,EWinBlank,ENone));
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBlankWindow::SetColor(TRgb aColor)
sl@0: /** Sets the colour of the blank window.
sl@0: 
sl@0: @param aColor Colour for the window. */
sl@0: 	{
sl@0: 	WriteInt(aColor.Internal(),EWsWinOpSetColor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBlankWindow::SetColor()
sl@0: /** Sets the background colour used for clearing when the window becomes uncovered 
sl@0: or visible to none. 
sl@0: 
sl@0: The window content will be left with whatever happened to be on the screen at the time. */
sl@0: 	{
sl@0: 	Write(EWsWinOpSetNoBackgroundColor);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBlankWindow::SetSize(const TSize &aSize)
sl@0: /** Sets the size of the blank window.
sl@0: 
sl@0: @param aSize Size. */
sl@0: 	{
sl@0: 	WriteSize(aSize,EWsWinOpSetSize);
sl@0: 	}
sl@0: 
sl@0: EXPORT_C void RBlankWindow::SetExtent(const TPoint &pos,const TSize &size)
sl@0: /** Sets the extent of the blank window.
sl@0: 
sl@0: @param pos The position of the window's origin, relative to its parent. 
sl@0: @param size Size for the window. */
sl@0: 	{
sl@0: 	Write(&pos,sizeof(pos),&size,sizeof(size),EWsWinOpSetExtent);
sl@0: 	}