⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 en_main.cpp

📁 在手机操作系统symbina上使用的一个脚本扩展语言的代码实现,可以参考用于自己的开发
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		}
	if (iMenuTitleArray)
		{
		const TInt count=iMenuTitleArray->Count();
		for (TInt ii=0;ii<count;++ii)
			{
			SOplMenuData& menuData=(*iMenuTitleArray)[ii];
			delete menuData.iBitmap[0];
			delete menuData.iBitmap[1];
			}
		delete iMenuTitleArray;
		iMenuTitleArray = NULL;
		}
	if (iMenuItemsArray)
		{
		iMenuItemsArray->ResetAndDestroy();
		delete iMenuItemsArray;
		iMenuItemsArray = NULL;
		}
	iMenuInitPtr = NULL;
	}

const TInt KMenuDimmed=0x1000;
const TInt KMenuSymbolOn=0x2000;
const TInt KMenuSymbolIndeterminate=0x4000;
const TInt KMenuCheckBox=0x0800;
const TInt KMenuRadioStart=0x0900;
const TInt KMenuRadioMiddle=0x0A00;
const TInt KMenuRadioEnd=0x0B00;
const TInt KMenuRadioMask=KMenuRadioEnd;
const TInt KMenuProfile=0x8000; // Used internally by OPLR only.
const TInt KMenuIrListener=0x9000; 	// Defined here for reference only: used in AppFrame OPX
									// as dummy for CIrListenAppUi::NewL() method.
const TInt KMenuFlagsMask=KMenuRadioMask|KMenuCheckBox|KMenuSymbolIndeterminate|KMenuSymbolOn|KMenuDimmed|KMenuProfile;

_LIT(KDummyMenuItem," ");

void COplRuntime::PrepareForMenuL()
	{
	iOplMenuBar = new(ELeave) COplMenuBar;
	iOplMenuBar->ConstructL(this,0,KMenuBarId);

	// Now add the TaskList and Profile items, in reverse order.
#if !defined(__SERIES60__)
	// Add dummy menu item. This also ensures iMenuItemsArray is populated.
#if !defined(__UIQ__)
	AddMenuItemL(&KDummyMenuItem,KMenuProfile);
#else
	if (!iMenuItemsArray)
		iMenuItemsArray = new(ELeave) CArrayPtrSeg<CEikMenuPaneItem>(1); 
#endif
	// Add the task menu pane.
	if (!iMenuTitleArray)
		iMenuTitleArray = new(ELeave) CArrayFixFlat<SOplMenuData> (16); // in line with UIKON
	SOplMenuData data;
	data.iOffsetIntoItemsArray=iMenuItemsArray->Count();
	data.iMenuTitleData.iMenuPaneResourceId=iMenuTitleArray->Count()+KMenuPaneIdOffset;
	data.iIsCascade=EFalse;
#if !defined(__UIQ__)
	_LIT(KCKONBitmap,"z:\\System\\Data\\ckon.mbm");
	data.iBitmap[0]=iEikonEnv->CreateBitmapL(KCKONBitmap, EMbmCkonTasklist);
	data.iBitmap[1]=iEikonEnv->CreateBitmapL(KCKONBitmap, EMbmCkonTasklism);
#else
	data.iBitmap[0]=NULL;
	data.iBitmap[1]=NULL;
#endif
	iMenuTitleArray->AppendL(data);
#endif
	}

#if !defined(__SERIES60__)
/** Support licensee-specific dynamic menu plugins.
 *
 */
void COplRuntime::AddProfileMenuPaneL()
	{
	__ASSERT_DEBUG(iOplMenuBar,User::Invariant());

	// Add dummy menu item
	AddMenuItemL(&KDummyMenuItem,KMenuProfile);

	// Add the profile menu pane.
	__ASSERT_DEBUG(iMenuTitleArray,User::Invariant());

	SOplMenuData data;
	data.iOffsetIntoItemsArray=iMenuItemsArray->Count();
	data.iMenuTitleData.iMenuPaneResourceId=KMenuPaneIdOffset;
	data.iIsCascade=EFalse;
	_LIT(KProfileBitmap,"z:\\System\\Data\\ProfileAutoMenu.mbm");
	data.iBitmap[0]=iEikonEnv->CreateBitmapL(KProfileBitmap,0);
	data.iBitmap[1]=iEikonEnv->CreateBitmapL(KProfileBitmap,1);
	iMenuTitleArray->AppendL(data);
	}
#else
void COplRuntime::AddProfileMenuPaneL() {}
#endif

/*
 * CascadeId(). Return the id of the menu pane whose text matches the parameter,
 * or zero if not found.
 */
TInt COplRuntime::CascadeId(const TDesC& aMatchItemText)
	{
	_LIT(KCascChar,">");
	if (iMenuTitleArray && aMatchItemText.Right(1)==KCascChar) // Can't be a cascade if no titles yet
		{
		const TInt count=iMenuTitleArray->Count();
		for(TInt index=0;index<count; index++)
			{
			SOplMenuData& oplData=(*iMenuTitleArray)[index];
			if (oplData.iIsCascade && oplData.iMenuTitleData.iText==aMatchItemText)
				return index+KMenuPaneIdOffset;
			}
		}
	return 0;
	}

void COplRuntime::AddMenuTitleL(const TDesC* aTitleText,TBool aIsCasc)
	{
	if (!iOplMenuBar) // mInit not called
		User::Leave(KOplStructure);
	if (!iMenuTitleArray)
		iMenuTitleArray = new(ELeave) CArrayFixFlat<SOplMenuData> (16); // in line with UIKON
	SOplMenuData data;
	data.iOffsetIntoItemsArray = iMenuItemsArray->Count();
	data.iMenuTitleData.iText = *aTitleText;
	data.iMenuTitleData.iMenuPaneResourceId = iMenuTitleArray->Count()+KMenuPaneIdOffset;
	data.iIsCascade=aIsCasc;
	data.iBitmap[0]=NULL;
	data.iBitmap[1]=NULL;
	iMenuTitleArray->AppendL(data);
	}

void COplRuntime::AddMenuBitmapL(CFbsBitmap* aBitmap,CFbsBitmap* aMask)
	{
	if (!iOplMenuBar) // mInit not called
		User::Leave(KOplStructure);
	if (!iMenuTitleArray)
		iMenuTitleArray = new(ELeave) CArrayFixFlat<SOplMenuData> (16); // in line with UIKON
	SOplMenuData data;
	data.iOffsetIntoItemsArray = iMenuItemsArray->Count();
	data.iMenuTitleData.iMenuPaneResourceId = iMenuTitleArray->Count()+KMenuPaneIdOffset;
	data.iIsCascade=EFalse; // Can't cascade with a bitmap
	data.iBitmap[0]=aBitmap;
	data.iBitmap[1]=aMask;
	iMenuTitleArray->AppendL(data);
	}

void COplRuntime::AddMenuItemL(const TDesC* aItemText, TInt aHotKeyCode)
	{
	if (!iMenuItemsArray)
		iMenuItemsArray = new(ELeave) CArrayPtrSeg<CEikMenuPaneItem>(1); 
	CEikMenuPaneItem* item = new(ELeave) CEikMenuPaneItem();
	CleanupStack::PushL(item);
	item->iData.iText = *aItemText;
	item->iData.iCommandId = iMenuItemsArray->Count()+KCommandIdOffset;
	item->iData.iFlags=0;
	if ((item->iData.iCascadeId = CascadeId(*aItemText))!=0)
		{
		item->iData.iText = (*aItemText).Left((*aItemText).Length()-1); // drop trailing ">" from cascade item
		}
	if (aHotKeyCode < 0)
		{
		item->iData.iFlags = EEikMenuItemSeparatorAfter;
		aHotKeyCode=-aHotKeyCode;
		}

#if defined(__SERIES60__)||defined(__UIQ__)
#else
	// Handle profile menu
	if (aHotKeyCode==KMenuProfile)
		item->iData.iCommandId=ECknTasksAutoMenuCommand1;
	else
#endif
		{
		item->iHotKeyCode=TInt16(aHotKeyCode&(~KMenuFlagsMask));
		if (item->iHotKeyCode<1 || (item->iHotKeyCode>32 && !TChar(item->iHotKeyCode).IsAlpha()))
			User::Leave(KErrArgument);
		aHotKeyCode&=KMenuFlagsMask;
		if (aHotKeyCode&KMenuDimmed)
			item->iData.iFlags|=EEikMenuItemDimmed;
		if (aHotKeyCode&KMenuSymbolOn)
			item->iData.iFlags|=EEikMenuItemSymbolOn;
		if (aHotKeyCode&KMenuSymbolIndeterminate)
			item->iData.iFlags|=EEikMenuItemSymbolIndeterminate;
		aHotKeyCode&=(~(KMenuDimmed|KMenuSymbolOn|KMenuSymbolIndeterminate));
		// the rest are mutually exclusive
		if (aHotKeyCode==KMenuCheckBox)
			item->iData.iFlags|=EEikMenuItemCheckBox;
		else if (aHotKeyCode==KMenuRadioStart)
			item->iData.iFlags|=EEikMenuItemRadioStart;
		else if (aHotKeyCode==KMenuRadioMiddle)
			item->iData.iFlags|=EEikMenuItemRadioMiddle;
		else if (aHotKeyCode==KMenuRadioEnd)
			item->iData.iFlags|=EEikMenuItemRadioEnd;
		}

	TInt offset=0;
	if (iMenuTitleArray)
		{	
		offset=(*iMenuTitleArray)[iMenuTitleArray->Count()-1].iOffsetIntoItemsArray;
		iMenuItemsArray->InsertL(offset,item);
		}
	else
		iMenuItemsArray->InsertL(0,item);
	CleanupStack::Pop(); //(menu) item
	}

CEikHotKeyTable* COplRuntime::CreateHotKeyTableLC()
	{ // does it need to be on the cleanup stack
	if (!iMenuItemsArray)
		User::Leave(KOplStructure);
	CEikHotKeyTable* hotKeyTable = new(ELeave) CEikHotKeyTable;
	CleanupStack::PushL(hotKeyTable);
	const TInt count=iMenuItemsArray->Count();
	for(TInt index=0;index<count; index++)
		{
		const CEikMenuPaneItem& item = *(*iMenuItemsArray)[index];
		TChar character(item.iHotKeyCode);
		if (character<=32)
			continue; // <=32 means no Hot-key
		if (character.IsUpper())
			hotKeyTable->AddItemL(item.iData.iCommandId,item.iHotKeyCode+32/*-('A'-1)*/,EModifierCtrl|EModifierShift);
		else
			hotKeyTable->AddItemL(item.iData.iCommandId,item.iHotKeyCode/*-('a'-1)*/,EModifierCtrl);
		}
	return hotKeyTable;
	}

_LIT(KProfileDllName,"ProfileAutoMenu.dll");
_LIT(KSystemLibsPath2,"\\System\\Libs\\Uikon_Init\\");

void COplRuntime::DisplayMenuL(TInt aTitle, TInt aItem, TInt16* aInitPtr)
	{ // Called by MENU keyword.
	if (!iOplMenuBar)
		User::Leave(KOplStructure);

	// Check that profile plugin is present...
	RFs& fileSystem=ConEnv()->FsSession();
	TFindFile findFile(fileSystem);
	if (findFile.FindByDir(KProfileDllName,KSystemLibsPath)==KErrNone)
		{
		AddProfileMenuPaneL();
		}
	// It has moved on the Nokia 9500 Communicator, so try under System\Libs\Uikon_init\ too ...
	else if (findFile.FindByDir(KProfileDllName,KSystemLibsPath2)==KErrNone)
		{
		AddProfileMenuPaneL();
		}

#if defined(__SERIES60__)
	iGoneThroughMenu=EFalse; // We've not been through the menu once yet.
#endif
	CEikMenuBar* oldMenu=iEikonEnv->AppUiFactory()->SwapMenuBar(iOplMenuBar);
	if (oldMenu!=iOplMenuBar)
		delete oldMenu;
	iOplMenuBar=NULL;
	if (aInitPtr)
		iMenuInitPtr = aInitPtr;

	iEikonEnv->AppUiFactory()->MenuBar()->SetHotKeyTable(CreateHotKeyTableLC());
	CleanupStack::Pop(); // hotkeyTable
	AddToStackL(iEikonEnv->AppUiFactory()->MenuBar(),ECoeStackPriorityMenu);
	iEikonEnv->AppUiFactory()->MenuBar()->TryDisplayMenuBarL();

	// EDNPSPR-4SGNDX: If aNewSelectedTitle is invalid, a EIKCOCTL 25 panic happens.
	// This was deferred for Crystal 6.0 so we work-around it directly here using
	// the proposed fix as posted in the defect.
	const TInt max=iMenuTitleArray->Count()-1;
	iEikonEnv->AppUiFactory()->MenuBar()->MoveHighlightToL(((aTitle>max) ? max : aTitle),aItem);
	}

#if !defined(__CRYSTAL__)
EXPORT_C
#endif
void COplRuntime::RestoreMenuL(CCoeControl* aCommandWindow,TInt aWindowId,MEikMenuObserver::TMenuType /*aType*/)
	{
	if (aWindowId == KMenuBarId)
		{// restore the menu bar
		CEikMenuBar::CTitleArray* titleArray = new(ELeave) CEikMenuBar::CTitleArray;
		CleanupStack::PushL(titleArray);
		const TInt count=iMenuTitleArray->Count();
		for (TInt ii=0;ii<count;++ii)
			{
			SOplMenuData& oplData=(*iMenuTitleArray)[ii];
			if (oplData.iIsCascade)
				continue;	// only a cascade, so don't add
			CEikMenuBarTitle* title=new(ELeave) CEikMenuBarTitle;
			CleanupStack::PushL(title);
			title->iData=oplData.iMenuTitleData;
			if (oplData.iBitmap[0])
				{
				title->CreateIconL(oplData.iBitmap[0],oplData.iBitmap[1]);
				title->SetBitmapsOwnedExternally(ETrue);
				}
			titleArray->AppendL(title);
			CleanupStack::Pop(); // title
			title=NULL;
			}
		STATIC_CAST(CEikMenuBar*,aCommandWindow)->SetMenuTitleArray(titleArray);		// in this function which
		CleanupStack::Pop();		// titleArray
		}
	else
		{
		// restore a menu tile

		// Prepare the correct menu pane, using entries from the iMenuItemsArray,
		// based on the WindowId parameter.
		// Use the iMenuTitleArray to work out the offsets into the iMenuItemsArray.
		//
		// On Series 60, there's a problem with the WindowId incorrectly picking up
		// a cascade pane, but this only happens for the main menu pane, which is
		// the first to be displayed. So, if this is the first time through, it cannot
		// be a cascade pane, and must be the main pane.

		TInt offset=0;
		TInt start=0;
		if (aWindowId==KMenuPopup)
			{
			offset=iMenuItemsArray->Count();
			}
		else
			{
#if defined(__SERIES60__)
			TInt arrayPos=aWindowId-KMenuPaneIdOffset;
			if (iGoneThroughMenu==EFalse) //not been through yet... 
				{
				iGoneThroughMenu=ETrue;
				// Skip until a non-cascade pane is found,
				// adjusting the start accordingly. 
				//	 start=prev iOffset
				const TInt count=iMenuTitleArray->Count();
				__ASSERT_ALWAYS(arrayPos<count,User::Leave(KOplStructure)); 
				while ((*iMenuTitleArray)[arrayPos].iIsCascade)
					{
					start=(*iMenuTitleArray)[arrayPos].iOffsetIntoItemsArray;
					arrayPos++;
					if (arrayPos>=count)
						User::Leave(KOplStructure); //No valid panes in menu.
					}
				}
			else
				{
				// Maybe this is a real cascade here.
				//so don't skip any...
				const TInt count=iMenuTitleArray->Count();
				__ASSERT_ALWAYS(arrayPos<count,User::Leave(KOplStructure));
				if (arrayPos)
					start=(*iMenuTitleArray)[arrayPos-1].iOffsetIntoItemsArray;
				}
			offset=(*iMenuTitleArray)[arrayPos].iOffsetIntoItemsArray;
#else
			const TInt arrayPos = aWindowId-KMenuPaneIdOffset;
			offset = (*iMenuTitleArray)[arrayPos].iOffsetIntoItemsArray;
			if (arrayPos)
				start=(*iMenuTitleArray)[arrayPos-1].iOffsetIntoItemsArray;
#endif
			}
		STATIC_CAST(CEikMenuPane*,aCommandWindow)->DrawableWindow()->SetOrdinalPosition(0);
		for (TInt ii=start;ii<offset;++ii)
			{
			STATIC_CAST(CEikMenuPane*,aCommandWindow)->AddMenuItemL((*iMenuItemsArray)[ii]->iData);
			}
		}
	}

void COplRuntime::SetUserFlags(TInt aUserFlags)
	{
	if (aUserFlags&KOplState64kLimit)
		{
		iHeap64->Compress();
		if (iHeap64->Size()>K64Kbytes)
			User::LeaveNoMemory();
		}
	if (aUserFlags&KOplStateSendSwitchOnMessage)
		User::LeaveIfError(iCoeEnv->RootWin().EnableOnEvents(EEventControlAlways));
	iUserFlags|=aUserFlags;
	}

void COplRuntime::ClearUserFlags(TInt aUserFlags)
	{
	iUserFlags&=~aUserFlags;
	if (aUserFlags&KOplStateSendSwitchOnMessage)
		iCoeEnv->RootWin().DisableOnEvents();
	}

void COplRuntime::PrepareToStartActiveScheduler()
	{
	iIOCollection->WsEventHandler().PrepareToStartActiveScheduler(*iCoeEnv);
	iCoeEnv->RootWin().CancelTextCursor();
	}

void COplRuntime::NotifyActiveSchedulerStopped()
	{
	iIOCollection->WsEventHandler().NotifyActiveSchedulerStopped();
	Console().DrawCursorIfOn(Console().CurrentPos());
	DrawablesCollection().DrawCursorIfOn();
	iCoeEnv->WsSession().Flush(); // flush the wserv buffer(removes menu/dialog windows)
	}

#if !defined(__CRYSTAL__)
EXPORT_C
#endif
CArrayFix<TCoeHelpContext>* COplRuntime::HelpContextL() const
	{
	// Build the TCoeHelpContext object, and pass it back to Cone.
	CArrayFix<TCoeHelpContext>* viewHelpContext=new(ELeave) CArrayFixFlat<TCoeHelpContext>(1);
	CleanupStack::PushL(viewHelpContext);

	COplRuntime* rt=TheRuntime(); // expensive call, so cache it here.
	TFixedArray<TCoeContextName,KOplLenContextNamesArray>* helpContext=rt->HelpContextNamesArray();
	if (helpContext)
		{
		TCoeContextName context=helpContext->At(EOplHelpView);
		TUid helpUid=rt->HelpUid();
		if (context.Length() && helpUid!=KNullUid)
			{
			viewHelpContext->AppendL(TCoeHelpContext(helpUid,context));
			}
		}
	CleanupStack::Pop(); // viewHelpContext
	return viewHelpContext;
	}

#if defined(__SERIES60__)
//hack hack hack

void CEikMenuBar::CloseState()
	{
	 __ASSERT_DEBUG(EFalse,User::Invariant());
// ????	    StopDisplayingMenuBar();

	}


void CEikMenuBar::ProcessCommandL(TInt aCommandId)
	{
	TheRuntime()->ProcessCommandL(aCommandId);
	}


// object provider - used by cone for menu ???
class TTypeUid::Ptr  CEikMenuBar::MopSupplyObject(class TTypeUid /*thing*/) 
	{
#pragma message("en_main.cpp: MopSupplyObject() should be supplying what exactly?")
	return TTypeUid::Null();
	}

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -