mulwidgets/mulsliderwidget/inc/mulsliderwidget.h
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:  Widget interface with utilities for slider widget.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef ALF_SCROLLBARWIDGET_H
       
    19 #define ALF_SCROLLBARWIDGET_H
       
    20 
       
    21 // ToolKit Includes
       
    22 #include <alf/alfanchorlayout.h>
       
    23 
       
    24 // WidgetModel Includes
       
    25 #include <alf/ialfwidgeteventhandler.h>
       
    26 #include "alf/alfwidget.h"
       
    27 #include <alf/alfexceptions.h>
       
    28 
       
    29 // Widget Includes
       
    30 #include <mul/imulsliderwidget.h>
       
    31 #include <mul/imulslidermodel.h>
       
    32 
       
    33 
       
    34 // Forward Declarations
       
    35 // From Alfred Client
       
    36 class CAlfEnv;
       
    37 class CAlfDisplay;
       
    38 class CAlfControl;
       
    39 
       
    40 // From namespace Alf
       
    41 namespace Alf
       
    42     {
       
    43 // Forward Declarations
       
    44 class IAlfVariantType;
       
    45 class IAlfElement;
       
    46 class IAlfWidgetEventHandler;
       
    47 class INode;
       
    48 class IAlfWidgetFactoryBase;
       
    49 class CAlfWidgetControl;
       
    50 class IAlfModel;
       
    51 class AlfElement;
       
    52 class AlfVisualTemplate;
       
    53 //class AlfScrollBarWidgetAttributeOwner;
       
    54     }
       
    55 
       
    56 //From name space duiuimodel
       
    57 namespace duiuimodel
       
    58     {
       
    59 class DuiNode;
       
    60     }
       
    61 
       
    62 
       
    63 namespace Alf
       
    64     {
       
    65     class IMulSliderBaseElementInternal;
       
    66 
       
    67     /**
       
    68      * A basic slider widget implementation.
       
    69      * Contains methods for creating the default
       
    70      * building blocks for the slider widget.
       
    71      */
       
    72 class MulSliderWidget : public IMulSliderWidget
       
    73     {
       
    74 public:
       
    75 
       
    76     /**
       
    77      * Creator Method.
       
    78      * 
       
    79      * @param aEnv The environment for the widget.
       
    80      * @param aContainer The container widget where this widget is contained.
       
    81      * @param aWidgetId The name of the widget. Not Owned.
       
    82      * @param aFilePath Path to XML file describing the presentation 
       
    83      *                  of the widget. Not Owned.
       
    84      * @param aCustomData Custom data. Not Owned.
       
    85      * @param aNode Node. Not Owned.
       
    86      * @return MulSliderWidget , or NULL if it does not create 
       
    87      */
       
    88     static MulSliderWidget* create(CAlfEnv& aEnv, 
       
    89                                     IAlfContainerWidget& aContainer, 
       
    90                                     const char* aWidgetId, 
       
    91                                     AlfCustomInitDataBase* aCustomData=NULL);
       
    92 
       
    93     /**
       
    94      * Virtual Destructor.
       
    95      */ 
       
    96     virtual ~MulSliderWidget();
       
    97 
       
    98     // From IAlfInterfaceBase
       
    99     /**
       
   100      * Getter for interfaces provided by the slider widget class.
       
   101      *
       
   102      * @since S60 ?S60_version
       
   103      * @param aType A descriptor to identify the type of the queried interface.
       
   104      * @return The queried interface, or NULL if the interface is not
       
   105      *         supported or available.
       
   106      */
       
   107     IAlfInterfaceBase* makeInterface(const IfId& aType);
       
   108 
       
   109     // From IAlfWidget
       
   110 
       
   111     /**
       
   112      * Return the control
       
   113      */
       
   114     CAlfWidgetControl* control() const;
       
   115     
       
   116     /**
       
   117      * getter for the parent container. The ownership is not passed.
       
   118      * @param none
       
   119      * @return the parent container or NULL if the widget is the root-widget.
       
   120      */
       
   121     virtual IAlfContainerWidget* parent() const;
       
   122 
       
   123     /**
       
   124      * Setter for the control. The control is owned by the Alfred environment.
       
   125      *
       
   126      * @since S60 ?S60_version
       
   127      * @param aControl The control for this widget.
       
   128      * @param aDeletePreviousControl delete previous control.TRUE by default.
       
   129      * @return void.
       
   130      */
       
   131     void setControl(CAlfWidgetControl* aControl, 
       
   132                                     bool aDeletePreviousControl = true);
       
   133 		/**
       
   134 		API returns the Slider Model of the widget.
       
   135     */                                    
       
   136     IMulSliderModel& SliderModel() ;
       
   137     /**
       
   138      * Gets the model.
       
   139      */
       
   140     IAlfModel* model();
       
   141 
       
   142     /** 
       
   143      * Sets the model.
       
   144      
       
   145      * @return void.
       
   146      */
       
   147     void setModel(IAlfModel* aModel, bool /*param*/);
       
   148 
       
   149     /** 
       
   150      * Return the widget name
       
   151      */
       
   152     const char* widgetName() const;
       
   153 
       
   154     /**
       
   155      * sets the focus to the child.
       
   156      
       
   157      * @return void.
       
   158      */
       
   159     void setChildFocus(bool /*aFocus*/);
       
   160 
       
   161     
       
   162     
       
   163     /** 
       
   164      * Sets the presentation for the widget using presentation XML file.
       
   165      
       
   166      * Destroys any existing presentation.
       
   167      * @param aFilePath Path to XML file describing the presentation 
       
   168      *                  of the widget. Not Owned.
       
   169      * @exception AlfWidgetException if no visualization node available 
       
   170      *                               in Presentation XML or if no control
       
   171      *                               is associated with the widget.
       
   172      * @exception bad_alloc 
       
   173      * @since S60 ?S60_version
       
   174      * @return void.
       
   175      */
       
   176     virtual void setPresentation(const char* aFilePath);
       
   177     
       
   178 	/**
       
   179 	 * Set the transparency for the background of the slider widget.
       
   180 	 *
       
   181 	 * @param True,  to set background as transparent
       
   182 	 * @param False, to set background as opaque	
       
   183 	 */
       
   184 	void MakeTransparent( bool aTransparent ) ;
       
   185 	
       
   186 	/**
       
   187 	 * Enable/Disable key handling .
       
   188 	 *
       
   189 	 * @param aVal: True,  to handle keyevents by Application
       
   190 	 * 		 	  False, to handle keyevents as defined in the control	
       
   191 	 */
       
   192 	void SetHandleKeyEvent( bool aVal ) ;
       
   193 	/**
       
   194 	 * API to show the widget
       
   195 	 * @param aShow - Shows the widget on value True. 
       
   196 	 * @param aTransitionTime - Transition time for widget to be shown.
       
   197 	 */
       
   198 	void ShowWidget(bool aShow, int aTransitionTime =0);
       
   199 	/**
       
   200 	 * API returns true if the widget is hidden
       
   201 	 */
       
   202 	bool IsHidden();
       
   203 	/**
       
   204 	 * API returns the container layout. 
       
   205 	 */
       
   206 	const CAlfLayout& ContainerLayout(); 
       
   207 		/**
       
   208 	 * Update template .
       
   209 	 *
       
   210 	 * @param aTemplateId: template id
       
   211 	 * 		 	 
       
   212 	 */
       
   213 	void changeTemplate(int aTemplateId);
       
   214 	/**
       
   215 	 * Adds event Handling for the Widget.
       
   216 	 *
       
   217 	 * @param aObserver: Observer of widget.
       
   218 	 * 		 	 
       
   219 	 */
       
   220 	void AddEventHandler( IAlfWidgetEventHandler& aObserver) ;
       
   221 	/**
       
   222 	 * Remove an observer to widget
       
   223 	 *
       
   224 	 * @param aObserver Observer of widget.
       
   225 	 */
       
   226 	 void RemoveEventHandler( IAlfWidgetEventHandler& aObserver); 
       
   227 	 /**
       
   228 	 * Returns opcaity of the widget.
       
   229 	 * 		 	 
       
   230 	 */
       
   231 	 bool GetOpacity(); 
       
   232 	 /**
       
   233 	 * Returns true if Key handling is enabled by widget.
       
   234 	 * 		 	 
       
   235 	 */
       
   236 	 bool IsKeyEnabled(); 
       
   237 	 
       
   238 	 /** 
       
   239     	* returns the Slider element 
       
   240     	*/
       
   241     IMulSliderBaseElementInternal* GetSliderElement();
       
   242     
       
   243     
       
   244 protected:
       
   245 
       
   246     /**
       
   247      * C++ constructor.
       
   248      * 
       
   249      * @param aEnv The environment for the widget.
       
   250      * @param aContainer The container widget where this widget is contained.
       
   251      * @param aWidgetId The name of the widget. Not Owned.
       
   252      * @param aFilePath Path to XML file describing the presentation 
       
   253      *                  of the widget. Not Owned.
       
   254      * @param aCustomData Custom data.
       
   255      * @param aNode Node. Not Owned.
       
   256      */
       
   257     MulSliderWidget(CAlfEnv& aEnv, 
       
   258                         IAlfContainerWidget& aContainer, 
       
   259                         const char* aWidgetId, 
       
   260                         AlfCustomInitDataBase* aCustomData=NULL);
       
   261 
       
   262     /**
       
   263      * Methods to create different default elements and control of scroll bar.
       
   264      *
       
   265      * @param aEnv The environment for the widget.
       
   266      * @param aDisplay The display for the widget.
       
   267      * @return void.
       
   268      */
       
   269     void constructDefault(CAlfEnv& aEnv, 
       
   270                             AlfCustomInitDataBase* aCustomData=NULL);
       
   271 
       
   272     /**
       
   273      * Constructs widget from declaration.
       
   274      *
       
   275      * @param aEnv The environment for the widget.
       
   276      * @param aNode declaration node.
       
   277      * @return void.
       
   278      */
       
   279     void constructComponentsFromNode(CAlfEnv& aEnv, 
       
   280                                     DuiNode& aNode);
       
   281 
       
   282     /**
       
   283      * Constructs widget from declaration. Recursive.
       
   284      *
       
   285      * @param aNode declaration node.
       
   286      */
       
   287     void processTreeRecursively( DuiNode& aNode );
       
   288     
       
   289     /** 
       
   290      * Creates the the widget using presentation XML file.
       
   291      * Other widget parts are default.
       
   292      * @param aEnv Alf Client Environment     
       
   293      * @param aFilePath Path to XML file describing the presentation 
       
   294      *                  of the widget. Not Owned.
       
   295      * @exception AlfWidgetException if no visualization node available 
       
   296      *                               in Presentation XML
       
   297      * @exception bad_alloc      
       
   298      * @since S60 ?S60_version
       
   299      * @return void.
       
   300      */
       
   301     void constructFromPresentationXML(CAlfEnv& aEnv, const char *aFilePath);
       
   302 
       
   303     /**
       
   304      * Creates the default control.
       
   305      *
       
   306      * @param aEnv The environment for the widget.
       
   307      * @return The Control.
       
   308      */
       
   309     CAlfWidgetControl *constructDefaultControl(CAlfEnv& aEnv);
       
   310     
       
   311 private :
       
   312 		/**
       
   313 			* Creates a Slider elment.
       
   314 			* @param - aElementId 
       
   315 			*/
       
   316     void CreateSliderElement(const char* aElementId);
       
   317     
       
   318 private:
       
   319 
       
   320     /**
       
   321      * Base widget. Own.
       
   322      */
       
   323      
       
   324     auto_ptr<AlfWidget> mWidget;
       
   325      
       
   326     /*
       
   327      * IAlfAttributeOwner implementation. Own.
       
   328      */
       
   329     //auto_ptr<AlfScrollBarWidgetAttributeOwner> mAttributeOwner;
       
   330     	 
       
   331 	IMulSliderBaseElementInternal* mElement;
       
   332     IMulSliderModel * mSliderModel; 
       
   333     CAlfWidgetControl * mSliderControl;
       
   334     bool mOpacity;
       
   335     bool mHandleKeyEvent;
       
   336     }; // class MulSliderWidget
       
   337     
       
   338     } // namespace Alf
       
   339 
       
   340 #endif // C_ALFSCROLLBARWIDGET_H