mmuifw_plat/alf_widgetmodel_api/inc/alf/ialfwidget.h
branchRCL_3
changeset 26 0e9bb658ef58
parent 0 e83bab7cf002
equal deleted inserted replaced
25:4ea6f81c838a 26:0e9bb658ef58
       
     1 /*
       
     2 * Copyright (c) 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:  The base class for all widgets.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef I_ALFWIDGET_H
       
    20 #define I_ALFWIDGET_H
       
    21 
       
    22 
       
    23 #include <alf/ialfinterfacebase.h>
       
    24 #include <alf/alftypes.h>
       
    25 #include <alf/alfvarianttype.h>
       
    26 
       
    27 namespace duiuimodel
       
    28     {
       
    29 class DuiNode;
       
    30     }
       
    31 
       
    32 using namespace duiuimodel;
       
    33 
       
    34 class CAlfEnv;
       
    35 
       
    36 namespace Alf
       
    37     {
       
    38 
       
    39 class CAlfWidgetControl;
       
    40 class IAlfModel;
       
    41 class IAlfWidgetFactory;
       
    42 class IAlfContainerWidget;
       
    43 class AlfCustomInitDataBase;  
       
    44 
       
    45 
       
    46 namespace alfwidget
       
    47     {
       
    48 static const IfId ident=
       
    49     {
       
    50     0,"alfwidget"
       
    51     };
       
    52     }
       
    53 /**
       
    54  *  An interface for all widgets.
       
    55  *  Widgets consist of a model and a control.
       
    56  *  The model is owned by the widget, but all
       
    57  *  controls are owned by Alfred environment.
       
    58  *  The widget can be queried for interfaces provided
       
    59  *  by derived widget classes, the control or the model.
       
    60  *  Widgets can be constructed using the widget factory.
       
    61  *  Widgets are owned and accessed using the Alfred
       
    62  *  environment.
       
    63  *
       
    64  *  @lib alfwidgetmodel.lib
       
    65  *  @since S60 ?S60_version
       
    66  *  @status Draft
       
    67  */
       
    68 class IAlfWidget : public IAlfInterfaceBase
       
    69     {
       
    70 public:
       
    71     static inline const IfId& type()
       
    72         {
       
    73         return alfwidget::ident;
       
    74         }
       
    75 
       
    76     /** Virtual destructor. */
       
    77     virtual ~IAlfWidget() {}
       
    78 
       
    79     /**
       
    80      * Getter for the control. The ownership is not passed.
       
    81      *
       
    82      * @since S60 ?S60_version
       
    83      * @return The control of this widget, or NULL if the control is not specified.
       
    84      */
       
    85     virtual CAlfWidgetControl* control() const = 0;
       
    86     
       
    87     /**
       
    88      * Getter for the parent container. The ownership is not passed.
       
    89      *
       
    90      * @return the parent container or 0 if the widget is the root-widget.
       
    91      */
       
    92     virtual IAlfContainerWidget* parent() const = 0;
       
    93 
       
    94     /**
       
    95      * Sets a new widget control. After this call has been succesfully executed, the control is 
       
    96      * owned by this widget. When a new widget control is set to a widget the previously set widget
       
    97      * control is removed.
       
    98      *
       
    99      * Through the aDeletePreviousControl - parameter user can specify whether the previously set 
       
   100      * control is destroyed when new control is set. Otherwise the previous control is left on the
       
   101      * ownership of the caller. The caller has to manually delete the control or reset it to another
       
   102      * widget or control group.
       
   103      *
       
   104      * If the control passed through this method exists in a control group it is appended to the
       
   105      * control group of the view where this widget is contained in and removed from its previous
       
   106      * control group.
       
   107      *
       
   108      * Widget should always have a valid control. An osncore::AlfException is thrown with error code
       
   109      * osncore::EInvalidArgument if a control that is already used in another widget is attempted to
       
   110      * be used with this widget. You have to replace the control in the source widget first
       
   111      * before you can reuse that control in the target widget. See two code snippets below for details:
       
   112      *
       
   113      * @code
       
   114      * // This will throw an osncore::AlfException with error code osncore::EInvalidArgument.
       
   115      * targetWidget.setControl(sourceWidget.control());
       
   116      * @endcode
       
   117      *
       
   118      * @code
       
   119      * CAlfWidgetControl* control = sourceWidget.control();
       
   120      * sourceWidget.setControl(newControl, false);
       
   121      * // This is ok, since control is not set in sourceWidget anymore.
       
   122      * targetWidget.setControl(control);
       
   123      * @endcode
       
   124      *
       
   125      * @see IAlfViewWidget
       
   126      *
       
   127      * @param aControl                The new widget control to be used with this widget.
       
   128      * @param aDeletePreviousControl  If set to true will destroy the previously set control from UI Accelerator Toolkit Environment.
       
   129      *
       
   130      * @exception osncore::AlfException If the given control is already set to another widget an osncore::AlfException
       
   131      *                                  is thrown with error code osncore::EInvalidArgument.
       
   132      */
       
   133     virtual void setControl( CAlfWidgetControl* aControl, bool aDeletePreviousControl = true ) = 0;
       
   134 
       
   135     /**
       
   136      * Getter for the model. The ownership is not passed.
       
   137      *
       
   138      * @since S60 ?S60_version
       
   139      * @return The model of this widget, or NULL if the model is not specified.
       
   140      */
       
   141     virtual IAlfModel* model() = 0;
       
   142 
       
   143     /**
       
   144      * Setter for the model. Ownership is passed and the old model is released.
       
   145      *
       
   146      * @since S60 ?S60_version
       
   147      * @param aModel The model for this widget.
       
   148      * @param aTakeOwnership Whether takes ownership of model or not
       
   149      * return void
       
   150      */
       
   151     virtual void setModel( IAlfModel* aModel,bool aTakeOwnership = true) = 0;
       
   152 
       
   153     /**
       
   154      * Get the name of the widget instance.
       
   155      *
       
   156      * @since S60 ?S60_version
       
   157      * @return Widget name
       
   158      */
       
   159     virtual const char* widgetName() const = 0;
       
   160 
       
   161     /**
       
   162      * Sets/Releases the Focus from child widget of container.
       
   163      * Does not set the actual focused status in roster.
       
   164      *
       
   165      * @since S60 ?S60_version
       
   166      * @param aFocus boolean value for focused status
       
   167      * return void
       
   168      */
       
   169     virtual void setChildFocus(bool aFocus) = 0;
       
   170 
       
   171     /** 
       
   172      * Sets the presentation for the widget using presentation XML file.
       
   173      * Destroys any existing presentation.
       
   174      * @param aFilePath Path to XML file describing the presentation 
       
   175      *                  of the widget. Not Owned.
       
   176      * @exception AlfWidgetException if no visualization node available 
       
   177      *                               in Presentation XML or if no control
       
   178      *                               is associated with the widget.
       
   179      * @exception bad_alloc 
       
   180      * @since S60 ?S60_version
       
   181      * @return void.
       
   182      */
       
   183     virtual void setPresentation(const char* aFilePath) = 0;    
       
   184     };
       
   185 
       
   186 /**
       
   187  * Placeholder for information required to instantiate a widget
       
   188  *  via the widget factory mechanism.
       
   189  *  A pointer to this structure is casted to a void pointer and sent to the
       
   190  *  factory plugin.
       
   191  *  @lib alfwidgetmodel.lib
       
   192  *  @since S60 ?S60_version
       
   193  */
       
   194 struct AlfWidgetInitData
       
   195     {
       
   196     /**
       
   197      * Owner environment for the widget
       
   198      */
       
   199     CAlfEnv* mEnv;
       
   200 
       
   201     /**
       
   202      * Container widget pointer that is going to contain the created widget.
       
   203      */
       
   204     IAlfContainerWidget* mContainerWidget;
       
   205      
       
   206     /**
       
   207      * Widget instance ID.This uniquely identifies every widget instance
       
   208      * and is its name. Also see AlfWidget::Widgetname().
       
   209      */
       
   210     char*     mWidgetId;
       
   211 
       
   212     /**
       
   213      * Pointer to node in declaration containing information for the widget.
       
   214      */
       
   215     DuiNode* mNode;
       
   216     
       
   217     /**
       
   218      * XML file name containing the declaration for the presention of the widget. 
       
   219      */
       
   220     const char* mFilePath;
       
   221     
       
   222     /**
       
   223      * Pointer to custom data passed via factory mechanism
       
   224      * Not Owned.
       
   225      */
       
   226     AlfCustomInitDataBase* mCustomData;  
       
   227     };
       
   228 
       
   229 
       
   230     } // namespace Alf
       
   231 
       
   232 #endif // I_ALFWIDGET_H
       
   233 
       
   234 // End of File