|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Splits layout chain by visual |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef T_GLXLAYOUTSPLITTER_H |
|
22 #define T_GLXLAYOUTSPLITTER_H |
|
23 |
|
24 #include <glxlayout.h> |
|
25 #include <mglxvisuallistobserver.h> |
|
26 |
|
27 class CAlfVisual; |
|
28 |
|
29 /** |
|
30 * TGlxLayoutSplitter |
|
31 * |
|
32 * Splits the layout chain based on a visual. Client can define |
|
33 * any number of visual-layout pairs, and a default layout |
|
34 * for the rest. |
|
35 * |
|
36 * @lib glxlayouts.lib |
|
37 */ |
|
38 class TGlxLayoutSplitter : public TGlxLayout, public MGlxVisualListObserver |
|
39 { |
|
40 public: |
|
41 |
|
42 /** |
|
43 * Constructor. Resets the values |
|
44 */ |
|
45 IMPORT_C TGlxLayoutSplitter(); |
|
46 |
|
47 /** |
|
48 * Destructor |
|
49 */ |
|
50 IMPORT_C ~TGlxLayoutSplitter(); |
|
51 |
|
52 /** |
|
53 * Sets the visual list for the splitter. |
|
54 * Must be called before using the splitter |
|
55 * @param aVisualList the visual list that this layout should deal with |
|
56 */ |
|
57 IMPORT_C void SetVisualListL( MGlxVisualList* aVisualList ); |
|
58 |
|
59 /** |
|
60 * Sets a layout that is bound to a visual |
|
61 * @param aVisual the visual that this layout should deal with |
|
62 */ |
|
63 |
|
64 //Changed the API from AddLayout to SetLayout |
|
65 IMPORT_C void SetLayoutL( |
|
66 MGlxLayout* aLayout, const CAlfVisual* aVisual ); |
|
67 |
|
68 /** |
|
69 * Removes a layout that is bound to a visual |
|
70 * @param aVisual the visual that this layout should deal with |
|
71 */ |
|
72 IMPORT_C void RemoveLayout( const CAlfVisual* aVisual ); |
|
73 |
|
74 /** |
|
75 * Sets the default layout. This layout is used when the |
|
76 * visual being evaluated is not linked to another layout |
|
77 * (by calling AddLayoutL). If default layout has not been |
|
78 * defined, the layout will fall through, i.e., values and |
|
79 * index will not be modified (for non-lined visuals). |
|
80 * @param aLayout layout pointer or null if client want's to |
|
81 * undefine default layout. |
|
82 */ |
|
83 IMPORT_C void SetDefaultLayout( MGlxLayout* aLayout ); |
|
84 |
|
85 /** |
|
86 * Remove all layouts and remove association with visual list. |
|
87 */ |
|
88 IMPORT_C void Reset(); |
|
89 |
|
90 protected: // From TGlxLayout |
|
91 |
|
92 /// @ref TGlxLayout::DoSetLayoutValues |
|
93 void DoSetLayoutValues( TGlxLayoutInfo& aInfo ); |
|
94 |
|
95 public: // From MGlxVisualListObserver |
|
96 |
|
97 /// @ref MGlxVisualListObserver::DoSetLayoutValues |
|
98 void HandleFocusChangedL( |
|
99 TInt aFocusIndex, TReal32 aItemsPerSecond, MGlxVisualList* aList, |
|
100 NGlxListDefs::TFocusChangeType aType ); |
|
101 /// @ref MGlxVisualListObserver::HandleSizeChanged |
|
102 void HandleSizeChanged( const TSize& aSize, MGlxVisualList* aList ); |
|
103 /// @ref MGlxVisualListObserver::HandleVisualRemoved |
|
104 void HandleVisualRemoved( |
|
105 const CAlfVisual* aVisual, MGlxVisualList* aList ); |
|
106 /// @ref MGlxVisualListObserver::HandleVisualAddedL |
|
107 void HandleVisualAddedL( |
|
108 CAlfVisual* aVisual, TInt aIndex, MGlxVisualList* aList ); |
|
109 |
|
110 private: |
|
111 |
|
112 // Helper fo get the layout that corresponds to given visual |
|
113 MGlxLayout* Layout( const CAlfVisual* aVisual ) const; |
|
114 // Helper fo get the layoutindex that corresponds to given visual |
|
115 TInt LayoutIndex( const CAlfVisual* aVisual ) const; |
|
116 |
|
117 private: |
|
118 |
|
119 /** |
|
120 * Helper struct to store the layout and visual |
|
121 */ |
|
122 struct TLayout |
|
123 { |
|
124 /// Ref: the layout |
|
125 MGlxLayout* iLayout; |
|
126 /// Ref: the visual |
|
127 const CAlfVisual* iVisual; |
|
128 /** |
|
129 * Helper to tell whether two TLayout structs match |
|
130 */ |
|
131 static TBool Match( const TLayout& aLhs, const TLayout& aRhs ); |
|
132 }; |
|
133 /// Own: the layout-visual structs |
|
134 RArray< TLayout > iLayouts; |
|
135 /// Ref: the default layout |
|
136 MGlxLayout* iDefaultLayout; |
|
137 /// Ref: the visual list |
|
138 MGlxVisualList* iVisualList; |
|
139 |
|
140 }; |
|
141 |
|
142 #endif // T_GLXLAYOUTSPLITTER_H |