|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Stores list of AknLayoutFont pointers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "AknFontRegistry.h" |
|
21 #include <AknLayoutFont.h> |
|
22 |
|
23 // CONSTANTS |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CAknFontRegistry::CAknFontRegistry |
|
29 // C++ default constructor can NOT contain any code that |
|
30 // might leave. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CAknFontRegistry::CAknFontRegistry() : |
|
34 iArray() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CAknFontRegistry::NewL |
|
40 // Two-phased constructor. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CAknFontRegistry* CAknFontRegistry::NewL() |
|
44 { |
|
45 CAknFontRegistry* self = new( ELeave )CAknFontRegistry(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // Destructor |
|
51 CAknFontRegistry::~CAknFontRegistry() |
|
52 { |
|
53 iArray.Close(); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // Insert in order. It is assumed that the number of calls to IsRegister will |
|
58 // justify the overhead in performing the registration |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CAknFontRegistry::RegisterFont( const CAknLayoutFont* aFont ) |
|
62 { |
|
63 // All errors ignored. OOM is the only one that makes senses, and it should |
|
64 // fail gracefully in the case of OOM |
|
65 (void)iArray.InsertInAddressOrder( aFont ); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // Remove pointer from list. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CAknFontRegistry::DeRegisterFont( const CAknLayoutFont* aFont ) |
|
73 { |
|
74 TInt found = FindFont( aFont ); |
|
75 if ( found != KErrNotFound ) |
|
76 { |
|
77 iArray.Remove( found ); |
|
78 } |
|
79 // All error conditions ignored. Should fail quietly. |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // Check pointer is in the list |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TBool CAknFontRegistry::IsRegistered( const CFont* aFont ) const |
|
87 { |
|
88 return ( FindFont( aFont ) != KErrNotFound ) ; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // Private method to look for the pointer |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TInt CAknFontRegistry::FindFont( const CFont* aFont ) const |
|
96 { |
|
97 return iArray.FindInAddressOrder( aFont ); |
|
98 } |
|
99 |
|
100 // End of File |