os/graphics/windowing/windowserver/nonnga/SERVER/WINBASE.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Window virtual base class, windows and window groups are derived from this
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <e32std.h>
sl@0
    19
#include "server.h"
sl@0
    20
#include "winbase.h"
sl@0
    21
#include "rootwin.h"
sl@0
    22
#include "windowgroup.h"
sl@0
    23
#include "walkwindowtree.h"
sl@0
    24
#include "wstop.h"
sl@0
    25
#include "EVQUEUE.H"
sl@0
    26
#include "EVENT.H"
sl@0
    27
#include "panics.h"
sl@0
    28
#include "pointer.h"
sl@0
    29
sl@0
    30
CWsWindowBase::CWsWindowBase(CWsClient* aOwner,WH_HANDLES aType, CScreen* aScreen) : CWsScreenObject(aOwner,aType,aScreen)		
sl@0
    31
	{
sl@0
    32
	}
sl@0
    33
sl@0
    34
void CWsWindowBase::ConstructL(CWsWindowBase *parent)
sl@0
    35
	{
sl@0
    36
	iParent=parent;
sl@0
    37
	iSibling=parent->iChild;
sl@0
    38
	parent->iChild=this;
sl@0
    39
	SetOrdinalPosition(0);
sl@0
    40
	iFadeCount = iParent->iFadeCount;
sl@0
    41
	}
sl@0
    42
sl@0
    43
CWsWindowBase *CWsWindowBase::GetPrevSibling() const
sl@0
    44
	{
sl@0
    45
	CWsWindowBase **prev= &iParent->iChild;
sl@0
    46
	CWsWindowBase *ret=NULL;
sl@0
    47
	while ((*prev)!=this)
sl@0
    48
		{
sl@0
    49
		ret=*prev;
sl@0
    50
		prev= &(*prev)->iSibling;
sl@0
    51
		}
sl@0
    52
	return(ret);
sl@0
    53
	}
sl@0
    54
sl@0
    55
CWsWindowBase *CWsWindowBase::LastSibling() const
sl@0
    56
	{
sl@0
    57
	const CWsWindowBase *win;
sl@0
    58
	for(win=this;win->iSibling;win=win->iSibling)
sl@0
    59
		{}
sl@0
    60
	return (CWsWindowBase*)win;
sl@0
    61
	}
sl@0
    62
sl@0
    63
CWsWindowBase *CWsWindowBase::PrevSiblingMultiParent() const
sl@0
    64
	{
sl@0
    65
	CWsWindowBase *win=GetPrevSibling();
sl@0
    66
	if (win)
sl@0
    67
		return(win);
sl@0
    68
	for(CWsWindowBase *parent=iParent->GetPrevSibling();parent;parent=parent->GetPrevSibling())
sl@0
    69
		if ((win=parent->iChild)!=NULL)
sl@0
    70
			return(win->LastSibling());
sl@0
    71
	return(NULL);
sl@0
    72
	}
sl@0
    73
sl@0
    74
// Andy - this is a kind of "next cousin" function
sl@0
    75
CWsWindowBase *CWsWindowBase::NextSiblingMultiParent() const
sl@0
    76
	{
sl@0
    77
	if (iSibling)
sl@0
    78
		return(iSibling);
sl@0
    79
	for(CWsWindowBase *parent=iParent->iSibling;parent;parent=parent->iSibling)
sl@0
    80
		{
sl@0
    81
		if (parent->iChild!=NULL)
sl@0
    82
			return(parent->iChild);
sl@0
    83
		}
sl@0
    84
	return(NULL);
sl@0
    85
	}
sl@0
    86
sl@0
    87
TInt CWsWindowBase::OrdinalPosition(TBool aFull) const
sl@0
    88
	{
sl@0
    89
	if (!iParent)
sl@0
    90
		{
sl@0
    91
		OwnerPanic(EWservPanicParentDeleted);
sl@0
    92
		}
sl@0
    93
	CWsWindowBase *win=iParent->iChild;
sl@0
    94
	if (!aFull)
sl@0
    95
		while(iOrdinalPriority<win->iOrdinalPriority)
sl@0
    96
			win=win->iSibling;
sl@0
    97
	TInt count;
sl@0
    98
	for(count=0;win!=this;count++)
sl@0
    99
		win=win->iSibling;
sl@0
   100
	return(count);
sl@0
   101
	}
sl@0
   102
sl@0
   103
/** Removes a window from the list of siblings maintained by its parent window.
sl@0
   104
sl@0
   105
The iSibling stored inside the window we remove is kept unchanged as it may be needed later.
sl@0
   106
sl@0
   107
@internalComponent
sl@0
   108
@released
sl@0
   109
*/
sl@0
   110
void CWsWindowBase::RemoveFromSiblingList()
sl@0
   111
	{
sl@0
   112
	if (iParent!=NULL)
sl@0
   113
		{
sl@0
   114
		CWsWindowBase **prev= &iParent->iChild;
sl@0
   115
		while ((*prev)!=this)
sl@0
   116
			prev= &(*prev)->iSibling;
sl@0
   117
		*prev=iSibling;
sl@0
   118
		}
sl@0
   119
	}
sl@0
   120
sl@0
   121
/* This const casts in this function are horrible and need revisiting. */
sl@0
   122
CWsWindowGroup *CWsWindowBase::WinGroup() const
sl@0
   123
	{
sl@0
   124
	switch (iWinType)
sl@0
   125
		{
sl@0
   126
		case EWinTypeClient:
sl@0
   127
			{
sl@0
   128
			if (iParent)
sl@0
   129
				{
sl@0
   130
				CWsWindowBase* win = const_cast<CWsWindowBase*>(this);
sl@0
   131
				while(win->WinType()!=EWinTypeGroup)
sl@0
   132
					win=win->BaseParent();
sl@0
   133
				return static_cast<CWsWindowGroup*>(win);
sl@0
   134
				}
sl@0
   135
			return 0;
sl@0
   136
			}
sl@0
   137
		case EWinTypeGroup:
sl@0
   138
			return const_cast<CWsWindowGroup*>(static_cast<const CWsWindowGroup*>(this));
sl@0
   139
		default:
sl@0
   140
			return 0;
sl@0
   141
		}
sl@0
   142
	}
sl@0
   143
sl@0
   144
TBool CWsWindowBase::CheckOrdinalPositionChange(TInt aPos)
sl@0
   145
//
sl@0
   146
// This routine checks to see whether the specified new ordinal position
sl@0
   147
// will causes a change, if so returns ETrue else EFalse.
sl@0
   148
//
sl@0
   149
	{
sl@0
   150
	if (!iParent)
sl@0
   151
		{
sl@0
   152
		OwnerPanic(EWservPanicParentDeleted);
sl@0
   153
		}
sl@0
   154
	CWsWindowBase *win= iParent->iChild;
sl@0
   155
	CWsWindowBase *prev= NULL;
sl@0
   156
	while(win==this || (win!=NULL && iOrdinalPriority<win->iOrdinalPriority))
sl@0
   157
		{
sl@0
   158
		prev=win;
sl@0
   159
		win=win->iSibling;
sl@0
   160
		}
sl@0
   161
	if (prev==this)
sl@0
   162
		win=this;
sl@0
   163
	else if (win==NULL || (win->iSibling==this && iOrdinalPriority>win->iOrdinalPriority))
sl@0
   164
		return ETrue;
sl@0
   165
	while(aPos--!=0 && win->iSibling!=NULL && iOrdinalPriority==win->iSibling->iOrdinalPriority)
sl@0
   166
		win=win->iSibling;
sl@0
   167
	return(win!=this);
sl@0
   168
	}
sl@0
   169
sl@0
   170
void CWsWindowBase::ChangeWindowPosition(TInt aPos,CWsWindowBase* aNewParent)
sl@0
   171
	{
sl@0
   172
	if (aNewParent != iParent)
sl@0
   173
		{
sl@0
   174
		iScreen->ScheduleRegionUpdate(NULL);		
sl@0
   175
		TWalkWindowTreeScheduleRedraws wwt;
sl@0
   176
		WalkWindowTree(wwt, EWalkChildren);
sl@0
   177
		}
sl@0
   178
	else if (WinType() == EWinTypeClient)
sl@0
   179
		{
sl@0
   180
		CWsClientWindow * cliwin = static_cast<CWsClientWindow*>(this);
sl@0
   181
		if (cliwin->IsVisible())
sl@0
   182
			{
sl@0
   183
			iScreen->ScheduleRegionUpdate(NULL);
sl@0
   184
			if (cliwin->IsTranslucent())
sl@0
   185
				{
sl@0
   186
				// There is still room for optimization here.  These redraws are only required if the window
sl@0
   187
				// moved through another window and BOTH of them were transparent, otherwise the visible
sl@0
   188
				// region change will sort out the redraws required.
sl@0
   189
				TWalkWindowTreeScheduleRedraws wwt;
sl@0
   190
				WalkWindowTree(wwt, EWalkChildren);
sl@0
   191
				}
sl@0
   192
			}
sl@0
   193
		}
sl@0
   194
	else if (WinType() == EWinTypeGroup)
sl@0
   195
		{
sl@0
   196
		iScreen->ScheduleRegionUpdate(NULL);
sl@0
   197
		if (static_cast<CWsWindowGroup*>(this)->HasVisibleTranslucentChild())
sl@0
   198
			{
sl@0
   199
			TWalkWindowTreeScheduleRedraws wwt;
sl@0
   200
			WalkWindowTree(wwt, EWalkChildren);				
sl@0
   201
			}
sl@0
   202
		}
sl@0
   203
sl@0
   204
	RemoveFromSiblingList();
sl@0
   205
	CWsWindowBase **prevWinPtr= &aNewParent->iChild;
sl@0
   206
	while((*prevWinPtr)!=NULL && iOrdinalPriority<(*prevWinPtr)->iOrdinalPriority)
sl@0
   207
		{
sl@0
   208
		prevWinPtr= &(*prevWinPtr)->iSibling;
sl@0
   209
		}
sl@0
   210
	while(aPos--!=0 && *prevWinPtr!=NULL && iOrdinalPriority==(*prevWinPtr)->iOrdinalPriority)
sl@0
   211
		{
sl@0
   212
		prevWinPtr= &(*prevWinPtr)->iSibling;
sl@0
   213
		}
sl@0
   214
	iSibling=*prevWinPtr;
sl@0
   215
	iParent=aNewParent;
sl@0
   216
	*prevWinPtr=this;
sl@0
   217
	}
sl@0
   218
sl@0
   219
void CWsWindowBase::SetOrdinalPosition(TInt aPos)
sl@0
   220
	{
sl@0
   221
	if (CheckOrdinalPositionChange(aPos))
sl@0
   222
		ChangeWindowPosition(aPos,iParent);
sl@0
   223
	}
sl@0
   224
sl@0
   225
TEventQueueWalkRet EventPurgeFunc(TAny *aPtr, TWsEvent *aEvent)
sl@0
   226
//
sl@0
   227
// Callback function for event queue walk
sl@0
   228
//
sl@0
   229
	{
sl@0
   230
	return(((CWsWindowBase *)aPtr)->EventPurgeCheck(aEvent));
sl@0
   231
	}
sl@0
   232
sl@0
   233
TEventQueueWalkRet CWsWindowBase::EventPurgeCheck(TWsEvent *aEvent)
sl@0
   234
	{
sl@0
   235
	if (aEvent->Handle()==ClientHandle())
sl@0
   236
		return(EEventQueueWalkDeleteEvent);
sl@0
   237
	return(EEventQueueWalkOk);
sl@0
   238
	}
sl@0
   239
sl@0
   240
void CWsWindowBase::PurgeEvents()
sl@0
   241
	{
sl@0
   242
	iWsOwner->EventQueue()->WalkEventQueue(&EventPurgeFunc,this);
sl@0
   243
	}
sl@0
   244
sl@0
   245
void CWsWindowBase::Shutdown()
sl@0
   246
//
sl@0
   247
// Destroy a window, disconnects from the window tree and destroys all it's child windows
sl@0
   248
//
sl@0
   249
	{
sl@0
   250
	if (iWsOwner!=NULL)
sl@0
   251
		PurgeEvents();
sl@0
   252
	if (iParent!=NULL)	// Check it's connected to something
sl@0
   253
		{
sl@0
   254
		CWsWindowBase *win;
sl@0
   255
		for(win=this;win && win->iParent!=(CWsWindowBase *)RootWindow();win=win->iParent)
sl@0
   256
			{}
sl@0
   257
		RemoveFromSiblingList();
sl@0
   258
		TWalkWindowTreeDisconnect wwt2(win ? ((CWsWindowGroup *)win)->TextCursor() : NULL);
sl@0
   259
		WalkWindowTree(wwt2,EWalkChildren); // Disconnect all child windows
sl@0
   260
		iChild=NULL;
sl@0
   261
		}
sl@0
   262
	TWindowServerEvent::RemoveFromSwitchOnEventList(*this);
sl@0
   263
	TWindowServerEvent::RemoveFromErrorMessageList(*this);
sl@0
   264
	TWindowServerEvent::RemoveFromGroupChangeEventEventList(*this);
sl@0
   265
	TWindowServerEvent::RemoveFromFocusChangeEventEventList(*this);
sl@0
   266
	TWindowServerEvent::RemoveFromGroupListChangeEventEventList(*this);
sl@0
   267
	TWindowServerEvent::RemoveFromModifierChangedEventList(*this);
sl@0
   268
	TWindowServerEvent::RemoveFromScreenDeviceChangeEventList(*this);
sl@0
   269
	CWsTop::StopWindowGettingOffEvents(this);
sl@0
   270
	}
sl@0
   271
sl@0
   272
TBool CWsWindowBase::CommandL(TInt aOpcode, TWsWinCmdUnion &aCmd)
sl@0
   273
//
sl@0
   274
// If the command is supported by the window base class process it and return ETrue
sl@0
   275
// if it is not supported return EFalse
sl@0
   276
//
sl@0
   277
	{
sl@0
   278
	switch(aOpcode)
sl@0
   279
		{
sl@0
   280
		case EWsWinOpFree:
sl@0
   281
			delete this;
sl@0
   282
			break;
sl@0
   283
		case EWsWinOpSetOrdinalPosition:
sl@0
   284
			SetOrdinalPosition(*aCmd.Int);
sl@0
   285
			break;
sl@0
   286
		case EWsWinOpOrdinalPriority:
sl@0
   287
			SetReply(iOrdinalPriority);
sl@0
   288
			break;
sl@0
   289
		case EWsWinOpOrdinalPosition:
sl@0
   290
			SetReply(OrdinalPosition(EFalse));
sl@0
   291
			break;
sl@0
   292
		case EWsWinOpFullOrdinalPosition:
sl@0
   293
			SetReply(OrdinalPosition(ETrue));
sl@0
   294
			break;
sl@0
   295
		case EWsWinOpClientHandle:
sl@0
   296
			SetReply(iClientHandle);
sl@0
   297
			break;
sl@0
   298
		case EWsWinOpParent:
sl@0
   299
			if (!iParent)
sl@0
   300
				{
sl@0
   301
				OwnerPanic(EWservPanicParentDeleted);
sl@0
   302
				}
sl@0
   303
			SetReply(iParent->iClientHandle);
sl@0
   304
			break;
sl@0
   305
		case EWsWinOpPrevSibling:
sl@0
   306
			{
sl@0
   307
			if (!iParent)
sl@0
   308
				{
sl@0
   309
				OwnerPanic(EWservPanicParentDeleted);
sl@0
   310
				}
sl@0
   311
			TUint32 reply=NULL;
sl@0
   312
			for(CWsWindowBase *win=this->GetPrevSibling();win;win=win->GetPrevSibling())
sl@0
   313
				{
sl@0
   314
				if (win->iWsOwner==iWsOwner)
sl@0
   315
					{
sl@0
   316
					reply=win->iClientHandle;
sl@0
   317
					break;
sl@0
   318
					}
sl@0
   319
				}
sl@0
   320
			SetReply(reply);
sl@0
   321
			}
sl@0
   322
			break;
sl@0
   323
		case EWsWinOpNextSibling:
sl@0
   324
			{
sl@0
   325
			TUint32 reply=NULL;
sl@0
   326
			for(CWsWindowBase *win=this->iSibling;win;win=win->iSibling)
sl@0
   327
				{
sl@0
   328
				if (win->iWsOwner==iWsOwner)
sl@0
   329
					{
sl@0
   330
					reply=win->iClientHandle;
sl@0
   331
					break;
sl@0
   332
					}
sl@0
   333
				}
sl@0
   334
			SetReply(reply);
sl@0
   335
			}
sl@0
   336
			break;
sl@0
   337
		case EWsWinOpChild:
sl@0
   338
			SetReply(iChild==NULL ? NULL : iChild->iClientHandle);
sl@0
   339
			break;
sl@0
   340
		case EWsWinOpScreenNumber:
sl@0
   341
			SetReply(Screen()->ScreenNumber());
sl@0
   342
			break;
sl@0
   343
		case EWsWinOpWindowGroupId:
sl@0
   344
			if (!WinGroup())
sl@0
   345
				{
sl@0
   346
				OwnerPanic(EWservPanicParentDeleted);
sl@0
   347
				}
sl@0
   348
			SetReply(WinGroup()->Identifier());
sl@0
   349
			break;
sl@0
   350
		case EWsWinOpEnableOnEvents:
sl@0
   351
			TWindowServerEvent::AddToSwitchOnEventListL(*this, *aCmd.EventControl);
sl@0
   352
			break;
sl@0
   353
		case EWsWinOpDisableOnEvents:
sl@0
   354
			TWindowServerEvent::RemoveFromSwitchOnEventList(*this);
sl@0
   355
			break;
sl@0
   356
		case EWsWinOpEnableErrorMessages:
sl@0
   357
			TWindowServerEvent::AddToErrorMessageListL(*this, *aCmd.EventControl);
sl@0
   358
			break;
sl@0
   359
		case EWsWinOpDisableErrorMessages:
sl@0
   360
			TWindowServerEvent::RemoveFromErrorMessageList(*this);
sl@0
   361
			break;
sl@0
   362
		case EWsWinOpEnableModifierChangedEvents:
sl@0
   363
			TWindowServerEvent::AddToModifierChangedEventListL(*this, aCmd.EnableModifierChangedEvents->modifierMask,
sl@0
   364
														aCmd.EnableModifierChangedEvents->circumstances);
sl@0
   365
			break;
sl@0
   366
		case EWsWinOpDisableModifierChangedEvents:
sl@0
   367
			TWindowServerEvent::RemoveFromModifierChangedEventList(*this);
sl@0
   368
			break;
sl@0
   369
		case EWsWinOpEnableGroupChangeEvents:
sl@0
   370
			TWindowServerEvent::AddToGroupChangeEventListL(*this);
sl@0
   371
			break;
sl@0
   372
		case EWsWinOpDisableGroupChangeEvents:
sl@0
   373
			TWindowServerEvent::RemoveFromGroupChangeEventEventList(*this);
sl@0
   374
			break;
sl@0
   375
		case EWsWinOpEnableFocusChangeEvents:
sl@0
   376
			TWindowServerEvent::AddToFocusChangeEventListL(*this);
sl@0
   377
			break;
sl@0
   378
		case EWsWinOpDisableFocusChangeEvents:
sl@0
   379
			TWindowServerEvent::RemoveFromFocusChangeEventEventList(*this);
sl@0
   380
			break;
sl@0
   381
		case EWsWinOpEnableGroupListChangeEvents:
sl@0
   382
			TWindowServerEvent::AddToGroupListChangeEventListL(*this);
sl@0
   383
			break;
sl@0
   384
		case EWsWinOpDisableGroupListChangeEvents:
sl@0
   385
			TWindowServerEvent::RemoveFromGroupListChangeEventEventList(*this);
sl@0
   386
			break;
sl@0
   387
		case EWsWinOpSetCustomPointerCursor:
sl@0
   388
			CWsObject *pointercursor;
sl@0
   389
			if ((pointercursor=iWsOwner->HandleToObj(*aCmd.Int, WS_HANDLE_POINTER_CURSOR))==NULL)
sl@0
   390
				OwnerPanic(EWservPanicSprite);
sl@0
   391
			SetPointerCursor((CWsPointerCursor *)pointercursor);
sl@0
   392
			break;
sl@0
   393
		case EWsWinOpSetPointerCursor:
sl@0
   394
			SetPointerCursorByIndex(*aCmd.UInt);
sl@0
   395
			break;
sl@0
   396
		case EWsWinOpClearPointerCursor:
sl@0
   397
			SetPointerCursor(NULL);
sl@0
   398
			break;
sl@0
   399
		case EWsWinOpSetNonFading:
sl@0
   400
			{
sl@0
   401
			WS_ASSERT_DEBUG(iScreen, EWsPanicNoScreen);
sl@0
   402
			// No fading will occur from a graphical perspective, but the fade counts
sl@0
   403
			// are maintained for BC reasons.
sl@0
   404
			TWalkWindowTreeSetNonFading wwt(*aCmd.Bool);
sl@0
   405
			WalkWindowTree(wwt,EWalkChildren);
sl@0
   406
			Screen()->AcceptFadeRequest( reinterpret_cast<CWsWindow*>(this), 
sl@0
   407
														 ETrue, 
sl@0
   408
														 EFalse, 
sl@0
   409
														 ETrue );
sl@0
   410
			}
sl@0
   411
			break;
sl@0
   412
		case EWsWinOpSetFade:
sl@0
   413
			{
sl@0
   414
			if (!iParent)
sl@0
   415
				{
sl@0
   416
				OwnerPanic(EWservPanicParentDeleted);
sl@0
   417
				}
sl@0
   418
			WS_ASSERT_DEBUG(iScreen, EWsPanicNoScreen);
sl@0
   419
			
sl@0
   420
			TUint8 blackMap;
sl@0
   421
			TUint8 whiteMap;
sl@0
   422
			if (aCmd.SetFaded->UseDefaultMap())
sl@0
   423
				{
sl@0
   424
				iScreen->GetFadingParams(blackMap,whiteMap);
sl@0
   425
				}
sl@0
   426
			else
sl@0
   427
				{
sl@0
   428
				aCmd.SetFaded->GetFadingParams(blackMap,whiteMap);
sl@0
   429
				}
sl@0
   430
	
sl@0
   431
			if (aCmd.SetFaded->IncludeChildren())
sl@0
   432
				{
sl@0
   433
				TWalkWindowTreeSetFaded wwt(aCmd.SetFaded->Faded(),this,blackMap,whiteMap);
sl@0
   434
				WalkWindowTree(wwt,EWalkChildren);
sl@0
   435
				}
sl@0
   436
			else
sl@0
   437
				{
sl@0
   438
				if (iWinType==EWinTypeGroup)
sl@0
   439
					OwnerPanic(EWservPanicOpcode);
sl@0
   440
				static_cast<CWsClientWindow*>(this)->SetFaded(aCmd.SetFaded->Faded(),blackMap,whiteMap); 
sl@0
   441
				}
sl@0
   442
sl@0
   443
			if (CWsTop::IsFadeEnabled()) 
sl@0
   444
				{
sl@0
   445
				Screen()->AcceptFadeRequest( reinterpret_cast<CWsWindow *> (this), 
sl@0
   446
											 aCmd.SetFaded->Faded(), 
sl@0
   447
											 EFalse, 
sl@0
   448
											 aCmd.SetFaded->IncludeChildren() );
sl@0
   449
				}
sl@0
   450
			}
sl@0
   451
			break;
sl@0
   452
		default:
sl@0
   453
			return(EFalse);
sl@0
   454
		}
sl@0
   455
	return(ETrue);
sl@0
   456
	}
sl@0
   457
sl@0
   458
TBool CWsWindowBase::QueueEvent(TInt aEvent) const
sl@0
   459
	{
sl@0
   460
	if (WsOwner())
sl@0
   461
		return(WsOwner()->EventQueue()->QueueEvent(iClientHandle, aEvent));
sl@0
   462
	return(EFalse);
sl@0
   463
	}
sl@0
   464
sl@0
   465
void CWsWindowBase::SetPointerCursorByIndex(TInt aIndex)
sl@0
   466
	{
sl@0
   467
	SetPointerCursor(CWsClient::SystemPointerCursor(aIndex));
sl@0
   468
	}
sl@0
   469
sl@0
   470
void CWsWindowBase::SetPointerCursor(CWsPointerCursor *aCursor)
sl@0
   471
	{
sl@0
   472
	CWsPointerCursor *old=iPointerCursor;
sl@0
   473
	iPointerCursor=aCursor;
sl@0
   474
	if (iPointerCursor)
sl@0
   475
		iPointerCursor->Open();
sl@0
   476
	WsPointer::UpdatePointerCursor();
sl@0
   477
	if (old)
sl@0
   478
		old->Close();
sl@0
   479
	}
sl@0
   480
sl@0
   481
TBool CWsWindowBase::TreeIsObscured() const
sl@0
   482
	{
sl@0
   483
	TBool result;
sl@0
   484
	TWalkWindowTreeIsObscured wwt(result);
sl@0
   485
	CONST_CAST(CWsWindowBase *,this)->WalkWindowTree(wwt,EWalkChildren);
sl@0
   486
	return(result);
sl@0
   487
	}
sl@0
   488
sl@0
   489
CEventQueue *CWsWindowBase::EventQueue() const
sl@0
   490
	{
sl@0
   491
	return(iWsOwner->EventQueue());
sl@0
   492
	}
sl@0
   493
sl@0
   494
void CWsWindowBase::WalkWindowTree(TWalkWindowTreeBase &aWalkClass,TWalkMode aMode)
sl@0
   495
//
sl@0
   496
// Walks windows in a front to back order
sl@0
   497
//
sl@0
   498
// If mode is EWalkBehind
sl@0
   499
//	call DoIt for all windows that are behind 'this'
sl@0
   500
// else if mode is EWalkChildren
sl@0
   501
//  call DoIt for all descendents
sl@0
   502
// else if mode is EWalkChildrenAndBehind
sl@0
   503
//  call DoIt for for all descendents and windows behind
sl@0
   504
//
sl@0
   505
	{
sl@0
   506
	if (this!=NULL)
sl@0
   507
		{
sl@0
   508
		CWsWindowBase *win=this;
sl@0
   509
		CWsWindowBase *end=RootWindow();
sl@0
   510
		CWsWindowBase *sibling=win->iSibling;
sl@0
   511
		CWsWindowBase *parent=win->iParent;
sl@0
   512
		if (aMode!=EWalkBehind)
sl@0
   513
			{
sl@0
   514
			if (aMode==EWalkChildren)
sl@0
   515
				end=win;
sl@0
   516
			goto start;
sl@0
   517
			}
sl@0
   518
		do
sl@0
   519
			{
sl@0
   520
			if (sibling!=NULL)
sl@0
   521
				{
sl@0
   522
				win=sibling;
sl@0
   523
start:			while(win->iChild!=NULL)
sl@0
   524
					win=win->iChild;
sl@0
   525
				}
sl@0
   526
			else
sl@0
   527
				win=parent;
sl@0
   528
			sibling=win->iSibling;	// De-reference win so it can be destroyed by 'DoIt'
sl@0
   529
			parent=win->iParent;
sl@0
   530
			if (win->iWinType!=EWinTypeGroup && aWalkClass.DoIt((CWsWindow *)win))
sl@0
   531
				return;
sl@0
   532
			} while(win!=end);
sl@0
   533
		}
sl@0
   534
	}
sl@0
   535
sl@0
   536
/* Walks windows in a front to back order
sl@0
   537
sl@0
   538
 If aResume is EFalse the walk is identical to above.
sl@0
   539
 Otherwise iWin is taken as the restart point, (any child windows will have been
sl@0
   540
 walked previously).
sl@0
   541
 */
sl@0
   542
void CWsWindowBase::WalkWindowTree(TResumableWalkWindowTreeBase& aWalkClass, TWalkMode aMode, TBool aResume)
sl@0
   543
	{
sl@0
   544
	if (this != NULL)
sl@0
   545
		{ // init
sl@0
   546
		if (!aResume)
sl@0
   547
			{
sl@0
   548
			aWalkClass.iWin = this;
sl@0
   549
			aWalkClass.iEnd = (aMode == EWalkChildren) ? this : RootWindow();
sl@0
   550
			aWalkClass.iParent = aWalkClass.iWin->iParent;
sl@0
   551
			if (aMode == EWalkBehind)
sl@0
   552
				{
sl@0
   553
				aWalkClass.iNextChild = aWalkClass.iWin->iSibling;
sl@0
   554
				}
sl@0
   555
			else
sl@0
   556
				{ // ensure walk includes this and its child windows
sl@0
   557
				aWalkClass.iNextChild = this;
sl@0
   558
				}
sl@0
   559
			}
sl@0
   560
		else if (aWalkClass.iWin == aWalkClass.iEnd)
sl@0
   561
			{
sl@0
   562
			return; // walk had already reached end
sl@0
   563
			}
sl@0
   564
sl@0
   565
		do
sl@0
   566
			{
sl@0
   567
			if (aWalkClass.iNextChild != NULL)
sl@0
   568
				{ // walk down tree to a leaf window
sl@0
   569
				aWalkClass.iWin = aWalkClass.iNextChild;
sl@0
   570
				while (aWalkClass.iWin->iChild != NULL)
sl@0
   571
					{
sl@0
   572
					aWalkClass.iWin = aWalkClass.iWin->iChild;
sl@0
   573
					}
sl@0
   574
				}
sl@0
   575
			else
sl@0
   576
				{ // walk up tree
sl@0
   577
				aWalkClass.iWin = aWalkClass.iParent;
sl@0
   578
				}
sl@0
   579
			// De-reference iWin so it can be destroyed by 'DoIt'
sl@0
   580
			aWalkClass.iNextChild = aWalkClass.iWin->iSibling;
sl@0
   581
			aWalkClass.iParent = aWalkClass.iWin->iParent;
sl@0
   582
			if ( ( aWalkClass.iWin->iWinType != EWinTypeGroup ) && aWalkClass.DoIt(static_cast<CWsWindow *>(aWalkClass.iWin)) )
sl@0
   583
				{
sl@0
   584
				return;
sl@0
   585
				}
sl@0
   586
			}
sl@0
   587
		while (aWalkClass.iWin != aWalkClass.iEnd);
sl@0
   588
		}
sl@0
   589
	}
sl@0
   590
sl@0
   591
#if defined(_DEBUG)
sl@0
   592
sl@0
   593
void CWsWindowBase::CheckTree()
sl@0
   594
	{
sl@0
   595
	TWalkWindowTreeCheck wwt1;
sl@0
   596
	WalkWindowTree(wwt1,EWalkChildren);
sl@0
   597
	}
sl@0
   598
sl@0
   599
enum {ENullWsHandle=0xFFFFFFFF};	// Events delivered to this handle are thrown away
sl@0
   600
TBool CWsWindowBase::IsClientHandleInUse(TUint32 aHandle)
sl@0
   601
	{
sl@0
   602
	if (aHandle==static_cast<TUint>(ENullWsHandle))		//This value has a special meaning in test code
sl@0
   603
		return EFalse;
sl@0
   604
	CWsObjectIx* index=iWsOwner->ObjectIndex();
sl@0
   605
	const CWsObject* obj;
sl@0
   606
	TInt length=index->Length();
sl@0
   607
	TInt ii;
sl@0
   608
	for (ii=0;ii<length;++ii)
sl@0
   609
		{
sl@0
   610
		obj=index->At(ii);
sl@0
   611
		if (obj && (obj->Type()==WS_HANDLE_WINDOW || obj->Type()==WS_HANDLE_GROUP_WINDOW))
sl@0
   612
			{
sl@0
   613
			if (STATIC_CAST(const CWsWindowBase*,obj)->ClientHandle()==aHandle)
sl@0
   614
				return ETrue;
sl@0
   615
			}
sl@0
   616
		}
sl@0
   617
	return EFalse;
sl@0
   618
	}
sl@0
   619
sl@0
   620
#endif
sl@0
   621
sl@0
   622
TBool CWsWindowBase::IsDSAHost() const
sl@0
   623
	{
sl@0
   624
	return EFalse;
sl@0
   625
	}
sl@0
   626