textinput/peninputarc/inc/peninputlayoutcontrolinc/peninputlayoutctrlgroup.h
changeset 0 eb1f2e154e89
child 19 5e18d8c489d6
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005-2005 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 file of control group and button group 
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef C_CCONTROLBROUP_H
       
    19 #define C_CCONTROLBROUP_H
       
    20 
       
    21 #include <peninputlayoutbasecontrol.h>
       
    22 class CButtonBase;
       
    23 class CCoeControl;
       
    24 /**
       
    25  *  CControlGroup
       
    26  *
       
    27  *  CControl group. A CControl group will consists of several controls.
       
    28  *
       
    29  *  @lib feplayoutcontrol.lib
       
    30  *  @since S60 V4.0
       
    31  */
       
    32 class CControlGroup : public CFepUiBaseCtrl
       
    33     {    
       
    34 public: 
       
    35     //constructor and destructor
       
    36     /**
       
    37      * Factory function.        
       
    38      *
       
    39      * @since S60 V4.0        
       
    40      * @param aUiLayout Ui layout who contains this control.Ownership not transferred
       
    41      * @param aControlId control Id
       
    42      * @return An instance of CControlGroup class        
       
    43      */                           
       
    44     IMPORT_C static CControlGroup* NewL(CFepUiLayout* aUiLayout,
       
    45     									TInt aControlId, 
       
    46     									TBool aRedrawBg = ETrue);
       
    47     
       
    48     CControlGroup* NewL(CFepUiLayout* aUiLayout,CCoeControl* aControl);
       
    49     /**
       
    50      * Destructor
       
    51      *
       
    52      * @since S60 V4.0        
       
    53      */                                   
       
    54     IMPORT_C virtual ~ CControlGroup();
       
    55 
       
    56     /**
       
    57      * Add a control to group
       
    58      *
       
    59      * @since S60 V4.0
       
    60      * @param aControl New control to be added.Ownership transferred
       
    61      * @param aOwnerFlag The flag tells whether transfer ownership to group. ETrue if group will be the owner
       
    62      *                   A owner is responsible for free the control. 
       
    63      *                     Deafult value is ETrue
       
    64      */                  
       
    65     IMPORT_C void AddControlL(CFepUiBaseCtrl* aControl, TBool aOwnerFlag = ETrue);   
       
    66     /**
       
    67      * Add a control to group
       
    68      *
       
    69      * @since S60 V4.0
       
    70      * @param aControl New control to be added.Ownership transferred. A CFepUiBasedCtrl 
       
    71      *                  will be created for this window based control
       
    72      * @param aOwnerFlag The flag tells whether transfer ownership to group. ETrue if group will be the owner
       
    73      *                   A owner is responsible for free the control. 
       
    74      *                     Deafult value is ETrue
       
    75      * @return The control associated to this window based control
       
    76      */                  
       
    77     IMPORT_C CFepUiBaseCtrl* AddControlL(CCoeControl* aControl);   
       
    78     
       
    79     /**
       
    80      * RemoveControl
       
    81      * Remove a control from the control group
       
    82      *
       
    83      * @since S60 v4.0
       
    84      * @param aControl The control to be removed.  
       
    85      * @return ETrue if remove successfully.   
       
    86      */          
       
    87     IMPORT_C TBool RemoveControl(CFepUiBaseCtrl* aControl);
       
    88     
       
    89     
       
    90     /**
       
    91      * Get control for an position index
       
    92      *
       
    93      * @since S60 V4.0
       
    94      * @param aIndex Control index in group. Index starts from 0
       
    95      * @return The control for position
       
    96      */                      
       
    97     IMPORT_C CFepUiBaseCtrl* At(TInt aIndex);
       
    98     
       
    99     /**
       
   100      * Get control counts
       
   101      *
       
   102      * @since S60 V4.0
       
   103      * @param None
       
   104      * @return Number of controls in group
       
   105      */                      
       
   106     IMPORT_C TInt NumOfControls();        
       
   107     
       
   108      /**
       
   109      * Find qualified control in layout whose control type is exactly the same as 
       
   110      * the given one.
       
   111      *
       
   112      * @since S60 v4.0
       
   113      * @param aType The contol type
       
   114      * @param aIndex The control index. The nth control for such type in this group.
       
   115      *               The index is counted seperated for different control type.
       
   116      * @return        The contrl found.
       
   117      */
       
   118     IMPORT_C CFepUiBaseCtrl* ControlByType(TControlType aType,TInt aIndex = 0);   
       
   119     
       
   120      /**
       
   121      * Find qualified control in layout according to the type and index.
       
   122      * Unlike ControlByType, it finds all controls which is kind of such type, 
       
   123      * includes those derived controls.
       
   124      * 
       
   125      * @since S60 v4.0
       
   126      * @param aType The contol type
       
   127      * @param aIndex The control index. The nth control for such type in this group.
       
   128      *               The index is counted seperated for different control type.
       
   129      * @return The contrl found.
       
   130      */
       
   131     IMPORT_C CFepUiBaseCtrl* ControlForKindOfType(TStockBaseCtrlType  aType,
       
   132                                                             TInt aIndex = 0);
       
   133     /**
       
   134      * Set control to be actived.
       
   135      *
       
   136      * @since S60 V4.0
       
   137      * @param aControl The control to be set to actived. Ownership not transferred.
       
   138      * @return Previous active control
       
   139      */                      
       
   140     IMPORT_C virtual CFepUiBaseCtrl* SetActiveCtrl(CFepUiBaseCtrl* aControl);
       
   141    
       
   142     /**
       
   143      * Set control to be temparory actived. When button is pressed, the control is 
       
   144      * temparary set to be actived. When button is up, it's set to be actived.
       
   145      *
       
   146      * @since S60 V4.0
       
   147      * @param aControl The control to be set to actived. Ownership not transferred.
       
   148      * @return Previous active control
       
   149      */              
       
   150     CFepUiBaseCtrl* SetTempActiveCtrl(CFepUiBaseCtrl* aCtrl);
       
   151     /**
       
   152      * Set control to be actived
       
   153      *
       
   154      * @since S60 V4.0
       
   155      * @param aIndex The control index. Ownership not transferred.
       
   156      * @return current active control
       
   157      */                      
       
   158     IMPORT_C CFepUiBaseCtrl* SetActiveCtrl(TInt aIndex);
       
   159     
       
   160     /**
       
   161      * Get active control
       
   162      *
       
   163      * @since S60 V4.0
       
   164      * @param None
       
   165      * @return The active control
       
   166      */                      
       
   167     IMPORT_C CFepUiBaseCtrl* ActiveControl();
       
   168     
       
   169     /**
       
   170      * Hide Control
       
   171      *
       
   172      * @since S60 V4.0
       
   173      * @param aIndex control index
       
   174      * @param aFlag control hide flag. ETrue if going to be hiden. Otherwise EFalse
       
   175      *                Deafult value is ETrue
       
   176      */                      
       
   177     IMPORT_C void HideControl(TInt aIndex,TBool aFlag = ETrue);
       
   178     
       
   179     /**
       
   180      * Hide Control
       
   181      *
       
   182      * @since S60 V4.0
       
   183      * @param aControl The button to be hiden
       
   184      * @param aFlag Contrl hide flag. ETrue if going to be hiden. Otherwise EFalse
       
   185      *                Default value is ETrue
       
   186      */                    
       
   187     IMPORT_C void HideControl(CFepUiBaseCtrl* aControl,TBool aFlag = ETrue);
       
   188     
       
   189     /**
       
   190      * Get the sub control for given control Id. 
       
   191      *
       
   192      * @param aCtrlId The control id
       
   193      * @return The contrl found.
       
   194      */
       
   195     IMPORT_C CFepUiBaseCtrl* ControlById(TInt aCtrlId);
       
   196        
       
   197     /**
       
   198      * Get control list
       
   199      *
       
   200      * @since S60 v4.0
       
   201      * @return The layout control list
       
   202      */    
       
   203     inline const RPointerArray<CFepUiBaseCtrl>& ControlList() const;
       
   204     
       
   205     inline const RPointerArray<CFepUiBaseCtrl>& PopCtrlList() const;    
       
   206 
       
   207     /**
       
   208      * Check whether this control is in the control group
       
   209      *
       
   210      * @since S60 v4.0
       
   211      * @param aCtrl The control to be found
       
   212      * @return EFalse if not included in the group. ETrue if founded
       
   213      */    
       
   214     CFepUiBaseCtrl* Find(CCoeControl* aCtrl);
       
   215     
       
   216     /**
       
   217     //From base class CFepUiBaseCtrl
       
   218     /**
       
   219      * From CFepUiBaseCtrl
       
   220      * Draw control
       
   221      *
       
   222      * @since S60 V4.0
       
   223      */              
       
   224     IMPORT_C virtual void Draw();
       
   225     
       
   226     /**
       
   227      * From CFepUiBaseCtrl    
       
   228      * Redraws the content in a control
       
   229      *
       
   230      * @since S60 V4.0
       
   231      * @param aRect The rect to be redrawed
       
   232      */               
       
   233      IMPORT_C virtual void ReDrawRect(const TRect& aRect);     
       
   234     
       
   235     /**
       
   236      * Redraws the content in a control if needed. The redraw is caused by aCtrl's updating aRect.
       
   237      *
       
   238      * @since S60 V5.0
       
   239      * @param aRect The rect to be redrawed
       
   240      * @param aCtrl The control who initiates the updating.
       
   241      */                    
       
   242      void RedrawRectIfNeeded(const TRect& aRect, CFepUiBaseCtrl* aCtrl);
       
   243 
       
   244     /**
       
   245      * From CFepUiBaseCtrl
       
   246      * Hide or shoe control. A hiden control will not handle the event.
       
   247      *
       
   248      * @since S60 V4.0
       
   249      * @param aFlag ETrue if want to hide the control.
       
   250      */                                               
       
   251     IMPORT_C virtual void Hide(TBool aFlag);
       
   252 
       
   253     /**
       
   254      * From CFepUiBaseCtrl
       
   255      * Move control
       
   256      *
       
   257      * @since S60 V4.0
       
   258      * @param aOffset The offset to be moved
       
   259      */                
       
   260     IMPORT_C void Move(const TPoint& aOffset);    
       
   261     
       
   262     /**
       
   263      * From CFepUiBaseCtrl
       
   264      * Cancel pointer down event.
       
   265      * This will be called when a control has pointer down but pointer up 
       
   266      * event happens in other ways.
       
   267      *
       
   268      * @since S60 V4.0
       
   269      * @param aFocusedFlag ETrue if got focused, otherwise EFalse
       
   270      */          
       
   271     IMPORT_C virtual void CancelPointerDownL();    
       
   272     
       
   273     /**
       
   274      * From CFepUiBaseCtrl
       
   275      * Handle pointer levae event. 
       
   276      * This will be called only when it's got pointer down event before and 
       
   277      * now pointer leaves without pointer up event
       
   278      *
       
   279      * @since S60 V4.0
       
   280      * @param aPoint current pointer position
       
   281      */    
       
   282     IMPORT_C virtual void HandlePointerLeave(const TPoint& aPoint);
       
   283     
       
   284     /**
       
   285      * From CFepUiBaseCtrl
       
   286      * Handle pointer enter event. 
       
   287      * This will be called only when it's got pointer down event before and 
       
   288      * pointer leaves but now comes back without pointer up event.
       
   289      *
       
   290      * @since S60 V4.0
       
   291      * @param aPoint current pointer position     
       
   292      */
       
   293     IMPORT_C virtual void HandlePointerEnter(const TPoint& aPoint);
       
   294 
       
   295     /**
       
   296      * From CFepUiBaseCtrl
       
   297      * OnActivate. Called when the layout is going to be shown.
       
   298      *
       
   299      * @since S60 v4.0
       
   300      */        
       
   301     IMPORT_C void OnActivate();
       
   302     
       
   303     /**
       
   304      * From CFepUiBaseCtrl
       
   305      * OnDeActivate. Called when the layout is going to be hidden
       
   306      *
       
   307      * @since S60 v4.0
       
   308      */        
       
   309     IMPORT_C void OnDeActivate();   
       
   310     /**
       
   311      * From CFepUiBaseCtrl
       
   312      * Call back function when layout starts dragging
       
   313      *
       
   314      * @since S60 V4.0
       
   315      */
       
   316     virtual IMPORT_C void OnLayoutDraggingStart();
       
   317 
       
   318     /**
       
   319      * From CFepUiBaseCtrl    
       
   320      * Call back function when layout ends dragging
       
   321      *
       
   322      * @since S60 V4.0
       
   323      */
       
   324     virtual IMPORT_C void OnLayoutDraggingEnd();
       
   325     
       
   326     /**
       
   327      * From CFepUiBaseCtrl
       
   328      * Construct from resource. Handle resource change
       
   329      *
       
   330      * @since S60 V4.0
       
   331      */                
       
   332     IMPORT_C void ConstructFromResourceL();
       
   333     
       
   334     /**
       
   335      * Update control's valid region when other control hiding or displaying.
       
   336      * This is usually used for HWR window to change it's writing area.
       
   337      *
       
   338      * @since S60 V4.0
       
   339      * @param aCtrl The control whose displaying status changed
       
   340      * @param bFlag ETrue if control is hiden, otherwise EFalse
       
   341      */        
       
   342     IMPORT_C virtual void UpdateValidRegion(CFepUiBaseCtrl* aCtrl,TBool aRemoveFlag);
       
   343     
       
   344     /**
       
   345      * Bring the control to top most in current control group and show it.
       
   346      *
       
   347      * @since S60 V5.0
       
   348      * @aParam aCtrl The control to be shown.
       
   349      */                                               
       
   350     IMPORT_C virtual void BringToTopInGroup(CFepUiBaseCtrl* aCtrl);
       
   351     
       
   352     IMPORT_C virtual void BringToBackInGroup(CFepUiBaseCtrl* aCtrl);
       
   353     void UpdateAreaInGrp(CFepUiBaseCtrl* aControl,const TRect& aRect,TBool aUpdateFlag); // = EFalse
       
   354     
       
   355     void UpdateAreaInGrpImmed(CFepUiBaseCtrl* aControl,const TRect& aRect,TBool aUpdateFlag);
       
   356     void RedrawRectInGrp( CFepUiBaseCtrl* aControl,const TRect& aRect );
       
   357 
       
   358     TInt GetNestedLevel();
       
   359 
       
   360     TInt GetIdx(const CFepUiBaseCtrl* aCtrl);
       
   361     
       
   362     void AdjustBkCtrlPos();
       
   363     
       
   364 protected:
       
   365     /**
       
   366     * Symbian second phrase constructor
       
   367     *
       
   368     * @since S60 V4.0
       
   369     */            
       
   370     IMPORT_C void ConstructL();
       
   371 
       
   372     /**
       
   373      * From CFepUiBaseCtrl
       
   374      * Handle pointer down event
       
   375      *
       
   376      * @since S60 V4.0
       
   377      * @param aPoint The point position relative the layout
       
   378      * @return The control which handles the event.     
       
   379      */                                        
       
   380     IMPORT_C virtual CFepUiBaseCtrl* HandlePointerDownEventL(const TPoint& aPoint);
       
   381     
       
   382     /**
       
   383      * From CFepUiBaseCtrl
       
   384      * Handle pointer move event
       
   385      *
       
   386      * @since S60 V4.0
       
   387      * @param aPoint The point position relative the layout
       
   388      * @return The control which handles the event.     
       
   389      */                  
       
   390     IMPORT_C virtual CFepUiBaseCtrl* HandlePointerMoveEventL(const TPoint& aPoint);
       
   391     
       
   392     /**
       
   393      * From CFepUiBaseCtrl
       
   394      * Handle pointer up event
       
   395      *
       
   396      * @since S60 V4.0
       
   397      * @param aPoint The point position relative the layout
       
   398      * @return The control which handles the event.     
       
   399      */                  
       
   400     IMPORT_C virtual CFepUiBaseCtrl* HandlePointerUpEventL(const TPoint& aPoint);
       
   401 
       
   402     const RRegion& CalculateNonHwrStartPtArea();
       
   403     void CalculateClipRegion();    
       
   404     
       
   405     /**
       
   406      * Handle system resource change
       
   407      *
       
   408      * @since S60 V5.0
       
   409      * @param aType The system resource change type
       
   410      */
       
   411     virtual IMPORT_C void HandleResourceChange(TInt aType);
       
   412     
       
   413     /**
       
   414      * Handle pen UI graphic device size change event
       
   415      *
       
   416      * @since S60 V5.0
       
   417      */
       
   418     virtual IMPORT_C void GraphicDeviceSizeChanged();
       
   419 protected:
       
   420     /**
       
   421      * Default constructor.        
       
   422      *
       
   423      * @since S60 V4.0        
       
   424      * @param aUiLayout Ui layout who contains this control
       
   425      * @param aControlId control Id
       
   426      */                                   
       
   427     IMPORT_C CControlGroup(CFepUiLayout* aUiLayout,TInt aControlId);
       
   428     
       
   429     /**
       
   430      * Default constructor.        
       
   431      *
       
   432      * @since S60 V4.0        
       
   433      * @param aUiLayout Ui layout who contains this control
       
   434      * @param aControlId control Id
       
   435      */                                   
       
   436     IMPORT_C CControlGroup(CFepUiLayout* aUiLayout,
       
   437     					   TInt aControlId,
       
   438     					   TBool aRedrawBg);
       
   439 
       
   440     /*
       
   441     * ControlForPoints
       
   442     * Get the control which contains the given point
       
   443     *
       
   444     * @param aPt the point to be checked
       
   445     * @return The control which contains the point
       
   446     */       
       
   447     CFepUiBaseCtrl* ControlForPoints(const TPoint& aPt);
       
   448 	
       
   449     /**
       
   450      * Draw ControlGroup Background        
       
   451      *
       
   452      * @since S60 V5.0        
       
   453      * @param aUpdateRegion The rect to be updated    
       
   454      */                                   	
       
   455 	virtual IMPORT_C void DrawControlGroupBackground( const TRect& aUpdateRegion );	
       
   456 private:
       
   457     /**
       
   458      * RemoveOwnedControl
       
   459      * Remove a control from group's owned control list
       
   460      *
       
   461      * @since S60 v4.0
       
   462      * @param aControl The control to be removed.  
       
   463      * @return ETrue if remove successfully.   
       
   464      */          
       
   465     TBool RemoveOwnedControl(CFepUiBaseCtrl* aControl);
       
   466 
       
   467     TInt FindSubRegion(CFepUiBaseCtrl* aCtrl);
       
   468     
       
   469     void RemoveCtrlFromSubCtrlInfoList(CFepUiBaseCtrl* aControl);
       
   470     void SaveSubCtrlShownState();
       
   471     void RemoveSubRegion(TInt aIdx);
       
   472     void AddSubRegionL(CFepUiBaseCtrl* aCtrl);
       
   473     void CalculateClipRegion(CFepUiBaseCtrl* aCtrl);
       
   474     TBool MoveSubCtrlToTop(CFepUiBaseCtrl* aCtrl, RPointerArray<CFepUiBaseCtrl>& aList);
       
   475     TBool MoveSubCtrlToBack(CFepUiBaseCtrl* aCtrl,RPointerArray<CFepUiBaseCtrl>& aList);
       
   476     void OnDeActivateL();
       
   477 protected:
       
   478     /**
       
   479      * Control list for all controls
       
   480      */
       
   481     RPointerArray<CFepUiBaseCtrl> iCtrlList;
       
   482 
       
   483     /**
       
   484      * Active control
       
   485      * Not own
       
   486      */
       
   487     CFepUiBaseCtrl* iActiveCtrl;    
       
   488     
       
   489     /**
       
   490      * Control which gets the pointer down event
       
   491      * Not own
       
   492      */
       
   493     CFepUiBaseCtrl* iCtrlWithPointerDown;    
       
   494 
       
   495     RRegion iNonHwrStartPtRegion;
       
   496     /**
       
   497      * Control list for all owned controls. 
       
   498      * Control group will be responsible for release owned controls
       
   499      */
       
   500     RPointerArray<CFepUiBaseCtrl> iOwnedCtrlList;  
       
   501     
       
   502     /**
       
   503      * This is the control list for those control which must be shown on top, and 
       
   504      * which doesn't directly belong ( as a direct child of)
       
   505      * to current group
       
   506      */        
       
   507     RPointerArray<CFepUiBaseCtrl> iPopCtrlList;    
       
   508 
       
   509 private:      
       
   510     //internal class to record sub control's information
       
   511     class CSubRegionArea : public CBase
       
   512         {
       
   513         public:        
       
   514             ~CSubRegionArea();        
       
   515         private:
       
   516             CSubRegionArea(const CFepUiBaseCtrl* aCtrl,const RRegion &aRegion);
       
   517         private:
       
   518             const CFepUiBaseCtrl* iSubCtrl;
       
   519             RRegion iSubRegion;
       
   520         friend class CControlGroup;
       
   521         };
       
   522     struct TSubCtrlShownState
       
   523         {
       
   524         CFepUiBaseCtrl* iSubCtrl;
       
   525         TBool           iHiden;
       
   526         };
       
   527     /**
       
   528      * temparory active control
       
   529      * Not own
       
   530      */
       
   531     CFepUiBaseCtrl* iTempActiveCtrl;
       
   532     
       
   533     RPointerArray<CSubRegionArea> iSubRegionArea;   
       
   534     
       
   535     /**
       
   536      * list to record sub control's hide/show state before control group is hidden
       
   537      */    
       
   538     RArray<TSubCtrlShownState> iSubCtrlShowStateBeforeHiden;
       
   539     
       
   540     /**
       
   541      * Reserved item1
       
   542      */
       
   543      TInt iNeedRedrawBg;
       
   544      
       
   545     /**
       
   546      * Reserved item2
       
   547      */
       
   548      TInt iReserved2;    
       
   549     };
       
   550 //end of classd CControlGroup
       
   551 
       
   552 #include "peninputlayoutctrlgroup.inl"
       
   553 
       
   554 #endif //C_CCONTROLBROUP_H