|
1 /* |
|
2 * Copyright (c) 2002 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: Grid of the MonthView. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 //debug |
|
21 #include "calendarui_debug.h" |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "calenmonthgrid.h" |
|
25 #include "calenmonthcontainer.h" |
|
26 #include "calenmonthcelllistboxdata.h" |
|
27 #include "calenmonthcelllistboxitemdrawer.h" |
|
28 |
|
29 #include <aknlayoutscalable_apps.cdl.h> |
|
30 |
|
31 // New line color groups in enhanced skinning |
|
32 static void DrawLAFLine(CWindowGc& aGc, const TAknLayoutRect& aArea, |
|
33 const TAknsItemID& aSkinComponent, TInt aColorGroup) |
|
34 { |
|
35 TRACE_ENTRY_POINT; |
|
36 |
|
37 TRgb lineColor = aArea.Color(); |
|
38 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), lineColor, |
|
39 aSkinComponent, aColorGroup); |
|
40 aGc.SetBrushColor( lineColor ); |
|
41 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
42 aGc.Clear( aArea.Rect() ); |
|
43 |
|
44 TRACE_EXIT_POINT; |
|
45 } |
|
46 |
|
47 static void DrawSecondaryLine(CWindowGc& aGc, const TAknLayoutRect& aArea) |
|
48 { |
|
49 TRACE_ENTRY_POINT; |
|
50 |
|
51 DrawLAFLine(aGc, aArea, KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG2); |
|
52 |
|
53 TRACE_EXIT_POINT; |
|
54 } |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 |
|
58 // C++ default constructor can NOT contain any code, that |
|
59 // might leave. |
|
60 // |
|
61 CCalenMonthGrid::CCalenMonthGrid |
|
62 (TTime aFirstDayOfGrid, CCalenMonthContainer* aMonthCont) |
|
63 : iFirstDayOfGrid(aFirstDayOfGrid),iMonthContainer(aMonthCont) |
|
64 { |
|
65 TRACE_ENTRY_POINT; |
|
66 |
|
67 SetVerticalMargin(0); |
|
68 SetHorizontalMargin(0); |
|
69 |
|
70 TRACE_EXIT_POINT; |
|
71 } |
|
72 |
|
73 // Destructor |
|
74 CCalenMonthGrid::~CCalenMonthGrid() |
|
75 { |
|
76 TRACE_ENTRY_POINT; |
|
77 TRACE_EXIT_POINT; |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------- |
|
81 // CCalenMonthGrid::Draw |
|
82 // Drawing month gird |
|
83 // (other items were commented in a header). |
|
84 // --------------------------------------------------------- |
|
85 // |
|
86 void CCalenMonthGrid::Draw(const TRect& aRect)const |
|
87 { |
|
88 TRACE_ENTRY_POINT; |
|
89 //const TBool useWeeks( UseWeeks() ); |
|
90 CAknGrid::Draw( aRect ); |
|
91 |
|
92 // For drawing Secondary grid lines |
|
93 DrawGridLines(); |
|
94 |
|
95 TRACE_EXIT_POINT; |
|
96 |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CCalenMonthGrid::DrawGridLines |
|
101 // Draws secondary lines of the grid |
|
102 // (other items were commented in a header). |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 void CCalenMonthGrid::DrawGridLines()const |
|
106 { |
|
107 TRACE_ENTRY_POINT; |
|
108 |
|
109 CWindowGc& gc = SystemGc(); |
|
110 TRect parentRect = iMonthContainer->Rect(); |
|
111 TRect main_pane(iMonthContainer->ReducePreview( parentRect ) ); |
|
112 |
|
113 |
|
114 TAknLayoutRect main_cale_month_pane; |
|
115 TInt layoutVariant = iMonthContainer->LayoutVariantIndex(CCalenMonthContainer::EMainCaleMonthPane); |
|
116 main_cale_month_pane.LayoutRect( main_pane, AknLayoutScalable_Apps::main_cale_month_pane(layoutVariant).LayoutLine() ); |
|
117 |
|
118 TAknLayoutRect cale_month_pane_g; |
|
119 |
|
120 // Get indexes for grid lines (cale_month_pane_g) |
|
121 TAknLayoutScalableTableLimits cale_month_pane_g_Limits = AknLayoutScalable_Apps::cale_month_pane_g_Limits(); |
|
122 TInt index( cale_month_pane_g_Limits.FirstIndex() ); |
|
123 TInt end( cale_month_pane_g_Limits.LastIndex() ); |
|
124 // First two are primary lines to separate heading and week number panes from grid |
|
125 // We draw them elsewhere |
|
126 const TInt firstGridLineIndex = 2; |
|
127 layoutVariant = iMonthContainer->LayoutVariantIndex(CCalenMonthContainer::ECaleMonthPaneG ); |
|
128 for ( index+=firstGridLineIndex; index<=end; ++index ) |
|
129 { |
|
130 cale_month_pane_g.LayoutRect( main_cale_month_pane.Rect(), |
|
131 AknLayoutScalable_Apps::cale_month_pane_g( index, layoutVariant ).LayoutLine() ); |
|
132 DrawSecondaryLine( gc, cale_month_pane_g ); |
|
133 } |
|
134 |
|
135 TRACE_EXIT_POINT; |
|
136 |
|
137 } |
|
138 |
|
139 |
|
140 // --------------------------------------------------------- |
|
141 // CCalenMonthGrid::FirstDayOfGrid |
|
142 // Return first day of grid |
|
143 // (other items were commented in a header). |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 TTime CCalenMonthGrid::FirstDayOfGrid() |
|
147 { |
|
148 TRACE_ENTRY_POINT; |
|
149 |
|
150 TRACE_EXIT_POINT; |
|
151 return iFirstDayOfGrid; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // CCalenMonthGrid::SetFirstDayOfGrid |
|
156 // Set argument aDay to first day of Grid |
|
157 // (other items were commented in a header). |
|
158 // --------------------------------------------------------- |
|
159 // |
|
160 void CCalenMonthGrid::SetFirstDayOfGrid(TTime aDay) |
|
161 { |
|
162 TRACE_ENTRY_POINT; |
|
163 |
|
164 iFirstDayOfGrid = aDay; |
|
165 |
|
166 TRACE_EXIT_POINT; |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------- |
|
170 // CCalenMonthGrid::CreateItemDrawerL |
|
171 // Creates CFormattedCellListBoxItemDrawer, |
|
172 // actually CCalenMonthCellListBoxItemDrawer. |
|
173 // (other items were commented in a header). |
|
174 // --------------------------------------------------------- |
|
175 // |
|
176 void CCalenMonthGrid::CreateItemDrawerL() |
|
177 { |
|
178 TRACE_ENTRY_POINT; |
|
179 |
|
180 CCalenMonthCellListBoxData* columnData = CCalenMonthCellListBoxData::NewL(); |
|
181 CleanupStack::PushL( columnData ); |
|
182 |
|
183 iItemDrawer = new(ELeave) |
|
184 CCalenMonthCellListBoxItemDrawer(Model(), this, iEikonEnv->NormalFont(), columnData); |
|
185 |
|
186 CleanupStack::Pop(); // columnData |
|
187 |
|
188 TRACE_EXIT_POINT; |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 void CCalenMonthGrid::UpdateScrollBarsL() |
|
196 { |
|
197 TRACE_ENTRY_POINT; |
|
198 |
|
199 // Override default implementation and just turn scrollbars off |
|
200 // This is needed, because CAknGrid doesn't respect scrollbar |
|
201 // visibility settings, but turns them on e.g. in HandleResourceChange |
|
202 CEikScrollBarFrame* sbf = ScrollBarFrame(); |
|
203 if ( sbf ) |
|
204 { |
|
205 sbf->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, |
|
206 CEikScrollBarFrame::EOff); |
|
207 } |
|
208 |
|
209 TRACE_EXIT_POINT; |
|
210 } |
|
211 // End of File |