javauis/lcdui_akn/lcdui/src/CMIDCanvasGraphicsItem.cpp
branchRCL_3
changeset 14 04becd199f91
child 18 9ac0a0a7da70
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2009 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:  CMIDCanvasGraphicsItem - Implements the native part Canvas Graphics Item class.
       
    15 *
       
    16 */
       
    17 
       
    18 // EXTERNAL INCLUDES
       
    19 #include <MMIDCustomComponentContainer.h>
       
    20 #include <lcdui.h>
       
    21 #include <fbs.h>
       
    22 #include <bitdev.h>
       
    23 #include <bitstd.h>
       
    24 #include <j2me/jdebug.h>
       
    25 
       
    26 // INTERNAL INCLUDES
       
    27 #include "CMIDCanvasGraphicsItem.h"
       
    28 #include "CMIDCanvasGraphicsItemPainter.h"
       
    29 #include "CMIDUtils.h"
       
    30 
       
    31 // Count of compound components in this custom component.
       
    32 const TInt KComponentCount      = 1;
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 // CMIDCanvasGraphicsItem::NewL
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CMIDCanvasGraphicsItem* CMIDCanvasGraphicsItem::NewL(
       
    39     const TCtorParams& aParams)
       
    40 {
       
    41     CMIDCanvasGraphicsItem* self = new(ELeave) CMIDCanvasGraphicsItem();
       
    42     CleanupStack::PushL(self);
       
    43     self->ConstructL(aParams);
       
    44     CleanupStack::Pop(self);
       
    45     return self;
       
    46 }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CMIDCanvasGraphicsItem::ConstructL
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 void CMIDCanvasGraphicsItem::ConstructL(const TCtorParams& aParams)
       
    53 {
       
    54     // Set painter
       
    55     iItemPainter = aParams.iPainterHandle;
       
    56     iComponentContainer = NULL;
       
    57     iUtils = aParams.iUtils;
       
    58 }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CMIDCanvasGraphicsItem::CMIDCanvasGraphicsItem
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CMIDCanvasGraphicsItem::CMIDCanvasGraphicsItem()
       
    65 {
       
    66     // No implementation.
       
    67 }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CMIDCanvasGraphicsItem::~CMIDCanvasGraphicsItem
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 CMIDCanvasGraphicsItem::~CMIDCanvasGraphicsItem()
       
    74 {
       
    75     DEBUG("CMIDCanvasGraphicsItem::~CMIDCanvasGraphicsItem +");
       
    76 
       
    77     // Remove this component from the container if set.
       
    78     if (iComponentContainer)
       
    79     {
       
    80         iComponentContainer->UnregisterComponent(this);
       
    81     }
       
    82 
       
    83     DEBUG("CMIDCanvasGraphicsItem::~CMIDCanvasGraphicsItem -");
       
    84 }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // CMIDCanvasGraphicsItem::CustomComponentControlCount
       
    88 // (other items are commented in the header file)
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 TInt CMIDCanvasGraphicsItem::CustomComponentControlCount() const
       
    92 {
       
    93     return KComponentCount;
       
    94 }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CMIDCanvasGraphicsItem::CustomComponentControl
       
    98 // (other items are commented in the header file)
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CCoeControl* CMIDCanvasGraphicsItem::CustomComponentControl(TInt aIndex)
       
   102 {
       
   103     if (aIndex == 0)
       
   104     {
       
   105         return iItemPainter;
       
   106     }
       
   107     return NULL;
       
   108 }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // CMIDCanvasGraphicsItem::CustomComponentContainerDisposing
       
   112 // (other items are commented in the header file)
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CMIDCanvasGraphicsItem::CustomComponentContainerDisposing()
       
   116 {
       
   117     iComponentContainer = NULL;
       
   118 }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CMIDCanvasGraphicsItem::SetParentL
       
   122 // (other items are commented in the header file)
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CMIDCanvasGraphicsItem::SetParentL(
       
   126     MMIDCustomComponentContainer* aComponentContainer)
       
   127 {
       
   128     DEBUG("CMIDCanvasGraphicsItem::SetParentL +");
       
   129 
       
   130     // Remove association from the previous container.
       
   131     if (iComponentContainer)
       
   132     {
       
   133         DEBUG("CMIDCanvasGraphicsItem::SetParentL, unregistering old association");
       
   134 
       
   135         iComponentContainer->UnregisterComponent(this);
       
   136         iComponentContainer = NULL;
       
   137     }
       
   138 
       
   139     // Associate this component to the new container.
       
   140     if (aComponentContainer)
       
   141     {
       
   142         DEBUG("CMIDCanvasGraphicsItem::SetParentL, registering new");
       
   143 
       
   144         // Register this custom component to the container.
       
   145         aComponentContainer->RegisterComponentL(this);
       
   146         // Initializes painter with the new parent
       
   147         iItemPainter->SetParentL(aComponentContainer);
       
   148     }
       
   149 
       
   150     // Store container. NULL is ok.
       
   151     iComponentContainer = aComponentContainer;
       
   152 
       
   153     DEBUG("CMIDCanvasGraphicsItem::SetParentL -");
       
   154 }
       
   155 
       
   156 // ---------------------------------------------------------------------------
       
   157 // CMIDCanvasGraphicsItem::SetDirectContainerL
       
   158 // (other items are commented in the header file)
       
   159 // ---------------------------------------------------------------------------
       
   160 //
       
   161 void CMIDCanvasGraphicsItem::SetDirectContainerL(
       
   162     MDirectContainer* aDirectContainer)
       
   163 {
       
   164     iItemPainter->SetDirectContainerL(aDirectContainer);
       
   165 }
       
   166 
       
   167 // ---------------------------------------------------------------------------
       
   168 // CMIDCanvasGraphicsItem::SetElevationL
       
   169 // (other items are commented in the header file)
       
   170 // ---------------------------------------------------------------------------
       
   171 //
       
   172 void CMIDCanvasGraphicsItem::SetElevationL(TInt aElevation)
       
   173 {
       
   174     DEBUG_INT("CMIDCanvasGraphicsItem::SetElevationL +, aElevation=%d",
       
   175               aElevation);
       
   176 
       
   177     // Parent must have been set.
       
   178     __ASSERT_DEBUG(iComponentContainer, User::Invariant());
       
   179 
       
   180     // The elevation is handled in custom component container.
       
   181     iComponentContainer->SetComponentIndexL(this, aElevation);
       
   182 
       
   183     DEBUG("CMIDCanvasGraphicsItem::SetElevationL -");
       
   184 }
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // CMIDCanvasGraphicsItem::Elevation
       
   188 // (other items are commented in the header file)
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 TInt CMIDCanvasGraphicsItem::Elevation()
       
   192 {
       
   193     DEBUG("CMIDCanvasGraphicsItem::Elevation +");
       
   194 
       
   195     // Parent must have been set.
       
   196     __ASSERT_DEBUG(iComponentContainer, User::Invariant());
       
   197 
       
   198     // The elevation is retrieved from custom component container
       
   199     TInt index = iComponentContainer->ComponentIndex(this);
       
   200 
       
   201     DEBUG_INT("CMIDCanvasGraphicsItem::Elevation - index=%d", index);
       
   202 
       
   203     return index;
       
   204 }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // CMIDCanvasGraphicsItem::Show
       
   208 // (other items are commented in the header file)
       
   209 // ---------------------------------------------------------------------------
       
   210 //
       
   211 void CMIDCanvasGraphicsItem::SetVisibleL(TBool aVisible)
       
   212 {
       
   213     DEBUG_INT("CMIDCanvasGraphicsItem::SetVisibleL +, aVisible=%d", aVisible);
       
   214 
       
   215     // SetParentL must be called before Show.
       
   216     __ASSERT_DEBUG(iComponentContainer, User::Invariant());
       
   217 
       
   218     iItemPainter->SetVisibleL(aVisible);
       
   219 
       
   220     DEBUG("CMIDCanvasGraphicsItem::SetVisibleL -");
       
   221 }
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 // CMIDCanvasGraphicsItem::SetSizeL
       
   225 // (other items are commented in the header file)
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CMIDCanvasGraphicsItem::SetSizeL(const TInt aWidth, const TInt aHeight)
       
   229 {
       
   230     DEBUG_INT2(
       
   231         "CMIDCanvasGraphicsItem::SetItemSize +, aWidth=%d, aHeight=%d",
       
   232         aWidth, aHeight);
       
   233 
       
   234     iItemPainter->SetItemSizeL(aWidth, aHeight);
       
   235 
       
   236     DEBUG("CMIDCanvasGraphicsItem::SetItemSize -");
       
   237 }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // CMIDCanvasGraphicsItem::SetPosition
       
   241 // (other items are commented in the header file)
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 void CMIDCanvasGraphicsItem::SetPosition(const TInt aX, const TInt aY)
       
   245 {
       
   246     DEBUG_INT2("CMIDCanvasGraphicsItem::SetPosition +, aX=%d, aY=%d", aX, aY);
       
   247 
       
   248     iItemPainter->SetPosition(aX, aY);
       
   249 
       
   250     DEBUG("CMIDCanvasGraphicsItem::SetPosition -");
       
   251 }
       
   252 
       
   253 // ---------------------------------------------------------------------------
       
   254 // CMIDCanvasGraphicsItem::Dispose
       
   255 // (other items are commented in the header file)
       
   256 // ---------------------------------------------------------------------------
       
   257 //
       
   258 void CMIDCanvasGraphicsItem::Dispose()
       
   259 {
       
   260     DEBUG("CMIDCanvasGraphicsItem::Dispose +");
       
   261 
       
   262     delete this;
       
   263 
       
   264     DEBUG("CMIDCanvasGraphicsItem::Dispose -");
       
   265 }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // CMIDCanvasGraphicsItem::HandleFullscreenModeChange
       
   269 // Intentionally this is not implemented.
       
   270 // CanavsGraohicsItem is not doing any action in this case.
       
   271 // ---------------------------------------------------------------------------
       
   272 //
       
   273 void CMIDCanvasGraphicsItem::HandleFullscreenModeChange()
       
   274 {
       
   275 }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CMIDCanvasGraphicsItem::HandleResolutionChange
       
   279 // Intentionally this is not implemented.
       
   280 // CanavsGraohicsItem is not doing any action in this case.
       
   281 // ---------------------------------------------------------------------------
       
   282 //
       
   283 void CMIDCanvasGraphicsItem::HandleResolutionChange()
       
   284 {
       
   285 }
       
   286 
       
   287 // End of file