Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

RmMFCNumericEdit.h

00001 //=================================================================================================//
00002 // filename: RmMFCNumericEdit.h                                                                    //
00003 //                                                                                                 //
00004 //           ATI Research, Inc.                                                                    //
00005 //           3D Application Research Group                                                         //
00006 //                                                                                                 //
00007 // description: Declaration for a generic class for a numeric edit box with input error checking   //
00008 //                                                                                                 //
00009 //=================================================================================================//
00010 //   (C) 2004 ATI Research, Inc.  All rights reserved.                                             //
00011 //=================================================================================================//
00012 
00013 #ifndef _RM_MFC_UTILITIES_NUMERIC_EDIT_H_
00014 #define _RM_MFC_UTILITIES_NUMERIC_EDIT_H_
00015 
00016 #include <MFCUtilities/RmMFCTypes.h>
00017 
00018 // These constants are used to set the ranges for sliders (integer and float)
00019 #define MIN_INT        -32767
00020 #define MAX_INT         32767
00021 #define FLT_DEFAULT_MIN 1.175494351e-38f
00022 #define FLT_DEFAULT_MAX 3.402823466e+38f
00023 
00024 // Default precision for displaying the number in the numeric edit field
00025 #define CTRL_DEFAULT_PRECISION 5
00026 
00027 //=========================================================================//
00028 // A class designed to create an edit field specialized for numeric input. //
00029 // Should be used to override standard MFC edit control.                   //
00030 //=========================================================================//
00031 class RMMFCUTIL_API CRmNumericEdit: public CEdit
00032 {
00033 
00034 public:
00035 
00036    // Default Constructor:
00037         CRmNumericEdit();       
00038    virtual ~CRmNumericEdit() {};
00039 
00040    // Initialized this control with a given input value, nPrecision indicates how many digits
00041    // this edit box will display after the decimal point, bSigned controls whether
00042    // we allow signed values:
00043         virtual void Init( float fValue = 0.00, int nPrecision = 2, bool bSigned = true );
00044    
00045    void SetData( float fValue, int nPrecision, bool bSigned );
00046 
00047         float GetNumericValue();
00048         void  SetNumericValue( float fValue );
00049 
00050    // Updates the text in the control:
00051         void UpdateText();
00052 
00053    // Retrieve the text from the edit control and update the value being modified:
00054    void UpdateValue();
00055 
00056    void SetScientificDisplay( bool bSciDisplay )
00057    {
00058       m_bSciFormat = bSciDisplay;
00059    }
00060 
00061    void SetNumericDisplayType( bool bInteger )
00062    {
00063       m_bInteger = bInteger;
00064    }
00065    
00066 protected:
00067 
00068         afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00069         afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00070         afx_msg void OnSetFocus();
00071         //afx_msg void OnKillFocus();   
00072    afx_msg void OnKillFocus(CWnd* pNewWnd);
00073 
00074         DECLARE_MESSAGE_MAP()
00075 
00076 protected:
00077 
00078    // Check that the input character is valid (i.e. numeric)
00079         bool IsValidChar( UINT nChar );
00080 
00081    // Conversion methods:
00082         float   TextToNumber( const RM_TCHAR *strText );
00083         RmStringT NumberToText( float fValue );
00084 
00085 //----Class data members:
00086 protected:
00087         
00088         float    m_fValue;         // Numeric value modified by the numeric edit field
00089         int              m_nPrecision;     // Number of digits displayed after the decimal point
00090         bool        m_bSigned;        // Allow negative values? 
00091         RmStringT m_strText;        // Text displayed in the edit box
00092 
00093    bool      m_bSciFormat;     // A flag to display the number in scientific format or not
00094    bool      m_bInteger;       // A flag to indicate the window display text type
00095 
00096 };
00097 
00098 
00099 #endif 

Generated on Fri Feb 25 16:08:38 2005 for RenderMonkey SDK by doxygen 1.3.6