|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Button for touch pane. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef BMTOUCHPANEBUTTON_H_ |
|
20 #define BMTOUCHPANEBUTTON_H_ |
|
21 |
|
22 #include <aknbutton.h> |
|
23 |
|
24 class MBubbleTouchPaneIconProvider; |
|
25 |
|
26 /** |
|
27 * Contains touch button data. |
|
28 * |
|
29 * @code |
|
30 * CBubbleTouchPaneButton* button = CBubbleTouchPaneButton::NewL( |
|
31 * iIconProvider); |
|
32 * CleanupStack::PushL( button ); |
|
33 * button->ConstructFromResouceL( reader ); |
|
34 * |
|
35 * CleanupStack::Pop( button ); |
|
36 * CleanupStack::PopAndDestroy(); // reader |
|
37 * |
|
38 * button->SetContainerWindowL( *this ); |
|
39 * button->SetObserver( this ); |
|
40 * button->ActivateL(); |
|
41 * @endcode |
|
42 * |
|
43 * @lib bubblemanager.lib |
|
44 * @since S60 S60 v5.0 |
|
45 */ |
|
46 |
|
47 NONSHARABLE_CLASS( CBubbleTouchPaneButton ) : public CAknButton |
|
48 { |
|
49 public: |
|
50 /** |
|
51 * Two-phased constructor. |
|
52 * @param aIconProvider the pointer to the icon provider |
|
53 * @param aFlags The flags for the button |
|
54 */ |
|
55 static CBubbleTouchPaneButton* NewL |
|
56 ( MBubbleTouchPaneIconProvider* aIconProvider, |
|
57 const TInt aFlags = 0 ); |
|
58 |
|
59 |
|
60 |
|
61 /** |
|
62 * Destructor. |
|
63 */ |
|
64 ~CBubbleTouchPaneButton(); |
|
65 |
|
66 public: |
|
67 /** |
|
68 * Returns command id of the button |
|
69 * |
|
70 * @since S60 ?S60_version |
|
71 * @param aPreviousState ?description |
|
72 */ |
|
73 TInt CommandId( TBool aPreviousState = EFalse ) const; |
|
74 |
|
75 /** |
|
76 * Checks does the button has the given command. |
|
77 * |
|
78 * @since S60 v5.0 |
|
79 * @param aCommand the command |
|
80 * @return The ETrue if command can be found from iCommands array |
|
81 */ |
|
82 TBool HasState( TInt aCommand ) const; |
|
83 |
|
84 /** |
|
85 * Constructs controls from a resource file. |
|
86 * |
|
87 * @param aReader The resource reader, with which to access the |
|
88 * control's resource values. |
|
89 */ |
|
90 void ConstructFromResouceL( TResourceReader& aReader ); |
|
91 |
|
92 /** |
|
93 * Sets the current state of the button. |
|
94 * |
|
95 * @since S60 v5.0 |
|
96 * @param aCommand the command |
|
97 * @param aDrawNow ETrue to redraw the button. |
|
98 */ |
|
99 void SetState( TInt aCommand, TBool aDrawNow ); |
|
100 |
|
101 /** |
|
102 * Sets button dimmed. |
|
103 * |
|
104 * @since S60 v5.0 |
|
105 * @param ?arg1 ?description |
|
106 */ |
|
107 void SetDimmed( TBool aDimmed ); |
|
108 |
|
109 /** |
|
110 * Handles a change to the control's resources. |
|
111 * |
|
112 * @param aType is a message UID value. |
|
113 */ |
|
114 void HandleResourceChange( TInt aType ); |
|
115 |
|
116 /** |
|
117 * Sets layout text and icon rectanble of the button. |
|
118 * |
|
119 * @param aLayoutText the layout text |
|
120 * @param aIconRect the rectangle of the button |
|
121 */ |
|
122 void SetLayout( const TAknLayoutText aLayoutText, |
|
123 const TRect aIconRect); |
|
124 |
|
125 /** |
|
126 * Sets correct graphics frame for button. |
|
127 * |
|
128 * @param frameId the button which is pressed |
|
129 */ |
|
130 TAknsItemID SelectPressedButton( TAknsItemID frameId )const; |
|
131 |
|
132 /** |
|
133 * Sets correct graphics frame for button. |
|
134 * |
|
135 * @param frameId the button which is dimmed |
|
136 */ |
|
137 TAknsItemID SelectDimmedButton( TAknsItemID frameId )const; |
|
138 protected: |
|
139 |
|
140 /** |
|
141 * C++ constructor for the one state button. |
|
142 * |
|
143 * @param aIconProvider the pointer to the icon provider |
|
144 * @param aFlags The flags for the button |
|
145 */ |
|
146 CBubbleTouchPaneButton( |
|
147 MBubbleTouchPaneIconProvider* aIconProvider, |
|
148 const TInt aFlags ); |
|
149 |
|
150 protected: |
|
151 //from base class CCoeControl |
|
152 /** |
|
153 * From CCoeControl. |
|
154 * Draws the control. Called by window server. |
|
155 */ |
|
156 void Draw(const TRect& aRect) const; |
|
157 |
|
158 private: |
|
159 /** |
|
160 * Symbian 2nd phase constructor. |
|
161 */ |
|
162 void ConstructL(); |
|
163 |
|
164 /** |
|
165 * Loads icons using the given icon provider |
|
166 * |
|
167 * @param aIconProvider the icon provider |
|
168 */ |
|
169 void LoadCustomIcons( MBubbleTouchPaneIconProvider& aIconProvider ); |
|
170 |
|
171 /** |
|
172 * Draw text and icon according to the layout. |
|
173 * |
|
174 * @param aGc the window graphics context |
|
175 */ |
|
176 void LayoutIconAndText( CWindowGc& aGc ) const; |
|
177 |
|
178 /** |
|
179 * Gets the correct text color. |
|
180 * |
|
181 * @param aPenColor the RGB colour value |
|
182 */ |
|
183 void GetTextColors( TRgb& aPenColor ) const; |
|
184 |
|
185 /** |
|
186 * Selects the correct text color. |
|
187 */ |
|
188 void SelectTextColor(); |
|
189 |
|
190 private: // data |
|
191 /** |
|
192 * Array of the button commands. |
|
193 */ |
|
194 RArray<TInt> iCommands; |
|
195 |
|
196 /** |
|
197 * Touch pane icon provider. |
|
198 * Not own. |
|
199 */ |
|
200 MBubbleTouchPaneIconProvider* iIconProvider; |
|
201 |
|
202 /** |
|
203 * Layout text |
|
204 */ |
|
205 TAknLayoutText iLayoutText; |
|
206 |
|
207 /** |
|
208 * Rectangle of the icon of the button. |
|
209 */ |
|
210 TRect iIconRect; |
|
211 }; |
|
212 |
|
213 #endif /*BMTOUCHPANEBUTTON_H_*/ |