mulwidgets/mulsliderwidget/src/mulsliderwidgetfactoryplugin.cpp
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     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:  Plugin factory implementation for slider widget.
       
    15 *
       
    16 */
       
    17 
       
    18 // OSN Includes
       
    19 #include <osn/ustring.h>
       
    20 
       
    21 // WidgetModel Includes
       
    22 #include "alf/alfwidget.h"
       
    23 #include <alf/ialfwidget.h>
       
    24 #include <alf/ialfelement.h>
       
    25 
       
    26 // Symbian Includes
       
    27 #include <ecom/ecom.h>
       
    28 
       
    29 // OpenC Includes
       
    30 #include <libc/string.h>
       
    31 
       
    32 // Widget Includes
       
    33 #include <mul/imulsliderwidget.h>
       
    34 #include <mul/mulsliderproductids.h>
       
    35 #include "imulsliderbaseelementinternal.h"
       
    36 //Internal includes
       
    37 #include "mulsliderwidgetfactoryplugin.h"
       
    38 #include "mulsliderwidget.h"
       
    39 #include "mulslidermodel.h"
       
    40 #include "mulslidervertical.h"
       
    41 #include "mulprogressbarslider.h"
       
    42 #include "mulsliderhorizontal.h"
       
    43 //#include "alfscrollbardefaultlctbaseelement.h"
       
    44 
       
    45 using namespace osncore;
       
    46 
       
    47 namespace Alf
       
    48     {
       
    49 const TInt KScrollBarWidgetFactoryPluginUid = {0x2000FA80};
       
    50 const int KProductCount = 5;
       
    51 
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Two-phased Symbian constructor.
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 MulSliderWidgetFactoryPlugin* MulSliderWidgetFactoryPlugin::NewL()
       
    58     {
       
    59     return new (EMM) MulSliderWidgetFactoryPlugin;
       
    60     }
       
    61 
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Destructor.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 MulSliderWidgetFactoryPlugin::~MulSliderWidgetFactoryPlugin()
       
    68     {
       
    69 
       
    70     }
       
    71     
       
    72     
       
    73 // ---------------------------------------------------------------------------
       
    74 // Creates either a scrollbar widget or a scrollbar model.
       
    75 // ---------------------------------------------------------------------------
       
    76 //
       
    77 IAlfInterfaceBase* MulSliderWidgetFactoryPlugin::createProduct(
       
    78     const char* aProduct,
       
    79     void* aInitData)
       
    80     {
       
    81     IAlfInterfaceBase* ret (0);
       
    82  
       
    83      if (!strcmp(aProduct, KSliderWidget))
       
    84         {
       
    85         AlfWidgetInitData* initData = (AlfWidgetInitData*)aInitData;        
       
    86         auto_ptr<MulSliderWidget> widget(MulSliderWidget::create(
       
    87             *initData->mEnv, 
       
    88             *initData->mContainerWidget,
       
    89             initData->mWidgetId,
       
    90             initData->mCustomData));            
       
    91         ret = widget->makeInterface (IMulSliderWidget::type());
       
    92         widget.release();
       
    93         }
       
    94     else if (!strcmp(aProduct, KSliderModel))
       
    95         {
       
    96         auto_ptr<MulSliderModel> model(new(EMM) MulSliderModel());
       
    97         ret = model->makeInterface (IMulSliderModel::type());
       
    98         model.release();
       
    99         }
       
   100     // Vertical  element support template 3, 9
       
   101     else if (!strcmp(aProduct, KSliderVerticalElement))
       
   102         {
       
   103         AlfElementInitData* initData = (AlfElementInitData*) aInitData;
       
   104         auto_ptr<MulSliderVertical> element(
       
   105             new(EMM) MulSliderVertical(
       
   106                 (CAlfWidgetControl&)(*initData->mControl),
       
   107                 initData->mElementId,
       
   108                 initData->mCustomData));
       
   109                 
       
   110         ret = element->makeInterface(IMulSliderBaseElementInternal::type());
       
   111         element.release();
       
   112         }
       
   113     // Progressbar element support template 7,8 
       
   114         else if(!strcmp(aProduct, KSliderProgressbarElement))
       
   115         {
       
   116         AlfElementInitData* initData = (AlfElementInitData*) aInitData;
       
   117         auto_ptr<MulSliderProgressive> element(
       
   118             new(EMM) MulSliderProgressive(
       
   119                 (CAlfWidgetControl&)(*initData->mControl),
       
   120                 initData->mElementId,
       
   121                 initData->mCustomData));
       
   122         ret = element->makeInterface(IMulSliderBaseElementInternal::type());
       
   123         element.release();
       
   124         }      
       
   125     // Horizontal element support template 1,2,4,6      
       
   126         else if(!strcmp(aProduct, KSliderHorizontalElement))
       
   127         {
       
   128         AlfElementInitData* initData = (AlfElementInitData*) aInitData;
       
   129         auto_ptr<MulSliderHorizontal> element(
       
   130             new(EMM) MulSliderHorizontal(
       
   131                 (CAlfWidgetControl&)(*initData->mControl),
       
   132                 initData->mElementId,
       
   133                 initData->mCustomData));
       
   134         ret = element->makeInterface(IMulSliderBaseElementInternal::type());
       
   135         element.release();
       
   136         }      
       
   137   
       
   138     return ret;
       
   139     }
       
   140     
       
   141     
       
   142 // ---------------------------------------------------------------------------
       
   143 // From IAlfInterfaceBase.
       
   144 // Creates interface based on the given type.
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 IAlfInterfaceBase* MulSliderWidgetFactoryPlugin::makeInterface(
       
   148     const IfId& aType)
       
   149     {
       
   150     UString param (aType.mImplementationId);
       
   151     if (param == UString (IAlfFactoryPlugin::type().mImplementationId))
       
   152         {
       
   153         return static_cast<IAlfFactoryPlugin*> (this);
       
   154         }
       
   155     else
       
   156         {
       
   157         // Do Nothing
       
   158         }
       
   159     return NULL;
       
   160     }
       
   161     
       
   162     
       
   163 // ---------------------------------------------------------------------------
       
   164 // Returns the amount of products this factory can produce.
       
   165 // ---------------------------------------------------------------------------
       
   166 //
       
   167 int MulSliderWidgetFactoryPlugin::productCount() const
       
   168     {
       
   169     return KProductCount;
       
   170     }
       
   171     
       
   172     
       
   173 // ---------------------------------------------------------------------------
       
   174 // Returns product information.
       
   175 // ---------------------------------------------------------------------------
       
   176 //
       
   177 const char* MulSliderWidgetFactoryPlugin::productInfo (int aIndex) const
       
   178     {
       
   179     switch (aIndex)
       
   180         {
       
   181     case ESliderWidget:
       
   182         {
       
   183         return KSliderWidget;
       
   184         }    
       
   185 
       
   186     case ESliderModel:
       
   187         {
       
   188         return KSliderModel;
       
   189         }
       
   190 
       
   191     case ESliderHorizontalElement:
       
   192         {
       
   193         return KSliderHorizontalElement;
       
   194         }
       
   195 
       
   196     case ESliderVerticalElement:
       
   197         {
       
   198         return KSliderVerticalElement;
       
   199         }
       
   200         
       
   201     case ESliderProgressbarElement:
       
   202         {
       
   203         return KSliderProgressbarElement;
       
   204         }    
       
   205         
       
   206     default:
       
   207         break;
       
   208 
       
   209         }
       
   210 
       
   211     return 0;
       
   212     }
       
   213 
       
   214     }// NameSpace 
       
   215 
       
   216 
       
   217 // ---------------------------------------------------------------------------
       
   218 // OTHER EXPORTED FUNCTIONS.
       
   219 // ---------------------------------------------------------------------------
       
   220 //
       
   221 
       
   222 using namespace Alf;
       
   223 const TImplementationProxy ImplementationTable[] =
       
   224     {
       
   225 #ifdef __EABI__
       
   226     IMPLEMENTATION_PROXY_ENTRY (
       
   227         KScrollBarWidgetFactoryPluginUid, 
       
   228         MulSliderWidgetFactoryPlugin::NewL)
       
   229 #else
       
   230         {
       
   231         {KScrollBarWidgetFactoryPluginUid}, 
       
   232         MulSliderWidgetFactoryPlugin::NewL}
       
   233 #endif
       
   234     };
       
   235 
       
   236 OSN_EXPORT const TImplementationProxy* ImplementationGroupProxy(
       
   237     TInt& aTableCount)
       
   238     {
       
   239     aTableCount = sizeof (ImplementationTable) / sizeof (TImplementationProxy);
       
   240 
       
   241     return ImplementationTable;
       
   242     }
       
   243 
       
   244