📄 desktopwindowcontainer.cpp
字号:
/* Copyright (C) 2006 Lucas Gomez All Rights Reserved.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
// INCLUDE FILES
#include <coemain.h>
#include <barsread.h>
#include "DesktopWindowContainer.h"
#include "VncViewer.rsg"
#include "VncViewerAppUi.h"
#include "LogWriter.h"
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CDesktopWindowContainer* CDesktopWindowContainer::NewL(const TRect& aRect,CConn* aConn)
{
CDesktopWindowContainer* self = CDesktopWindowContainer::NewLC(aRect,aConn);
CleanupStack::Pop(self);
return self;
}
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CDesktopWindowContainer* CDesktopWindowContainer::NewLC(const TRect& aRect,CConn* aConn)
{
CDesktopWindowContainer* self = new (ELeave) CDesktopWindowContainer();
CleanupStack::PushL(self);
self->ConstructL(aRect,aConn);
return self;
}
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CDesktopWindowContainer::ConstructL(const TRect& aRect,CConn* aConn)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
// Activate the window, which makes it ready to be drawn
ActivateL();
iConn=aConn;
iImage=CPixelBufferImage::NewL(iConn->GetCP()->GetWidth(),iConn->GetCP()->GetHeight());
iCursor=CCursor::NewL();
iCursorBacking=CManagedPixelBuffer::NewL();
iZoom.SetRect(0,0,iImage->GetWidth(),iImage->GetHeight());
}
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::CDesktopWindowContainer()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CDesktopWindowContainer::CDesktopWindowContainer()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::~CDesktopWindowContainer()
// Destructor.
// -----------------------------------------------------------------------------
//
CDesktopWindowContainer::~CDesktopWindowContainer()
{
if(iImage)
{
delete iImage;
iImage=NULL;
}
if(iCursor)
{
delete iCursor;
iCursor=NULL;
}
if(iCursorBacking)
{
delete iCursorBacking;
iCursorBacking=NULL;
}
}
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CDesktopWindowContainer::Draw(const TRect& aRect) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect(Rect());
// Clears the screen
if(iGraphics)
{
iGraphics->SetClippingRect(aRect);
//iGraphics->BitBlt(TPoint(0,0),iImage->iImage,drawRect);
iGraphics->DrawBitmap(drawRect,iImage->GetImage(),iZoom);
iGraphics->CancelClippingRect();
}
else
gc.Clear(drawRect);
}
// -----------------------------------------------------------------------------
// CDesktopWindowContainer::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CDesktopWindowContainer::SizeChanged()
{
DrawNow();
}
/**
* HandleControlEventL()
* Handles an event from an observed control.
* This function is called when a control for which
* this control is the observer calls CCoeControl::ReportEventL().
*
* @param CCoeControl *aControl The control that sent the event.
* @param TCoeEvent aEventType The event type.
*/
void CDesktopWindowContainer::HandleControlEventL(CCoeControl* /*aControl*/, TCoeEvent /*aEventType*/)
{
}
/*
-----------------------------------------------------------------------------
TInt CDesktopWindowContainer::CountComponentControls() const
Description: return the number of controls in the current container
Comments :
Return values: number of controls in the container
-----------------------------------------------------------------------------
*/
TInt CDesktopWindowContainer::CountComponentControls() const
{
return 0;
}
/*
-----------------------------------------------------------------------------
CCoeControl* CDesktopWindowContainer::ComponentControl(TInt aIndex) const
Description: return control pointer according to index
Comments :
Return values: pointer to CCoeControl object
-----------------------------------------------------------------------------
*/
CCoeControl* CDesktopWindowContainer::ComponentControl(TInt aIndex) const
{
return NULL;
}
/*
-----------------------------------------------------------------------------
TKeyResponse CDesktopWindowContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType)
Description: Called by framework when a key is pressed
Comments :
Return values: whether the key has been consumed or not.
-----------------------------------------------------------------------------
*/
TKeyResponse CDesktopWindowContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if(aType==EEventKey)
{
TInt verticalAdjustment=iConn->GetCP()->GetHeight()/Rect().Height();
TInt horizontalAdjustment=iConn->GetCP()->GetWidth()/Rect().Width();
iKeyAcceleration=(aKeyEvent.iRepeats==1?iKeyAcceleration+1:0);
switch(aKeyEvent.iScanCode)
{
case EStdKeyLeftArrow:
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EMove;
pointerEvent.iPosition=TPoint((iCursorPosX-horizontalAdjustment)-iKeyAcceleration,
iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
// - If local cursor rendering is enabled then use it
if(iCursorAvailable)
{
// - Render the cursor!
HideLocalCursor();
if(pointerEvent.iPosition.iX>=0 && pointerEvent.iPosition.iX<iImage->GetWidth() &&
pointerEvent.iPosition.iY>=0 && pointerEvent.iPosition.iY<iImage->GetHeight())
{
iCursorPosX=pointerEvent.iPosition.iX;
iCursorPosY=pointerEvent.iPosition.iY;
ShowLocalCursor();
// Scrolling the window
if(!iZoom.Contains(TPoint(iCursorPosX,iCursorPosY)))
{
iZoom.Move(-horizontalAdjustment-iKeyAcceleration,0);
if(iZoom.iTl.iX<0)
iZoom.Move(-iZoom.iTl.iX,0);
}
}
}
}
break;
case EStdKeyRightArrow:
{
TBuf<10> temp;
temp.AppendNum(aKeyEvent.iRepeats);
CLogWriter::InstanceL()->LogTrace(temp);
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EMove;
pointerEvent.iPosition=TPoint((iCursorPosX+horizontalAdjustment)+iKeyAcceleration,
iCursorPosY);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
// - If local cursor rendering is enabled then use it
if(iCursorAvailable)
{
// - Render the cursor!
HideLocalCursor();
if(pointerEvent.iPosition.iX>=0 && pointerEvent.iPosition.iX<iImage->GetWidth() &&
pointerEvent.iPosition.iY>=0 && pointerEvent.iPosition.iY<iImage->GetHeight())
{
iCursorPosX=pointerEvent.iPosition.iX;
iCursorPosY=pointerEvent.iPosition.iY;
ShowLocalCursor();
// Scrolling the window
if(!iZoom.Contains(TPoint(iCursorPosX,iCursorPosY)))
{
iZoom.Move(+horizontalAdjustment+iKeyAcceleration,0);
if(iZoom.iBr.iX>iImage->GetWidth()-1)
iZoom.Move(iImage->GetWidth()-1-iZoom.iBr.iX,0);
}
}
}
}
break;
case EStdKeyUpArrow:
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EMove;
pointerEvent.iPosition=TPoint(iCursorPosX,
(iCursorPosY-verticalAdjustment)-iKeyAcceleration);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
// - If local cursor rendering is enabled then use it
if(iCursorAvailable)
{
// - Render the cursor!
HideLocalCursor();
if(pointerEvent.iPosition.iX>=0 && pointerEvent.iPosition.iX<iImage->GetWidth() &&
pointerEvent.iPosition.iY>=0 && pointerEvent.iPosition.iY<iImage->GetHeight())
{
iCursorPosX=pointerEvent.iPosition.iX;
iCursorPosY=pointerEvent.iPosition.iY;
ShowLocalCursor();
// Scrolling the window
if(!iZoom.Contains(TPoint(iCursorPosX,iCursorPosY)))
{
iZoom.Move(0,-verticalAdjustment-iKeyAcceleration);
if(iZoom.iTl.iY<0)
iZoom.Move(0,-iZoom.iTl.iY);
}
}
}
}
break;
case EStdKeyDownArrow:
{
TPointerEvent pointerEvent;
pointerEvent.iType=TPointerEvent::EMove;
pointerEvent.iPosition=TPoint(iCursorPosX,
(iCursorPosY+verticalAdjustment)+iKeyAcceleration);
pointerEvent.iModifiers=aKeyEvent.iModifiers;
if(!iConn->GetViewOnly())
iConn->WritePointerEvent(pointerEvent);
// - If local cursor rendering is enabled then use it
if(iCursorAvailable)
{
// - Render the cursor!
HideLocalCursor();
if(pointerEvent.iPosition.iX>=0 && pointerEvent.iPosition.iX<iImage->GetWidth() &&
pointerEvent.iPosition.iY>=0 && pointerEvent.iPosition.iY<iImage->GetHeight())
{
iCursorPosX=pointerEvent.iPosition.iX;
iCursorPosY=pointerEvent.iPosition.iY;
ShowLocalCursor();
// Scrolling the window
if(!iZoom.Contains(TPoint(iCursorPosX,iCursorPosY)))
{
iZoom.Move(0,+verticalAdjustment+iKeyAcceleration);
if(iZoom.iBr.iY>iImage->GetHeight())
iZoom.Move(0,iImage->GetHeight()-1-iZoom.iBr.iY);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -