javauis/lcdui_akn/lcdui/inc/CMIDControlItem.h
branchRCL_3
changeset 14 04becd199f91
child 23 e5618cc85d74
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003-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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMIDCONTROLITEM_H
       
    20 #define CMIDCONTROLITEM_H
       
    21 
       
    22 #include <gdi.h>
       
    23 #include <coecntrl.h>
       
    24 #include <fepbase.h>    // for MCoeCaptionRetrieverForFep
       
    25 
       
    26 // for CMIDForm::TDirection as parameter of PostFocusTransferEvent function
       
    27 #include "CMIDForm.h"
       
    28 // CMIDItem inheritance in class declaration
       
    29 #include "CMIDItem.h"
       
    30 
       
    31 class CMIDItemLabel;
       
    32 class MAknsControlContext;
       
    33 class CAknsFrameBackgroundControlContext;
       
    34 
       
    35 NONSHARABLE_CLASS(CMIDControlItem) : public CMIDItem, public MCoeCaptionRetrieverForFep
       
    36 {
       
    37 public:
       
    38     virtual ~CMIDControlItem();
       
    39     //
       
    40     // From CMIDItem
       
    41     //
       
    42     virtual TBool IsSelectable() const;
       
    43     virtual void SetLabelL(const TDesC& aLabel);
       
    44 
       
    45     virtual TInt LabelHeight() const;
       
    46     inline void SetSizeQuiet(const TSize& aSize);   // won't call SizeChanged
       
    47     inline void SetPositionQuiet(const TPoint& aPosition);   // won't call PositionChanged
       
    48 
       
    49 
       
    50     // Returns height of a label that has only one line of text
       
    51     TInt OneLineLabelHeight() const;
       
    52 
       
    53     // from CCoeControl
       
    54     virtual void SetContainerWindowL(const CCoeControl& aContainer);
       
    55     void SetFocus(TBool aFocus, TDrawNow aDrawNow = ENoDrawNow);
       
    56     virtual void FocusChanged(TDrawNow aDrawNow);
       
    57     TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
       
    58 
       
    59     // From MCoeCaptionRetrieverForFep
       
    60     void GetCaptionForFep(TDes& aCaption) const;
       
    61 
       
    62     void SetLabelColor(CMIDItemLabel* aLabelControl);
       
    63 
       
    64     //
       
    65     // Resets the preferred size. This is called on all items at the beginning of form layout.
       
    66     // This means we can fiddle with the preferred size of items during layout.
       
    67     // Returns the new preferred size.
       
    68     //
       
    69     virtual TSize ResetPreferredSize() const;
       
    70     virtual void AdjustToNewWidthL(TInt aWidth);
       
    71     virtual void AdjustToSizeL(const TSize& aSize);
       
    72     inline virtual CMIDItemLabel* LabelControl();
       
    73 
       
    74     virtual TRect FocusableRect(); // returns a rect that should be partially visible for an Item to have focus
       
    75 
       
    76     virtual void ResolutionChange(TInt aType); // this is called when resolution is changed
       
    77     virtual void ColorChange(TInt aType); //this is called when there is a skin or color scheme change
       
    78 
       
    79     /**
       
    80      * @return ETrue if label exists and is not empty
       
    81      */
       
    82     TBool HasLabel();
       
    83 
       
    84     /**
       
    85      * The function is being invoked after form has changed focus of the component.
       
    86      * Subclasses of CMIDControlItem may override the default implementation to be notified about the focus transfer.
       
    87      * @param aFocus true if the component has gained focus
       
    88      * @param aDirection TDirection
       
    89      */
       
    90     virtual void PostFocusTransferEvent(TBool aFocus,CMIDForm::TDirection aDirection);
       
    91 
       
    92     /**
       
    93      * The method is invoked from CMIDForm::HandleResourceChange when there is a need
       
    94      * to restore the focus inside the item (if the item has its own subitems).
       
    95      * (For instance there is focus on ChoiceGroupItem inside the form with inner focus
       
    96      * to some sub-item. After the resolution change the main focus on form item is restored,
       
    97      * but focused sub-item would be below the screen, so this method is called in order
       
    98      * to restore focus on sub-item.)
       
    99      * Every form item, which is able to focus its own internal sub-items should
       
   100      * implement this method.
       
   101      */
       
   102     virtual void RestoreInnerFocus();
       
   103 
       
   104     /**
       
   105       * This method is called when the window server
       
   106       * fades or unfades the current window
       
   107       * @param aFaded true if the window is goiging to be faded, false if unfaded
       
   108       */
       
   109     virtual void HandleWindowFade(TBool aFaded);
       
   110 
       
   111 protected:
       
   112     CMIDControlItem(MMIDItem::TLayout aLayout, CMIDUIManager* aUIManager);
       
   113     void ConstructL();
       
   114 
       
   115     TInt FormClientAreaWidth() const; // Width of form2_midp_field_pane (scroll bar excluded)
       
   116     TRect FormClientAreaRect() const; // Layout of Rect of form2_midp_field_pane (scroll bar excluded)
       
   117     TInt ItemContentBottomMargin() const; // Bottom margin of form2_midp_content_pane
       
   118 
       
   119 public:
       
   120     inline TBool GetVisibilityInForm();
       
   121     inline void SetVisibilityInForm(const TBool aVisibility);
       
   122 
       
   123 protected:
       
   124     CCoeEnv* iCoeEnv;
       
   125     CMIDItemLabel* iLabelControl; // The label for the control
       
   126 
       
   127     //The background control context for when the item is highlighted
       
   128     CAknsFrameBackgroundControlContext* iHighlightedBackgroundCc;
       
   129 
       
   130     TBool iVisibilityInForm;
       
   131 };
       
   132 
       
   133 inline void CMIDControlItem::SetSizeQuiet(const TSize& aSize)
       
   134 {
       
   135     iSize = aSize;
       
   136 }
       
   137 
       
   138 inline void CMIDControlItem::SetPositionQuiet(const TPoint& aPosition)
       
   139 {
       
   140     iPosition = aPosition;
       
   141 }
       
   142 
       
   143 inline CMIDItemLabel* CMIDControlItem::LabelControl()
       
   144 {
       
   145     return iLabelControl;
       
   146 }
       
   147 
       
   148 inline TBool CMIDControlItem::GetVisibilityInForm()
       
   149 {
       
   150     return iVisibilityInForm;
       
   151 }
       
   152 
       
   153 inline void CMIDControlItem::SetVisibilityInForm(const TBool aVisibility)
       
   154 {
       
   155     iVisibilityInForm = aVisibility;
       
   156 }
       
   157 
       
   158 #endif // CMIDCONTROLITEM_H