1 /* |
|
2 * Copyright (c) 2009 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: Calendar widget's date icon layout handler |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <HbDocumentLoader> |
|
20 #include <HbFrameDrawer> |
|
21 #include <HbLabel> |
|
22 #include <HbWidget> |
|
23 #include <HbFrameItem> |
|
24 |
|
25 // User includes |
|
26 #include "mainlayouthandler.h" |
|
27 #include "calendarwidgetdebug.h" |
|
28 |
|
29 // Local constants |
|
30 namespace |
|
31 { |
|
32 const char WIDGET[] = "CalendarWidget"; |
|
33 const char *SEPARATOR_LABEL = "separatorLabel"; |
|
34 const char *SEPARATOR_IMAGE_NAME = "qtg_graf_divider_v_thin"; |
|
35 const char *BACKGROUND_IMAGE_NAME = "qtg_fr_hswidget_normal"; |
|
36 const HbFrameDrawer::FrameType BACKGROUND_FRAME_TYPE = HbFrameDrawer::NinePieces; |
|
37 const HbFrameDrawer::FrameType SEPARATOR_FRAME_TYPE = HbFrameDrawer::OnePiece; |
|
38 } // namespace |
|
39 |
|
40 // ======== MEMBER FUNCTIONS ======== |
|
41 |
|
42 MainLayoutHandler::MainLayoutHandler() |
|
43 : mWidget(0), |
|
44 mSeparatorLabel(0), |
|
45 mIconLayoutItem(0), |
|
46 mBackgroundLayoutItem(0), |
|
47 mSeparatorLayoutItem(0) |
|
48 { |
|
49 LOGS("MainLayoutHandler::MainLayoutHandler"); |
|
50 } |
|
51 |
|
52 MainLayoutHandler::~MainLayoutHandler() |
|
53 { |
|
54 LOGS("MainLayoutHandler::~MainLayoutHandler"); |
|
55 } |
|
56 |
|
57 void MainLayoutHandler::initializeLayout(const HbDocumentLoader &layoutLoader, QObject *owner) |
|
58 { |
|
59 LOGS("MainLayoutHandler::initializeLayout"); |
|
60 setParent(owner); |
|
61 |
|
62 mWidget = (HbWidget*)layoutLoader.findWidget(WIDGET); |
|
63 mSeparatorLabel = qobject_cast<HbLabel*>(layoutLoader.findWidget(QString(SEPARATOR_LABEL))); |
|
64 |
|
65 // The rest of the initializion is pointless if loading of the main widget fails. |
|
66 if (!mWidget) { |
|
67 return; |
|
68 } |
|
69 |
|
70 addItem(mWidget); |
|
71 mWidget->setVisible(true); |
|
72 |
|
73 HbFrameDrawer* backgroundFrameDrawer = new HbFrameDrawer(BACKGROUND_IMAGE_NAME, |
|
74 BACKGROUND_FRAME_TYPE); |
|
75 mBackgroundLayoutItem = new HbFrameItem(backgroundFrameDrawer); |
|
76 mWidget->setBackgroundItem(mBackgroundLayoutItem); |
|
77 HbFrameDrawer* separatorFrameDrawer = new HbFrameDrawer(SEPARATOR_IMAGE_NAME, |
|
78 SEPARATOR_FRAME_TYPE); |
|
79 mSeparatorLayoutItem = new HbFrameItem(separatorFrameDrawer); |
|
80 mSeparatorLabel->setBackgroundItem(mSeparatorLayoutItem); |
|
81 |
|
82 setPreferredSize(mWidget->preferredSize()); |
|
83 } |
|
84 |
|
85 void MainLayoutHandler::updateLayout() |
|
86 { |
|
87 LOGS("MainLayoutHandler::updateLayout"); |
|
88 } |
|
89 |
|
90 void MainLayoutHandler::onThemeChange() |
|
91 { |
|
92 LOGS("MainLayoutHandler::onThemeChange"); |
|
93 if (mBackgroundLayoutItem) { |
|
94 mBackgroundLayoutItem->frameDrawer().themeChanged(); |
|
95 } |
|
96 if (mSeparatorLayoutItem) { |
|
97 mSeparatorLayoutItem->frameDrawer().themeChanged(); |
|
98 } |
|
99 } |
|