aknquerydata.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name     : AknQueryData.h
00004 *  Part of  : Avkon
00005 *
00006 *  Description:
00007 *   Implementation of Query data classes for query dialogs
00008 *  Version:
00009 *
00010 *  Copyright © 2002 Nokia Corporation.
00011 *  This material, including documentation and any related 
00012 *  computer programs, is protected by copyright controlled by 
00013 *  Nokia Corporation. All rights are reserved. Copying, 
00014 *  including reproducing, storing,  adapting or translating, any 
00015 *  or all of this material requires the prior written consent of 
00016 *  Nokia Corporation. This material also contains confidential 
00017 *  information which may not be disclosed to others without the 
00018 *  prior written consent of Nokia Corporation.
00019 * ============================================================================
00020 */
00021 
00022 #ifndef AKNQUERYDATA_H
00023 #define AKNQUERYDATA_H
00024 
00025 #include <e32std.h>
00026 #include <aknquerycontrol.h>
00027 #include <in_sock.h>
00028 #include <lbsposition.h>
00029 
00030 class CAknQueryDialog;
00031 class TInetAddr;
00032 
00033 
00034 IMPORT_C TInt GetMaxTextLength(const CAknQueryControl* aControl, const TDes& aDataText, TInt aApiValue);
00035 
00036 class MAknQueryData
00037     {
00038     public:
00039         virtual void SetL(CAknQueryControl* aControl, TInt aMaxLength) = 0;
00040         virtual void Get(CAknQueryControl* aControl) = 0;
00041     };
00042 
00043 template<class T>
00044 class TAknQueryData : public MAknQueryData
00045     {
00046     public:
00047         TAknQueryData(T& aData) : iData(aData) {}
00048 
00049         void SetL(CAknQueryControl* aControl, TInt aMaxLength);
00050         void Get(CAknQueryControl* aControl);
00051 
00052     public:
00053         T& iData;
00054     };
00055 
00056 template<>
00057 class TAknQueryData<TDes> : public MAknQueryData
00058     {
00059     public:
00060         TAknQueryData(TDes& aData) : iData(aData) {}
00061 
00062         void SetL(CAknQueryControl* aControl,TInt aMaxLength)
00063             { aControl->SetTextL(iData); 
00064               aControl->SetTextEntryLength(
00065                   GetMaxTextLength(aControl,iData,aMaxLength)); }
00066         void Get(CAknQueryControl* aControl) 
00067             { aControl->GetText(iData); }
00068     public:
00069         TDes& iData;
00070     };
00071 
00072 template<>
00073 class TAknQueryData<TInt> : public MAknQueryData
00074     {
00075     public:
00076         TAknQueryData(TInt& aData) : iData(aData) {}
00077 
00078         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
00079             { aControl->SetNumberL(iData); }
00080         void Get(CAknQueryControl* aControl) 
00081             { iData=aControl->GetNumber(); }
00082     public:
00083         TInt& iData;
00084     };
00085 
00086 template<>
00087 class TAknQueryData<TTime> : public MAknQueryData
00088     {
00089     public:
00090         TAknQueryData(TTime& aData) : iData(aData) {}
00091 
00092         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
00093             { aControl->SetTime(iData); }
00094         void Get(CAknQueryControl* aControl) 
00095             { iData=aControl->GetTime(); }
00096     public:
00097         TTime& iData;
00098     };
00099 
00100 template<>
00101 class TAknQueryData<TTimeIntervalSeconds> : public MAknQueryData
00102     {
00103     public:
00104         TAknQueryData(TTimeIntervalSeconds& aData) : iData(aData) {}
00105 
00106         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
00107             { aControl->SetDuration(iData); }
00108         void Get(CAknQueryControl* aControl) 
00109             { iData=aControl->GetDuration(); }
00110     public:
00111         TTimeIntervalSeconds& iData;
00112     };
00113 
00114 template<>
00115 class TAknQueryData<TReal> : public MAknQueryData
00116     {
00117     public:
00118         TAknQueryData(TReal& aData) : iData(aData) {}
00119 
00120         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
00121             { aControl->SetFloatingPointNumberL(&iData); }
00122         void Get(CAknQueryControl* aControl) 
00123             { iData=aControl->GetFloatingPointNumberL(); }
00124     public:
00125         TReal& iData;
00126     };
00127 
00128 
00129 template<>  
00130 class TAknQueryData<TInetAddr> : public MAknQueryData
00131     {
00132     public:
00133         TAknQueryData(TInetAddr& aData) : iData(aData) {}
00134         void SetL(CAknQueryControl* aControl,TInt /*aMaxLength*/)
00135             {
00136                 CAknExtQueryControl* control = STATIC_CAST(CAknExtQueryControl*,aControl);
00137                 control->SetInetAddress(iData);
00138             }
00139         void Get(CAknQueryControl* aControl) 
00140             {
00141                 CAknExtQueryControl* control = STATIC_CAST(CAknExtQueryControl*,aControl);
00142                 iData=control->GetInetAddress();
00143             }
00144 
00145     public:
00146         TInetAddr& iData;
00147     };
00148 template<>    
00149 class TAknQueryData<TPosition> : public MAknQueryData
00150         {
00151 public:
00152         TAknQueryData(TPosition &aData) : iData(aData) {}
00153         void SetL(CAknQueryControl* aControl, TInt /*aMaxLength*/)
00154                 {
00155                 aControl->SetLocation(iData);
00156                 }
00157         void Get(CAknQueryControl* aControl)
00158                 {
00159                 aControl->GetLocation(iData);
00160                 }
00161 private:
00162         TPosition& iData;
00163         };
00164 
00165 #endif

Copyright © Nokia Corporation 2001-2008
Back to top