66
|
1 |
/*******************************************************************************
|
|
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved. This program and the accompanying materials
|
|
4 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
5 |
* which accompanies this distribution, and is available at
|
|
6 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
7 |
*
|
|
8 |
* Contributors:
|
|
9 |
* Nokia Corporation - S60 implementation
|
|
10 |
*******************************************************************************/
|
|
11 |
|
|
12 |
|
|
13 |
#ifndef SWTTABLE_H
|
|
14 |
#define SWTTABLE_H
|
|
15 |
|
|
16 |
|
|
17 |
#include "eswtwidgetsexpanded.h"
|
|
18 |
#include "swtscrollablebase.h"
|
|
19 |
#include "swtcomposite.h"
|
|
20 |
|
|
21 |
|
|
22 |
class MSwtTableItem;
|
|
23 |
class MSwtTableColumn;
|
|
24 |
class CSwtTableListBox;
|
|
25 |
class CSwtImageTextItem;
|
|
26 |
class TSwtTableMargins;
|
|
27 |
class CSwtTableHeader;
|
|
28 |
|
|
29 |
|
|
30 |
/**
|
|
31 |
* This class implements the native peer of Table.
|
|
32 |
* Table is implemented as a compound control with 2 components:
|
|
33 |
* a listbox control and a column header control.
|
|
34 |
* @lib eswt.dll
|
|
35 |
*/
|
|
36 |
NONSHARABLE_CLASS(CSwtTable)
|
|
37 |
: public CSwtComposite
|
|
38 |
, public MSwtTable
|
|
39 |
, public MCoeControlObserver
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
/**
|
|
43 |
* Two-phased constructor.
|
|
44 |
* @param aDisplay The display object
|
|
45 |
* @param aPeer The Java peer of the table
|
|
46 |
* @param aParent The parent Composite of the table
|
|
47 |
* @param aStyle The style flags given to the table Java constructor
|
|
48 |
*/
|
|
49 |
static CSwtTable* NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer,
|
|
50 |
MSwtComposite& aParent, TInt aStyle);
|
|
51 |
|
|
52 |
/**
|
|
53 |
* Destructor.
|
|
54 |
*/
|
|
55 |
virtual ~CSwtTable();
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Returns the component listbox items.
|
|
59 |
* @return An array of items.
|
|
60 |
*/
|
|
61 |
const RPointerArray<CSwtImageTextItem>& GetImageTextItems() const;
|
|
62 |
|
|
63 |
/**
|
|
64 |
* A helper for posting a selection event for an item in the Table.
|
|
65 |
* @param aDetail Detail code for the event.
|
|
66 |
* @param aItemIndex The index of the selected item.
|
|
67 |
*/
|
|
68 |
void PostSelectionEventL(TInt aDetail, TInt aItemIndex) const;
|
|
69 |
|
|
70 |
/**
|
|
71 |
* A helper for posting a default selection event for an item in the Table.
|
|
72 |
* @param The index of the selected item.
|
|
73 |
*/
|
|
74 |
void PostDefaultSelectionEventL(TInt aItemIndex) const;
|
|
75 |
|
|
76 |
/**
|
|
77 |
* A helper for posting a selection event for a column in the Table.
|
|
78 |
* @param The native peer of the selected column.
|
|
79 |
*/
|
|
80 |
void PostColumnSelectionEventL(TSwtPeer aColumn) const;
|
|
81 |
|
|
82 |
/**
|
|
83 |
* A helper for posting a resize event for a column in the Table.
|
|
84 |
* @param The native peer of the selected column.
|
|
85 |
*/
|
|
86 |
void PostColumnResizeEventL(TSwtPeer aColumn) const;
|
|
87 |
|
|
88 |
/**
|
|
89 |
* A helper for posting a move event for a column in the Table.
|
|
90 |
* @param The native peer of the selected column.
|
|
91 |
*/
|
|
92 |
void PostColumnMoveEventL(TSwtPeer aColumn) const;
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Returns the position and extent of the header.
|
|
96 |
* @return The header rectangle.
|
|
97 |
*/
|
|
98 |
TRect GetHeaderRect() const;
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Return the margins common to all items.
|
|
102 |
* @return The margins to use in the currently active layout.
|
|
103 |
*/
|
|
104 |
TSwtTableMargins GetMargins() const;
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Return the checkbox size common to all items.
|
|
108 |
* @return The checkbox size to use in the currently active layout.
|
|
109 |
*/
|
|
110 |
TSize GetCheckBoxSize() const;
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Return the checkbox bitmaps common to all items.
|
|
114 |
* @param aChecked True if the checked state bitmap should be returned, false for unchecked
|
|
115 |
* @param aBitmap aBitmap Returned checkbox bitmap. Owned by this class.
|
|
116 |
* @param aMask aMask Returned checkbox mask. Owned by this class.
|
|
117 |
*/
|
|
118 |
void GetCheckBoxBitmaps(const TBool& aChecked, const CFbsBitmap** aBitmap,
|
|
119 |
const CFbsBitmap** aMask) const;
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Gets index of an item by its CSwtImageTextItem pointer.
|
|
123 |
* @param aItem The pointer.
|
|
124 |
* @return The index. -1 if not found.
|
|
125 |
*/
|
|
126 |
TInt IndexOfTableItem(const CSwtImageTextItem* aItem) const;
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Returns the highlighted text color rgb value to use in the currently active layout.
|
|
130 |
* @return The rgb value.
|
|
131 |
*/
|
|
132 |
TRgb GetHighlightTextRgb() const;
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Returns if the table background has a custom color set for it.
|
|
136 |
* @return True if a custom color has been set, false otherwise.
|
|
137 |
*/
|
|
138 |
TBool BackgroundSet() const;
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Returns if the item at the specified index has been checked.
|
|
142 |
* Items can only be checked in KSwtStyleCheck style table.
|
|
143 |
* @param aIndex The index of the item to query.
|
|
144 |
* @return True if the item has been checked, false otherwise.
|
|
145 |
*/
|
|
146 |
TBool IsChecked(const TInt& aIndex) const;
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Checks the item at the specified index.
|
|
150 |
* Items can only be checked in KSwtStyleCheck style table.
|
|
151 |
* @param aIndex The index of the item to check.
|
|
152 |
*/
|
|
153 |
void CheckItem(const TInt& aIndex);
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Unchecks the item at the specified index.
|
|
157 |
* Items can only be checked in KSwtStyleCheck style table.
|
|
158 |
* @param aIndex The index of the item to uncheck.
|
|
159 |
*/
|
|
160 |
void UncheckItem(const TInt& aIndex);
|
|
161 |
|
|
162 |
/**
|
|
163 |
* @return True if the table is operating in list-mode (no TableColumns).
|
|
164 |
*/
|
|
165 |
TBool ListMode() const;
|
|
166 |
|
|
167 |
/**
|
|
168 |
* Unchecks the item at the specified index.
|
|
169 |
* Items can only be checked in KSwtStyleCheck style table.
|
|
170 |
* @param aHScrollOffset
|
|
171 |
*/
|
|
172 |
void UpdateHeaderHScrollOffset(const TInt& aHScrollOffset);
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Notifies the Table compound control that the default font in the component
|
|
176 |
* list box has changed.
|
|
177 |
*/
|
|
178 |
void ListBoxDefaultFontChanged();
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Get notified by the contained listbox about kinetic scrolling
|
|
182 |
*/
|
|
183 |
void HandlePhysics(TBool aStatus);
|
|
184 |
|
|
185 |
/**
|
|
186 |
* If a fg colors has been set, get its rgb otherwise get NULL.
|
|
187 |
*/
|
|
188 |
const TRgb* CustomForeground() const;
|
|
189 |
|
|
190 |
// from base class CCoeControl
|
|
191 |
|
|
192 |
TInt CountComponentControls() const;
|
|
193 |
CCoeControl* ComponentControl(TInt aIndex) const;
|
|
194 |
void SizeChanged();
|
|
195 |
void HandleResourceChange(TInt aType);
|
|
196 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
|
197 |
void FocusChanged(TDrawNow aDrawNow);
|
|
198 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
199 |
void Draw(const TRect& aRect) const;
|
|
200 |
|
|
201 |
// from base class MSwtTable
|
|
202 |
|
|
203 |
CSwtPeerArray* GetTableItemsL();
|
|
204 |
CSwtPeerArray* GetTableColumnsL();
|
|
205 |
const RArray<TInt>& GetColumnWidths() const;
|
|
206 |
const RArray<TInt>& GetColumnAlignments() const;
|
|
207 |
const RArray<TInt>& GetColumnImageCounts() const;
|
|
208 |
MSwtComposite* Composite();
|
|
209 |
void AddTableItemL(MSwtTableItem& aChild, TInt aRowIndex);
|
|
210 |
void AddTableColumnL(MSwtTableColumn& aChild, TInt aColumnIndex);
|
|
211 |
void RemoveTableColumn(MSwtTableColumn& aChild);
|
|
212 |
void DeselectItems(const TInt* aIndices, TInt aCount);
|
|
213 |
void DeselectRange(TInt aStart, TInt aEnd);
|
|
214 |
TInt IndexOfTableColumn(const MSwtTableColumn *aColumn) const;
|
|
215 |
TInt IndexOfTableItemAt(const MSwtTableItem *aItem, TInt aStart) const;
|
|
216 |
TInt IndexOfTableItem(const MSwtTableItem *aItem) const;
|
|
217 |
TInt GetColumnCount() const;
|
|
218 |
TInt GetTableColumnCount() const;
|
|
219 |
TBool GetHeaderVisible() const;
|
|
220 |
TSwtPeer GetItemL(TInt aIndex) const;
|
|
221 |
TSwtPeer GetColumnL(TInt aIndex) const;
|
|
222 |
TInt GetItemCount() const;
|
|
223 |
TRect GetItemRect(TInt aRowIndex) const;
|
|
224 |
TBool GetLinesVisible() const;
|
|
225 |
TInt GetSelectionIndex() const;
|
|
226 |
TInt GetSelectionCount() const;
|
|
227 |
const CArrayFix<TInt>* GetSelectionIndicesL() const;
|
|
228 |
const TSize& ImageSize() const;
|
|
229 |
void NotifyImageAdded(TInt aColumnIndex);
|
|
230 |
void NotifyImageRemoved(TInt aColumnIndex);
|
|
231 |
void PackColumn(TInt aColumnIndex);
|
|
232 |
void RemoveItemL(TInt aIndex);
|
|
233 |
void RemoveRangeL(TInt aStart, TInt aEnd);
|
|
234 |
void RemoveItemsL(const TInt* aIndices, TInt aCount);
|
|
235 |
void RemoveAll();
|
|
236 |
void SelectItemL(TInt aIndex, TBool aScroll);
|
|
237 |
void SetHeaderVisible(TBool aShow);
|
|
238 |
void SetLinesVisible(TBool aShow);
|
|
239 |
void SelectRangeL(TInt aStart, TInt aEnd);
|
|
240 |
void SelectAllL();
|
|
241 |
void SetFocusIndex(TInt aIndex);
|
|
242 |
void ShowSelection();
|
|
243 |
CSwtPeerArray* GetSelectionL();
|
|
244 |
TBool IsSelected(TInt aIndex) const;
|
|
245 |
TInt GetTopIndex() const;
|
|
246 |
void SetTopIndex(TInt aIndex);
|
|
247 |
void SetColumnTextL(MSwtTableColumn& aTableColumn, const TDesC& aText);
|
|
248 |
TInt GetColumnWidth(TInt aColumnIndex) const;
|
|
249 |
TInt GetColumnAlignment(TInt aColumnIndex);
|
|
250 |
void SetColumnWidth(TInt aColumnIndex, TInt aWidth);
|
|
251 |
void SetColumnAlignment(TInt aColumnIndex, TInt aAlignment);
|
|
252 |
void SetTableImageSizeIfNotDefined(const TSize& aSize,
|
|
253 |
const TBool& aAddedToItem = ETrue);
|
|
254 |
void UpdateItemHeight(const TInt& aChangedFontHeight);
|
|
255 |
TInt GetGridLineWidth() const;
|
|
256 |
TInt GetHeaderHeight() const;
|
|
257 |
void ShowTableColumn(MSwtTableColumn& aTableColumn);
|
|
258 |
void ShowTableItem(MSwtTableItem& aTableItem);
|
|
259 |
TInt GetItemHeight() const;
|
|
260 |
TSwtPeer GetItemFromPoint(TPoint &aPoint) const;
|
|
261 |
const TRgb& GetDefaultForeground() const;
|
|
262 |
const TDesC& GetColumnText(TInt aColumnIndex) const;
|
|
263 |
void SetColumnImage(TInt aColumnIndex, const MSwtImage* aImage);
|
|
264 |
|
|
265 |
// from base class MSwtControl
|
|
266 |
|
|
267 |
CCoeControl& CoeControl();
|
|
268 |
const CCoeControl& CoeControl() const;
|
|
269 |
TBool IsFocusable(TInt aReason = KSwtFocusByApi) const;
|
|
270 |
TInt FocusBackgroundPolicy() const;
|
|
271 |
TSize ComputeSizeL(TInt aWHint, TInt aHHint);
|
|
272 |
TInt GetBorderWidth() const;
|
|
273 |
TRect ClientRect() const;
|
|
274 |
void ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
275 |
TRgb GetBackground() const;
|
|
276 |
TRgb GetForeground() const;
|
|
277 |
void SetBackgroundL(const MSwtColor* aColor);
|
|
278 |
void SetForegroundL(const MSwtColor* aColor);
|
|
279 |
void SetFontL(const MSwtFont* aFont);
|
|
280 |
TBool IsKeyUsed(TUint aKeyCode) const;
|
|
281 |
TBool MSKSelCmdEnabled() const;
|
|
282 |
void UpdateDoNotDrawFlag();
|
|
283 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
284 |
void EnableFocusHighlight(TBool aEnable);
|
|
285 |
#endif //RD_JAVA_S60_RELEASE_9_2
|
|
286 |
|
|
287 |
// from base class ASwtScrollableBase
|
|
288 |
|
|
289 |
CEikScrollBarFrame* SbFrame() const;
|
|
290 |
TRect SbInnerRect(const TRect& aRect) const;
|
|
291 |
TRect SbOuterRect(const TRect& aRect) const;
|
|
292 |
void ComputeTrim(TRect& aRect) const;
|
|
293 |
void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
|
|
294 |
|
|
295 |
// from base class CSwtComposite
|
|
296 |
|
|
297 |
void RegisterChildL(MSwtControl& aChild);
|
|
298 |
|
|
299 |
// from base class MCoeControlObserver
|
|
300 |
|
|
301 |
void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType);
|
|
302 |
|
|
303 |
// from base class ASwtControlBase
|
|
304 |
|
|
305 |
public:
|
|
306 |
const MSwtFont& DefaultFont() const;
|
|
307 |
protected:
|
|
308 |
HBufC* MSKLabelL() const;
|
|
309 |
|
|
310 |
private:
|
|
311 |
|
|
312 |
/**
|
|
313 |
* The constructor.
|
|
314 |
* @param aDisplay The display object.
|
|
315 |
* @param aPeer The java peer table object.
|
|
316 |
* @param aParent The parent composite.
|
|
317 |
* @param aStyle The style flags passed to the Java constructor.
|
|
318 |
*/
|
|
319 |
CSwtTable(MSwtDisplay& aDisplay, TSwtPeer aPeer, MSwtComposite& aParent, TInt aStyle);
|
|
320 |
|
|
321 |
/**
|
|
322 |
* 2nd phase constructor.
|
|
323 |
*/
|
|
324 |
void ConstructL();
|
|
325 |
|
|
326 |
/**
|
|
327 |
* Gets the currently focused item index.
|
|
328 |
* @return The index.
|
|
329 |
*/
|
|
330 |
TInt GetFocusIndex() const;
|
|
331 |
|
|
332 |
/**
|
|
333 |
* Recalculates the layout for the whole control and applies the new layout.
|
|
334 |
*/
|
|
335 |
void LayoutTable();
|
|
336 |
|
|
337 |
/**
|
|
338 |
* A leaving version of HandleResourceChange
|
|
339 |
* @param aType The type param received in HandleResourceChange
|
|
340 |
*/
|
|
341 |
void HandleResourceChangeL(TInt aType);
|
|
342 |
|
|
343 |
/**
|
|
344 |
* Loading of the scaled layout data.
|
|
345 |
*/
|
|
346 |
void LoadLayouts();
|
|
347 |
|
|
348 |
/**
|
|
349 |
* Loading of the scaled & skinned graphic data.
|
|
350 |
*/
|
|
351 |
void LoadGraphicsL();
|
|
352 |
|
|
353 |
/*
|
|
354 |
* Restores the selection indexes from the given array after items have been added or removed.
|
|
355 |
* @param aStart The starting index after which items were added or removed.
|
|
356 |
* @param aSelectionArray The selection array containing the selection indexes before
|
|
357 |
adding/removing items.
|
|
358 |
* @param aItemsAdded True if items were added, false if removed.
|
|
359 |
*/
|
|
360 |
void UpdateSelectionIndexesL(const TInt& aStart,
|
|
361 |
const TInt& aEnd,
|
|
362 |
CArrayFix<TInt>* aSelectionArray,
|
|
363 |
const TBool& aItemsAdded);
|
|
364 |
|
|
365 |
/**
|
|
366 |
* Updates the middle-softkey label.
|
|
367 |
*/
|
|
368 |
void UpdateMSKLabelL();
|
|
369 |
|
|
370 |
private: // data
|
|
371 |
|
|
372 |
/**
|
|
373 |
* Header visibility state.
|
|
374 |
*/
|
|
375 |
TBool iHeaderVisible;
|
|
376 |
|
|
377 |
/**
|
|
378 |
* The grid visibility state.
|
|
379 |
*/
|
|
380 |
TBool iLinesVisible;
|
|
381 |
|
|
382 |
/**
|
|
383 |
* The unique size for all the images.
|
|
384 |
*/
|
|
385 |
TSize iImageSize;
|
|
386 |
|
|
387 |
/**
|
|
388 |
* If a custom background color has been set for the table.
|
|
389 |
*/
|
|
390 |
TBool iTableBackgroundSet;
|
|
391 |
|
|
392 |
/**
|
|
393 |
* The custom background color set to table.
|
|
394 |
*/
|
|
395 |
TRgb iTableBackground;
|
|
396 |
|
|
397 |
/**
|
|
398 |
* If a custom foreground color has been set for the table.
|
|
399 |
*/
|
|
400 |
TBool iTableForegroundSet;
|
|
401 |
|
|
402 |
/**
|
|
403 |
* The custom foreground color set to table.
|
|
404 |
*/
|
|
405 |
TRgb iTableForeground;
|
|
406 |
|
|
407 |
/**
|
|
408 |
* The skinned default foreground color used for unset/null.
|
|
409 |
*/
|
|
410 |
TRgb iTableDefaultForeground;
|
|
411 |
|
|
412 |
/**
|
|
413 |
* The skinned default highlight text color used if foreground is not set.
|
|
414 |
*/
|
|
415 |
TRgb iTableDefaultHighlightText;
|
|
416 |
|
|
417 |
/**
|
|
418 |
* This array contains the width of each column.
|
|
419 |
*/
|
|
420 |
RArray<TInt> iColumnWidths;
|
|
421 |
|
|
422 |
/**
|
|
423 |
* This array contains the alignment of each column.
|
|
424 |
*/
|
|
425 |
RArray<TInt> iColumnAlignments;
|
|
426 |
|
|
427 |
/**
|
|
428 |
* This array contains the number of images in the items of each column.
|
|
429 |
* The images in the header are not included in this count.
|
|
430 |
*/
|
|
431 |
RArray<TInt> iColumnImagesCounts;
|
|
432 |
|
|
433 |
/**
|
|
434 |
* Scaled layout data common to all items.
|
|
435 |
*/
|
|
436 |
TInt iHighlightTopBottomMargin;
|
|
437 |
TInt iHighlightLeftRightMargin;
|
|
438 |
TSize iCheckBoxSize;
|
|
439 |
TInt iGridLineWidth;
|
|
440 |
|
|
441 |
/**
|
|
442 |
* The native listbox control.
|
|
443 |
* Own.
|
|
444 |
*/
|
|
445 |
CSwtTableListBox* iTableListBox;
|
|
446 |
|
|
447 |
/**
|
|
448 |
* The header of the table.
|
|
449 |
* Own.
|
|
450 |
*/
|
|
451 |
CSwtTableHeader* iHeader;
|
|
452 |
|
|
453 |
/**
|
|
454 |
* The array of drawable listbox items.
|
|
455 |
* Not own.
|
|
456 |
*/
|
|
457 |
RPointerArray<CSwtImageTextItem> iImageTextItems;
|
|
458 |
|
|
459 |
/**
|
|
460 |
* The array of native TableItem peers.
|
|
461 |
* Not own.
|
|
462 |
*/
|
|
463 |
RPointerArray<MSwtTableItem> iTableItems;
|
|
464 |
|
|
465 |
/**
|
|
466 |
* The array of native TableColumn peers.
|
|
467 |
* Not own.
|
|
468 |
*/
|
|
469 |
RPointerArray<MSwtTableColumn> iTableColumns;
|
|
470 |
|
|
471 |
/**
|
|
472 |
* The Selection array for storing the selection state, for multiselection only.
|
|
473 |
* Own.
|
|
474 |
*/
|
|
475 |
CArrayFix<TInt>* iOldSelectionArray;
|
|
476 |
|
|
477 |
/**
|
|
478 |
* Scaled & skinned graphics common to all items.
|
|
479 |
* Own.
|
|
480 |
*/
|
|
481 |
CFbsBitmap* iCheckBoxOffBitmap;
|
|
482 |
CFbsBitmap* iCheckBoxOffMask;
|
|
483 |
CFbsBitmap* iCheckBoxOnBitmap;
|
|
484 |
CFbsBitmap* iCheckBoxOnMask;
|
|
485 |
};
|
|
486 |
|
|
487 |
#endif // SWTTABLE_H
|