📄 g_keywrd.cpp
字号:
CEikCommandButton::TLayout layout = CEikCommandButton::ETextRightPictureLeft;
CEikCommandButton::TExcess excess = CEikCommandButton::EShare;
TInt optArgs=aRuntime.IP8();
switch (optArgs)
{
case 3:
{
TInt16 oplLayout=aStack.PopInt16();
layout=(CEikCommandButton::TLayout)(oplLayout & 0x0f);
excess=(CEikCommandButton::TExcess)(oplLayout & 0xf0);
}
case 2:
mask=(CFbsBitmap*)aStack.PopInt32();
mask=getBitmapIfOplDrawable(aRuntime,mask);
case 1:
if ((bitmap=(CFbsBitmap*)aStack.PopInt32())==NULL)
User::Leave(KOplErrInvalidArgs);
bitmap=getBitmapIfOplDrawable(aRuntime,bitmap);
break;
default:
break;
}
TInt state=aStack.PopInt16();
TInt height=aStack.PopInt16();
TInt width=aStack.PopInt16();
TInt type=aStack.PopInt16();
TPtrC text=aStack.PopString();
COplDrawable* drawable=aRuntime.DrawablesCollection().CurrentDrawable();
switch(type)
{
case 0:
// just any ignore bitmaps
drawable->DrawS3ButtonL(state,width,height,text);
break;
case 1:
switch(state)
{
case 0:
case 1:
break;
// 2 is EIndeterminate.
// case 2:
// state=17;
// break;
default:
User::Leave(KErrArgument);
}
// fall through to case 3:
case 2:
{
if (drawable->DrawableFlag()==EIsOplBitmap)
User::Leave(KOplErrInvalidWindow);
CEikCommandButton* button=new(ELeave) CEikCommandButton;
CleanupStack::PushL(button);
button->CCoeControl::SetContainerWindowL(((COplWindow*)drawable)->Window());
if (optArgs)
{
button->SetPictureL(bitmap,mask);
button->Picture()->SetPictureOwnedExternally(ETrue);
if (optArgs==3)
{
button->SetButtonLayout(layout);
button->SetExcessSpace(excess);
}
if (text.Length()==0)
button->SetDisplayContent(CEikCommandButton::EPictureOnly);
}
switch(state)
{
case 0:
case 1:
break;
default:
User::Leave(KErrArgument);
}
button->SetTextL(text);
button->Label()->SetFont(drawable->Font());
button->SetExtent(drawable->CursorPosition(),TSize(width,height));
button->ActivateL();
button->SetState((CEikButtonBase::TState)state);
button->DrawNow();
CleanupStack::PopAndDestroy(); // button
break;
}
default:
User::Leave(KErrArgument);
}
// flushing needed?
}
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////// OTHER UI KEYWORDS ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
void OpCode::Busy(CStack& aStack, COplRuntime& aRuntime, CFrame* /*aFramePtr*/)
{
TInt numOfArgs = aRuntime.IP8();
TInt corner = 1; // by default - will display message at bottom right of screen
TInt delay = 0;
TPtrC busyMsgString;
if (numOfArgs > 2) // ie numOfArgs == 3
delay = aStack.PopInt16();
if (numOfArgs > 1) // ie numOfArgs == 2 or 3
corner = aStack.PopInt16();
if (numOfArgs>0)
busyMsgString.Set(aStack.PopString());
TInt len=busyMsgString.Length();
if (len==0)
{
((CEikonEnv*)aRuntime.ConEnv())->BusyMsgCancel();
return;
}
if (len>KEikBusyMsgMaxLen)
User::Leave(KOplErrInvalidArgs);
TGulAlignment alignment;
COplDrawable::CalcMsgPosition(corner,alignment);
((CEikonEnv*)aRuntime.ConEnv())->BusyMsgL(busyMsgString,alignment,TTimeIntervalMicroSeconds32(500000*delay));
}
void OpCode::gIPrint(CStack& aStack, COplRuntime& aRuntime, CFrame* /*aFramePtr*/)
{
TInt numOfArgs = aRuntime.IP8();
TInt corner = 3;
if (numOfArgs == 1)
corner = aStack.PopInt16();
TPtrC infoMsgString = aStack.PopString();
TGulAlignment alignment;
COplDrawable::CalcMsgPosition(corner,alignment);
((CEikonEnv*)aRuntime.ConEnv())->InfoMsgWithAlignment(alignment,infoMsgString);
}
void OpCode::gInfo32(CStack& aStack, COplRuntime& aRuntime, CFrame* /* */)
{
TUint32* array=(TUint32*)OplUtil::PopOffsetAsAddrL(aStack,aRuntime.Heap64(),sizeof(TUint32)*KGInfo32ArraySize);
array+=2; // first two positions in the array are unused
CDrawablesCollection& collection = aRuntime.DrawablesCollection();
COplDrawable* currentDrawable = collection.CurrentDrawable();
CFbsFont* currentFont = currentDrawable->Font();
TPoint cursorPos(0,0);
TTextCursor cursor;
TFontSpec fontSpec=currentFont->FontSpecInTwips();
OplUtil::PutLong(array,currentFont->HeightInPixels()); // (3)
OplUtil::PutLong(++array,(currentFont->HeightInPixels() - currentFont->AscentInPixels())); // (4)
OplUtil::PutLong(++array,currentFont->AscentInPixels()); // (5)
OplUtil::PutLong(++array,currentFont->MaxNormalCharWidthInPixels()); // (6)
OplUtil::PutLong(++array,currentFont->MaxCharWidthInPixels()); // (7)
TInt style = currentDrawable->CurrentStyle();
TInt32 flags = (fontSpec.iTypeface.IsSymbol()?0:1); // standard ASCII font
if (style&KStyleBold)
flags += 4;
if (style&KStyleItalics)
flags += 8;
if (style&KStyleMonoSpaced)
flags += 32;
else
flags += 16;
OplUtil::PutLong(++array,flags); // (8)
OplUtil::PutLong(++array,currentDrawable->FontId());
array++; // move to start next element
Mem::FillZ(array,sizeof(TUint32)*8); // zero fill
array+=7; // move pointer to next element
OplUtil::PutLong(++array,currentDrawable->CurrentDrawMode()); // (18)
OplUtil::PutLong(++array,currentDrawable->CurrentTextMode()); // (19)
OplUtil::PutLong(++array,currentDrawable->CurrentStyle()); // (20)
TBool cursorOn=EFalse;
TInt32 drawableWithCursor=0;
if (aRuntime.Console().IsCursorOn())
{
cursorOn=ETrue;
drawableWithCursor=-1;
}
else
{
drawableWithCursor=collection.DrawableWithCursor(); // must be a window
if (drawableWithCursor>0)
{
COplWindow* cursorWindow=STATIC_CAST(COplWindow*,collection.DrawableL(drawableWithCursor));
cursorOn=cursorWindow->CursorState();
if (cursorOn)
{
cursorPos=cursorWindow->CursorPosition();
cursor=cursorWindow->Cursor();
}
}
}
OplUtil::PutLong(++array,cursorOn);
OplUtil::PutLong(++array,drawableWithCursor); // (22)
OplUtil::PutLong(++array,cursor.iWidth); // (23)
OplUtil::PutLong(++array,cursor.iHeight); // (24)
OplUtil::PutLong(++array,cursor.iAscent); // (25)
OplUtil::PutLong(++array,cursorPos.iX); // (26)
OplUtil::PutLong(++array,cursorPos.iY); // (27)
if (currentDrawable->DrawableFlag() == EIsOplBitmap)
OplUtil::PutLong(++array,1);
else // (28)
OplUtil::PutLong(++array,0);
TInt16 effects = 0;
// ETypeObloid dropped by WSERV
// if (cursor.iType == TTextCursor::ETypeObloid)
// effects = 1;
if (cursor.iFlags&TTextCursor::EFlagNoFlash)
effects += 2;
TRgb black(0,0,0);
if (cursor.iColor != black)
effects += 4;
OplUtil::PutLong(++array,effects); // (29)
OplUtil::PutLong(++array,COplDrawable::DisplayMode(currentDrawable->GetDisplayMode())); // (30)
OplUtil::PutLong(++array,currentDrawable->ForegroundColor().Red()); // (31)
OplUtil::PutLong(++array,currentDrawable->ForegroundColor().Green()); // (32)
OplUtil::PutLong(++array,currentDrawable->ForegroundColor().Blue()); // (33)
OplUtil::PutLong(++array,currentDrawable->BackgroundColor().Red()); // (34)
OplUtil::PutLong(++array,currentDrawable->BackgroundColor().Green()); // (35)
OplUtil::PutLong(++array,currentDrawable->BackgroundColor().Blue()); // (36)
}
void OpCode::gPeekLine(CStack& aStack, COplRuntime& aRuntime, CFrame* /*aFramePtr*/)
{
TInt mode = aStack.PopInt16();
if (mode<-1||mode>2)
User::Leave(KErrArgument);
TInt pixels = aStack.PopInt16();
TInt words=(pixels<<((mode==-1)?0:mode)); // bit count
words=(words+15)/16; // word count rounded up
TUint16* p=(TUint16*)OplUtil::PopOffsetAsAddrL(aStack,aRuntime.Heap64(),words*sizeof(TUint16));
TPtr8 ptrToBuf((TUint8*)p,words*2);
TPoint start = COplDrawable::PopPoint(aStack);
TInt drawableId = aStack.PopInt16();
COplDrawable* drawable = aRuntime.DrawablesCollection().DrawableL(drawableId);
TDisplayMode dispMode=EGray2;
// set last word to all set so inversion sets to zero
if (mode==-1)
OplUtil::PutWord(&p[words-1],(TUint16)0xffff);
else
dispMode=COplDrawable::DisplayMode(mode);
CFbsBitmap* bitmap;
if (drawable->DrawableFlag() == EIsOplBitmap)
bitmap=&(((COplBitmap*)drawable)->FbsBitmap());
else
{
bitmap=new(ELeave) CFbsBitmap;
CleanupStack::PushL(bitmap);
((COplWindow*)drawable)->BackupBmpHandleL(*bitmap);
}
bitmap->GetScanLine(ptrToBuf,start,pixels,dispMode);
if (mode==-1)
{
while (words--)
{
OplUtil::PutWord(p,(TUint16)~OplUtil::GetWord(p));
++p;
}
}
if (drawable->DrawableFlag() != EIsOplBitmap) // must have created a bitmap
CleanupStack::PopAndDestroy();
}
void OpCode::gColor(CStack& aStack, COplRuntime& aRuntime, CFrame* /*aFramePtr*/)
{
TUint8 blue = (TUint8)aStack.PopInt16();
TUint8 green = (TUint8)aStack.PopInt16();
TUint8 red = (TUint8)aStack.PopInt16();
TRgb color = TRgb(red,green,blue);
// red value
aRuntime.DrawablesCollection().CurrentDrawable()->SetForegroundColor(color);
}
void OpCode::gColorBackground(CStack& aStack, COplRuntime& aRuntime, CFrame* /*aFramePtr*/)
{
TUint8 blue = (TUint8)aStack.PopInt16();
TUint8 green = (TUint8)aStack.PopInt16();
TUint8 red = (TUint8)aStack.PopInt16();
TRgb color = TRgb(red,green,blue);
// red value
aRuntime.DrawablesCollection().CurrentDrawable()->SetBackgroundColor(color);
}
void OpCode::gGrey(CStack& aStack, COplRuntime& aRuntime, CFrame* /*aFramePtr*/)
{
TInt mode = aStack.PopInt16();
TRgb color=KRgbBlack;
if (mode==1)
color=KRgbGray;
aRuntime.DrawablesCollection().CurrentDrawable()->SetForegroundColor(color);
}
void OpCode::gClock(CStack& aStack , COplRuntime& aRuntime, CFrame* /* */)
{
//((CEikonEnv*)aRuntime.ConEnv())->AlertWin(_L("GCLOCK not yet implemented"));
// just fix stack for now
TInt noOfParams=aRuntime.IP8();
COplDrawable* drawable=aRuntime.DrawablesCollection().CurrentDrawable();
if (drawable->DrawableFlag()==EIsOplBitmap)
User::Leave(KOplErrInvalidWindow);
TInt offset=0;
TInt type=6; // default to this for now !!!
TInt style=0;
TInt fontId=0x9a; // default font
TPtrC format;
switch (noOfParams)
{
case 6:
style=aStack.PopInt16();
// fall through
case 5:
fontId=aStack.PopInt32();
// fall through
case 4:
format.Set(aStack.PopString());
// fall through
case 3:
offset=aStack.PopInt32();
// fall through
case 2:
type=aStack.PopInt16();
// fall through
case 1:
break;
case 0: // gClock OFF
((COplWindow*)drawable)->DeleteClock();
return;
default:
break; // never happens
}
((COplWindow*)drawable)->DeleteClock(); // delete if exists
if (!(type&0x100))
offset*=60;
type&=0xff;
if (type==11) // formatted clock used to be 10 but string format has changed
{
((COplWindow*)drawable)->CreateFormattedClockL(((CEikonEnv*)aRuntime.ConEnv())->ClockDllL(),offset,fontId,style,format);
}
else
{
((COplWindow*)drawable)->CreateClockL(*(CEikonEnv*)aRuntime.ConEnv(),type,offset);
}
}
void OpCode::gColorInfo(CStack& aStack, COplRuntime& aRuntime, CFrame* /* */)
{
// gColorInfo cInfo&(3) where 1=TDisplayMode, 2=number of colors, 3=number of grays.
TUint32* array=(TUint32*)OplUtil::PopOffsetAsAddrL(aStack,aRuntime.Heap64(),sizeof(TUint32)*KGColorInfoArraySize);
TInt color=0;
TInt gray=0;
TDisplayMode dMode=aRuntime.ConEnv()->WsSession().GetDefModeMaxNumColors(color,gray);
OplUtil::PutLong(array,dMode);//(1)
OplUtil::PutLong(++array,color);//(2)
OplUtil::PutLong(++array,gray);//(3)
}
/* End of $Workfile G_KEYWRD.CPP$ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -