kerneltest/e32test/window/t_colour.cpp
changeset 0 a41df078684a
child 271 dc268b18d709
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // e32test\window\t_colour.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <e32twin.h>
       
    20 #include <e32debug.h>
       
    21 
       
    22 class ColorTest
       
    23 	{
       
    24 public:
       
    25 	void ModesAndText(TVideoMode aMode);
       
    26 	void Colors();
       
    27 	RConsole con;
       
    28 	};
       
    29 
       
    30 void ColorTest::ModesAndText(TVideoMode aMode)
       
    31 	{
       
    32 
       
    33 	TInt r=con.SetMode(aMode);
       
    34 	con.SetCursorPosAbs(TPoint(1,4));
       
    35 	if(r!=KErrNone)
       
    36         {
       
    37 		con.Write(_L("Not supported."));
       
    38     	TConsoleKey key;
       
    39 	    con.Read(key);
       
    40         }
       
    41 	else
       
    42 		{
       
    43 		con.Write(_L("Normal text..."));
       
    44 		con.SetCursorPosAbs(TPoint(1,6));
       
    45 		con.SetTextAttribute(ETextAttributeBold);
       
    46 		con.Write(_L("Bold text..."));
       
    47 		con.SetCursorPosAbs(TPoint(1,8));
       
    48 		con.SetTextAttribute(ETextAttributeInverse);
       
    49 		con.Write(_L("Inverted text..."));
       
    50 		con.SetCursorPosAbs(TPoint(1,10));
       
    51 		con.SetTextAttribute(ETextAttributeHighlight);
       
    52 		con.Write(_L("Highlighted text..."));
       
    53 		Colors();
       
    54 		}
       
    55 	con.ClearScreen();
       
    56 	con.SetTextAttribute(ETextAttributeNormal);
       
    57 	con.SetCursorPosAbs(TPoint(3,2));
       
    58 	}
       
    59 	
       
    60 void ColorTest::Colors()
       
    61 	{
       
    62 	RConsole col;
       
    63 
       
    64 	col.Create();
       
    65 	col.Control(_L("-Vis"));
       
    66 	col.Init(_L("Colours"),TSize(18,18));
       
    67 	col.Control(_L("+Max"));
       
    68 	col.SetWindowPosAbs(TPoint(1,0));
       
    69 	col.Control(_L("+Vis -Cursor"));
       
    70 	for(TInt t=0;t<256;t++)
       
    71 		{
       
    72 		if(!(t%16))
       
    73 			col.SetCursorPosAbs(TPoint(1,1+t/16));
       
    74 		col.SetTextColors(0,t);
       
    75 		col.Write(_L(" "));
       
    76 		}
       
    77 	TConsoleKey key;
       
    78 	col.Read(key);
       
    79 	col.Destroy();
       
    80 	}
       
    81 
       
    82 GLDEF_C TInt E32Main()
       
    83     {
       
    84 	ColorTest t;
       
    85 
       
    86 	TInt r = t.con.Init(_L("Colour Test"),TSize(28,12));
       
    87 	if (r != KErrNone)
       
    88 		{
       
    89 		RDebug::Printf("Could not create text console: %d", r);
       
    90 		return r;
       
    91 		}
       
    92 	
       
    93 	t.con.Control(_L("+Max"));
       
    94 	t.con.SetCursorPosAbs(TPoint(3,2));
       
    95 	t.con.Write(_L("Testing mode EMono:"));
       
    96 	t.ModesAndText(EMono);
       
    97 	t.con.Write(_L("Testing mode EGray4:"));
       
    98 	t.ModesAndText(EGray4);
       
    99 	t.con.Write(_L("Testing mode EGray16:"));
       
   100 	t.ModesAndText(EGray16);
       
   101 	t.con.Write(_L("Testing mode EColor256:"));
       
   102 	t.ModesAndText(EColor256);
       
   103 
       
   104 	return(0);
       
   105     }