src/hbinput/inputwidgets/hbinputcandidatelist.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
--- a/src/hbinput/inputwidgets/hbinputcandidatelist.cpp	Thu Sep 02 20:44:51 2010 +0300
+++ b/src/hbinput/inputwidgets/hbinputcandidatelist.cpp	Fri Sep 17 08:32:10 2010 +0300
@@ -34,6 +34,8 @@
 
 #include <hbdeviceprofile.h>
 
+#include <HbFrameDrawer>
+#include <hbframedrawerpool_p.h>
 #include <hbinputmethod.h>
 #include <hbinputsettingproxy.h>
 #include <hbinputvkbhost.h>
@@ -41,11 +43,11 @@
 
 #include "hbdialog_p.h"
 
+const QString HbCandidateListBackground("qtg_fr_popup_secondary");
 const int HbCandListDefaultNumRows = 5;
 const qreal HbCandListMaxWidthMultiplier = 0.8;
 const qreal HbCandListMinWidth = 30.0;
 const qreal HbAutoComplPopupSideMargin = 15.0;
-const qreal HbAutoComplPopupVerticalMargin = 15.0;
 const qreal HbAutoComplPopupMinAllowedHeight = 25.0;
 
 /// @cond
@@ -58,7 +60,7 @@
     HbCandidateListPrivate(HbInputMethod *input);
     ~HbCandidateListPrivate();
     void calculateAndSetSize(qreal maxWidth);
-    void initFrameIcon();
+    void setBackground();
 
 public:
     HbListWidget *mList;
@@ -66,7 +68,6 @@
     int numRows;
     int numCandidates;
     int longestStringWidth;
-    HbFrameItem *mFrameBackground;
     HbListWidgetItem *mSpellQueryItem;
     bool mCandidateCommitted;
     bool mSpellQueryOpenIsPending;
@@ -77,7 +78,6 @@
       numRows(HbCandListDefaultNumRows),
       numCandidates(0),
       longestStringWidth(0),
-      mFrameBackground(0),
       mSpellQueryItem(0),
       mCandidateCommitted(false),
       mSpellQueryOpenIsPending(false)
@@ -90,15 +90,14 @@
 {
 }
 
-void HbCandidateListPrivate::initFrameIcon()
+void HbCandidateListPrivate::setBackground()
 {
-    Q_Q(HbCandidateList);
-
-    mFrameBackground = static_cast<HbFrameItem *>(q->primitive((HbStyle::Primitive)HbStylePrivate::P_Popup_background));
-
-    if (mFrameBackground == 0) {
-        mFrameBackground = static_cast<HbFrameItem *>(HbStylePrivate::createPrimitive(HbStylePrivate::P_Popup_background, q));
-    }
+  Q_Q(HbCandidateList);
+  HbFrameDrawer *drawer = HbFrameDrawerPool::get(HbCandidateListBackground, HbFrameDrawer::NinePieces, QSizeF(q->boundingRect().width(), q->boundingRect().height()));
+  if (drawer) {
+    drawer->setFillWholeRect(true);
+    q->setBackgroundItem(new HbFrameItem(drawer));
+  }
 }
 
 
@@ -167,8 +166,8 @@
     HbInputRegionCollector::instance()->attach(this);
 
     d->setPriority(HbPopupPrivate::VirtualKeyboard + 1);  // Should be shown on top of virtual keyboard.
-    d->initFrameIcon();
-
+    d->setBackground();
+  
     d->mList->setParent(this);
 
     // Make sure the preview pane never steals focus.
@@ -334,14 +333,6 @@
     }
 }
 
-void HbCandidateList::updatePrimitives()
-{
-    Q_D(HbCandidateList);
-
-    d->mFrameBackground->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
-    d->mFrameBackground->frameDrawer().setFrameGraphicsName("qtg_fr_popup_secondary");
-    d->mFrameBackground->setGeometry(boundingRect());
-}
 
 /*!
 Finds correct size and position for auto-completion popup. It checks if there is enough space to display candidate popup,