os/kernelhwsrv/kernel/eka/ewsrv/co_cli.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_cli.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,318 @@
     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_cli.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include "ws_std.h"
    1.22 +
    1.23 +TInt RConsole::Connect()
    1.24 +	{
    1.25 +	return CreateSession(KE32WindowServer,Version(),KMessageSlots);
    1.26 +	}
    1.27 +
    1.28 +EXPORT_C TInt RConsole::Create()
    1.29 +//
    1.30 +// Connect with the window server if connection not already made,
    1.31 +// then create a default console window without displaying it
    1.32 +//
    1.33 +	{
    1.34 +
    1.35 +	if (Handle()==KNullHandle)
    1.36 +		{
    1.37 +		TInt r = Connect();
    1.38 +		if (r!=KErrNone)
    1.39 +			return r;
    1.40 +		}
    1.41 +	return SendReceive(CWsSession::EConsoleCreate, TIpcArgs());
    1.42 +	}
    1.43 +
    1.44 +EXPORT_C TInt RConsole::Init(const TDesC &aName,const TSize &aSize)
    1.45 +//
    1.46 +// Connect with the window server if connection not already made,
    1.47 +// then open/display a console window on with the specified title.
    1.48 +//
    1.49 +	{
    1.50 +
    1.51 +	if (Handle()==KNullHandle)
    1.52 +		{
    1.53 +		TInt r = Connect();
    1.54 +		if (r!=KErrNone)
    1.55 +			return r;
    1.56 +		}
    1.57 +	TPckgC<TSize> size(aSize);
    1.58 +	return SendReceive(CWsSession::EConsoleSet, TIpcArgs(&aName, &size));
    1.59 +	}
    1.60 +
    1.61 +EXPORT_C TInt RConsole::SetTitle(const TDesC &aName)
    1.62 +//
    1.63 +// Change the title of the window
    1.64 +//
    1.65 +	{
    1.66 +
    1.67 +	return SendReceive(CWsSession::EConsoleSetTitle, TIpcArgs(&aName));
    1.68 +	}
    1.69 +
    1.70 +EXPORT_C TInt RConsole::SetSize(const TSize &aSize)
    1.71 +//
    1.72 +// Change the underlying size of the window
    1.73 +//
    1.74 +	{
    1.75 +
    1.76 +	TPckgC<TSize> size(aSize);
    1.77 +	return SendReceive(CWsSession::EConsoleSetSize, TIpcArgs(&size));
    1.78 +	}
    1.79 +
    1.80 +EXPORT_C TInt RConsole::Size(TSize &aSize) const
    1.81 +//
    1.82 +// Read the current window size
    1.83 +//
    1.84 +	{
    1.85 +
    1.86 +	TPckg<TSize> size(aSize);
    1.87 +	return SendReceive(CWsSession::EConsoleSize, TIpcArgs( (TDes8*)&size ));
    1.88 +	}
    1.89 +
    1.90 +EXPORT_C TInt RConsole::ScreenSize(TSize &aSize) const
    1.91 +//
    1.92 +// Read the screen size in characters
    1.93 +//
    1.94 +	{
    1.95 +	
    1.96 +	TPckg<TSize> size(aSize);
    1.97 +	return SendReceive(CWsSession::EConsoleScreenSize, TIpcArgs( (TDes8*)&size ));
    1.98 +	}
    1.99 +
   1.100 +EXPORT_C TVersion RConsole::Version()
   1.101 +//
   1.102 +// Return the client side version number.
   1.103 +//
   1.104 +	{
   1.105 +
   1.106 +	return TVersion(KW32MajorVersionNumber,KW32MinorVersionNumber,KE32BuildVersionNumber);
   1.107 +	}
   1.108 +
   1.109 +EXPORT_C TInt RConsole::Write(const TDesC &aDes)
   1.110 +//
   1.111 +// Write to the console.
   1.112 +//
   1.113 +	{
   1.114 +
   1.115 +	return SendReceive(CWsSession::EConsoleWrite, TIpcArgs(&aDes));
   1.116 +	}
   1.117 +
   1.118 +EXPORT_C TInt RConsole::ClearScreen()
   1.119 +//
   1.120 +// Clear window
   1.121 +//
   1.122 +	{
   1.123 +
   1.124 +	return SendReceive(CWsSession::EConsoleClearScreen, TIpcArgs());
   1.125 +	}
   1.126 +
   1.127 +EXPORT_C TInt RConsole::ClearToEndOfLine()
   1.128 +//
   1.129 +// Clear window from current cursor position to the end of the line
   1.130 +//
   1.131 +	{
   1.132 +
   1.133 +	return SendReceive(CWsSession::EConsoleClearToEndOfLine, TIpcArgs());
   1.134 +	}
   1.135 +
   1.136 +EXPORT_C TInt RConsole::Destroy()
   1.137 +//
   1.138 +// Remove and close down the window
   1.139 +//
   1.140 +	{
   1.141 +
   1.142 +	return SendReceive(CWsSession::EConsoleDestroy, TIpcArgs());
   1.143 +	}
   1.144 +
   1.145 +EXPORT_C TInt RConsole::SetWindowPosAbs(const TPoint &aPosition)
   1.146 +//
   1.147 +// Position the window
   1.148 +//
   1.149 +	{
   1.150 +	
   1.151 +	TPckgC<TPoint> point(aPosition);
   1.152 +	return SendReceive(CWsSession::EConsoleSetWindowPosAbs, TIpcArgs(&point));
   1.153 +	}
   1.154 +
   1.155 +EXPORT_C TInt RConsole::SetCursorHeight(TInt aPercentage)
   1.156 +//
   1.157 +// Set the percentage height of the cursor
   1.158 +//
   1.159 +	{
   1.160 +
   1.161 +	return SendReceive(CWsSession::EConsoleSetCursorHeight, TIpcArgs(aPercentage));
   1.162 +	}
   1.163 +		
   1.164 +EXPORT_C TInt RConsole::SetCursorPosAbs(const TPoint &aPosition)
   1.165 +//
   1.166 +// Position the cursor in the window buffer
   1.167 +//
   1.168 +	{
   1.169 +
   1.170 +	TPckgC<TPoint> point(aPosition);
   1.171 +	return SendReceive(CWsSession::EConsoleSetCursorPosAbs, TIpcArgs(&point));
   1.172 +	}
   1.173 +
   1.174 +EXPORT_C TInt RConsole::SetCursorPosRel(const TPoint &aVector)
   1.175 +//
   1.176 +// Position the cursor in the window buffer
   1.177 +//
   1.178 +	{
   1.179 +
   1.180 +	TPckg<TPoint> point(aVector);
   1.181 +	return SendReceive(CWsSession::EConsoleSetCursorPosRel, TIpcArgs(&point));
   1.182 +	}
   1.183 +
   1.184 +EXPORT_C TInt RConsole::CursorPos(TPoint &aPosition) const
   1.185 +//
   1.186 +// Read current cursor position relative to the window
   1.187 +//
   1.188 +	{
   1.189 +
   1.190 +	TPckg<TPoint> point(aPosition);
   1.191 +	return SendReceive(CWsSession::EConsoleCursorPos, TIpcArgs( (TDes8*)&point ));
   1.192 +	}
   1.193 +
   1.194 +EXPORT_C TInt RConsole::Control(const TDesC &aDes)
   1.195 +//
   1.196 +// Control window properties
   1.197 +//
   1.198 +	{
   1.199 +
   1.200 +	return SendReceive(CWsSession::EConsoleControl, TIpcArgs(&aDes));
   1.201 +	}
   1.202 +
   1.203 +EXPORT_C TInt RConsole::Read(TConsoleKey &aKeystroke)
   1.204 +//
   1.205 +// Synchronous get keystroke from window
   1.206 +//
   1.207 +	{
   1.208 +
   1.209 +	return SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke ));
   1.210 +	}
   1.211 +
   1.212 +EXPORT_C void RConsole::Read(TConsoleKey &aKeystroke,TRequestStatus &aStatus)
   1.213 +//
   1.214 +// Asynchronous get keystroke from window
   1.215 +//
   1.216 +	{
   1.217 +
   1.218 +	SendReceive(CWsSession::EConsoleRead, TIpcArgs( (TDes8*)&aKeystroke ), aStatus);
   1.219 +	}
   1.220 +
   1.221 +EXPORT_C TInt RConsole::ReadCancel()
   1.222 +//
   1.223 +// Cancel asynchronous read request
   1.224 +//
   1.225 +	{
   1.226 +
   1.227 +	return SendReceive(CWsSession::EConsoleReadCancel, TIpcArgs());
   1.228 +	}
   1.229 +
   1.230 +EXPORT_C TInt RConsole::SetMode(TVideoMode aMode)
   1.231 +//
   1.232 +//
   1.233 +//
   1.234 +	{
   1.235 +	
   1.236 +	if (Handle()==KNullHandle)
   1.237 +		{
   1.238 +		TInt r = Connect();
   1.239 +		if (r!=KErrNone)
   1.240 +			return r;
   1.241 +		}
   1.242 +	return SendReceive(CWsSession::EConsoleSetMode, TIpcArgs(aMode));
   1.243 +	}
   1.244 +
   1.245 +EXPORT_C void RConsole::SetPaletteEntry(TUint aIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue)
   1.246 +//
   1.247 +//
   1.248 +//
   1.249 +	{
   1.250 +	
   1.251 +	if (Handle()==KNullHandle)
   1.252 +		{
   1.253 +		TInt r = Connect();
   1.254 +		if (r!=KErrNone)
   1.255 +			return;
   1.256 +		}
   1.257 +	SendReceive(CWsSession::EConsoleSetPaletteEntry, TIpcArgs(aIndex,aRed,aGreen,aBlue));
   1.258 +	}
   1.259 +
   1.260 +EXPORT_C void RConsole::GetPaletteEntry(TUint aIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue)
   1.261 +//
   1.262 +//
   1.263 +//
   1.264 +	{
   1.265 +	
   1.266 +	if (Handle()==KNullHandle)
   1.267 +		{
   1.268 +		TInt r = Connect();
   1.269 +		if (r!=KErrNone)
   1.270 +			return;
   1.271 +		}
   1.272 +	TPckg<TUint8> r(aRed);
   1.273 +	TPckg<TUint8> g(aGreen);
   1.274 +	TPckg<TUint8> b(aBlue);
   1.275 +	SendReceive(CWsSession::EConsoleGetPaletteEntry, TIpcArgs(aIndex, &r, &g, &b));
   1.276 +	}
   1.277 +
   1.278 +EXPORT_C void RConsole::SetTextColors(TUint aFgColor,TUint aBgColor)
   1.279 +//
   1.280 +//
   1.281 +//
   1.282 +	{
   1.283 +	
   1.284 +	if (Handle()==KNullHandle)
   1.285 +		{
   1.286 +		TInt r = Connect();
   1.287 +		if (r!=KErrNone)
   1.288 +			return;
   1.289 +		}
   1.290 +	SendReceive(CWsSession::EConsoleSetTextColors, TIpcArgs(aFgColor, aBgColor));
   1.291 +	}
   1.292 +
   1.293 +EXPORT_C void RConsole::SetUIColors(TUint aWindowBgColor,TUint aBorderColor,TUint aScreenColor)
   1.294 +//
   1.295 +//
   1.296 +//
   1.297 +	{
   1.298 +	
   1.299 +	if (Handle()==KNullHandle)
   1.300 +		{
   1.301 +		TInt r = Connect();
   1.302 +		if (r!=KErrNone)
   1.303 +			return;
   1.304 +		}
   1.305 +	SendReceive(CWsSession::EConsoleSetUIColors, TIpcArgs(aWindowBgColor, aBorderColor, aScreenColor));
   1.306 +	}
   1.307 +
   1.308 +EXPORT_C void RConsole::SetTextAttribute(TTextAttribute aAttr)
   1.309 +//
   1.310 +//
   1.311 +//
   1.312 +	{
   1.313 +
   1.314 +	if (Handle()==KNullHandle)
   1.315 +		{
   1.316 +		TInt r = Connect();
   1.317 +		if (r!=KErrNone)
   1.318 +			return;
   1.319 +		}
   1.320 +	SendReceive(CWsSession::EConsoleSetTextAttribute, TIpcArgs(aAttr));
   1.321 +	}