os/kernelhwsrv/kernel/eka/ewsrv/co_twin.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kernel/eka/ewsrv/co_twin.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,230 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\ewsrv\co_twin.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "ws_std.h"
    1.22 +
    1.23 +extern "C"
    1.24 +EXPORT_C TAny* NewConsole()
    1.25 +//
    1.26 +// Create a new console window.
    1.27 +//
    1.28 +	{
    1.29 +	return new CConsoleTextWin;
    1.30 +	}
    1.31 +
    1.32 +CConsoleTextWin *CConsoleTextWin::NewL(const TDesC &aTitle,TSize aSize)
    1.33 +//
    1.34 +// Create a new console window. Leave on any error.
    1.35 +//
    1.36 +	{
    1.37 +
    1.38 +	CConsoleTextWin *pC=new(ELeave) CConsoleTextWin;
    1.39 +	User::LeaveIfError(pC->iConsole.Init(aTitle,aSize));
    1.40 +	return(pC);
    1.41 +	}
    1.42 +
    1.43 +CConsoleTextWin::CConsoleTextWin()
    1.44 +//
    1.45 +// Constrcutor
    1.46 +//
    1.47 +	{}
    1.48 +
    1.49 +CConsoleTextWin::~CConsoleTextWin()
    1.50 +//
    1.51 +// Destructor
    1.52 +//
    1.53 +	{
    1.54 +
    1.55 +	iConsole.Close();
    1.56 +	}
    1.57 +
    1.58 +TInt CConsoleTextWin::Create(const TDesC &aTitle,TSize aSize)
    1.59 +//
    1.60 +// Create a new console window.
    1.61 +//
    1.62 +	{
    1.63 +
    1.64 +	TInt r=iConsole.Init(aTitle,aSize);
    1.65 +	if (r==KErrNone)
    1.66 +		{
    1.67 +		r=iConsole.Control(_L("+Maximize +NewLine -Lock -Wrap"));
    1.68 +		}
    1.69 +	return(r);
    1.70 +	}
    1.71 +
    1.72 +void CConsoleTextWin::Read(TRequestStatus &aStatus)
    1.73 +//
    1.74 +// Asynchronous get keystroke from window
    1.75 +//
    1.76 +	{
    1.77 +
    1.78 +	iConsole.Read(iKey,aStatus);
    1.79 +	}
    1.80 +
    1.81 +
    1.82 +void ConsServerCheck(TInt aResult, TInt aLine)
    1.83 +	{
    1.84 +	if(aResult!=KErrNone)
    1.85 +		{
    1.86 +#ifdef _DEBUG
    1.87 +		RDebug::Printf("EConsServerFailed with %d at line %d",aResult,aLine);
    1.88 +#endif
    1.89 +		(void)aLine;
    1.90 +		Panic(EConsServerFailed);
    1.91 +		}
    1.92 +	}
    1.93 +
    1.94 +
    1.95 +void CConsoleTextWin::ReadCancel()
    1.96 +//
    1.97 +// Cancel asynchronous read request
    1.98 +//
    1.99 +	{
   1.100 +
   1.101 +	TInt r=iConsole.ReadCancel();
   1.102 +	ConsServerCheck(r,__LINE__);
   1.103 +	}
   1.104 +
   1.105 +void CConsoleTextWin::Write(const TDesC &aDes)
   1.106 +//
   1.107 +// Write to the console.
   1.108 +//
   1.109 +	{
   1.110 +
   1.111 +	TInt r=iConsole.Write(aDes);
   1.112 +	ConsServerCheck(r,__LINE__);
   1.113 +	}
   1.114 +
   1.115 +TPoint CConsoleTextWin::CursorPos() const
   1.116 +//
   1.117 +// Read current cursor position relative to the window
   1.118 +//
   1.119 +	{
   1.120 +
   1.121 +	TPoint p;
   1.122 +	TInt r=iConsole.CursorPos(p);
   1.123 +	ConsServerCheck(r,__LINE__);
   1.124 +	return(p);
   1.125 +	}
   1.126 +
   1.127 +void CConsoleTextWin::SetCursorPosAbs(const TPoint &aPosition)
   1.128 +//
   1.129 +// Position the cursor in the window buffer
   1.130 +//
   1.131 +	{
   1.132 +
   1.133 +	TInt r=iConsole.SetCursorPosAbs(aPosition);
   1.134 +	ConsServerCheck(r,__LINE__);
   1.135 +	}
   1.136 +
   1.137 +void CConsoleTextWin::SetCursorPosRel(const TPoint &aVector)
   1.138 +//
   1.139 +// Position the cursor in the window buffer
   1.140 +//
   1.141 +	{
   1.142 +
   1.143 +	TInt r=iConsole.SetCursorPosRel(aVector);
   1.144 +	ConsServerCheck(r,__LINE__);
   1.145 +	}
   1.146 +
   1.147 +void CConsoleTextWin::SetCursorHeight(TInt aPercentage)
   1.148 +//
   1.149 +// Set the percentage height of the cursor
   1.150 +//
   1.151 +	{
   1.152 +
   1.153 +	TInt r=iConsole.SetCursorHeight(aPercentage);
   1.154 +	ConsServerCheck(r,__LINE__);
   1.155 +	}
   1.156 +		
   1.157 +void CConsoleTextWin::SetTitle(const TDesC &aTitle)
   1.158 +//
   1.159 +// Set the console window title
   1.160 +//
   1.161 +	{
   1.162 +
   1.163 +	TInt r=iConsole.SetTitle(aTitle);
   1.164 +	ConsServerCheck(r,__LINE__);
   1.165 +	}
   1.166 +
   1.167 +void CConsoleTextWin::ClearScreen()
   1.168 +//
   1.169 +// Clear screen
   1.170 +//
   1.171 +	{
   1.172 +
   1.173 +	TInt r=iConsole.ClearScreen();
   1.174 +	ConsServerCheck(r,__LINE__);
   1.175 +	}
   1.176 +
   1.177 +void CConsoleTextWin::ClearToEndOfLine()
   1.178 +//
   1.179 +// Clear window from current cursor position to the end of the line
   1.180 +//
   1.181 +	{
   1.182 +
   1.183 +	TInt r=iConsole.ClearToEndOfLine();
   1.184 +	ConsServerCheck(r,__LINE__);
   1.185 +	}
   1.186 +
   1.187 +TSize CConsoleTextWin::ScreenSize() const
   1.188 +//
   1.189 +// Return the current screen size
   1.190 +//
   1.191 +	{
   1.192 +
   1.193 +	TSize s;
   1.194 +	TInt r=iConsole.Size(s);
   1.195 +	ConsServerCheck(r,__LINE__);
   1.196 +	return(s);
   1.197 +	}
   1.198 +
   1.199 +TKeyCode CConsoleTextWin::KeyCode() const
   1.200 +//
   1.201 +// Return the current keycode
   1.202 +//
   1.203 +	{
   1.204 +
   1.205 +	return(iKey.Code());
   1.206 +	}
   1.207 +
   1.208 +TUint CConsoleTextWin::KeyModifiers() const
   1.209 +//
   1.210 +// Return the current key modifiers
   1.211 +//
   1.212 +	{
   1.213 +
   1.214 +	return(iKey.Modifiers());
   1.215 +	}
   1.216 +
   1.217 +void CConsoleTextWin::SetTextAttribute(TTextAttribute anAttribute)
   1.218 +//
   1.219 +// Set text attribute
   1.220 +//
   1.221 +	{
   1.222 +
   1.223 +	iConsole.SetTextAttribute(anAttribute);
   1.224 +	}
   1.225 +
   1.226 +RConsole &CConsoleTextWin::Console()
   1.227 +//
   1.228 +// Return the console object.
   1.229 +//
   1.230 +	{
   1.231 +
   1.232 +	return(iConsole);
   1.233 +	}