00001 /* 00002 * ============================================================================ 00003 * Name : CAknSlider from aknslider.h 00004 * Part of : Avkon 00005 * Description : Slider editor class 00006 * Version : %version: e003sa02#25 % 00007 * 00008 * Copyright © 2005-2006 Nokia. All rights reserved. 00009 * This material, including documentation and any related 00010 * computer programs, is protected by copyright controlled by 00011 * Nokia. All rights are reserved. Copying, including 00012 * reproducing, storing, adapting or translating, any 00013 * or all of this material requires the prior written consent of 00014 * Nokia. This material also contains confidential 00015 * information which may not be disclosed to others without the 00016 * prior written consent of Nokia. 00017 * ============================================================================ 00018 */ 00019 00020 #ifndef __AKNSLIDER_H__ 00021 #define __AKNSLIDER_H__ 00022 00023 // INCLUDES 00024 #include <eikbctrl.h> 00025 #include <eiklabel.h> 00026 #include <eikimage.h> 00027 #start_since SINCE_3_1_SDK 00028 #include <avkon.hrh> // For TAknOrientation 00029 #end_since SINCE_3_1_SDK 00030 00031 // CONSTANTS 00032 00033 // The following is max. length of the entire formatted value text including 00034 // number, special characters and supplied text. 00035 const TInt KValueLabelTextMaxLength = 30; 00036 00037 // Forward declarations 00038 class CGulIcon; 00039 class MAknsSkinInstance; 00040 class CAknSliderExtension; 00041 #start_since SINCE_3_1_SDK 00042 class CAknSliderData; 00043 struct TAknSliderGfx; 00044 #end_since SINCE_3_1_SDK 00045 00046 // CLASS DECLARATION 00047 class CAknSlider : public CEikBorderedControl 00048 { 00049 public: // Enumerations 00050 #start_since SINCE_3_1_SDK 00051 00057 enum 00058 { 00063 EElemEmptyLeftCap, 00064 00069 EElemEmptyRightCap, 00070 00074 EElemEmptyLine, 00075 00079 EElemFilledLine, 00080 00084 EElemFilledLeftCap, 00085 00089 EElemFilledRightCap, 00090 00094 EElemMarker, 00095 00100 EElemTickMark 00101 }; 00102 #end_since SINCE_3_1_SDK 00103 #start_since SINCE_3_1_SDK 00104 00109 enum 00110 { 00123 EPosFilling = 0x01, 00129 EPosMarker = 0x02 00130 }; 00131 #end_since SINCE_3_1_SDK 00132 public: 00136 IMPORT_C CAknSlider(); 00137 00141 IMPORT_C ~CAknSlider(); 00142 00152 IMPORT_C void SetValueL( TInt aValue ); 00153 00159 IMPORT_C TInt Value() const; 00160 00168 IMPORT_C void SetRange( TInt aMinimumValue, TInt aMaximumValue ); 00169 00176 IMPORT_C void SetStepSize( TInt aStepSize ); 00177 00183 IMPORT_C void SetMinimumTextL( const TDesC& aText ); 00184 00190 IMPORT_C void SetMaximumTextL( const TDesC& aText ); 00191 00197 IMPORT_C void SetDecimalPlaces( TInt aDecimalPlaces ); 00198 00204 IMPORT_C TInt DecimalPlaces() const; 00205 00206 #start_since SINCE_3_1_SDK 00207 00239 IMPORT_C void SetGraphics( TInt aElement, 00240 CFbsBitmap* aBitmap, 00241 CFbsBitmap* aMask ); 00242 #end_since SINCE_3_1_SDK 00243 00244 #start_since SINCE_3_1_SDK 00245 00258 IMPORT_C void UseDefaultGraphics( TInt aElement ); 00259 #end_since SINCE_3_1_SDK 00260 00261 #start_since SINCE_3_1_SDK 00262 00277 IMPORT_C TBool UsesDefaultGraphics( TInt aElement ) const; 00278 #end_since SINCE_3_1_SDK 00279 00280 #start_since SINCE_3_1_SDK 00281 00299 IMPORT_C void SetPositionIndicators( TUint32 aFlags ); 00300 #end_since SINCE_3_1_SDK 00301 00302 00303 #start_since SINCE_3_1_SDK 00304 00312 IMPORT_C TUint32 PositionIndicators() const; 00313 #end_since SINCE_3_1_SDK 00314 00315 #start_since SINCE_3_1_SDK 00316 00324 IMPORT_C TAknOrientation Orientation() const; 00325 #end_since SINCE_3_1_SDK 00326 00327 #start_since SINCE_3_1_SDK 00328 00338 IMPORT_C void SetTicksEnabled( TBool aStatus ); 00339 #end_since SINCE_3_1_SDK 00340 00341 #start_since SINCE_3_1_SDK 00342 00350 IMPORT_C TBool TicksEnabled() const; 00351 #end_since SINCE_3_1_SDK 00352 00353 #start_since SINCE_3_1_SDK 00354 00365 IMPORT_C void SetTickInterval( TUint aInterval ); 00366 #end_since SINCE_3_1_SDK 00367 00368 #start_since SINCE_3_1_SDK 00369 00377 IMPORT_C TUint TickInterval() const; 00378 #end_since SINCE_3_1_SDK 00379 00391 IMPORT_C static CFbsBitmap* CreateBitmapL( TInt aValue, 00392 TInt aResourceId ); 00393 00405 IMPORT_C static CFbsBitmap* CreateBitmapL( TInt aValue, 00406 TInt aMinimumValue, 00407 TInt aMaximumValue ); 00408 00419 IMPORT_C static CGulIcon* CreateSetStyleListBoxIconL( TInt aValue, 00420 TInt aResourceId ); 00421 00432 IMPORT_C static CGulIcon* CreateSetStyleListBoxIconL( TInt aValue, 00433 TInt aMinimumValue, 00434 TInt aMaximumValue ); 00435 00436 public: 00443 TSize MinimumSize(); 00444 00452 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 00453 TEventCode aType ); 00454 00460 IMPORT_C void ConstructFromResourceL( TResourceReader& aReader ); 00461 00469 IMPORT_C void ConstructFromResourceL( CCoeControl* aParent, 00470 TInt aValue, 00471 TResourceReader& aReader ); 00472 00478 IMPORT_C void HandleResourceChange( TInt aType ); 00479 00480 public: 00487 IMPORT_C TInt NumberOfLines() const; 00488 00499 IMPORT_C static HBufC* CreateValueTextInHBufCL( TInt aValue, 00500 TInt aResourceId ); 00501 00502 protected: 00506 void SizeChanged(); 00507 00513 void Draw( const TRect& aRect ) const; 00514 00520 IMPORT_C virtual TInt CountComponentControls() const; 00521 00528 IMPORT_C virtual CCoeControl* ComponentControl( TInt aIndex ) const; 00529 00530 public: 00536 IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); 00537 00538 private: 00542 IMPORT_C void* ExtensionInterface( TUid aInterface ); 00543 00544 protected: 00548 IMPORT_C void SetValueTextL(); 00549 00550 private: 00555 void ConstructL(); 00556 00557 void InitializeBitmapsL(); 00558 00568 static void DoSetValueTextL( TDes& valueBuf, TInt aValue, 00569 const CAknSliderData& aResourceData ); 00573 TInt RepeatStepSize() const; 00574 00581 CAknSliderData* SliderData() const; 00582 00598 static void FormatWithOrWithoutTokenL( TDes& aOutput, 00599 const TDesC& aFormat, 00600 const TDesC& aValue ); 00601 00602 // layout methods 00603 void FormSliderLayout1(); 00604 void FormSliderLayout2(); 00605 void FormSliderLayout3(); 00606 void SettingsItemSliderLayout(); 00607 void MIDPFormSliderLayout(); 00608 00609 void SetLabelColor(); 00610 00611 // Temporary methods for vertical or horizontal layout 00612 void MockVerticalSliderLayout(); 00613 void MockHorizontalSliderLayout(); 00614 00615 void CreateDecoratorImageFromResourceL( TInt aImageResourceId ); 00616 00617 // Internal access methods 00618 TInt Layout() const; 00619 TInt StepSize() const; 00620 TInt MaximumValue() const; 00621 TInt MinimumValue() const; 00622 TInt Range() const; 00623 00624 // Starts a timer for feedback effect visualization. 00625 void StartTimerL(); 00626 00627 // Callback for feedback effect. 00628 static TInt IndicationDrawCallbackL( TAny* aThis ); 00629 00630 // Implementation of the feedback effect. 00631 void SmallDirectionIndicationL(); 00632 00633 void DrawHorizontalTickMarks( CWindowGc& aGc ) const; 00634 void DrawVerticalTickMarks( CWindowGc& aGc ) const; 00635 00636 void TranslateValueL( TInt aDelta ); 00637 00638 void GetMarkerRect( TRect& aRect ) const; 00639 TSize MarkerSize() const; 00640 TPoint MarkerPos() const; 00641 00642 void DrawHorizontal( TBool aDrawMarker ) const; 00643 void DrawVertical( TBool aDrawMarker ) const; 00644 00645 void DrawHorizontalLine( CWindowGc& aGc ) const; 00646 void DrawVerticalLine( CWindowGc& aGc ) const; 00647 00648 void FetchGfx( TAknSliderGfx& aGfx, TInt aElement, const TSize& aSize ) const; 00649 00650 // calculate the correct value according to the input point 00651 TInt CalcAlignedValue( const TPoint& aPoint ); 00652 00653 private: 00654 CEikImage* iImage; 00655 CEikLabel* iValueLabel; 00656 CEikLabel* iMinLabel; 00657 CEikLabel* iMaxLabel; 00658 CFbsBitmap* iMarkerBmp; 00659 CFbsBitmap* iMarkerMaskBmp; 00660 TRect iMarkerArea; 00661 TRect iLineRect; 00662 TInt iValue; 00663 TBool iEditable; 00664 TRgb iColor; 00665 00666 // Not used, kept for binary compatibility. Another pointer with same name 00667 // in iData is really used 00668 HBufC* iSingularText; 00669 00670 CAknSliderData* iData; 00671 CAknSliderExtension* iExt; 00672 00673 TInt iSpare[4]; 00674 }; 00675 00676 // __AKNSLIDER_H__ 00677 #endif 00678 00679 // End of File