webengine/wmlengine/src/lmgr/include/LMgrObjectBox.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2003 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 the License "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:  Provides a means for PluginInst's to communicate with thier owner
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CPLUGINBOX_H
       
    21 #define CPLUGINBOX_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32def.h>
       
    25 #include <e32base.h>
       
    26 
       
    27 #include "nw_gdi_types.h"
       
    28 #include "nw_lmgr_propertylist.h"
       
    29 #include "GDIDeviceContext.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 #ifdef __cplusplus
       
    33 extern "C" {
       
    34 #endif /* __cplusplus */
       
    35 
       
    36 typedef struct NW_LMgr_RootBox_s NW_LMgr_RootBox_t;
       
    37 typedef struct NW_LMgr_Box_s NW_LMgr_Box_t;
       
    38 typedef struct NW_LMgr_FormatContext_s NW_LMgr_FormatContext_t;
       
    39 typedef struct NW_LMgr_EventHandler_s NW_LMgr_EventHandler_t;
       
    40 typedef struct NW_Text_Abstract_s NW_Text_t;
       
    41 typedef struct NW_Image_AbstractImage_s NW_Image_AbstractImage_t;
       
    42 
       
    43 #ifdef __cplusplus
       
    44 }
       
    45 #endif /* __cplusplus */
       
    46 
       
    47 class CCoeControl; 
       
    48 class MLMgrObjectBoxListener;
       
    49 class MLMgrBoxDestructionListener;
       
    50 
       
    51 // CLASS DECLARATION
       
    52 
       
    53 // TODO: This class should be derived from CMediaBox once the browser is
       
    54 //       converted to c++.
       
    55 
       
    56 class CLMgrObjectBox : public CBase
       
    57     {
       
    58     public:  // Constructors and destructor
       
    59         /**
       
    60         * Two-phased constructor.
       
    61         *
       
    62         * @param aBox the NW_LMgr_NpiBox it is managing.
       
    63         */
       
    64         static CLMgrObjectBox* NewL(NW_LMgr_Box_t* aBox);
       
    65 
       
    66         /**
       
    67         * Creates a NPI box-tree, an active container box with a single NPI box as a child.
       
    68         *
       
    69         * @param aEventHandler the active container box's event handler.
       
    70         * @param aPluginContainerBox upon success, an active container box.
       
    71         * @param aPluginBox upon success, the new NPI Box
       
    72         * @return TBrowserStatusCode
       
    73         */
       
    74         static TBrowserStatusCode NewBox(NW_LMgr_EventHandler_t* aEventHandler, 
       
    75                 NW_LMgr_Box_t** aPluginContainerBox, NW_LMgr_Box_t** aPluginBox);
       
    76 
       
    77         /**
       
    78         * Destructor.
       
    79         */
       
    80         virtual ~CLMgrObjectBox();
       
    81 
       
    82 
       
    83     public:  // New Methods
       
    84         /**
       
    85         * Allows the box to be placed on the on a new line and grows
       
    86         * the box to the width of "space" if the box doesn't have 
       
    87         * a width property.
       
    88         *
       
    89         * @param aSpace the amount of space available on the line.
       
    90         * @param aSplitBox not used.
       
    91         * @param aFlags LMgr split flags.
       
    92         * @return KBrsrLmgrNoSplit, KBrsrSuccess
       
    93         */
       
    94         virtual TBrowserStatusCode Split(NW_GDI_Metric_t aSpace, 
       
    95                 NW_LMgr_Box_t** aSplitBox, NW_Uint8 aFlags);
       
    96 
       
    97         /**
       
    98         * Calculates the minimum size needed for the box.
       
    99         *
       
   100         * @param aSize the size of the box.
       
   101         * @return void
       
   102         */
       
   103         virtual void GetMinimumContentSize(NW_GDI_Dimension2D_t& aSize);
       
   104 
       
   105         /**
       
   106         * Draws the border, background and place holder (while the place
       
   107         * holder is shown).
       
   108         *
       
   109         * @param  aDeviceContext the device context used for drawing.
       
   110         * @param  aHasFocus whether the box has focus.
       
   111         * @return TBrowserStatusCode
       
   112         */
       
   113         virtual TBrowserStatusCode Draw(const CGDIDeviceContext& aDeviceContext,
       
   114                 NW_Bool aHasFocus);
       
   115 
       
   116         /**
       
   117         * If necessary it positions the CPluginInst to match the box's 
       
   118         * bounds and renders the box.
       
   119         *
       
   120         * @param  aDeviceContext the device context used for drawing.
       
   121         * @param  aClipRect the current clip rect.
       
   122         * @param  aCurrentBox the current box.
       
   123         * @param  aCurrentBox flags used during rendering.
       
   124         * @param  aHasFocus whether the box has focus.
       
   125         * @param  aSkipChildren whether the children should be skipped.
       
   126         * @param  aRootBox the root box.
       
   127         * @return TBrowserStatusCode
       
   128         */
       
   129         virtual TBrowserStatusCode Render(const CGDIDeviceContext& aDeviceContext,
       
   130                 const NW_LMgr_RootBox_t& aRootBox, const NW_GDI_Rectangle_t& aClipRect, 
       
   131                 const NW_LMgr_Box_t* aCurrentBox, NW_Uint8 aFlags, NW_Bool& aHasFocus, 
       
   132                 NW_Bool& aSkipChildren);
       
   133 
       
   134         /**
       
   135         * Set the box's listener
       
   136         *
       
   137         * @param aListener the listener
       
   138         * @return void
       
   139         */
       
   140         void SetBoxListener(MLMgrObjectBoxListener* aListener);
       
   141 
       
   142         /**
       
   143         * Adds a box destruction listener.
       
   144         *
       
   145         * @param aListener the listener
       
   146         * @return void
       
   147         */
       
   148         void AddBoxDestructionListenerL(MLMgrBoxDestructionListener* aListener);
       
   149 
       
   150         /**
       
   151         * Removes a box destruction listener.
       
   152         *
       
   153         * @param aListener the listener
       
   154         * @return void
       
   155         */
       
   156         void RemoveBoxDestructionListener(MLMgrBoxDestructionListener* aListener);
       
   157 
       
   158         /**
       
   159         * Sets the place holder text.
       
   160         *
       
   161         * @param aText
       
   162         * @return void
       
   163         */
       
   164         void SetPlaceHolderTextL(const TDesC& aNewText);
       
   165 
       
   166         /**
       
   167         * Set the place-holder text to the given resource id.
       
   168         *
       
   169         * @param aResourceId the string's resource id.
       
   170         *
       
   171         * @return void
       
   172         */
       
   173         void SetPlaceHolderTextL(TInt aResourceId);
       
   174 
       
   175         /**
       
   176         * Removes the place holder's text and image.
       
   177         *
       
   178         * @return void
       
   179         */
       
   180         void RemovePlaceHolder(void);
       
   181 
       
   182         /**
       
   183         * Returns ETrue if the place holder is being shown.
       
   184         *
       
   185         * @return ETure or EFalse
       
   186         */
       
   187         TBool IsShowingPlaceHolder(void);
       
   188 
       
   189         /**
       
   190         * Returns if the plugin is active or not.
       
   191         *
       
   192         * @param .
       
   193         * @return if the plugin is active or not.
       
   194         */
       
   195         TBool IsActive() const;
       
   196 
       
   197         /**
       
   198         * Each CLMgrObjectBox is contained in a container-box.  In order to identify the 
       
   199         * plugin box associated with a given elementNode the NW_CSS_Prop_elementId 
       
   200         * CSS property is applied, where the property value equals the element-node.
       
   201         * FindBoxTree returns the box that contains a NW_CSS_Prop_elementId with a
       
   202         * value matching aBoxKey. 
       
   203         *
       
   204         * @param aBoxTree the box-tree of the enclosing content handler.
       
   205         * @param aBoxKey a pointer to the associated element-node.
       
   206         * @return the CLMgrObjectBox's container-box.
       
   207         */
       
   208         static NW_LMgr_Box_t* FindBoxTree(const NW_LMgr_Box_t& aBoxTree,
       
   209                 void* aBoxKey);
       
   210 
       
   211         /**
       
   212         * Each CLMgrObjectBox is contained in a container-box.  FindObjectBox finds 
       
   213         * and returns the first NW_LMgr_NpiBox found in aBoxTree.
       
   214         *
       
   215         * @param aBoxTree the CLMgrObjectBox's container-box.
       
   216         * @return the NW_LMgr_NpiBox.
       
   217         */
       
   218 	    static NW_LMgr_Box_t* FindObjectBox(const NW_LMgr_Box_t& aBoxTree);
       
   219 
       
   220         /**
       
   221         * Returns the given property as a descriptor.
       
   222         *
       
   223         * @param aBoxTree the CLMgrObjectBox's container-box.
       
   224         * @return the NW_LMgr_NpiBox.
       
   225         */
       
   226         static TDesC* GetTextProperty(const NW_LMgr_Box_t& aBox, 
       
   227                 NW_LMgr_PropertyName_t aProperty);
       
   228 
       
   229         /**
       
   230         * Returns the view infrastructure's CCoeControl associated the given root-box.
       
   231         *
       
   232         * @param aRootBox a root-box.
       
   233         * @return the CCoeControl associated the given root-box.
       
   234         */
       
   235         static CCoeControl* GetParentWindow(const NW_LMgr_RootBox_t& aRootBox);
       
   236 
       
   237         /**
       
   238         * Returns the OOC ObjectBox.
       
   239         *
       
   240         * @param .
       
   241         * @return the OOC ObjectBox.
       
   242         */
       
   243         NW_LMgr_Box_t* Box(){return iBox;}
       
   244 
       
   245 
       
   246     private:  // Private Methods
       
   247         /**
       
   248         * C++ default constructor.
       
   249         */
       
   250         CLMgrObjectBox(NW_LMgr_Box_t* aBox);
       
   251 
       
   252         /**
       
   253         * By default Symbian 2nd phase constructor is private.
       
   254         */
       
   255         void ConstructL(void);
       
   256 
       
   257         /**
       
   258         * Returns the view infrastructure's CCoeControl associated with this instance.
       
   259         *
       
   260         * @return the CCoeControl associated with this instance.
       
   261         */
       
   262         CCoeControl* GetParentWindow(void);
       
   263 
       
   264         /**
       
   265         * Shows, sizes, and locates the CPluginInst or place holder to correspond with 
       
   266         * the box.
       
   267         *
       
   268         * @param aLocation where the PluginInst should be placed
       
   269         * @param aSize the size the PluginInst or place holder should be.
       
   270         * @return void
       
   271         */
       
   272         void AttachPluginInst(const NW_GDI_Point2D_s& aLocation,
       
   273                 const NW_GDI_Dimension2D_t& aSize);
       
   274 
       
   275         /**
       
   276         * Detaches the CPluginInst from its parent.
       
   277         *
       
   278         * @param void
       
   279         * @return void
       
   280         */
       
   281         void DetachPluginInst(void);
       
   282 
       
   283         /**
       
   284         * Adjusts the location and size of the PluginInst or place holder so it matches iBox's
       
   285         * bounds.
       
   286         *
       
   287         * @param  aDeviceContext the device context used for drawing.
       
   288         * @return void
       
   289         */
       
   290         void SyncPluginInstBounds(const CGDIDeviceContext& aDeviceContext);
       
   291 
       
   292         /**
       
   293         * Implements the the NPI handling rules for vertical layout
       
   294         * 1. Scale the box maintaining the aspect ratio if width is greater than display width
       
   295         * 2. Scale the box maintaining the aspect ratio if height is greater than display height
       
   296         * 3. If box is too small it doesn't participate in the layout.
       
   297         *
       
   298         * @param aOrigSize the original size of the box
       
   299         * @param aNewSize the new size of the box
       
   300         * @return void
       
   301         */
       
   302         void HandleVerticalLayout(const NW_GDI_Dimension2D_t& aOrigSize, 
       
   303                NW_GDI_Dimension2D_t& aNewSize);
       
   304 
       
   305         /**
       
   306         * Creates a copy of aText such that it width is <= aAvailableSpace -- truncating as necessary.
       
   307         *
       
   308         * @param  aText the string to be copied.
       
   309         * @param  aDeviceContext the device context used for drawing.
       
   310         * @param  aAvailableSpace the amount of space available -- the size aText must fit in.
       
   311         * @param  aAddDots if true "..." will be appended if aText needs to be clipped.
       
   312         * @return a copy of aText whos width is <= aAvailableSpace.
       
   313         */
       
   314         TDesC* ClipText(const TDesC& aText, const CGDIDeviceContext& aDeviceContext,
       
   315                 NW_GDI_Metric_t aAvailableSpace, TBool aAddDots);
       
   316 
       
   317 
       
   318     private:  // Data
       
   319 	    NW_LMgr_Box_t*                              iBox;
       
   320         CCoeControl*                                iPluginInst;
       
   321         TBool                                       iPluginAttached;
       
   322         TBool                                       iInHyperLink;
       
   323 
       
   324         TBool                                       iShowingPlaceHolder;
       
   325         const NW_Image_AbstractImage_t*             iPlaceHolderImage;
       
   326         TDesC*                                      iOrigPlaceHolderText;
       
   327         TDesC*                                      iPlaceHolderText;
       
   328         TBool                                       iCalculatePlaceHolderClip;
       
   329 
       
   330         TBool                                       iForceSyncPluginInst;
       
   331         NW_GDI_Point2D_t                            iLocation;
       
   332         NW_GDI_Dimension2D_t                        iSize;
       
   333 
       
   334         MLMgrObjectBoxListener*                     iBoxListener;
       
   335         RPointerArray<MLMgrBoxDestructionListener>  iDestructionListeners;
       
   336     };
       
   337 
       
   338 #endif      // CPLUGINBOX_H