mulwidgets/mulsliderwidget/inc/mulslidermodel.h
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     1 /*
       
     2 * Copyright (c) 2007 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: Header for presentation element - slider model interface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MUL_SLIDERMODEL_H
       
    20 #define MUL_SLIDERMODEL_H
       
    21 
       
    22 // Widget Model and Exported API includes
       
    23 #include <mul/imulslidermodel.h>
       
    24 
       
    25 // OsnCore includes
       
    26 #include <osn/alfptrvector.h>
       
    27 #include <osn/ustring.h>
       
    28 #include "imulsliderbaseelementinternal.h"
       
    29 #include <mul/mulvisualitem.h>
       
    30 #include <mul/imulsliderwidget.h>
       
    31 // Namespace
       
    32 using namespace osncore;
       
    33 
       
    34 namespace Alf
       
    35     {
       
    36 
       
    37 //Forward Declarations
       
    38 class AlfModel;
       
    39 class MulSliderWidget;
       
    40 
       
    41 /**
       
    42  *  slider model implementation.
       
    43  *
       
    44  *  Implements utility methods to create and update
       
    45  *  the data hierarchy of a slider.
       
    46  */
       
    47 class MulSliderModel : public IMulSliderModel
       
    48     {
       
    49 public:
       
    50     /////////////////////////////////////////
       
    51     /////// FROM MULSLIDER//////////////////
       
    52 	/**
       
    53 	 * Set the value of the primary thumb.
       
    54 	 *
       
    55 	 * @param aValue Position of the primary thumb.
       
    56 	 *  
       
    57 	 */
       
    58 	 void SetPrimaryValue(int aValue) ;
       
    59 
       
    60 	/**
       
    61 	 * Return the value of the primary thumb of the slider.
       
    62 	 *
       
    63 	 *  @return Value of the primary thumb.
       
    64 	 *  
       
    65 	 */
       
    66 	 int PrimaryValue() const ;
       
    67 	
       
    68 	/**
       
    69 	 * Set the value of the secondary thumb.
       
    70 	 *
       
    71 	 * @param aValue Position of the secondary thumb.
       
    72 	 *  
       
    73 	 */
       
    74 	 void SetSecondaryValue(int aValue) ;
       
    75 
       
    76 	/**
       
    77 	 * Return the value of the secondary thumb of the slider.
       
    78 	 *
       
    79 	 *  @return Value of the secondary thumb.
       
    80 	 *  
       
    81 	 */
       
    82 	 int SecondaryValue() const ;
       
    83 
       
    84 	/**
       
    85 	 * Return the total number of ticks.
       
    86 	 *
       
    87 	 *  @return Number of ticks (int)
       
    88 	 *  
       
    89 	 */
       
    90 	 int TotalTicks() const ;
       
    91 
       
    92 
       
    93 	/**
       
    94 	 * Set Template that will be used to represent data.
       
    95 	 * 
       
    96 	 * @param aTemplateId Template associated with the widget.
       
    97 	 * 
       
    98 	 */
       
    99 	 void SetTemplate( sliderTemplate aTemplateId) ;
       
   100 	 
       
   101 	/**
       
   102 	 * Get Template that will be used to represent data.
       
   103 	 * 
       
   104 	 * 
       
   105 	 * 
       
   106 	 */
       
   107 	 sliderTemplate GetTemplate();
       
   108 	 
       
   109     /**
       
   110 	 * SetRightText that will be used to represent data.
       
   111 	 * 
       
   112 	 * @param aRightText
       
   113 	 * 
       
   114 	 */
       
   115 	 void SetRightText(char* aRightText) ;
       
   116 	
       
   117 	/**
       
   118 	 * GetRightText that will be used to represent data.
       
   119 	 * 
       
   120 	 *
       
   121 	 * 
       
   122 	 */
       
   123 	 const char* GetRightText() ;
       
   124      
       
   125      /**
       
   126 	 * SetLeftText that will be used to represent data.
       
   127 	 * 
       
   128 	 * @param aLeftText 
       
   129 	 * 
       
   130 	 */
       
   131 	 void SetLeftText(char* aLeftText) ;
       
   132      
       
   133      /**
       
   134 	 * GetLeftText that will be used to represent data.
       
   135 	 * 
       
   136 	 * 
       
   137 	 * 
       
   138 	 */
       
   139 	 const char* GetLeftText() ;
       
   140 	
       
   141 	 /**
       
   142 	 * SetPercentText that will be used to represent data.
       
   143 	 * 
       
   144 	 * 
       
   145 	 */	 
       
   146 	 void SetPercentText(char* aPercText) ;			
       
   147 			
       
   148      /**
       
   149 	 * GetPercentText that will be used to represent data.
       
   150 	 *
       
   151 	 * 
       
   152 	 */				
       
   153 	 const char* GetPercentText() ;
       
   154 	
       
   155 	  /**
       
   156 	 * SetMinRange that will be used to represent data.
       
   157 	 * 
       
   158 	 * 
       
   159 	 */
       
   160 	 void SetMinRange(int aMinRange) ;
       
   161      
       
   162       /**
       
   163 	 * GetMinRange that will be used to represent data.
       
   164 	 * 
       
   165 	 * 
       
   166 	 */
       
   167 	 int MinRange()const ;
       
   168 	
       
   169 	  /**
       
   170 	 * SetMaxRange that will be used to represent data.
       
   171 	 * 
       
   172 	 * 
       
   173 	 */				
       
   174 	 void SetMaxRange(int aMaxRange) ;
       
   175      
       
   176      /**
       
   177 	 * MaxRange that will be used to represent data.
       
   178 	 * 
       
   179 	 * 
       
   180 	 */
       
   181 	 int MaxRange()const ;
       
   182      
       
   183      /**
       
   184 	 * SetTick that will be used to represent data.
       
   185 	 * 
       
   186 	 * 
       
   187 	 */
       
   188 	 void SetTick(int aTick) ;
       
   189 
       
   190      /**
       
   191 	 * GetTick that will be used to represent data.
       
   192 	 * 
       
   193 	 * 
       
   194 	 */
       
   195 	 int Tick()const ;
       
   196     	 
       
   197     /**
       
   198      * Constructor.
       
   199      */
       
   200     MulSliderModel();
       
   201 
       
   202     /**
       
   203      * Destructor.
       
   204      */
       
   205     ~MulSliderModel();
       
   206 
       
   207     
       
   208 
       
   209     /** From base class IAlfModel
       
   210      *
       
   211      */
       
   212 
       
   213     /**
       
   214      *  Add a new observer to be notified of any changes in the model.
       
   215      *
       
   216      *  @param    aObserver   The model change observer to be added.
       
   217      *  @return void
       
   218      *  @since S60 ?S60_version
       
   219      */
       
   220     void addModelChangeObserver(IAlfModelChangeObserver& aObserver);
       
   221 
       
   222     /**
       
   223      *  Remove an observer which is added to get notified of any changes
       
   224      *  in the model.
       
   225      *
       
   226      *  @param aObserver The model change observer to be removed.
       
   227      *  @return void
       
   228      *  @since S60 ?S60_version
       
   229      */
       
   230     void removeModelChangeObserver(IAlfModelChangeObserver& aObserver);
       
   231 
       
   232     /**
       
   233      *  API to change the model completely at one short. 
       
   234      *  
       
   235      *  @see IAlfModel
       
   236      *  @param    aData    The new data.
       
   237      *  @return void
       
   238      *  @since S60 ?S60_version
       
   239      */
       
   240     void setData(IAlfVariantType* aData);
       
   241 
       
   242     /**
       
   243      * Change a given  of data fields in the model . All model change
       
   244      * observers are notified about the change.
       
   245      *
       
   246      * @param aNumContainerIndices The number of indices in aContainerIndices.
       
   247      * @param aContainerIndices    The container indices to find the correct 
       
   248      *                             location in the data hierarchy.The ownership 
       
   249      *                             is transferred. 
       
   250      * @param aData                The new data to be set.
       
   251      * @since S60 ?S60_version
       
   252      */
       
   253     void updateData(int  aNumContainerIndices,
       
   254         int* aContainerIndices,
       
   255         IAlfVariantType* aData);
       
   256 
       
   257     /**
       
   258      * Add a  number of data fields in the model data. All model change
       
   259      * observers are notified about the change.
       
   260      *
       
   261      * @param aNumContainerIndices The number of indices in aContainerIndices.
       
   262      * @param aContainerIndices    The container indices to find the correct 
       
   263      *                             location in the data hierarchy.The ownership
       
   264      *                             is transferred. 
       
   265      * @param aData                The new data.
       
   266      * @return void
       
   267      * @since S60 ?S60_version
       
   268      */
       
   269     void addData(int aNumContainerIndices,
       
   270         int* aContainerIndices,
       
   271         IAlfVariantType* aData);
       
   272 
       
   273     /**
       
   274      * Remove a  number of data fields in the model data. All model change
       
   275      * observers are notified about the change.
       
   276      *
       
   277      * @param aNumContainerIndices The number of indices in aContainerIndices.
       
   278      * @param aContainerIndices    The container indices to find the correct 
       
   279      *                             location in the data hierarchy.The ownership
       
   280      *                             is transferred.
       
   281      * @return void
       
   282      * @since S60 ?S60_version
       
   283      */
       
   284     void removeData(int aNumContainerIndices, int* aContainerIndices);
       
   285 
       
   286     /**
       
   287      *  API for executing batch operations
       
   288      *
       
   289      *  @param aOperationsArray    An RPOinterArray containing the list of 
       
   290      *                             operations to be executed in batch.
       
   291      *  @return void
       
   292      *  @since S60 ?S60_version
       
   293      */
       
   294     void executeOperations(AlfPtrVector<AlfModelOperation>&  aOperationsArray);
       
   295 
       
   296     /**
       
   297      *  API for executing one operation at a Time
       
   298      *
       
   299      *  @param aOperation          An Operation to be executed on the model.
       
   300      *  @since S60 ?S60_version
       
   301      */
       
   302     void executeOperation(AlfModelOperation* aOperation);
       
   303 
       
   304     /**
       
   305      *  Clears the Model.
       
   306      *
       
   307      *  @return void
       
   308      *  @since S60 ?S60_version
       
   309      */
       
   310     void clearModel();
       
   311        
       
   312     IAlfVariantType* data() const;
       
   313 
       
   314     IAlfInterfaceBase* makeInterface(const IfId& aType);
       
   315     
       
   316    /**
       
   317     *  Get the Element Interface.
       
   318     *
       
   319     *  @return The Element pointer.
       
   320     *  @since S60 ?S60_version
       
   321     */
       
   322     IMulSliderBaseElementInternal* GetElement();
       
   323     
       
   324     
       
   325     /**
       
   326      * SetData
       
   327      */
       
   328     void SetData(const MulVisualItem& aSliderItem);
       
   329   
       
   330     
       
   331     /**
       
   332      * Data
       
   333      */
       
   334     const MulVisualItem& Data() const;
       
   335 
       
   336     
       
   337     /*
       
   338      * IsLandscape
       
   339      */
       
   340     bool IsLandscape();
       
   341   
       
   342     
       
   343     /**
       
   344      * pointer to slidermodelData.
       
   345      */  
       
   346     void storeWidget(MulSliderWidget* aWidget);
       
   347     
       
   348     void UpdateElement();
       
   349  
       
   350 private:
       
   351     
       
   352 	/*
       
   353      * pointer to slidermodelData.
       
   354      */ 
       
   355     struct SliderModelDataImpl *mSldrModelData;
       
   356 
       
   357     AlfModel* mModel;  //Owned
       
   358     }; // class MulSliderModel
       
   359 
       
   360     } // End of namespace Alf
       
   361 
       
   362 #endif // MUL_SLIDERMODEL_H
       
   363 //End Of File