javauis/lcdui_akn/lcdui/inc/CMIDItem.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19: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 CMIDITEM_H
       
    20 #define CMIDITEM_H
       
    21 
       
    22 // CEikBorderedControl inheritance in class declaration
       
    23 #include <eikbctrl.h>
       
    24 #include "lcdui.h"
       
    25 // API for using commands that item owns
       
    26 #include "CMIDCommand.h"
       
    27 
       
    28 class CMIDCommandList;
       
    29 class CMIDForm;
       
    30 class CMIDMenuHandler;
       
    31 class CMIDUIManager;
       
    32 
       
    33 // Base class for all Items
       
    34 
       
    35 NONSHARABLE_CLASS(CMIDItem) : public CEikBorderedControl, public MMIDCommandObserver
       
    36 {
       
    37 public:
       
    38     virtual ~CMIDItem();
       
    39     //
       
    40     // Returns basic properties shared by all items
       
    41     //
       
    42     virtual TPtrC Label() const;
       
    43     MMIDItem::TLayout Layout() const;
       
    44     CMIDCommandList* CommandList() const;
       
    45     virtual TBool IsSelectable() const = 0;
       
    46     /**
       
    47      * Returns the appropriate command for the MSK at the moment. It can be a
       
    48      * built-in command if set or a default command, if set.
       
    49      **/
       
    50     CMIDCommand* GetMSKCommand() const;
       
    51     CMIDCommand* DefaultCommand() const;
       
    52     virtual void SetForm(CMIDForm* aForm);
       
    53     CMIDForm* Form() const;
       
    54     virtual void ItemAddedToFormL();
       
    55     virtual void ItemRemovedFromForm();
       
    56     virtual void HandleCurrentL(TBool aCurrent);
       
    57 
       
    58     /**
       
    59      * Used to notify item that form scrolling has been completed and
       
    60      * new position has been set for the item.
       
    61      *
       
    62      * @since S60 3.2
       
    63      */
       
    64     virtual void NotifyScrollingCompleted();
       
    65 
       
    66     //
       
    67     // Get functions used by form
       
    68     //
       
    69     TSize PreferredSize();
       
    70     MMIDItem::TLayout Layout();
       
    71     virtual TInt ItemPreferredHeightWithoutLabel() = 0;
       
    72     //
       
    73     // Set functions used by form
       
    74     //
       
    75     void SetPreferredWidth(TInt aWidth);
       
    76     void SetPreferredHeight(TInt aHeight);
       
    77     void SetLayoutL(MMIDItem::TLayout aLayout);
       
    78     //
       
    79     virtual TInt Type();
       
    80 
       
    81     /**
       
    82      * Command handling function from MMIDCommandObserver. Default implementation
       
    83      * in CMIDItem is empty, but subclasses can override the method if they
       
    84      * provide commands that need to be processed internally rather than sent
       
    85      * to Java side (e.g. build-in MSK commands).
       
    86      **/
       
    87     TBool ProcessCommandL(CMIDCommand* aCommand);
       
    88 
       
    89     /**
       
    90      * Get UI manager
       
    91      * @return CMIDUIManager instance
       
    92      *
       
    93      * @since s60
       
    94      */
       
    95     virtual CMIDUIManager* GetUIManager() const;
       
    96 
       
    97 protected:
       
    98     CMIDItem(MMIDItem::TLayout aLayout, CMIDUIManager* aUIManager);
       
    99     void ConstructL();
       
   100     //
       
   101     // Sets some basic item properties from subclasses
       
   102     //
       
   103     virtual void SetLabelL(const TDesC& aLabel);
       
   104     /**
       
   105      * Adds command for item
       
   106      * @param aCommand - command to add
       
   107      * @param aFormNotification - form notification flag
       
   108      *          ETrue (default) - form is notified about command change
       
   109      *          EFalse - avoid form notification
       
   110      */
       
   111     void AddCommandL(MMIDCommand* aCommand, TBool aFormNotification = ETrue);
       
   112     /**
       
   113      * Remove command from item
       
   114      * @param aCommand - command to remove
       
   115      * @param aFormNotification - form notification flag
       
   116      *          ETrue (default) - form is notified about command change
       
   117      *          EFalse - avoid form notification
       
   118      */
       
   119     void RemoveCommand(MMIDCommand* aCommand, TBool aFormNotification = ETrue);
       
   120     void SetDefaultCommand(MMIDCommand* aCommand);
       
   121     /**
       
   122      * Sets a new command to be displayed in the MSK. If the command is
       
   123      * not NULL, it will override the default command set by the application
       
   124      * programmer.
       
   125      * Built-in MSK command is used e.g. in lists for selecting and in date
       
   126      * field items to toggle the am/pm field.
       
   127      **/
       
   128     void SetBuiltInMSKCommand(CMIDCommand* aCommand);
       
   129 
       
   130     void NotifyFormAboutCommandChange();
       
   131 
       
   132     void SetPreferredSize(const TSize& aSize,const TSize& aMinimumSize);
       
   133     virtual TSize CheckRequestedSize(const TSize& aRequestedSize) const;
       
   134 
       
   135 protected:
       
   136     //
       
   137     // Layout and label are stored here even though, especially for label, it may
       
   138     // be stored in the subclass instead/as well
       
   139     //
       
   140     MMIDItem::TLayout iLayout;
       
   141     HBufC* iLabel;
       
   142     //
       
   143     CMIDForm* iForm;
       
   144     //
       
   145     CMIDCommandList* iCommandList;
       
   146     //
       
   147     // The default command
       
   148     //
       
   149     CMIDCommand* iDefaultCommand;
       
   150     //
       
   151     // The built-in MSK command that will override default command if not null.
       
   152     CMIDCommand* iBuiltInMSKCommand;
       
   153     //
       
   154     // This can be used to store the actual preferred size that the item
       
   155     // reports
       
   156     //
       
   157     TSize iPreferredSize;
       
   158     //
       
   159     // This is set to the size requested by the MIDlet and may not be the
       
   160     // actual preferred size reported by the item. It needs to be stored since
       
   161     // any recalculation of size needs to take this into account
       
   162     //
       
   163     TSize iRequestedPreferredSize;
       
   164     //
       
   165     // Set when this Item is added to a Form.
       
   166     // Used to restrict the preferred size.
       
   167     //
       
   168     TInt iFormWidth;
       
   169     // UI manager instance
       
   170     CMIDUIManager* iUIManager;
       
   171 public:
       
   172     //
       
   173     // For layout algorithm. Calculated by Form
       
   174     //
       
   175     MMIDItem::TLayout iEffectiveLayout;
       
   176     //
       
   177     // This defines whether there's a new line BEFORE the item is added
       
   178     // to the form. Calculated by Form
       
   179     //
       
   180     TBool iNewLine;
       
   181     //
       
   182     // we can use this to get the type
       
   183     //
       
   184     MMIDItem* iMMidItem;
       
   185 
       
   186     CMIDMenuHandler* iMenuHandler; // we don't own this
       
   187 };
       
   188 
       
   189 #endif // CMIDITEM_H
       
   190 
       
   191 
       
   192