|
1 /* |
|
2 * Copyright (c) 1997-1999 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <barsread.h> |
|
20 #include <coemain.h> |
|
21 #include <coeccntx.h> |
|
22 #include "eikdlgtb.h" |
|
23 #include <eikcmobs.h> |
|
24 #include <eikfctry.h> |
|
25 #include <eikpanic.h> |
|
26 #include <gulcolor.h> |
|
27 #include <eikenv.h> |
|
28 |
|
29 EXPORT_C CEikDialogToolBar::~CEikDialogToolBar() |
|
30 { |
|
31 delete iBrushAndPenContext; |
|
32 } |
|
33 |
|
34 EXPORT_C CEikDialogToolBar::CEikDialogToolBar() |
|
35 { |
|
36 __DECLARE_NAME(_S("CEikDialogToolBar")); |
|
37 } |
|
38 |
|
39 EXPORT_C void CEikDialogToolBar::BaseConstructL() |
|
40 { |
|
41 __ASSERT_DEBUG(Observer(),Panic(EEikPanicDialogToolBarNoObserver)); |
|
42 CEikControlGroup::ConstructL(CEikControlGroup::EFromTopLeft,CEikControlGroup::ELayHorizontally); |
|
43 RWindow& window=Window(); |
|
44 window.SetBackgroundColor(iEikonEnv->ControlColor(EColorDialogBackground,*this)); |
|
45 window.SetPointerGrab(ETrue); |
|
46 window.SetShadowDisabled(ETrue); |
|
47 EnableDragEvents(); |
|
48 iBrushAndPenContext=CCoeBrushAndPenContext::NewL(); |
|
49 iBrushAndPenContext->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
50 iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorDialogBackground,*this)); |
|
51 iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorDialogText,*this)); |
|
52 SetControlContext(iBrushAndPenContext); |
|
53 } |
|
54 |
|
55 EXPORT_C void CEikDialogToolBar::ConstructFromResourceL(TResourceReader& aReader) |
|
56 { |
|
57 BaseConstructL(); |
|
58 const TInt width=aReader.ReadInt16(); |
|
59 if (width) |
|
60 SetLengthInPixels(width); |
|
61 const TInt count=aReader.ReadInt16(); |
|
62 for (TInt ii=0;ii<count;++ii) |
|
63 { |
|
64 const TInt ctrlType=aReader.ReadInt16(); |
|
65 CCoeControl* ctrl=EikControlFactory::CreateByTypeL(ctrlType).iControl; |
|
66 // if (!ctrl) |
|
67 // ctrl=iCommandObserver->CreateCustomCommandControlL(ctrlType); |
|
68 __ASSERT_DEBUG(ctrl, Panic(EEikPanicToolBarNullControl)); |
|
69 ctrl->SetContainerWindowL(*this); |
|
70 ctrl->SetNonFocusing(); |
|
71 CleanupStack::PushL(ctrl); |
|
72 const TInt id=aReader.ReadInt16(); |
|
73 const TInt length=aReader.ReadInt16(); |
|
74 TEikGroupControl groupCtrl(ctrl,id,aReader.ReadInt16(),length); |
|
75 AddControlL(groupCtrl); //ownership now taken by array |
|
76 CleanupStack::Pop(); |
|
77 ctrl->ConstructFromResourceL(aReader); |
|
78 } |
|
79 } |
|
80 |
|
81 EXPORT_C TKeyResponse CEikDialogToolBar::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
82 { |
|
83 const TInt count=iControlArray->Count(); |
|
84 for (TInt ii=0;ii<count;ii++) |
|
85 { |
|
86 if ((*iControlArray)[ii].iControl->OfferKeyEventL(aKeyEvent,aType)==EKeyWasConsumed) |
|
87 return EKeyWasConsumed; |
|
88 } |
|
89 return EKeyWasNotConsumed; |
|
90 } |
|
91 |
|
92 EXPORT_C void CEikDialogToolBar::AddControlL(TEikGroupControl& aGroupControl) |
|
93 { |
|
94 CEikControlGroup::AddControlL(aGroupControl); |
|
95 aGroupControl.iControl->SetObserver(this); |
|
96 } |
|
97 |
|
98 void CEikDialogToolBar::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType) |
|
99 { |
|
100 if (aEventType==MCoeControlObserver::EEventStateChanged) |
|
101 { |
|
102 iStateChangeControl=aControl; |
|
103 ReportEventL(aEventType); |
|
104 } |
|
105 } |
|
106 |
|
107 EXPORT_C CCoeControl* CEikDialogToolBar::StateChangeControl() const |
|
108 { |
|
109 return iStateChangeControl; |
|
110 } |
|
111 |
|
112 EXPORT_C TInt CEikDialogToolBar::StateChangeControlId() const |
|
113 { |
|
114 if (!iStateChangeControl) |
|
115 return KErrNotFound; |
|
116 return ControlId(iStateChangeControl); |
|
117 } |
|
118 |
|
119 /** |
|
120 * Gets the list of logical colors employed in the drawing of the control, |
|
121 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
122 * |
|
123 * @since ER5U |
|
124 */ |
|
125 EXPORT_C void CEikDialogToolBar::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
126 { |
|
127 CEikControlGroup::GetColorUseListL(aColorUseList); |
|
128 |
|
129 TInt commonAttributes = TCoeColorUse::ESurrounds|TCoeColorUse::EActive|TCoeColorUse::ENormal|TCoeColorUse::ENeutral; |
|
130 TCoeColorUse colorUse; |
|
131 |
|
132 colorUse.SetLogicalColor(EColorToolbarText); |
|
133 colorUse.SetUse(TCoeColorUse::EFore|commonAttributes); |
|
134 aColorUseList.AppendL(colorUse); |
|
135 |
|
136 colorUse.SetLogicalColor(EColorToolbarBackground); |
|
137 colorUse.SetUse(TCoeColorUse::EBack|commonAttributes); |
|
138 aColorUseList.AppendL(colorUse); |
|
139 } |
|
140 |
|
141 /** |
|
142 * Handles a change to the control's resources of type aType |
|
143 * which are shared across the environment, e.g. colors or fonts. |
|
144 * |
|
145 * @since ER5U |
|
146 */ |
|
147 EXPORT_C void CEikDialogToolBar::HandleResourceChange(TInt aType) |
|
148 { |
|
149 CEikControlGroup::HandleResourceChange(aType); |
|
150 |
|
151 if(aType==KEikColorResourceChange) |
|
152 { |
|
153 iBrushAndPenContext->SetBrushColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this)); |
|
154 iBrushAndPenContext->SetPenColor(iEikonEnv->ControlColor(EColorToolbarText,*this)); |
|
155 Window().SetBackgroundColor(iEikonEnv->ControlColor(EColorToolbarBackground,*this)); |
|
156 } |
|
157 } |