66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2007 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: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CMIDCONTROLITEM_H
|
|
20 |
#define CMIDCONTROLITEM_H
|
|
21 |
|
|
22 |
#include <gdi.h>
|
|
23 |
#include <coecntrl.h>
|
|
24 |
#include <fepbase.h> // for MCoeCaptionRetrieverForFep
|
|
25 |
|
|
26 |
// for CMIDForm::TDirection as parameter of PostFocusTransferEvent function
|
|
27 |
#include "CMIDForm.h"
|
|
28 |
// CMIDItem inheritance in class declaration
|
|
29 |
#include "CMIDItem.h"
|
|
30 |
|
|
31 |
class CMIDItemLabel;
|
|
32 |
class MAknsControlContext;
|
|
33 |
class CAknsFrameBackgroundControlContext;
|
|
34 |
|
|
35 |
NONSHARABLE_CLASS(CMIDControlItem) : public CMIDItem, public MCoeCaptionRetrieverForFep
|
|
36 |
{
|
|
37 |
public:
|
|
38 |
virtual ~CMIDControlItem();
|
|
39 |
//
|
|
40 |
// From CMIDItem
|
|
41 |
//
|
|
42 |
virtual TBool IsSelectable() const;
|
|
43 |
virtual void SetLabelL(const TDesC& aLabel);
|
|
44 |
|
|
45 |
virtual TInt LabelHeight() const;
|
|
46 |
inline void SetSizeQuiet(const TSize& aSize); // won't call SizeChanged
|
|
47 |
inline void SetPositionQuiet(const TPoint& aPosition); // won't call PositionChanged
|
|
48 |
|
|
49 |
|
|
50 |
// Returns height of a label that has only one line of text
|
|
51 |
TInt OneLineLabelHeight() const;
|
|
52 |
|
|
53 |
// from CCoeControl
|
|
54 |
virtual void SetContainerWindowL(const CCoeControl& aContainer);
|
|
55 |
void SetFocus(TBool aFocus, TDrawNow aDrawNow = ENoDrawNow);
|
|
56 |
virtual void FocusChanged(TDrawNow aDrawNow);
|
|
57 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
58 |
|
|
59 |
// From MCoeCaptionRetrieverForFep
|
|
60 |
void GetCaptionForFep(TDes& aCaption) const;
|
|
61 |
|
|
62 |
void SetLabelColor(CMIDItemLabel* aLabelControl);
|
|
63 |
|
|
64 |
//
|
|
65 |
// Resets the preferred size. This is called on all items at the beginning of form layout.
|
|
66 |
// This means we can fiddle with the preferred size of items during layout.
|
|
67 |
// Returns the new preferred size.
|
|
68 |
//
|
|
69 |
virtual TSize ResetPreferredSize() const;
|
|
70 |
virtual void AdjustToNewWidthL(TInt aWidth);
|
|
71 |
virtual void AdjustToSizeL(const TSize& aSize);
|
|
72 |
inline virtual CMIDItemLabel* LabelControl();
|
|
73 |
|
|
74 |
virtual TRect FocusableRect(); // returns a rect that should be partially visible for an Item to have focus
|
|
75 |
|
|
76 |
virtual void ResolutionChange(TInt aType); // this is called when resolution is changed
|
|
77 |
virtual void ColorChange(TInt aType); //this is called when there is a skin or color scheme change
|
|
78 |
|
|
79 |
/**
|
|
80 |
* @return ETrue if label exists and is not empty
|
|
81 |
*/
|
|
82 |
TBool HasLabel();
|
|
83 |
|
|
84 |
/**
|
|
85 |
* The function is being invoked after form has changed focus of the component.
|
|
86 |
* Subclasses of CMIDControlItem may override the default implementation to be notified about the focus transfer.
|
|
87 |
* @param aFocus true if the component has gained focus
|
|
88 |
* @param aDirection TDirection
|
|
89 |
*/
|
|
90 |
virtual void PostFocusTransferEvent(TBool aFocus,CMIDForm::TDirection aDirection);
|
|
91 |
|
|
92 |
/**
|
|
93 |
* The method is invoked from CMIDForm::HandleResourceChange when there is a need
|
|
94 |
* to restore the focus inside the item (if the item has its own subitems).
|
|
95 |
* (For instance there is focus on ChoiceGroupItem inside the form with inner focus
|
|
96 |
* to some sub-item. After the resolution change the main focus on form item is restored,
|
|
97 |
* but focused sub-item would be below the screen, so this method is called in order
|
|
98 |
* to restore focus on sub-item.)
|
|
99 |
* Every form item, which is able to focus its own internal sub-items should
|
|
100 |
* implement this method.
|
|
101 |
*/
|
|
102 |
virtual void RestoreInnerFocus();
|
|
103 |
|
|
104 |
/**
|
|
105 |
* This method is called when the window server
|
|
106 |
* fades or unfades the current window
|
|
107 |
* @param aFaded true if the window is goiging to be faded, false if unfaded
|
|
108 |
*/
|
|
109 |
virtual void HandleWindowFade(TBool aFaded);
|
|
110 |
|
|
111 |
protected:
|
|
112 |
CMIDControlItem(MMIDItem::TLayout aLayout, CMIDUIManager* aUIManager);
|
|
113 |
void ConstructL();
|
|
114 |
|
|
115 |
TInt FormClientAreaWidth() const; // Width of form2_midp_field_pane (scroll bar excluded)
|
|
116 |
TRect FormClientAreaRect() const; // Layout of Rect of form2_midp_field_pane (scroll bar excluded)
|
|
117 |
TInt ItemContentBottomMargin() const; // Bottom margin of form2_midp_content_pane
|
|
118 |
|
|
119 |
public:
|
|
120 |
inline TBool GetVisibilityInForm();
|
|
121 |
inline void SetVisibilityInForm(const TBool aVisibility);
|
|
122 |
|
|
123 |
/**
|
|
124 |
* Sets the iHighlighted flag. Used by CMIDForm.
|
|
125 |
*/
|
|
126 |
inline void SetHighlight(const TBool aHighlight);
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Returns ETrue, if item is highlighted on Form.
|
|
130 |
*/
|
|
131 |
inline TBool IsHighlighted();
|
|
132 |
|
|
133 |
protected:
|
|
134 |
CCoeEnv* iCoeEnv;
|
|
135 |
CMIDItemLabel* iLabelControl; // The label for the control
|
|
136 |
|
|
137 |
// The background control context for when the item is highlighted
|
|
138 |
CAknsFrameBackgroundControlContext* iHighlightedBackgroundCc;
|
|
139 |
|
|
140 |
TBool iVisibilityInForm;
|
|
141 |
|
|
142 |
// This flag is true, if item on Form is currently highlighted.
|
|
143 |
// Flag is used for returning correct background content
|
|
144 |
// (see MopSupplyObject).
|
|
145 |
TBool iHighlighted;
|
|
146 |
};
|
|
147 |
|
|
148 |
inline void CMIDControlItem::SetSizeQuiet(const TSize& aSize)
|
|
149 |
{
|
|
150 |
iSize = aSize;
|
|
151 |
}
|
|
152 |
|
|
153 |
inline void CMIDControlItem::SetPositionQuiet(const TPoint& aPosition)
|
|
154 |
{
|
|
155 |
iPosition = aPosition;
|
|
156 |
}
|
|
157 |
|
|
158 |
inline CMIDItemLabel* CMIDControlItem::LabelControl()
|
|
159 |
{
|
|
160 |
return iLabelControl;
|
|
161 |
}
|
|
162 |
|
|
163 |
inline TBool CMIDControlItem::GetVisibilityInForm()
|
|
164 |
{
|
|
165 |
return iVisibilityInForm;
|
|
166 |
}
|
|
167 |
|
|
168 |
inline void CMIDControlItem::SetVisibilityInForm(const TBool aVisibility)
|
|
169 |
{
|
|
170 |
iVisibilityInForm = aVisibility;
|
|
171 |
}
|
|
172 |
|
|
173 |
inline void CMIDControlItem::SetHighlight(const TBool aHighlight)
|
|
174 |
{
|
|
175 |
iHighlighted = aHighlight;
|
|
176 |
}
|
|
177 |
|
|
178 |
inline TBool CMIDControlItem::IsHighlighted()
|
|
179 |
{
|
|
180 |
return iHighlighted;
|
|
181 |
}
|
|
182 |
|
|
183 |
#endif // CMIDCONTROLITEM_H
|