📄 desktopwindowcontainer.cpp
字号:
}
break;
case 167: // The joystick button
{ // we make a zoom
TSize screenSize=Rect().Size();
if(iZoom.Size()!=screenSize)
{
iZoom.SetRect(TPoint(iCursorPosX-screenSize.iWidth/2,iCursorPosY-screenSize.iHeight/2),screenSize);
if(iZoom.iTl.iX<0)
iZoom.Move(-iZoom.iTl.iX,0);
if(iZoom.iTl.iY<0)
iZoom.Move(0,-iZoom.iTl.iY);
if(iZoom.iBr.iX>iImage->GetWidth()-1)
iZoom.Move(iImage->GetWidth()-1-iZoom.iBr.iX,0);
if(iZoom.iBr.iY>iImage->GetHeight())
iZoom.Move(0,iImage->GetHeight()-1-iZoom.iBr.iY);
}
else
{
iZoom.SetRect(TPoint(0,0),TSize(iImage->GetWidth(),iImage->GetHeight()));
}
}
break;
default:
{
}
}
return EKeyWasConsumed;
}
else if (aType==EEventKeyDown)
{
switch(aKeyEvent.iScanCode)
{
#ifdef __WINSCW__
case EStdKeyNkpAsterisk:
#else
case '*':
#endif
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EButton1Down;
pointerEvent.iPosition=TPoint(iCursorPosX,iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
}
break;
case '0':
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EButton2Down;
pointerEvent.iPosition=TPoint(iCursorPosX,iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
}
break;
case EStdKeyHash:
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EButton3Down;
pointerEvent.iPosition=TPoint(iCursorPosX,iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
}
break;
default:
{
}
}
return EKeyWasConsumed;
}
else if (aType==EEventKeyUp)
{
switch(aKeyEvent.iScanCode)
{
#ifdef __WINSCW__
case EStdKeyNkpAsterisk:
#else
case '*':
#endif
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EButton1Up;
pointerEvent.iPosition=TPoint(iCursorPosX,iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
}
break;
case '0':
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EButton2Up;
pointerEvent.iPosition=TPoint(iCursorPosX,iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
}
break;
case EStdKeyHash:
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EButton3Up;
pointerEvent.iPosition=TPoint(iCursorPosX,iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
}
break;
default:
{
}
}
return EKeyWasConsumed;
}
else
return EKeyWasNotConsumed;
}
void CDesktopWindowContainer::InitGraphics()
{
iGraphics=&(SystemGc());
}
CPixelFormat* CDesktopWindowContainer::GetPF()
{
return iImage->GetPF();
}
void CDesktopWindowContainer::SetCursor(TInt aHotspotX,TInt aHotspotY,TInt aW,TInt aH,RBuf8& aData,RBuf8& aMask)
{
// strictly we should use a mutex around this test since useLocalCursor
// might be being altered by the GUI thread. However it's only a single
// boolean and it doesn't matter if we get the wrong value anyway.
if(!iConn->GetUseLocalCursor()) return;
if(!iCursorAvailable)
{
//XDefineCursor(dpy, win(), noCursor);
iCursorAvailable=ETrue;
}
HideLocalCursor();
iCursor->SetHotspotX(aHotspotX);
iCursor->SetHotspotY(aHotspotY);
iCursor->SetSize(aW,aH);
iCursor->SetPF(GetPF());
iCursor->GetData().Copy(aData.Left(iCursor->DataLen()));
iCursor->GetMask().Copy(aMask.Left(iCursor->MaskLen()));
iCursorBacking->SetSize(aW,aH);
iCursorBacking->SetPF(GetPF());
ShowLocalCursor();
}
void CDesktopWindowContainer::SetColourMapEntries(TInt aFirstColour,TInt aNColours,RArray<TInt>& aRgbs)
{
iImage->SetColourMapEntries(aFirstColour,aNColours,aRgbs);
iImage->UpdateColourMap();
iImage->Put(0,0,iImage->GetWidth(),iImage->GetHeight(),iGraphics);
DrawNow(TRect(TPoint(0,0),TSize(iImage->GetWidth(),iImage->GetHeight())));
}
void CDesktopWindowContainer::Resize()
{
CLogWriter::InstanceL()->LogTrace(_L("CDesktopWindowContainer::Resize() called"));
TInt w=iConn->GetCP()->GetWidth();
TInt h=iConn->GetCP()->GetHeight();
HideLocalCursor();
//SetSize(TSize(w,h));
iImage->Resize(w,h);
iZoom.Resize(w,h);
iCursorPosX=w/2;
iCursorPosY=h/2;
}
void CDesktopWindowContainer::DrawInvalidRect()
{
if(!iInvalidRect) return;
TInt x=iInvalidLeft;
TInt w=iInvalidRight-x;
TInt y=iInvalidTop;
TInt h=iInvalidBottom-y;
iInvalidRect=EFalse;
iImage->Put(x,y,w,h,iGraphics);
DrawNow(TRect(TPoint(x,y),TSize(w,h)));
}
void CDesktopWindowContainer::Invalidate(TInt aX,TInt aY,TInt aW,TInt aH)
{
if(iInvalidRect)
{
if(aX<iInvalidLeft) iInvalidLeft=aX;
if(aX+aW>iInvalidRight) iInvalidRight=aX+aW;
if(aY<iInvalidTop) iInvalidTop=aY;
if(aY+aH>iInvalidBottom) iInvalidBottom=aY+aH;
}
else
{
iInvalidLeft=aX;
iInvalidRight=aX+aW;
iInvalidTop=aY;
iInvalidBottom=aY+aH;
iInvalidRect=ETrue;
}
if((iInvalidRight-iInvalidLeft)*(iInvalidBottom-iInvalidTop)>100000)
DrawInvalidRect();
}
void CDesktopWindowContainer::BeginRect(TInt /*aX*/,TInt /*aY*/,TInt /*aW*/,TInt /*aH*/,TEncodings /*aEncoding*/)
{
iInvalidRect=EFalse;
}
void CDesktopWindowContainer::EndRect(TInt /*aX*/,TInt /*aY*/,TInt /*aW*/,TInt /*aH*/,TEncodings /*aEncoding*/)
{
DrawInvalidRect();
}
void CDesktopWindowContainer::FillRect(TInt aX,TInt aY,TInt aW,TInt aH,TInt aP)
{
if(OverlapsCursor(aX,aY,aW,aH)) HideLocalCursor();
iImage->FillRect(aX,aY,aW,aH,aP);
Invalidate(aX,aY,aW,aH);
ShowLocalCursor();
}
void CDesktopWindowContainer::ImageRect(TInt aX,TInt aY,TInt aW,TInt aH,TDes8& aP,TInt aOffset)
{
if(OverlapsCursor(aX,aY,aW,aH)) HideLocalCursor();
iImage->ImageRect(aX,aY,aW,aH,aP,aOffset);
Invalidate(aX,aY,aW,aH);
ShowLocalCursor();
}
void CDesktopWindowContainer::CopyRect(TInt aX,TInt aY,TInt aW,TInt aH,TInt aSx,TInt aSy)
{
if(OverlapsCursor(aX,aY,aW,aH) || OverlapsCursor(aSx,aSy,aW,aH))
HideLocalCursor();
iImage->CopyRect(aX,aY,aW,aH,aSx,aSy);
if(iConn->GetFastCopyRect())
{
iGraphics->CopyRect(TPoint(aX-aSx,aY-aSy),TRect(TPoint(aSx,aSy),TSize(aW,aH)));
}
else
{
Invalidate(aX,aY,aW,aH);
}
}
TBool CDesktopWindowContainer::OverlapsCursor(TInt aX,TInt aY,TInt aW,TInt aH)
{
return(aX<iCursorBackingX+iCursorBacking->GetWidth() &&
aY<iCursorBackingY+iCursorBacking->GetHeight() &&
aX+aW>iCursorBackingX && aY+aH>iCursorBackingY);
}
void CDesktopWindowContainer::ResetLocalCursor()
{
HideLocalCursor();
//XDefineCursor(dpy, win(), dotCursor);
iCursorAvailable = false;
}
void CDesktopWindowContainer::CheckClipboard()
{
/* if(clipboardDialog->systemClipboard != null &&
cc.viewer.sendClipboard.getValue()) {
Transferable t = ClipboardDialog.systemClipboard.getContents(this);
if ((t != null) && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
String newContents = (String) t.getTransferData(DataFlavor.stringFlavor);
if (newContents != null && !newContents.equals(oldContents)) {
cc.writeClientCutText(newContents);
oldContents = newContents;
cc.clipboardDialog.setContents(newContents);
}
} catch (Exception e) {
System.out.println("Exception getting clipboard data: " + e.getMessage());
}
}
}*/
}
void CDesktopWindowContainer::HideLocalCursor()
{
// - Blit the cursor backing store over the cursor
if(iCursorVisible)
{
iCursorVisible=EFalse;
iImage->ImageRect(iCursorBackingX,iCursorBackingY,iCursorBacking->GetWidth(),
iCursorBacking->GetHeight(),iCursorBacking->GetData(),0);
iImage->Put(iCursorBackingX,iCursorBackingY,iCursorBacking->GetWidth(),
iCursorBacking->GetHeight(),iGraphics);
DrawNow(TRect(TPoint(iCursorBackingX,iCursorBackingY),
TSize(iCursorBacking->GetWidth(),iCursorBacking->GetHeight())));
}
}
void CDesktopWindowContainer::ShowLocalCursor()
{
if(iCursorAvailable && !iCursorVisible)
{
if(!iImage->GetPF()->Equal(iCursor->GetPF()) ||
iCursor->GetWidth()==0 || iCursor->GetHeight()==0)
{
CLogWriter::InstanceL()->LogTrace(_L("attempting to render invalid local cursor"));
iCursorAvailable=EFalse;
return;
}
iCursorVisible=ETrue;
TInt cursorLeft=iCursorPosX-iCursor->GetHotspotX();
TInt cursorTop=iCursorPosY-iCursor->GetHotspotY();
TInt cursorRight=cursorLeft+iCursor->GetWidth();
TInt cursorBottom=cursorTop+iCursor->GetHeight();
TInt x=(cursorLeft>=0 ? cursorLeft : 0);
TInt y=(cursorTop>=0 ? cursorTop : 0);
TInt w=((cursorRight<iImage->GetWidth() ? cursorRight : iImage->GetWidth())-x);
TInt h=((cursorBottom<iImage->GetHeight() ? cursorBottom : iImage->GetHeight())-y);
iCursorBackingX=x;
iCursorBackingY=y;
iCursorBacking->SetSize(w,h);
for(TInt j=0;j<h;j++)
iCursorBacking->GetData().MidTPtr(j*w).Copy(iImage->GetData().Mid((y+j)*iImage->GetWidth()+x,w));
iImage->MaskRect(cursorLeft,cursorTop,iCursor->GetWidth(),iCursor->GetHeight(),
iCursor->GetData(),iCursor->GetMask());
iImage->Put(x,y,w,h,iGraphics);
DrawNow(TRect(TPoint(x,y),TSize(w,h)));
}
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -