javauis/lcdui_akn/lcdui/inc/CMIDCustomItem.h
branchRCL_3
changeset 14 04becd199f91
child 24 6c158198356e
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003-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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMIDCUSTOMITEM_H
       
    20 #define CMIDCUSTOMITEM_H
       
    21 
       
    22 #include <gdi.h>
       
    23 #include <lcdui.h>
       
    24 #include <reflcdui.h>
       
    25 //
       
    26 #include "CMIDForm.h"
       
    27 // CMIDControlItem inheritance in class declaration
       
    28 #include "CMIDControlItem.h"
       
    29 // interface class for receiving media key events
       
    30 #include "MMIDMediaKeysListener.h"
       
    31 // PointerEventSuppressor
       
    32 #include <aknpointereventsuppressor.h>
       
    33 
       
    34 #ifdef RD_TACTILE_FEEDBACK
       
    35 #include "CMIDTactileFeedbackExtension.h"
       
    36 #endif //RD_TACTILE_FEEDBACK
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CMIDRemConObserver;
       
    40 class CMIDKeyDecoder;
       
    41 class CEikLabel;
       
    42 
       
    43 NONSHARABLE_CLASS(CMIDCustomItem) : public CMIDControlItem, public MMIDCustomItem,
       
    44 #ifndef RD_JAVA_NGA_ENABLED
       
    45         public MDirectScreenAccess,
       
    46 #endif
       
    47         public MMIDBufferProcessor, public MDirectContainer, public MMIDMediaKeysListener
       
    48 #ifdef RD_TACTILE_FEEDBACK
       
    49         , public MMIDTactileFeedbackComponent
       
    50 #endif // RD_TACTILE_FEEDBACK
       
    51 
       
    52 {
       
    53 public:
       
    54     static CMIDCustomItem* NewL(MMIDEnv& aEnv, const TDesC& aLabel, CMIDUIManager* aUIManager);
       
    55 
       
    56     TBool           SupportsInternalTraversal() const;
       
    57 
       
    58     //
       
    59     // From MMIDCustomItem
       
    60     //
       
    61     TInt            InteractionModes() const;
       
    62     void            SetFocusAndScroll(TBool aFocus,const TRect* aScroll,TInt aDirection);
       
    63 
       
    64     void            SetContainerWindowL(const CCoeControl& aWindow);
       
    65     void            Invalidate(const TSize& aMinSize, const TSize& aPrefSize);
       
    66     const TSize&    PreferredContentSize() const;
       
    67     const TSize&    MinimumContentSize() const;
       
    68 
       
    69     CFbsBitmap*     FrameBuffer() const;
       
    70     MDirectContainer& DirectContainer();
       
    71     //
       
    72     // From MMIDItem
       
    73     //
       
    74     void  SetLabelL(const TDesC& aLabel);
       
    75     void  SetLayoutL(TLayout aLayout);
       
    76 
       
    77     void  SetPreferredSizeL(const TSize& aSize);
       
    78     TSize PreferredSize() const;
       
    79 
       
    80     TSize MinimumSize() const;
       
    81 
       
    82     void  AddCommandL(MMIDCommand* aCommand);
       
    83     void  RemoveCommand(MMIDCommand* aCommand);
       
    84     void  SetDefaultCommand(MMIDCommand* aCommand);
       
    85 
       
    86     //
       
    87     // From MMIDComponent
       
    88     //
       
    89     void Dispose();
       
    90     MMIDBufferProcessor* Processor();
       
    91 
       
    92     //
       
    93     // From MMIDBufferProcessor
       
    94     //
       
    95 #ifdef RD_JAVA_NGA_ENABLED
       
    96     virtual TBool ProcessL(
       
    97         const TMIDBufferOp*& aRead, const TMIDBufferOp* aEnd,
       
    98         TInt& aCycles, java::util::Monitor* aMonitor);
       
    99 #else
       
   100     virtual TBool ProcessL(
       
   101         const TMIDBufferOp*& aRead, const TMIDBufferOp* aEnd,
       
   102         TInt& aCycles, TRequestStatus* aStatus = NULL);
       
   103 #endif
       
   104     void  AbortAsync();
       
   105 
       
   106     //
       
   107     // From CCoeControl
       
   108     //
       
   109     TSize MinimumSize();
       
   110     TInt CountComponentControls() const;
       
   111     CCoeControl* ComponentControl(TInt aIndex) const;
       
   112     void Draw(const TRect& aRect) const;
       
   113     void SizeChanged();
       
   114     void PositionChanged();
       
   115     TKeyResponse OfferKeyEventL(const TKeyEvent& aEvent, TEventCode aType);
       
   116 #ifdef RD_SCALABLE_UI_V2
       
   117     void HandlePointerEventL(const TPointerEvent &aPointerEvent);
       
   118 #endif //RD_SCALABLE_UI_V2
       
   119     void HandleCurrentL(TBool aCurrent);
       
   120 
       
   121 public:
       
   122     TSize ResetPreferredSize() const;
       
   123     TSize CheckRequestedSize(const TSize& aRequestedSize) const;
       
   124     void FocusChanged(TDrawNow aDrawNow);
       
   125     void HandleVisibilityChange();
       
   126     // overrides CMIDItem::SetForm(CMIDForm* aForm)
       
   127     void SetForm(CMIDForm* aForm);
       
   128 
       
   129     TInt ItemPreferredHeightWithoutLabel();
       
   130 
       
   131 public:
       
   132     // from CMIDItem
       
   133     void ItemAddedToFormL();
       
   134     void ItemRemovedFromForm();
       
   135 
       
   136     // from CMIDControlItem
       
   137     void PostFocusTransferEvent(TBool aFocus,CMIDForm::TDirection aDirection);
       
   138 
       
   139     void AdjustToSizeL(const TSize& aSize);
       
   140 
       
   141     void ResolutionChange(TInt aType);
       
   142 
       
   143     void HandleWindowFade(TBool aFaded);
       
   144 
       
   145 private:
       
   146     /**
       
   147      * PointerEventSuppressor.
       
   148      * Own.
       
   149      */
       
   150     CAknPointerEventSuppressor* iPointerEventSuppressor;
       
   151     TPoint iPointerPressedCoordinates;
       
   152     TBool iPointerEventSuppressionOngoing;
       
   153     TInt iPESPointerMovementInTwips;
       
   154     TInt iPESTimeInMilliseconds;
       
   155 
       
   156     /**
       
   157      * Ctor
       
   158      * @param aEnv Environment instance
       
   159      * @param aUIManager UI Manager
       
   160      */
       
   161     CMIDCustomItem(MMIDEnv& aEnv, CMIDUIManager* aUIManager);
       
   162     ~CMIDCustomItem();
       
   163     void ConstructL(const TDesC& aLabel);
       
   164 
       
   165     CMIDForm::TDirection TranslateKey(const TKeyEvent& aEvent);
       
   166 
       
   167     void ResetBuffers();
       
   168     void CreateBuffersL();
       
   169 
       
   170     void UpdateMargins();
       
   171 
       
   172 #ifndef RD_JAVA_NGA_ENABLED
       
   173     /**
       
   174      * Pauses the direct screen access.
       
   175      * Sets iDirectPaused flag to true.
       
   176      */
       
   177     void PauseDirectAccess();
       
   178 
       
   179     /**
       
   180      * Sets iDirectPaused flag to true.
       
   181      * Resumes the direct screen access using StartDirectAccess().
       
   182      */
       
   183     void ResumeDirectAccess();
       
   184 
       
   185     /**
       
   186      * Stops direct screen access.
       
   187      */
       
   188     void StopDirectAccess();
       
   189 
       
   190     void StartDirectAccess();
       
   191 #endif
       
   192 
       
   193     /**
       
   194      * Checks if there are hw keyboards available in the device and returns the
       
   195      * interaction modes based on keyboard availability.
       
   196      *
       
   197      * @return  TInt containing the supported keyboard interaction modes.
       
   198      * @since S60 5.0
       
   199      */
       
   200     TInt KeyboardInteractionModesL() const;
       
   201 
       
   202 
       
   203     /**
       
   204      * Notifies the current displayable
       
   205      * about the direct content position update
       
   206      *
       
   207      * @since S60 5.0
       
   208      * @return  ETrue if the update was done
       
   209                 EFalse if the update could be done
       
   210      */
       
   211     TBool UpdateDirectContentBounds();
       
   212 
       
   213 #ifndef RD_JAVA_NGA_ENABLED
       
   214 public:
       
   215 // From MDirectScreenAccess
       
   216     virtual void AbortNow(RDirectScreenAccess::TTerminationReasons aReasons);
       
   217     virtual void Restart(RDirectScreenAccess::TTerminationReasons aReasons);
       
   218 #endif
       
   219 
       
   220 // From MDirectContainer
       
   221 public:
       
   222     void MdcAddContent(MDirectContent* aContent);
       
   223     void MdcRemoveContent(MDirectContent* aContent);
       
   224     TRect MdcContainerWindowRect() const;
       
   225     TBool MdcContainerVisibility() const;
       
   226     TRect MdcContentBounds() const;
       
   227     void MdcItemContentRect(TRect& aContentRect, TRect& aScreenRect) const;
       
   228     void MdcHandlePointerEventL(TPointerEvent& aPointerEvent);
       
   229     void MdcFlushContainer(const TRect& aRect);
       
   230     void MdcAddContentBounds(const TRect& aRect);
       
   231     void MdcRemoveContentBounds(const TRect& aRect);
       
   232     void MdcGetDSAResources(MUiEventConsumer& aConsumer);
       
   233     void MdcGetUICallback(MUiEventConsumer& aConsumer, TInt aCallbackId);
       
   234 
       
   235 // From MMIDMediaKeysListener
       
   236 public:
       
   237     /**
       
   238      * This method is called when a media key has been pressed.
       
   239      * Posts the key event to Java layer.
       
   240      *
       
   241      * @param TMIDKeyEvent      Media key event that has occured.
       
   242      * @since S60 3.2
       
   243      */
       
   244     void HandleMediaKeyEvent(TMIDKeyEvent& aKeyEvent);
       
   245 
       
   246     void ChangeDirectContainerVisibility(TBool aVisible);
       
   247 
       
   248 #ifdef RD_TACTILE_FEEDBACK
       
   249 
       
   250     CMIDTactileFeedbackExtension* iTactileFeedback;
       
   251 
       
   252 public:
       
   253     MMIDTactileFeedbackComponent* TactileFeedbackComponent();
       
   254 
       
   255     void UpdateTactileFeedback();
       
   256 
       
   257     void RegisterFeedbackArea(TInt aId, TRect aRect, TInt aStyle);
       
   258     void UnregisterFeedbackArea(TInt aId);
       
   259     void UnregisterFeedbackForControl();
       
   260     void MoveAreaToFirstPriority(TInt aId);
       
   261 #endif
       
   262 
       
   263 
       
   264 private:
       
   265     /** The content buffer, used by the
       
   266     Graphics object associated to this custom item */
       
   267     CFbsBitmap* iFrameBuffer;
       
   268     CFbsBitGc* iFrameContext;
       
   269     CFbsBitmapDevice* iFrameDevice;
       
   270 
       
   271     /** The offscreen buffer, implements double buffering
       
   272     to assure content is kept between drawn. This allows
       
   273     having skin underneath the content if nothing is drawn on it.
       
   274     */
       
   275     CFbsBitmap* iOffScreenBuffer;
       
   276     CFbsBitGc* iOffScreenContext;
       
   277     CFbsBitmapDevice* iOffScreenDevice;
       
   278 
       
   279     TSize       iMinimumContentSize; // This doesn't include margin
       
   280     TSize       iPreferredContentSize;  // This doesn't include margin
       
   281     TRect       iContentRect;
       
   282     TBool       iEntered;
       
   283     TBool       iSupportsInternalTraversal;
       
   284     MMIDEnv&    iEnv;
       
   285 
       
   286     /**
       
   287      * Indicates that the iFrameBuffer may be reset (with background skin).
       
   288      * It prevents the situation where iFrameBuffer is reset
       
   289      * before it has been copied to iOffScreenBuffer.
       
   290      */
       
   291     TBool iResetFrameBuffer;
       
   292 
       
   293     /**
       
   294      * Item can only have one DirectContent.
       
   295      * Content is null if content is not added
       
   296      * with MdcAddContent method.
       
   297      */
       
   298     MDirectContent* iDirectContent;
       
   299     TBool iDirectAreaAddedToDisplayable;
       
   300     TRect iDirectArea;
       
   301 
       
   302     TMargins iContentMargins; // Margins for the content in relation to controlItem area
       
   303     CMIDRemConObserver* iRemConObserver;
       
   304     CMIDKeyDecoder* iKeyDecoder;
       
   305     // Nokia-MIDlet-S60-Selection-Key-Compatibility
       
   306     TBool iS60SelectionKeyCompatibility;
       
   307 
       
   308 #ifndef RD_JAVA_NGA_ENABLED
       
   309     CDirectScreenAccess* iDirectAccess;
       
   310 
       
   311     /**
       
   312      * Indicates that direct screen access is paused
       
   313      * using PauseDirectAccess().
       
   314      */
       
   315     TBool iDirectPaused;
       
   316 #endif
       
   317 
       
   318     TBool iRestoreDirectContentWhenUnfaded;
       
   319 
       
   320     // Stores information if CustomItem changed it visibility
       
   321     // from invisible (e.g. outside Form, to background) to visible and vice versa
       
   322     TBool iPreviousVisibility;
       
   323 
       
   324     /**
       
   325      * A consumer which is waiting for the callback.
       
   326      * Set in case that Container Window have not been set
       
   327      * before MdcGetDSAResources call.
       
   328      * Not owned.
       
   329      */
       
   330     MUiEventConsumer* iConsumerWaitingForDSAResourcesCallback;
       
   331 
       
   332     /**
       
   333      * Stores the last window position as returned
       
   334      * from DrawableWindow()->Position() to be useful
       
   335      * from another than MMAPI ES thread.
       
   336      */
       
   337     TPoint iLastWindowPosition;
       
   338 
       
   339 };
       
   340 
       
   341 #endif // CMIDCUSTOMITEM_H
       
   342 
       
   343 
       
   344