mulwidgets/muldatamodel/inc/muldatawindow.h
changeset 0 e83bab7cf002
equal deleted inserted replaced
-1:000000000000 0:e83bab7cf002
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Data Window Implemenation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MULDATAWINDOW_H_
       
    20 #define MULDATAWINDOW_H_
       
    21 
       
    22 #include "mulmodeldef.h"
       
    23 
       
    24 namespace Alf
       
    25 	{
       
    26 	
       
    27 //Forward Declaration
       
    28 class MulModelImpl;
       
    29 
       
    30 /**
       
    31  * Implametation of Data Window Class
       
    32  * This class maintain offset for buffer item that are required by widget,
       
    33  * so only that much item remain present in alf model instance.It update buffer items
       
    34  * when highlight changed and notify model to update alf model if items are not present
       
    35  * in Alf model.
       
    36  * 
       
    37  */
       
    38 class MulDataWindow
       
    39 	{
       
    40 public: //Constructor and Destructor
       
    41 	
       
    42 	/**
       
    43 	 * C++ constructor
       
    44 	 * 
       
    45 	 * @param aMulModel refrece of model implementation
       
    46 	 */
       
    47 	MulDataWindow( MulModelImpl& aMulModel );
       
    48 
       
    49 	/**
       
    50 	 * Descturctor
       
    51 	 */
       
    52 	~MulDataWindow();
       
    53 	
       
    54 public: //New Method
       
    55 
       
    56 	/**
       
    57 	 * Set window size
       
    58 	 * 
       
    59 	 * @param aWindowSize No of items that are visible on screen
       
    60 	 */
       
    61 	void SetWindowSize( int aWindowSize );
       
    62 	
       
    63 	/**
       
    64 	 * Set Buffer size
       
    65 	 * Here buffser size mean number of items that will be above and below window
       
    66 	 * By default buffer size is equal to window size if following api is not called.
       
    67 	 *
       
    68 	 * @param aBufferSize Size of buffer
       
    69 	 */
       
    70 	void SetBufferSize( int aBufferSize );
       
    71 	
       
    72 	/**
       
    73 	 * Change highlighted index. 
       
    74 	 * Changing highlight will check that data window needs to be updated or not 
       
    75 	 * and if required it update data window
       
    76 	 *
       
    77 	 * @aHighlightIndex New highlighted item in Data window
       
    78 	 * @throws invaid_argument exception
       
    79 	 */
       
    80 	void SetHighlight( int aHighlightIndex );
       
    81 	
       
    82 	/**
       
    83 	 * Scroll Window to mention item index 
       
    84 	 * it will check that data window needs to be updated or not 
       
    85 	 * and if required it update data window
       
    86 	 *
       
    87 	 * @aItemIndex item index
       
    88 	 * @throws invaid_argument exception
       
    89 	 */
       
    90 	void ScrollWindow( int aItemIndex );
       
    91 	
       
    92 	/**
       
    93 	 * Return Highlighted item's index
       
    94 	 * 
       
    95 	 * @return Highlighted item's index
       
    96 	 */
       
    97 	int Highlight() const
       
    98 		{
       
    99 		return mHighlight;
       
   100 		}
       
   101 	
       
   102 	/**
       
   103 	 * Return previous top offset
       
   104 	 * 
       
   105 	 * @return Previos top offset
       
   106 	 */
       
   107 	int OldTopOffset() const
       
   108 		{
       
   109 		return mOldBufferTop;
       
   110 		}
       
   111 	
       
   112 	/**
       
   113 	 * Return previous bottom offset
       
   114 	 * 
       
   115 	 * @return Previos bottom offset
       
   116 	 */
       
   117 	int OldBottomOffset() const
       
   118 		{
       
   119 		return mOldBufferBottom;
       
   120 		}
       
   121 	
       
   122 	/**
       
   123 	 * Return current top offset
       
   124 	 * 
       
   125 	 * @return Current top offset
       
   126 	 */
       
   127 	int TopOffset() const
       
   128 		{
       
   129 		return mBufferTop;
       
   130 		}
       
   131 	
       
   132 	/**
       
   133 	 * Return current bottom offset
       
   134 	 * 
       
   135 	 * @return Current bottom offset
       
   136 	 */
       
   137 	int BottomOffset() const
       
   138 		{
       
   139 		return mBufferBottom;
       
   140 		}
       
   141 	
       
   142 	/**
       
   143 	 * Return visible window top offset
       
   144 	 * 
       
   145 	 * @return Current window top offset
       
   146 	 */
       
   147 	int TopWindowOffset() const
       
   148 		{
       
   149 		return mWindowTop;
       
   150 		}
       
   151 	
       
   152 	/**
       
   153 	 * Return visible window bottom offset
       
   154 	 * 
       
   155 	 *  @return Current window bottom offset
       
   156 	 */
       
   157 	int BottomWindowOffset() const
       
   158 		{
       
   159 		return mWindowBottom;
       
   160 		}
       
   161 		
       
   162 	/**
       
   163 	 * Return the Old Rear Top offset
       
   164 	 * 
       
   165 	 * @return Old Rear Top offset
       
   166 	 */
       
   167 	int OldRearTopOffset() const
       
   168 		{
       
   169 		return mOldRearBufferTop;
       
   170 		}
       
   171 	
       
   172 	/**
       
   173 	 * Return the Old Rear Bottom offset
       
   174 	 * 
       
   175 	 * @return Old Rear Bottom offset
       
   176 	 */
       
   177 	int OldRearBottomOffset() const
       
   178 		{
       
   179 		return mOldRearBufferBottom;
       
   180 		}		
       
   181 	
       
   182 	/**
       
   183 	 * Return the Rear Top offset
       
   184 	 * 
       
   185 	 * @return Rear Top offset
       
   186 	 */
       
   187 	int RearTopOffset() const
       
   188 		{
       
   189 		return mRearBufferTop;
       
   190 		}
       
   191 	
       
   192 	/**
       
   193 	 * Return the Rear Bottom offset
       
   194 	 * 
       
   195 	 * @return Rear Bottom offset
       
   196 	 */
       
   197 	int RearBottomOffset() const
       
   198 		{
       
   199 		return mRearBufferBottom;
       
   200 		}
       
   201 	
       
   202 	/**
       
   203 	 * Return buffer size
       
   204 	 * 
       
   205 	 * @return Current buffer size
       
   206 	 */
       
   207 	int BufferSize() const
       
   208 		{
       
   209 		return mBufferSize;
       
   210 		}
       
   211 		
       
   212 	/**
       
   213 	 * Return window size
       
   214 	 * 
       
   215 	 * @return Current window size
       
   216 	 */
       
   217 	int WindowSize() const
       
   218 		{
       
   219 		return mWindowSize;
       
   220 		}		
       
   221 	
       
   222 	/**
       
   223 	 * Check that items falls in data window or not
       
   224 	 * 
       
   225 	 * @param aItemIndex index of item
       
   226 	 * @return true if item is in data window otherwise false
       
   227 	 */
       
   228 	bool IsItemInDataWindow(int aItemIndex ) const;
       
   229 	
       
   230 	/**
       
   231 	 * Returns Relative index in datawindow from Absolute index
       
   232 	 *
       
   233 	 * @param aAbsoluteIndex Absolute index
       
   234 	 * @return Relative index
       
   235 	 */
       
   236 	int RelativeIndex( int aAbsoluteIndex ) const;
       
   237 	
       
   238 	/**
       
   239 	 * Returns Absoulte index from relative index
       
   240 	 *
       
   241 	 * @param aRelativeIndex Relative index
       
   242 	 * @return Absolute index
       
   243 	 */
       
   244 	int AbsoluteIndex( int aRelativeIndex ) const;
       
   245 	
       
   246 	/**
       
   247 	 * Check that valid window size it set or not.
       
   248 	 * 
       
   249 	 * @return true - valid window size is set 
       
   250 	 * 		   false - otherwisze
       
   251 	 */
       
   252 	bool IsWindowEnabled() const
       
   253 		{
       
   254 		return ( mWindowSize != KNotInitialized );
       
   255 		}
       
   256 
       
   257 	/**
       
   258 	 * Adjust buffer offset according to window offset
       
   259 	 */
       
   260 	void AdjustBuffer();
       
   261 	
       
   262 	/**
       
   263 	 * modify the window top and window bottom values
       
   264 	 */	
       
   265 	void SetVisibleWindow(int aWindowTop, int aWindowBottom);
       
   266 	
       
   267 	/**
       
   268 	 * Return the complete buffer size, i.e. both top, bottom buffer and the window
       
   269 	 */	
       
   270 	int ActualBufferSize() const
       
   271 		{
       
   272 		return (2 * mBufferSize) + mWindowSize;	
       
   273 		}
       
   274 		
       
   275 	/**
       
   276 	 * Change highlighted index. 
       
   277 	 * This change will not check that data window needs to be updated or not 
       
   278 	 *
       
   279 	 * @aHighlightIndex New highlighted item in Data window
       
   280 	 * @throws invaid_argument exception
       
   281 	 */
       
   282 	void UpdateHighlight( int aHighlightIndex );
       
   283 		
       
   284 	/**
       
   285 	 * Save old values
       
   286 	 */
       
   287 	void SaveOldValues()
       
   288 		{
       
   289 		mOldBufferTop = mBufferTop;
       
   290 		mOldBufferBottom = mBufferBottom;
       
   291 		
       
   292 		mOldRearBufferTop = mRearBufferTop;
       
   293 		mOldRearBufferBottom = mRearBufferBottom;
       
   294 		}
       
   295 		
       
   296 	/**
       
   297 	 * Compares the current and old buffer values and returns true if teh values are cahnged
       
   298 	 */
       
   299 	bool IsBufferOffsetChanged();					
       
   300 
       
   301 private://New Method
       
   302 	
       
   303 	/**
       
   304 	 * Check that visible window need to be updated or not.
       
   305 	 * If required it update visible window.
       
   306 	 */
       
   307 	void UpdateDataWindow();
       
   308 	
       
   309 	/**
       
   310 	 * Data window is updated and window need to sifted down
       
   311 	 */
       
   312 	void ShiftWindowDown();
       
   313 	
       
   314 	/**
       
   315 	 * Data window is updated and window need to sifted up
       
   316 	 */
       
   317 	void ShiftWindowUp();
       
   318 			
       
   319 private: // Data
       
   320 
       
   321 	MulModelImpl& mMulModel; //not own
       
   322 	
       
   323 	int mHighlight;	
       
   324 	
       
   325 	//this is index of item wich decide window offset
       
   326 	int mItemIndex; //dont know what should be better name
       
   327 	int mOldItemIndex;
       
   328 	
       
   329 	int mBufferSize;
       
   330 	
       
   331 	int mWindowSize;
       
   332 	int mWindowOffset;
       
   333 	
       
   334 	int mWindowTop;
       
   335 	int mWindowBottom;
       
   336 	
       
   337 	int mBufferTop;
       
   338 	int mBufferBottom;
       
   339 	
       
   340 	int mOldBufferTop;
       
   341 	int mOldBufferBottom;
       
   342 		
       
   343 	int mRearBufferTop;
       
   344 	int mRearBufferBottom;
       
   345 	
       
   346 	int mOldRearBufferTop;
       
   347 	int mOldRearBufferBottom;
       
   348 	
       
   349 	};
       
   350 
       
   351 	} //namespace Alf
       
   352 
       
   353 #endif /*MULDATAWINDOW_H_*/
       
   354 
       
   355 //End of file
       
   356