testexecfw/statsrv/device/source/statapi/inc/stat_window.h
changeset 0 3e07fef1e154
equal deleted inserted replaced
-1:000000000000 0:3e07fef1e154
       
     1 /*
       
     2 * Copyright (c) 2005-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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 /*************************************************************************
       
    21  *
       
    22  * Switches
       
    23  *
       
    24  ************************************************************************/
       
    25 #ifndef __STATUI_H__
       
    26 #define __STATUI_H__
       
    27 
       
    28 /*************************************************************************
       
    29  *
       
    30  * System Includes
       
    31  *
       
    32  ************************************************************************/
       
    33 #include <eikenv.h>
       
    34 #include <eikappui.h>
       
    35 #include <eikproc.h>
       
    36 #include <eikdialg.h>
       
    37 #include <eikmenub.h>
       
    38 #include <eikapp.h>
       
    39 #include <eikdoc.h>
       
    40 #include <eikedwin.h>
       
    41 #include <coeutils.h>
       
    42 #include <barsread.h>
       
    43 #include <eikfctry.h>
       
    44 #include <eiklabel.h>
       
    45 
       
    46 /*************************************************************************
       
    47  *
       
    48  * Local Includes
       
    49  *
       
    50  ************************************************************************/
       
    51 #include "stat_interfaces.h"
       
    52 #include "activeconnection.h"
       
    53 
       
    54 /*************************************************************************
       
    55  *
       
    56  * Definitions
       
    57  *
       
    58  ************************************************************************/
       
    59 
       
    60 // Control ID Constants
       
    61 #define KStatusLabel			0
       
    62 #define KErrorLabel				1
       
    63 #define KVersionLabel			2
       
    64 #define KTransportLabel			3
       
    65 #define KAddressLabel			4
       
    66 #define KTransportEdit			5
       
    67 #define KAddressEdit			6
       
    68 #define KActionButton			7
       
    69 #define KExitButton				8
       
    70 #define KInfoLabel				9
       
    71 #define KLogButton				10
       
    72 #define KControlCount			11
       
    73 
       
    74 #define		KMaxChoiceItemSize			16
       
    75 #define		KMaxChoiceItems				8
       
    76 
       
    77 /*************************************************************************
       
    78  *
       
    79  * CStatChoice - Multi-choice box. This control is based on a read-only 
       
    80  * CEikEdwin. It is initialised with a set of strings. Users can cycle
       
    81  * through the option either by tapping on the control or using the 
       
    82  * left-right keys.
       
    83  *
       
    84  ************************************************************************/
       
    85 class CStatChoice : public CEikEdwin
       
    86 {
       
    87 public:
       
    88 	// Clean up
       
    89 	~CStatChoice();
       
    90 
       
    91 	// User interface to get and set items
       
    92 	TInt AddItemL( TDesC &aItemStr );
       
    93 	TDesC *CurrentItemStr();
       
    94 	void SetCurrentItem( TInt aIndex );
       
    95 	TInt CurrentItem();
       
    96 	void ClearAllItems();
       
    97 
       
    98 	// Handle User Input
       
    99 	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   100 	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   101 	void SetNextItem();
       
   102 	void SetPrevItem();
       
   103 
       
   104 private:
       
   105 	// Attributes
       
   106 	TInt iItemCount, iCurrentItem;
       
   107 	TBuf<KMaxChoiceItemSize> *iChoiceItems[KMaxChoiceItems];
       
   108 };
       
   109 
       
   110 /*************************************************************************
       
   111  *
       
   112  * CStatWindow - STAT GUI. Single window.
       
   113  *
       
   114  ************************************************************************/
       
   115 class CStatWindow : public CCoeControl, public MCoeControlObserver, public MNotifyUI
       
   116 {
       
   117 public:
       
   118 	// Constructors
       
   119 	CStatWindow *NewL( const TRect& rect, MStatController *aStatController );
       
   120 	CStatWindow();
       
   121 	~CStatWindow();
       
   122 	void ConstructL( const TRect& rect, MStatController *aStatController );
       
   123 
       
   124 	// Public Interface
       
   125 	void SetForeground( TBool aIsForeground );
       
   126 	TCommStatus GetCommStatus();
       
   127 
       
   128 	// Handle User Input
       
   129 	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   130 	void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
       
   131 	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   132 
       
   133 	// From MNotifyUI
       
   134 	void HandleStatusChange( TInt aSessionId, TCommStatus aNewStatus );
       
   135 	void HandleError( TInt aError, void *);//aErrorData);
       
   136 	void HandleInfo( const TDesC *aInfo );
       
   137 
       
   138 protected:
       
   139 	/*********************************************************************
       
   140 	 *
       
   141 	 * CStatIniData - Data structure used to write to and read from a user
       
   142 	 * preference file that stores interface options between sessions.
       
   143 	 *
       
   144 	 *********************************************************************/
       
   145 	class CStatIniData : public CBase
       
   146 	{
       
   147 	public:
       
   148 		CStatIniData(void);
       
   149 		~CStatIniData();
       
   150 
       
   151 	public:
       
   152 		TBool WriteIniData(const TDesC& aName) const;
       
   153 		TBool ReadIniData(const TDesC& aName);
       
   154 
       
   155 	public:
       
   156 		TStatConnectType iConnectType;
       
   157 		TInt iAddress;
       
   158 		TBool iIsRunning;
       
   159 		TBool iConnectAutomatically;
       
   160 
       
   161 	private:
       
   162 		HBufC* GetFileContents(const TDesC& aName) const;
       
   163 	};
       
   164 
       
   165 private:
       
   166 	// From CCoeControl
       
   167 	TInt CountComponentControls() const;
       
   168 	CCoeControl* ComponentControl( TInt aIndex ) const;
       
   169 	void Draw(const TRect& aRect) const;
       
   170 
       
   171 	// Helper Functions
       
   172 	TRect GetControlPosition( TInt aIndex ) const;
       
   173 	TInt PositionInRange( TPoint aPosition, TRect aArea ) const;
       
   174 	TInt GetControlFromPoint( TPoint aPosition ) const;
       
   175 	void OnTransportChange();
       
   176 	void HandleActionL( void );
       
   177 	void ClearControlPanel() const;
       
   178 	void DrawEditBorders() const; 
       
   179 	void	SetVersionLabelL();
       
   180 private:
       
   181 	// Controls
       
   182 	CEikCommandButton *iActionButton, *iExitButton, *iLogButton;
       
   183 	CEikLabel *iStatusLabel, *iErrorLabel, *iInfoLabel, *iVersionLabel;
       
   184 	CEikLabel *iTransportLabel, *iAddressLabel;
       
   185 	CStatChoice *iTransportEdit, *iAddressEdit;
       
   186 
       
   187 	// Attributes
       
   188 	TInt iLoggingEnabled;
       
   189 	TBool bIsForeground;
       
   190 	TCommStatus iStatStatus;
       
   191 	MStatController *iStatController;
       
   192 	mutable TInt iClearLabelsOnly;	// Ensure this is mutable and so can
       
   193 									// be updated from within the 'const'
       
   194 									// declared 'Draw' mehod.
       
   195 
       
   196 	CActiveConnection *iAOConnection;	// Active object whose
       
   197 										// only task is to open
       
   198 										// a TCP socket to initialise
       
   199 										// the socket server.
       
   200 
       
   201 	// Ini data that we retain for the lifetime of the window.
       
   202 	CStatIniData *iIniData;
       
   203 };
       
   204 
       
   205 #endif //__STATUI_H__