uiacceltk/hitchcock/Client/src/alfgridlayout.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Grid layout
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "alf/alfgridlayout.h"
       
    21 #include "alf/alflayout.h"
       
    22 #include "alf/alfcontrol.h"
       
    23 #include "alfclient.h"
       
    24 #include "alf/alfenv.h"
       
    25 #include "alf/alfgencomponent.h"
       
    26 #include "alf/alfconstants.h"
       
    27 #include "alflogger.h"
       
    28 
       
    29 
       
    30 // Struct for private data
       
    31 struct CAlfGridLayout::TGridLayoutPrivateData
       
    32     {
       
    33     
       
    34     };
       
    35 
       
    36 // ======== LOCAL FUNCTIONS ========
       
    37 
       
    38 
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // 1st phase constructor
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 EXPORT_C CAlfGridLayout::CAlfGridLayout()
       
    46     : CAlfLayout()
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // 2nd phase constructor
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 EXPORT_C void CAlfGridLayout::ConstructL(CAlfControl& aOwner)
       
    56     {
       
    57     CAlfLayout::ConstructL(aOwner);     
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // Destructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C CAlfGridLayout::~CAlfGridLayout()
       
    65     {
       
    66     if ( iGridLayoutData )
       
    67         {
       
    68         }
       
    69         
       
    70     delete iGridLayoutData;
       
    71     iGridLayoutData = NULL;
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // Creates new grid layout for the control.
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CAlfGridLayout* CAlfGridLayout::AddNewL(
       
    80     CAlfControl& aOwnerControl,
       
    81     TInt aColumns, TInt aRows,
       
    82     CAlfLayout* aParentLayout )
       
    83     {
       
    84     CAlfGridLayout* layout = STATIC_CAST(CAlfGridLayout*,
       
    85         aOwnerControl.AppendLayoutL(EAlfLayoutTypeGrid, aParentLayout));
       
    86     layout->SetColumnsL(aColumns);
       
    87     layout->SetRowsL(aRows);
       
    88     return layout;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // Sets amount of columns in the grid.
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C void CAlfGridLayout::SetColumnsL(TInt aColumnCount)
       
    96     {
       
    97     TPckgC<TInt> buf (aColumnCount);
       
    98 
       
    99     TInt err = Comms()->DoCmdNoReply(EAlfGridLayoutSetColumns, buf );
       
   100     
       
   101     if ( err )
       
   102         {
       
   103         __ALFLOGSTRING1( "CAlfGridLayout::SetColumnsL error %d", err )
       
   104         User::Leave(err);
       
   105         }
       
   106     }
       
   107     
       
   108 // ---------------------------------------------------------------------------
       
   109 // Sets amount of rows in the grid.
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 EXPORT_C void CAlfGridLayout::SetRowsL(TInt aRowCount)
       
   113     {
       
   114     TPckgC<TInt> buf (aRowCount);
       
   115 
       
   116     TInt err = Comms()->DoCmdNoReply(EAlfGridLayoutSetRows, buf );
       
   117     
       
   118     if ( err )
       
   119         {
       
   120         __ALFLOGSTRING1( "CAlfGridLayout::SetRowsL error %d", err )
       
   121         User::Leave(err);
       
   122         }
       
   123     }
       
   124 
       
   125 EXPORT_C void CAlfGridLayout::SetColumnsL(const RArray<TInt>& aWeights)
       
   126     {
       
   127     HBufC8* buffer = ExternalizeLC(aWeights);
       
   128 
       
   129     TInt err = Comms()->DoCmdNoReply(EAlfGridLayoutSetColumnWeights, *buffer );
       
   130     if ( err )
       
   131         {
       
   132         __ALFLOGSTRING1( "CAlfGridLayout::SetColumnsL error %d", err )
       
   133         User::Leave(err);
       
   134         }
       
   135         
       
   136     CleanupStack::PopAndDestroy( buffer );
       
   137     }
       
   138 
       
   139 EXPORT_C void CAlfGridLayout::SetRowsL(const RArray<TInt>& aWeights)
       
   140     {
       
   141     HBufC8* buffer = ExternalizeLC(aWeights);
       
   142 
       
   143     TInt err = Comms()->DoCmdNoReply(EAlfGridLayoutSetRowsWeights, *buffer );
       
   144     if ( err )
       
   145         {
       
   146         __ALFLOGSTRING1( "CAlfGridLayout::SetRowsL error %d", err )
       
   147         User::Leave(err);
       
   148         }
       
   149         
       
   150     CleanupStack::PopAndDestroy( buffer );
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------------------------
       
   154 // Weight metrics
       
   155 // ---------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C void CAlfGridLayout::FillWeightsL(TAlfGridDimension aDim, TInt aCount, const TAlfMetric& aWeight)
       
   158     {
       
   159     TAlfGridLayoutFillWeightsParams params;
       
   160     params.iDim = aDim;
       
   161     params.iCount = aCount;
       
   162     params.iWeight = aWeight;
       
   163     TPckg<TAlfGridLayoutFillWeightsParams> paramsPckg(params);
       
   164 
       
   165     TBuf8<1> dum;
       
   166     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutFillWeights, paramsPckg, dum );
       
   167     if ( err != KErrNone )
       
   168         {
       
   169         __ALFLOGSTRING1( "CAlfGridLayout::FillWeightsL return error %d", err )
       
   170         User::Leave(err);
       
   171         }
       
   172     }
       
   173     
       
   174 EXPORT_C void CAlfGridLayout::AppendWeightL(TAlfGridDimension aDim, const TAlfMetric& aWeight)
       
   175     {
       
   176     TAlfGridLayoutAppendWeightParams params;
       
   177     params.iDim = aDim;
       
   178     params.iWeight = aWeight;
       
   179     TPckg<TAlfGridLayoutAppendWeightParams> paramsPckg(params);
       
   180 
       
   181     TBuf8<1> dum;
       
   182     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutAppendWeight, paramsPckg, dum );
       
   183     if ( err != KErrNone )
       
   184         {
       
   185         __ALFLOGSTRING1( "CAlfGridLayout::AppendWeightL return error %d", err )
       
   186         User::Leave(err);
       
   187         }
       
   188     }
       
   189     
       
   190 EXPORT_C void CAlfGridLayout::InsertWeightL(TAlfGridDimension aDim, const TAlfMetric& aWeight, TInt aPos)
       
   191     {
       
   192     TAlfGridLayoutInsertWeightParams params;
       
   193     params.iDim = aDim;
       
   194     params.iWeight = aWeight;
       
   195     params.iPos = aPos;
       
   196     TPckg<TAlfGridLayoutInsertWeightParams> paramsPckg(params);
       
   197 
       
   198     TBuf8<1> dum;
       
   199     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutInsertWeight, paramsPckg, dum );
       
   200     if ( err != KErrNone )
       
   201         {
       
   202         __ALFLOGSTRING1( "CAlfGridLayout::InsertWeightL return error %d", err )
       
   203         User::Leave(err);
       
   204         }
       
   205     }
       
   206     
       
   207 EXPORT_C void CAlfGridLayout::ReplaceWeightL(TAlfGridDimension aDim, const TAlfMetric& aWeight, TInt aPos)
       
   208     {
       
   209     TAlfGridLayoutReplaceWeightParams params;
       
   210     params.iDim = aDim;
       
   211     params.iWeight = aWeight;
       
   212     params.iPos = aPos;
       
   213     TPckg<TAlfGridLayoutReplaceWeightParams> paramsPckg(params);
       
   214 
       
   215     TBuf8<1> dum;
       
   216     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutReplaceWeight, paramsPckg, dum );
       
   217     if ( err != KErrNone )
       
   218         {
       
   219         __ALFLOGSTRING1( "CAlfGridLayout::ReplaceWeightL return error %d", err )
       
   220         User::Leave(err);
       
   221         }
       
   222     }
       
   223     
       
   224 EXPORT_C void CAlfGridLayout::RemoveWeightL(TAlfGridDimension aDim, TInt aPos)
       
   225     {
       
   226     TAlfGridLayoutRemoveWeightParams params;
       
   227     params.iDim = aDim;
       
   228     params.iPos = aPos;
       
   229     TPckg<TAlfGridLayoutRemoveWeightParams> paramsPckg(params);
       
   230 
       
   231     TBuf8<1> dum;
       
   232     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutRemoveWeight, paramsPckg, dum );
       
   233     if ( err != KErrNone )
       
   234         {
       
   235         __ALFLOGSTRING1( "CAlfGridLayout::RemoveWeightL return error %d", err )
       
   236         User::Leave(err);
       
   237         }
       
   238     
       
   239     }
       
   240     
       
   241 EXPORT_C TAlfMetric CAlfGridLayout::Weight(TAlfGridDimension aDim, TInt aPos) const
       
   242     {
       
   243     TAlfGridLayoutWeightParams params;
       
   244     params.iDim = aDim;
       
   245     params.iPos = aPos;
       
   246     TPckg<TAlfGridLayoutWeightParams> paramsPckg(params);
       
   247 
       
   248     TAlfMetric metric;
       
   249     TPckg<TAlfMetric> metricPckg(metric);
       
   250         
       
   251     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutWeight, paramsPckg, metricPckg);
       
   252     if ( err )
       
   253         {
       
   254         __ALFLOGSTRING1( "CAlfGridLayout::RowCount ignore error %d", err )
       
   255         }
       
   256     return metric;
       
   257     }
       
   258     
       
   259 EXPORT_C TInt CAlfGridLayout::DimensionCount(TAlfGridDimension aDim) const
       
   260     {
       
   261     TPckgC<TInt> buf (aDim);
       
   262     TInt count = 0;
       
   263     TPckg<TInt> countPckg(count);
       
   264     
       
   265     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutCount, buf, countPckg);
       
   266     if ( err )
       
   267         {
       
   268         __ALFLOGSTRING1( "CAlfGridLayout::RowCount ignore error %d", err )
       
   269         }
       
   270     
       
   271     return count;
       
   272     }
       
   273     
       
   274     
       
   275 // ---------------------------------------------------------------------------
       
   276 // Sets expanding flags in the grid.
       
   277 // ---------------------------------------------------------------------------
       
   278 //
       
   279 EXPORT_C void CAlfGridLayout::SetExpanding(TInt aFlags)
       
   280     {
       
   281     TPckgC<TInt> buf (aFlags);
       
   282 
       
   283     TInt err = Comms()->DoCmdNoReply(EAlfGridLayoutSetExpanding, buf);
       
   284     
       
   285     if ( err )
       
   286         {
       
   287         __ALFLOGSTRING1( "CAlfGridLayout::SetExpanding ignore error %d", err )
       
   288         }
       
   289     }
       
   290     
       
   291 // ---------------------------------------------------------------------------
       
   292 // Gets amount of rows in the grid.
       
   293 // ---------------------------------------------------------------------------
       
   294 //
       
   295 EXPORT_C TInt CAlfGridLayout::RowCount() const
       
   296     {
       
   297     TBuf8<1> dum;
       
   298     TInt count = 0;
       
   299     TPckg<TInt> countPckg(count);
       
   300     
       
   301     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutRowCount, dum, countPckg);
       
   302     if ( err )
       
   303         {
       
   304         __ALFLOGSTRING1( "CAlfGridLayout::RowCount ignore error %d", err )
       
   305         }
       
   306     
       
   307     return count;
       
   308     }
       
   309     
       
   310 // ---------------------------------------------------------------------------
       
   311 // Gets amount of columns in the grid.
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 EXPORT_C TInt CAlfGridLayout::ColumnCount() const
       
   315     {
       
   316     TBuf8<1> dum;
       
   317     TInt count = 0;
       
   318     TPckg<TInt> countPckg(count);
       
   319     
       
   320     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutColumnCount, dum, countPckg);
       
   321     if ( err )
       
   322         {
       
   323         __ALFLOGSTRING1( "CAlfGridLayout::ColumnCount ignore error %d", err )
       
   324         }
       
   325     
       
   326     return count;
       
   327     }
       
   328     
       
   329 // ---------------------------------------------------------------------------
       
   330 // Calculates the position of a child in the grid.
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 EXPORT_C TPoint CAlfGridLayout::OrdinalToBlock(TInt aOrdinal) const
       
   334     {
       
   335     TPckgC<TInt> buf (aOrdinal);
       
   336     TPoint result;
       
   337     TPckg<TPoint> resBuf(result);
       
   338     
       
   339     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutOrdinalToBlock, buf, resBuf);
       
   340     
       
   341     if ( err )
       
   342         {
       
   343         __ALFLOGSTRING1( "CAlfGridLayout::OrdinalToBlock ignore error %d", err )
       
   344         }
       
   345         
       
   346     return result;                                 
       
   347     }
       
   348 
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // Set Layout Mode Flags
       
   352 // ---------------------------------------------------------------------------
       
   353 // 
       
   354 
       
   355 EXPORT_C void CAlfGridLayout::SetLayoutModeFlags(TAlfGridDimension aDim, TUint aGridLayoutModeFlags)
       
   356 {
       
   357     TInt2 params( aDim, aGridLayoutModeFlags );
       
   358     TPckg<TInt2> paramsPckg(params);
       
   359 
       
   360     TInt err = Comms()->DoCmdNoReply(EAlfGridLayoutSetLayoutModeFlags, paramsPckg );
       
   361     
       
   362     if ( err )
       
   363         {
       
   364         __ALFLOGSTRING1( "CAlfGridLayout::SetLayoutModeFlags ignore error %d", err )
       
   365         }
       
   366 }
       
   367 
       
   368 // ---------------------------------------------------------------------------
       
   369 // Get Layout Mode Flags
       
   370 // ---------------------------------------------------------------------------
       
   371 // 
       
   372 EXPORT_C TInt CAlfGridLayout::LayoutModeFlags(TAlfGridDimension aDim)
       
   373 {
       
   374     TUint flags = 0;
       
   375     TPckg<TUint> flagPckg(flags);
       
   376     TPckgC<TInt> paramsPckg (aDim);  
       
   377     
       
   378     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutLayoutModeFlags, paramsPckg, flagPckg);
       
   379     
       
   380     if ( err )
       
   381         {
       
   382         __ALFLOGSTRING1( "CAlfGridLayout::LayoutModeFlags ignore error %d", err )
       
   383         }
       
   384         
       
   385    return flags;
       
   386 }
       
   387     
       
   388 // ---------------------------------------------------------------------------
       
   389 // Clear Layout Mode Flags
       
   390 // ---------------------------------------------------------------------------
       
   391 // 
       
   392 
       
   393 EXPORT_C void CAlfGridLayout::ClearLayoutModeFlags(TAlfGridDimension aDim, TUint aGridLayoutModeFlags)
       
   394 {    
       
   395     TInt2 params( aDim, aGridLayoutModeFlags );
       
   396     TPckg<TInt2> paramsPckg(params);
       
   397     TBuf8<1> resBuf;    
       
   398     
       
   399     TInt err = Comms()->DoSynchronousCmd(EAlfGridLayoutClearLayoutModeFlags, paramsPckg, resBuf);
       
   400     
       
   401     if ( err )
       
   402         {
       
   403         __ALFLOGSTRING1( "CAlfGridLayout::ClearLayoutModeFlags ignore error %d", err )
       
   404         }  
       
   405 }
       
   406     
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // Place holder from CAlfVisual
       
   410 // ---------------------------------------------------------------------------
       
   411 //     
       
   412 EXPORT_C void CAlfGridLayout::RemoveAndDestroyAllD()
       
   413     {
       
   414     CAlfLayout::RemoveAndDestroyAllD();
       
   415     }
       
   416   
       
   417 // ---------------------------------------------------------------------------
       
   418 // Place holder from CAlfVisual
       
   419 // ---------------------------------------------------------------------------
       
   420 //  
       
   421 EXPORT_C void CAlfGridLayout::UpdateChildrenLayout(TInt aTransitionTime )
       
   422     {
       
   423     CAlfLayout::UpdateChildrenLayout( aTransitionTime );
       
   424     }
       
   425   
       
   426 // ---------------------------------------------------------------------------
       
   427 // Place holder from CAlfVisual
       
   428 // ---------------------------------------------------------------------------
       
   429 //  
       
   430 EXPORT_C CAlfVisual* CAlfGridLayout::FindTag(const TDesC8& aTag)
       
   431     {
       
   432     return CAlfLayout::FindTag( aTag );
       
   433     }
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // Place holder from CAlfVisual
       
   437 // ---------------------------------------------------------------------------
       
   438 //  
       
   439 EXPORT_C void CAlfGridLayout::DoRemoveAndDestroyAllD()
       
   440     {
       
   441     CAlfLayout::DoRemoveAndDestroyAllD();
       
   442     }
       
   443     
       
   444 // ---------------------------------------------------------------------------
       
   445 // Place holder from CAlfLayout
       
   446 // ---------------------------------------------------------------------------
       
   447 //  
       
   448 EXPORT_C TAlfXYMetric CAlfGridLayout::BaseUnit() const
       
   449     {
       
   450     return CAlfLayout::BaseUnit();
       
   451     }
       
   452 
       
   453 // ---------------------------------------------------------------------------
       
   454 //  future proofing  
       
   455 // ---------------------------------------------------------------------------
       
   456 //  
       
   457 EXPORT_C void CAlfGridLayout::PropertyOwnerExtension(const TUid& aExtensionUid, TAny** aExtensionParams)
       
   458     {
       
   459     CAlfLayout::PropertyOwnerExtension(aExtensionUid,aExtensionParams);
       
   460     }
       
   461