epoc32/include/mw/aknquerydata.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2 * Copyright (c) 2002 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: 
    15 *   Implementation of Query data classes for query dialogs
    16 *
    17 */
    18 
    19 
    20 #ifndef AKNQUERYDATA_H
    21 #define AKNQUERYDATA_H
    22 
    23 #include <e32std.h>
    24 #include <aknQueryControl.h>
    25 #include <in_sock.h>
    26 #include <lbsposition.h>
    27 
    28 class CAknQueryDialog;
    29 class TInetAddr;
    30 
    31 
    32 IMPORT_C TInt GetMaxTextLength(const CAknQueryControl* aControl, const TDes& aDataText, TInt aApiValue);
    33 
    34 class MAknQueryData
    35     {
    36     public:
    37         virtual void SetL(CAknQueryControl* aControl, TInt aMaxLength) = 0;
    38         virtual void Get(CAknQueryControl* aControl) = 0;
    39     };
    40 
    41 template<class T>
    42 class TAknQueryData : public MAknQueryData
    43     {
    44     public:
    45         TAknQueryData(T& aData) : iData(aData) {}
    46 
    47         void SetL(CAknQueryControl* aControl, TInt aMaxLength);
    48         void Get(CAknQueryControl* aControl);
    49 
    50     public:
    51         T& iData;
    52     };
    53 
    54 template<>
    55 class TAknQueryData<TDes> : public MAknQueryData
    56     {
    57     public:
    58         TAknQueryData(TDes& aData) : iData(aData) {}
    59 
    60         void SetL(CAknQueryControl* aControl,TInt aMaxLength)
    61             { aControl->SetTextL(iData); 
    62               aControl->SetTextEntryLength(
    63                   GetMaxTextLength(aControl,iData,aMaxLength)); }
    64         void Get(CAknQueryControl* aControl) 
    65             { aControl->GetText(iData); }
    66     public:
    67         TDes& iData;
    68     };
    69 
    70 template<>
    71 class TAknQueryData<TInt> : public MAknQueryData
    72     {
    73     public:
    74         TAknQueryData(TInt& aData) : iData(aData) {}
    75 
    76         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
    77             { aControl->SetNumberL(iData); }
    78         void Get(CAknQueryControl* aControl) 
    79             { iData=aControl->GetNumber(); }
    80     public:
    81         TInt& iData;
    82     };
    83 
    84 template<>
    85 class TAknQueryData<TTime> : public MAknQueryData
    86     {
    87     public:
    88         TAknQueryData(TTime& aData) : iData(aData) {}
    89 
    90         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
    91             { aControl->SetTime(iData); }
    92         void Get(CAknQueryControl* aControl) 
    93             { iData=aControl->GetTime(); }
    94     public:
    95         TTime& iData;
    96     };
    97 
    98 template<>
    99 class TAknQueryData<TTimeIntervalSeconds> : public MAknQueryData
   100     {
   101     public:
   102         TAknQueryData(TTimeIntervalSeconds& aData) : iData(aData) {}
   103 
   104         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
   105             { aControl->SetDuration(iData); }
   106         void Get(CAknQueryControl* aControl) 
   107             { iData=aControl->GetDuration(); }
   108     public:
   109         TTimeIntervalSeconds& iData;
   110     };
   111 
   112 template<>
   113 class TAknQueryData<TReal> : public MAknQueryData
   114     {
   115     public:
   116         TAknQueryData(TReal& aData) : iData(aData) {}
   117 
   118         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
   119             { aControl->SetFloatingPointNumberL(&iData); }
   120         void Get(CAknQueryControl* aControl) 
   121             { iData=aControl->GetFloatingPointNumberL(); }
   122     public:
   123         TReal& iData;
   124     };
   125 
   126 
   127 template<>  
   128 class TAknQueryData<TInetAddr> : public MAknQueryData
   129     {
   130     public:
   131         TAknQueryData(TInetAddr& aData) : iData(aData) {}
   132         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
   133             {
   134                 CAknExtQueryControl* control = STATIC_CAST(CAknExtQueryControl*,aControl);
   135                 control->SetInetAddress(iData);
   136             }
   137         void Get(CAknQueryControl* aControl) 
   138             {
   139                 CAknExtQueryControl* control = STATIC_CAST(CAknExtQueryControl*,aControl);
   140                 iData=control->GetInetAddress();
   141             }
   142 
   143     public:
   144         TInetAddr& iData;
   145     };
   146 template<>    
   147 class TAknQueryData<TPosition> : public MAknQueryData
   148 	{
   149 public:
   150 	TAknQueryData(TPosition &aData) : iData(aData) {}
   151 	void SetL(CAknQueryControl* aControl, TInt /*aMaxLength*/)
   152 		{
   153 		aControl->SetLocation(iData);
   154 		}
   155 	void Get(CAknQueryControl* aControl)
   156 		{
   157 		aControl->GetLocation(iData);
   158 		}
   159 private:
   160 	TPosition& iData;
   161 	};
   162 
   163 #endif