|
1 /******************************************************************************* |
|
2 * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #ifndef SWTMENUITEM_H |
|
14 #define SWTMENUITEM_H |
|
15 |
|
16 |
|
17 #include "eswtwidgetscore.h" |
|
18 |
|
19 |
|
20 /** |
|
21 * CSwtMenuItem |
|
22 * @lib eswt |
|
23 */ |
|
24 NONSHARABLE_CLASS(CSwtMenuItem) |
|
25 : public CBase |
|
26 , public MSwtMenuItem |
|
27 { |
|
28 // Own methods |
|
29 public: |
|
30 /** |
|
31 * Two phase constructor. |
|
32 * @param aDisplay |
|
33 * @param aPeer |
|
34 * @param aParent |
|
35 * @param aIndex |
|
36 * @param aStyle |
|
37 * @return CSwtMenuItem* |
|
38 */ |
|
39 static CSwtMenuItem* NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer, |
|
40 MSwtMenu& aParent, TInt aIndex, TInt aStyle, TInt aCommandId = 0); |
|
41 |
|
42 protected: |
|
43 /** |
|
44 * First phase constructor. |
|
45 * @param aDisplay |
|
46 * @param aPeer |
|
47 * @param aParent |
|
48 * @param aIndex |
|
49 * @param aStyle |
|
50 */ |
|
51 inline CSwtMenuItem(MSwtDisplay& aDisplay, TSwtPeer aPeer, |
|
52 MSwtMenu& aParent, TInt aIndex, TInt aStyle, TInt aCommandId); |
|
53 |
|
54 /** |
|
55 * Destructor. |
|
56 */ |
|
57 virtual ~CSwtMenuItem(); |
|
58 |
|
59 /** |
|
60 * Second phase constructor. |
|
61 */ |
|
62 void ConstructL(); |
|
63 |
|
64 // From MSwtMenuItem |
|
65 public: |
|
66 TSwtPeer Dispose(); |
|
67 TSwtPeer JavaPeer() const; |
|
68 TBool GetSelection() const; |
|
69 void SetAcceleratorL(TInt aAccelerator); |
|
70 void SetEnabled(TBool aEnabled); |
|
71 void SetImageL(const MSwtImage* aImage); |
|
72 void SetMenuL(const MSwtMenu* aMenu); |
|
73 void SetSelection(TBool aSelected); |
|
74 void SetTextL(const TDesC& aText); |
|
75 TInt Accelerator() const; |
|
76 TBool IsEnabled() const; |
|
77 const MSwtImage* Image() const; |
|
78 void GetImageBitmapsL(CFbsBitmap*& aBitmap, CFbsBitmap*& aMask, const TSize& aSize); |
|
79 const MSwtMenu* Menu() const; |
|
80 const TDesC& Text() const; |
|
81 TInt CommandId() const; |
|
82 TInt Style() const; |
|
83 const MSwtMenu& Parent() const; |
|
84 void UpdatePaneL(CEikMenuPane& aPane, TSwtMenuItemData aDetail); |
|
85 |
|
86 private: |
|
87 /** |
|
88 * The current pane that displays the menu item. |
|
89 * NULL if not displayed. |
|
90 */ |
|
91 CEikMenuPane* Pane() const; |
|
92 |
|
93 /** |
|
94 * Search for radio sibblings in parent menu. |
|
95 */ |
|
96 TInt FirstRadioSibbling() const; |
|
97 TInt LastRadioSibbling() const; |
|
98 |
|
99 /** |
|
100 * Get ordinal index of this |
|
101 */ |
|
102 TInt Index() const; |
|
103 |
|
104 /** |
|
105 * Remove item from pane. |
|
106 */ |
|
107 void CleanPane() const; |
|
108 |
|
109 // Data |
|
110 private: |
|
111 /** |
|
112 * Current display. |
|
113 */ |
|
114 MSwtDisplay& iDisplay; |
|
115 |
|
116 /** |
|
117 * Java peer. |
|
118 */ |
|
119 const TSwtPeer iPeer; |
|
120 |
|
121 /** |
|
122 * Parent menu. |
|
123 */ |
|
124 MSwtMenu& iParent; |
|
125 |
|
126 /** |
|
127 * Index of the item. |
|
128 */ |
|
129 TInt iIndexOfCreation; |
|
130 |
|
131 /** |
|
132 * Style flags. |
|
133 */ |
|
134 TInt iStyle; |
|
135 |
|
136 /** |
|
137 * For radio and checkbox. |
|
138 */ |
|
139 TBool iSelected; |
|
140 |
|
141 /** |
|
142 * Accelerator. |
|
143 */ |
|
144 TInt iAccelerator; |
|
145 |
|
146 /** |
|
147 * Enablement flag. |
|
148 */ |
|
149 TBool iEnabled; |
|
150 |
|
151 /** |
|
152 * Item title. |
|
153 * Own. |
|
154 */ |
|
155 HBufC* iText; |
|
156 |
|
157 /** |
|
158 * Command id. |
|
159 */ |
|
160 TInt iCommandId; |
|
161 |
|
162 /** |
|
163 * Item image. Ref counted, may be NULL. |
|
164 * Not own. |
|
165 */ |
|
166 const MSwtImage* iImage; |
|
167 |
|
168 /** |
|
169 * Contained menu. May be NULL. |
|
170 * Not own. |
|
171 */ |
|
172 const MSwtMenu* iMenu; |
|
173 |
|
174 /** |
|
175 * Contained dummy image mask. May be NULL. |
|
176 */ |
|
177 CFbsBitmap* iDummyMask; |
|
178 |
|
179 /** |
|
180 * Used to keep track of image subreferences. The reson for using an array |
|
181 * here is not knowing when the menu panes get closed and further not knowing |
|
182 * on what screen those menu panes are open. So we must cache all the sizes |
|
183 * needed and remove the references only when the image is changed or the |
|
184 * menu item is destroyed. |
|
185 */ |
|
186 RArray<TSize> iImageSizes; |
|
187 }; |
|
188 |
|
189 #endif // SWTMENUITEM_H |