|
1 /* |
|
2 * Copyright (c) 2003 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 #include <coemain.h> |
|
20 // |
|
21 #include "CMIDSpacer.h" |
|
22 |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CMIDSpacer* CMIDSpacer::NewL(const TSize& aMinimumSize, CMIDUIManager* aUIManager) |
|
29 { |
|
30 CMIDSpacer* item = new(ELeave) CMIDSpacer(aUIManager); |
|
31 CleanupStack::PushL(item); |
|
32 item->ConstructL(aMinimumSize); |
|
33 CleanupStack::Pop(item); |
|
34 return item; |
|
35 } |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CMIDSpacer::CMIDSpacer(CMIDUIManager* aUIManager) |
|
41 :CMIDControlItem(EDefault, aUIManager) |
|
42 { |
|
43 iMMidItem = this; |
|
44 } |
|
45 |
|
46 void CMIDSpacer::ConstructL(const TSize& aMinimumSize) |
|
47 { |
|
48 CMIDControlItem::ConstructL(); |
|
49 SetMinimumSizeL(aMinimumSize); |
|
50 SetFocusing(EFalse); |
|
51 } |
|
52 |
|
53 TBool CMIDSpacer::IsSelectable() const |
|
54 { |
|
55 return EFalse; |
|
56 } |
|
57 |
|
58 TSize CMIDSpacer::MinimumSize() |
|
59 { |
|
60 return iMinimumSize; |
|
61 } |
|
62 |
|
63 void CMIDSpacer::Draw(const TRect& /*aRect*/) const |
|
64 { |
|
65 } |
|
66 |
|
67 /** |
|
68 * If the preferred size is currently unlocked (i.e. has not been set) |
|
69 * this will return the minimum size. If the preferred size has been |
|
70 * locked then this will return the preferred size. |
|
71 */ |
|
72 TSize CMIDSpacer::PreferredSize() const |
|
73 { |
|
74 if (iPreferredSize.iHeight == -1 && iPreferredSize.iHeight == -1) |
|
75 { |
|
76 return MinimumSize(); |
|
77 } |
|
78 else |
|
79 { |
|
80 return iPreferredSize; |
|
81 } |
|
82 } |
|
83 |
|
84 /** |
|
85 * aSize is only ever TSize(0,0) or greater. If the new minimum size is |
|
86 * greater than the preferred size, then the preferred size needs to be |
|
87 * set equal to the min size. |
|
88 */ |
|
89 void CMIDSpacer::SetMinimumSizeL(const TSize& aSize) |
|
90 { |
|
91 iMinimumSize = aSize; |
|
92 } |
|
93 |
|
94 void CMIDSpacer::SetLabelL(const TDesC& /*aLabel*/) |
|
95 // |
|
96 // Never called |
|
97 // |
|
98 { |
|
99 ASSERT(EFalse); |
|
100 } |
|
101 |
|
102 void CMIDSpacer::SetLayoutL(TLayout aLayout) |
|
103 { |
|
104 CMIDControlItem::SetLayoutL(aLayout); |
|
105 } |
|
106 |
|
107 void CMIDSpacer::SetPreferredSizeL(const TSize& aSize) |
|
108 { |
|
109 CMIDItem::SetPreferredSize(aSize,MinimumSize()); |
|
110 } |
|
111 |
|
112 void CMIDSpacer::Dispose() |
|
113 { |
|
114 delete this; |
|
115 } |
|
116 |
|
117 void CMIDSpacer::AddCommandL(MMIDCommand* /*aCommand*/) |
|
118 // |
|
119 // Never called |
|
120 // |
|
121 { |
|
122 ASSERT(EFalse); |
|
123 } |
|
124 |
|
125 void CMIDSpacer::RemoveCommand(MMIDCommand* /*aCommand*/) |
|
126 // |
|
127 // Never called |
|
128 // |
|
129 { |
|
130 ASSERT(EFalse); |
|
131 } |
|
132 |
|
133 void CMIDSpacer::SetDefaultCommand(MMIDCommand* /*aCommand*/) |
|
134 // |
|
135 // Never called |
|
136 // |
|
137 { |
|
138 ASSERT(EFalse); |
|
139 } |
|
140 |
|
141 TSize CMIDSpacer::MinimumSize() const |
|
142 // |
|
143 // Initially TSize(0,0) until actually set |
|
144 // |
|
145 { |
|
146 CCoeControl* control = const_cast<CMIDSpacer*>(this); |
|
147 return control->MinimumSize(); |
|
148 } |
|
149 |
|
150 TInt CMIDSpacer::ItemPreferredHeightWithoutLabel() |
|
151 { |
|
152 return iMinimumSize.iHeight; |
|
153 } |
|
154 |
|
155 void CMIDSpacer::SetUsedForStringFormatting(TBool iVal) |
|
156 { |
|
157 iUsedForStringFormatting = iVal; |
|
158 } |
|
159 |
|
160 TBool CMIDSpacer::UsedForStringFormatting() |
|
161 { |
|
162 return iUsedForStringFormatting; |
|
163 } |