271
|
1 |
// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies).
|
0
|
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 |
|
271
|
18 |
#define __E32TEST_EXTENSION__
|
|
19 |
|
0
|
20 |
#include <e32test.h>
|
|
21 |
#include <e32twin.h>
|
|
22 |
#include <e32debug.h>
|
271
|
23 |
#include <e32svr.h>
|
|
24 |
|
|
25 |
const TInt KNumColors=256;
|
|
26 |
|
|
27 |
LOCAL_D RTest test(_L("T_COLOUR"));
|
|
28 |
|
|
29 |
LOCAL_C void SimulateKeyPress(TStdScanCode aScanCode)
|
|
30 |
{
|
|
31 |
TRawEvent eventDown;
|
|
32 |
eventDown.Set(TRawEvent::EKeyDown, aScanCode);
|
|
33 |
UserSvr::AddEvent(eventDown);
|
|
34 |
TRawEvent eventUp;
|
|
35 |
eventUp.Set(TRawEvent::EKeyUp, aScanCode);
|
|
36 |
UserSvr::AddEvent(eventUp);
|
|
37 |
}
|
0
|
38 |
|
|
39 |
class ColorTest
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
void ModesAndText(TVideoMode aMode);
|
|
43 |
void Colors();
|
|
44 |
RConsole con;
|
|
45 |
};
|
|
46 |
|
|
47 |
void ColorTest::ModesAndText(TVideoMode aMode)
|
|
48 |
{
|
|
49 |
|
|
50 |
TInt r=con.SetMode(aMode);
|
|
51 |
con.SetCursorPosAbs(TPoint(1,4));
|
|
52 |
if(r!=KErrNone)
|
|
53 |
{
|
|
54 |
con.Write(_L("Not supported."));
|
271
|
55 |
test.Printf(_L("Not supported.\r\n"));
|
0
|
56 |
TConsoleKey key;
|
271
|
57 |
SimulateKeyPress(EStdKeyEnter);
|
|
58 |
con.Read(key);
|
0
|
59 |
}
|
|
60 |
else
|
|
61 |
{
|
|
62 |
con.Write(_L("Normal text..."));
|
|
63 |
con.SetCursorPosAbs(TPoint(1,6));
|
|
64 |
con.SetTextAttribute(ETextAttributeBold);
|
|
65 |
con.Write(_L("Bold text..."));
|
|
66 |
con.SetCursorPosAbs(TPoint(1,8));
|
|
67 |
con.SetTextAttribute(ETextAttributeInverse);
|
|
68 |
con.Write(_L("Inverted text..."));
|
|
69 |
con.SetCursorPosAbs(TPoint(1,10));
|
|
70 |
con.SetTextAttribute(ETextAttributeHighlight);
|
|
71 |
con.Write(_L("Highlighted text..."));
|
|
72 |
Colors();
|
|
73 |
}
|
|
74 |
con.ClearScreen();
|
|
75 |
con.SetTextAttribute(ETextAttributeNormal);
|
|
76 |
con.SetCursorPosAbs(TPoint(3,2));
|
|
77 |
}
|
|
78 |
|
|
79 |
void ColorTest::Colors()
|
|
80 |
{
|
|
81 |
RConsole col;
|
|
82 |
|
|
83 |
col.Create();
|
|
84 |
col.Control(_L("-Vis"));
|
|
85 |
col.Init(_L("Colours"),TSize(18,18));
|
|
86 |
col.Control(_L("+Max"));
|
|
87 |
col.SetWindowPosAbs(TPoint(1,0));
|
|
88 |
col.Control(_L("+Vis -Cursor"));
|
271
|
89 |
for(TInt t=0;t<KNumColors;t++)
|
0
|
90 |
{
|
|
91 |
if(!(t%16))
|
271
|
92 |
{
|
0
|
93 |
col.SetCursorPosAbs(TPoint(1,1+t/16));
|
271
|
94 |
}
|
0
|
95 |
col.SetTextColors(0,t);
|
|
96 |
col.Write(_L(" "));
|
|
97 |
}
|
271
|
98 |
|
|
99 |
for(TInt i=0;i<KNumColors;i++)
|
|
100 |
{
|
|
101 |
TUint8 red, green, blue;
|
|
102 |
col.GetPaletteEntry(i, red, green, blue);
|
|
103 |
}
|
|
104 |
|
|
105 |
col.SetPaletteEntry(1,20,250,250);
|
|
106 |
|
|
107 |
TInt j = 0;
|
|
108 |
// Window background color
|
|
109 |
for(j=0;j<KNumColors;j++)
|
|
110 |
{
|
|
111 |
col.SetUIColors(j,0,0);
|
|
112 |
}
|
|
113 |
// Border color
|
|
114 |
for(j=0;j<KNumColors;j++)
|
|
115 |
{
|
|
116 |
col.SetUIColors(0,j,0);
|
|
117 |
}
|
|
118 |
// Screen color
|
|
119 |
for(j=0;j<KNumColors;j++)
|
|
120 |
{
|
|
121 |
col.SetUIColors(0,0,j);
|
|
122 |
}
|
|
123 |
|
0
|
124 |
TConsoleKey key;
|
271
|
125 |
SimulateKeyPress(EStdKeyEnter);
|
0
|
126 |
col.Read(key);
|
271
|
127 |
col.ClearScreen();
|
0
|
128 |
col.Destroy();
|
|
129 |
}
|
|
130 |
|
|
131 |
GLDEF_C TInt E32Main()
|
|
132 |
{
|
271
|
133 |
test.Title();
|
|
134 |
__UHEAP_MARK;
|
|
135 |
|
|
136 |
test.Start(_L("Testing RConsole"));
|
0
|
137 |
ColorTest t;
|
|
138 |
|
|
139 |
TInt r = t.con.Init(_L("Colour Test"),TSize(28,12));
|
|
140 |
if (r != KErrNone)
|
|
141 |
{
|
|
142 |
RDebug::Printf("Could not create text console: %d", r);
|
|
143 |
return r;
|
|
144 |
}
|
|
145 |
|
271
|
146 |
TInt ret = t.con.SetSize(TSize(10,10));
|
|
147 |
test_Equal(KErrNotSupported, ret);
|
|
148 |
|
0
|
149 |
t.con.Control(_L("+Max"));
|
|
150 |
t.con.SetCursorPosAbs(TPoint(3,2));
|
271
|
151 |
test.Next(_L("Testing mode EMono:"));
|
0
|
152 |
t.con.Write(_L("Testing mode EMono:"));
|
|
153 |
t.ModesAndText(EMono);
|
271
|
154 |
test.Next(_L("Testing mode EGray4:"));
|
0
|
155 |
t.con.Write(_L("Testing mode EGray4:"));
|
|
156 |
t.ModesAndText(EGray4);
|
271
|
157 |
test.Next(_L("Testing mode EGray16:"));
|
0
|
158 |
t.con.Write(_L("Testing mode EGray16:"));
|
|
159 |
t.ModesAndText(EGray16);
|
271
|
160 |
test.Next(_L("Testing mode EColor256:"));
|
0
|
161 |
t.con.Write(_L("Testing mode EColor256:"));
|
|
162 |
t.ModesAndText(EColor256);
|
271
|
163 |
test.Next(_L("Testing mode EColor4K:"));
|
|
164 |
t.con.Write(_L("Testing mode EColor4K:"));
|
|
165 |
t.ModesAndText(EColor4K);
|
|
166 |
test.Next(_L("Testing mode EColor64K:"));
|
|
167 |
t.con.Write(_L("Testing mode EColor64K:"));
|
|
168 |
t.ModesAndText(EColor64K);
|
|
169 |
test.Next(_L("Testing mode EColor16M:"));
|
|
170 |
t.con.Write(_L("Testing mode EColor16M:"));
|
|
171 |
t.ModesAndText(EColor16M);
|
|
172 |
|
|
173 |
__UHEAP_MARKEND;
|
|
174 |
test.End();
|
0
|
175 |
return(0);
|
|
176 |
}
|