src/hbcore/gui/hbwidgetbase.cpp
changeset 23 e6ad4ef83b23
parent 21 4633027730f5
child 30 80e4d18b72f5
--- a/src/hbcore/gui/hbwidgetbase.cpp	Wed Aug 18 10:05:37 2010 +0300
+++ b/src/hbcore/gui/hbwidgetbase.cpp	Thu Sep 02 20:44:51 2010 +0300
@@ -26,6 +26,7 @@
 #include <QApplication>
 #include <QGraphicsWidget>
 #include <QDebug>
+#include <hbstyleprimitivedata.h>
 #ifdef HB_EFFECTS
 #include <hbeffect.h>
 #include <hbeffectinternal_p.h>
@@ -62,8 +63,7 @@
 
 HbWidgetBasePrivate::HbWidgetBasePrivate() :
         mApiProtectionFlags(0),
-        attributes(0),
-        polished(0)
+        attributes(0)
 
 {
     q_ptr = 0;
@@ -102,19 +102,6 @@
     }
 }
 
-//Optimizes updateGeometry calls for hbwidget and its descendents.
-bool HbWidgetBasePrivate::ignoreGeometryUpdate()
-{
-
-    return false;
-}
-
-
-void HbWidgetBasePrivate::activateParentLayout()
-{
-
-}
-
 void HbWidgetBasePrivate::setInsidePopup(bool insidePopup)
 {
     Q_Q( HbWidgetBase );
@@ -224,7 +211,7 @@
     if (change == QGraphicsItem::ItemVisibleChange) {
         if (value.toBool()) {
             //For HbWidget/Primitives size is not set as they will be layouted
-            //after being polished.This is done to avoid flickering as primitives tend
+            //after being polished. This is done to avoid flickering as primitives tend
             //to paint themselves before layouting, if they are added to existing layout.
             // If HbWidgets/primitives are used as standalone widgets, 
             //their size and position must be set explicitly.
@@ -422,6 +409,36 @@
     option->boundingRect = boundingRect();
 }
 
+
+/*!
+  Initializes the common primitive data. This method sets the common \a state parameter.
+  
+  The state style option consists of flags. If this widget is enabled the flag QStyle::State_Enabled is set. 
+  If this widget is active the flag QStyle::State_Active will be set.    
+  Derived implementations should create a base call to this method.
+  
+  This function does not call the base class implementation.
+  \param primitiveData, pointer to the primitive data
+  \param primitive, primitive pointer, in case there is a need to query data from the primitive (e.g. item name)
+    
+*/
+void HbWidgetBase::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive)
+{
+
+    Q_ASSERT(primitiveData);
+    Q_UNUSED(primitive);
+
+    primitiveData->state = QStyle::State_None;
+    if (isEnabled())
+        primitiveData->state |= QStyle::State_Enabled;
+    
+    if (QGraphicsWidget *w = window()) {
+        if (w->isActiveWindow())
+            primitiveData->state |= QStyle::State_Active;
+    }
+}
+
+
 /*!
     This event handler, for \a event, receives gesture events. Its base
     implementation ignores all gestures delivered in the \a event.