sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\window\t_colour.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class ColorTest sl@0: { sl@0: public: sl@0: void ModesAndText(TVideoMode aMode); sl@0: void Colors(); sl@0: RConsole con; sl@0: }; sl@0: sl@0: void ColorTest::ModesAndText(TVideoMode aMode) sl@0: { sl@0: sl@0: TInt r=con.SetMode(aMode); sl@0: con.SetCursorPosAbs(TPoint(1,4)); sl@0: if(r!=KErrNone) sl@0: { sl@0: con.Write(_L("Not supported.")); sl@0: TConsoleKey key; sl@0: con.Read(key); sl@0: } sl@0: else sl@0: { sl@0: con.Write(_L("Normal text...")); sl@0: con.SetCursorPosAbs(TPoint(1,6)); sl@0: con.SetTextAttribute(ETextAttributeBold); sl@0: con.Write(_L("Bold text...")); sl@0: con.SetCursorPosAbs(TPoint(1,8)); sl@0: con.SetTextAttribute(ETextAttributeInverse); sl@0: con.Write(_L("Inverted text...")); sl@0: con.SetCursorPosAbs(TPoint(1,10)); sl@0: con.SetTextAttribute(ETextAttributeHighlight); sl@0: con.Write(_L("Highlighted text...")); sl@0: Colors(); sl@0: } sl@0: con.ClearScreen(); sl@0: con.SetTextAttribute(ETextAttributeNormal); sl@0: con.SetCursorPosAbs(TPoint(3,2)); sl@0: } sl@0: sl@0: void ColorTest::Colors() sl@0: { sl@0: RConsole col; sl@0: sl@0: col.Create(); sl@0: col.Control(_L("-Vis")); sl@0: col.Init(_L("Colours"),TSize(18,18)); sl@0: col.Control(_L("+Max")); sl@0: col.SetWindowPosAbs(TPoint(1,0)); sl@0: col.Control(_L("+Vis -Cursor")); sl@0: for(TInt t=0;t<256;t++) sl@0: { sl@0: if(!(t%16)) sl@0: col.SetCursorPosAbs(TPoint(1,1+t/16)); sl@0: col.SetTextColors(0,t); sl@0: col.Write(_L(" ")); sl@0: } sl@0: TConsoleKey key; sl@0: col.Read(key); sl@0: col.Destroy(); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: ColorTest t; sl@0: sl@0: TInt r = t.con.Init(_L("Colour Test"),TSize(28,12)); sl@0: if (r != KErrNone) sl@0: { sl@0: RDebug::Printf("Could not create text console: %d", r); sl@0: return r; sl@0: } sl@0: sl@0: t.con.Control(_L("+Max")); sl@0: t.con.SetCursorPosAbs(TPoint(3,2)); sl@0: t.con.Write(_L("Testing mode EMono:")); sl@0: t.ModesAndText(EMono); sl@0: t.con.Write(_L("Testing mode EGray4:")); sl@0: t.ModesAndText(EGray4); sl@0: t.con.Write(_L("Testing mode EGray16:")); sl@0: t.ModesAndText(EGray16); sl@0: t.con.Write(_L("Testing mode EColor256:")); sl@0: t.ModesAndText(EColor256); sl@0: sl@0: return(0); sl@0: }