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

RmMFCPopupSlider.h

00001 //=================================================================================================//
00002 // filename:  RmMFCPopupSlider.h                                                                   //
00003 //                                                                                                 //
00004 //           ATI Research, Inc.                                                                    //
00005 //           3D Application Research Group                                                         //
00006 //                                                                                                 //
00007 // Description: declaration file for a popup slider which can be attached to a numeric edit        //
00008 //              control and modifies the value displayed in the control                            //
00009 //=================================================================================================//
00010 //   (C) 2004 ATI Research, Inc.  All rights reserved.                                             //
00011 //=================================================================================================//
00012 
00013 #ifndef _RM_MFC_UTILITIES_POPUP_SLIDER_H_
00014 #define _RM_MFC_UTILITIES_POPUP_SLIDER_H_
00015 
00016 #include <MFCUtilities/RmMFCTypes.h>
00017 
00018 // Message definition for slider events
00019 #define MSG_SLIDER_UPDATE        WM_USER + 1201           // When the slider's position has changed
00020 #define MSG_SLIDER_CLOSED        WM_USER + 1202           // When the slider's been closed
00021 #define MSG_SLIDER_RANGE_CHANGED WM_USER + 1203           // When the slider range was modifying
00022 
00023 class RMMFCUTIL_API CPopupSlider: public CWnd
00024 {
00025    
00026 public:
00027 
00028    // Create a slider that will be placed at a given point p, has an initial value of fValue,
00029    // and operates in the range of [ fMin, fMax ]. pParentWnd is the window that will 
00030    // receive the messages (CSP_DELTAPOS & CPS_CLOSEUP) when the slider value changes and
00031    // when the slider closes. 
00032    CPopupSlider( CPoint p, float fValue, float fMin, float fMax, bool bClamp, CWnd* pParentWnd, bool bDynamicRange = true  );
00033 
00034    BOOL Create( CPoint p, CWnd* pParentWnd );
00035    
00036    // Kill this slider:
00037    void EndPopupSlider( int nMessage = MSG_SLIDER_CLOSED );
00038 
00039    // Retrieves the value from the slider:
00040    float GetSliderValue()
00041    {
00042       return m_fValue;
00043    }
00044 
00045    // Retrieves the range from the slider:
00046    void GetSliderRange( float* pfMin, float* pfMax )
00047    {
00048       (*pfMin) = m_fMin;
00049       (*pfMax) = m_fMax;
00050    }
00051 
00052    
00053 protected:
00054 
00055    // Computes the slider indicator position based on the slider value:
00056    void ComputeSliderPosition();
00057 
00058 
00059    // Draw the slider and its indicator in the window:
00060    void DrawSlider();
00061 
00062    // Update slider position and repaint the window:
00063    void UpdateSliderWindow();
00064 
00065    // This method processes mouse move events when the right mouse button is in the UP state. In that  
00066    // case the mouse moving changes the value this popup slider is modifying:                         
00067    void UpdateSliderValue( CPoint mousePt );
00068   
00069    // This method processes mouse move events when the right mouse button is pressed DOWN and this     
00070    // popup slider doesn't have the range clamped down. In that case this method will shrink or expand 
00071    // the range based on the mouse moving up or down relative to the slider position on the screen:    
00072    void UpdateSliderRange( CPoint mousePt );
00073 
00074    
00075    
00076 protected://.................MFC Generated message map functions
00077    
00078    afx_msg BOOL OnEraseBackground( CDC* pDC );
00079    afx_msg void OnNcDestroy();
00080    afx_msg void OnPaint();
00081    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00082    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
00083    afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
00084    afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00085    afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00086    afx_msg void OnKillFocus(CWnd* pNewWnd);
00087    afx_msg BOOL OnMouseWheel( UINT nFlags, short zDelta, CPoint pt );
00088    afx_msg void OnCaptureChanged(CWnd *pWnd);
00089    
00090    // This is defined here to suppord MFC for Visual Studio 7.0 and 6.0:
00091 #if _MFC_VER < 0x0700
00092    afx_msg void OnActivateApp(BOOL bActive, HTASK hTask);
00093 #else
00094    afx_msg void OnActivateApp(BOOL bActive, DWORD hTask);
00095 #endif
00096    
00097    
00098    DECLARE_MESSAGE_MAP()
00099 
00100 private:
00101    CPopupSlider() {};         // Shouldn't create a slider w/ the default constructor
00102       
00103 private://....................Member variables
00104    
00105    CWnd* m_pParent;           // The parent window
00106    
00107    bool m_bClosingSlider;     // Closing slider flag
00108    
00109    float m_fSliderPosition;   // The position of the slider indicator
00110    
00111    float m_fValue;            // The value that this slider was modifying
00112 
00113    float m_fMin;              // The range for the variable this slider is modifying
00114    float m_fMax;
00115    bool  m_bClamp;
00116 
00117    HCURSOR m_mouseCursor;     
00118    
00119    bool  m_bDynamicRange;     // Is the range allowed to be modified on the fly, or should it be static
00120    bool  m_bRButtonDown;      // Was the right mouse button pressed down?
00121 
00122    float m_fStepSize;         // The step size for modifying the range of the popup slider when allowed
00123 
00124    int m_nOldPosition;        // Stores the previous position of the mouse cursor
00125    CPoint m_oldPoint;         // Stores the previous position of the mouse cursor
00126 
00127    
00128 };
00129 
00130 #endif 

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