📄 connparams.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 "ConnParams.h"
//LITERALS
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CConnParams::CConnParams()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CConnParams::CConnParams()
{
iWidth=0;
iHeight=0;
iPF=NULL;
}
// ---------------------------------------------------------------------------
// CConnParams::~CConnParams()
// Destructor.
// ---------------------------------------------------------------------------
//
CConnParams::~CConnParams()
{
if(iPF)
{
delete iPF;
iPF=NULL;
}
iEncodings.Close();
}
TBool CConnParams::ReadVersion(InStream* aIS)
{
RBuf8 buf;
buf.CreateMaxL(12);
TRAPD(err,aIS->ReadBytes(buf,0,12));
if(err==KErrNone)
{
if ((buf[0] != 'R') || (buf[1] != 'F') || (buf[2] != 'B') || (buf[3] != ' ')
|| (buf[4] < '0') || (buf[4] > '9') || (buf[5] < '0') || (buf[5] > '9')
|| (buf[6] < '0') || (buf[6] > '9') || (buf[7] != '.')
|| (buf[8] < '0') || (buf[8] > '9') || (buf[9] < '0') || (buf[9] > '9')
|| (buf[10] < '0') || (buf[10] > '9') || (buf[11] != '\n'))
{
buf.Close();
return EFalse;
}
}
else
{
buf.Close();
return EFalse;
}
iMajorVersion = (buf[4] - '0') * 100 + (buf[5] - '0') * 10 + (buf[6] - '0');
iMinorVersion = (buf[8] - '0') * 100 + (buf[9] - '0') * 10 + (buf[10] - '0');
buf.Close();
return ETrue;
}
void CConnParams::WriteVersion(OutStream* aOS)
{
RBuf8 buf;
buf.CreateMaxL(12);
buf[0] = 'R'; buf[1] = 'F'; buf[2] = 'B'; buf[3] = ' ';
buf[4] = ('0' + (iMajorVersion / 100) % 10);
buf[5] = ('0' + (iMajorVersion / 10) % 10);
buf[6] = ('0' + iMajorVersion % 10);
buf[7] = '.';
buf[8] = ('0' + (iMinorVersion / 100) % 10);
buf[9] = ('0' + (iMinorVersion / 10) % 10);
buf[10] = ('0' + iMinorVersion % 10);
buf[11] = '\n';
aOS->WriteBytes(buf,0,12);
aOS->Flush();
buf.Close();
}
void CConnParams::SetVersion(TInt aMajor,TInt aMinor)
{
iMajorVersion=aMajor;
iMinorVersion=aMinor;
}
TBool CConnParams::IsVersion(TInt aMajor,TInt aMinor)
{
return iMajorVersion==aMajor && iMinorVersion==aMinor;
}
TBool CConnParams::BeforeVersion(TInt aMajor,TInt aMinor)
{
return (iMajorVersion<aMajor ||
(iMajorVersion==aMajor && iMinorVersion<aMinor));
}
TBool CConnParams::AfterVersion(TInt aMajor,TInt aMinor)
{
return !BeforeVersion(aMajor,aMinor+1);
}
CPixelFormat* CConnParams::GetPF()
{
return iPF;
}
void CConnParams::SetPF(CPixelFormat* aPF)
{
if(iPF!=aPF)
{
if(iPF)
delete iPF;
iPF=aPF;
}
}
TEncodings CConnParams::GetCurrentEncoding()
{
return iCurrentEncoding;
}
TInt CConnParams::GetNEncodings()
{
return iNEncodings;
}
TInt CConnParams::EncodingNum(TDesC& aName)
{
if(aName.Compare(KEncodingRaw)==0) return EEncodingRaw;
if(aName.Compare(KEncodingCopyRect)==0) return EEncodingCopyRect;
if(aName.Compare(KEncodingRRE)==0) return EEncodingRRE;
if(aName.Compare(KEncodingCoRRE)==0) return EEncodingCoRRE;
if(aName.Compare(KEncodingHextile)==0) return EEncodingHextile;
if(aName.Compare(KEncodingZRLE)==0) return EEncodingZRLE;
return -1;
}
const TDesC& CConnParams::EncodingName(TEncodings aEncoding)
{
switch(aEncoding)
{
case EEncodingRaw : return KEncodingRaw;
case EEncodingCopyRect : return KEncodingCopyRect;
case EEncodingRRE : return KEncodingRRE;
case EEncodingCoRRE : return KEncodingCoRRE;
case EEncodingHextile : return KEncodingHextile;
case EEncodingZRLE : return KEncodingZRLE;
}
}
RArray<TEncodings> CConnParams::GetEncodings()
{
return iEncodings;
}
void CConnParams::SetEncodings(TInt aNEncodings,RArray<TEncodings>& aEncodings)
{
if(aNEncodings>iNEncodings)
{
iEncodings.Reset();
}
iNEncodings=aNEncodings;
iUseCopyRect=EFalse;
iSupportsLocalCursor=EFalse;
iSupportsDesktopResize=EFalse;
iCurrentEncoding=EEncodingRaw;
for(TInt i=0;i<iNEncodings;i++)
{
iEncodings[i]=aEncodings[i];
if (aEncodings[i]==EEncodingCopyRect)
iUseCopyRect=ETrue;
else if(aEncodings[i]==EEncodingPseudoEncodingCursor)
iSupportsLocalCursor=ETrue;
else if(aEncodings[i]==EEncodingPseudoEncodingDesktopSize)
iSupportsDesktopResize=ETrue;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -