00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef _RM_MFC_UTILITIES_VARIABLE_EDIT_CTRL_H_
00014 #define _RM_MFC_UTILITIES_VARIABLE_EDIT_CTRL_H_
00015
00016 #if _MSC_VER > 1000
00017 #pragma once
00018 #endif // _MSC_VER > 1000
00019
00020
00021
00022 #include <Utilities/RmUtilControlPlacement.h>
00023 #include <MFCUtilities/RmMFCTypes.h>
00024 #include <MFCUtilities/RmMFCNumericEdit.h>
00025 #include <MFCUtilities/RmMFCSliderEdit.h>
00026 #include <MFCUtilities/RmMFCUtilitiesResource.h>
00027 #include <MFCUtilities/RmMFCUtilitiesResource.h>
00028 #include <MFCUtilities/RmMFCScrollWnd.h>
00029
00030 #define RM_INCLUDE_SCROLLING_VALUE_CONTROL_WINDOW 0
00031
00032
00033
00034
00035
00036
00037
00038
00039 class RMMFCUTIL_API CRmVariableEditCtrl : public CDialog
00040 {
00041 public:
00042
00043 enum SetupOrientationType
00044 {
00045 SetupOrientationTop,
00046 SetupOrientationRight,
00047 SetupOrientationBottom,
00048
00049 };
00050
00051 protected:
00052
00053
00054
00055
00056
00057
00058
00059
00060 class CRmSetupButton : public CButton
00061 {
00062 public:
00063
00064 CRmSetupButton()
00065 {
00066 m_bCheck = false;
00067
00068 }
00069
00070 virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
00071
00072 virtual bool GetCheck() { return( m_bCheck ); }
00073 virtual void SetCheck( bool bCheck ) { m_bCheck = bCheck; }
00074
00075 protected:
00076
00077 bool m_bCheck;
00078
00079 };
00080
00081 public:
00082
00083
00084 CRmVariableEditCtrl();
00085
00086 BOOL Create( HWND hwndParent,
00087 RmVariable *pVariable,
00088 bool bShowSetup = true,
00089 RmPlugInID *pRmPlugInID = NULL );
00090
00091 BOOL Create( HWND hwndParent,
00092 RmVariable *pVariable,
00093 SetupOrientationType setupOrientation,
00094 bool bShowSetup = true,
00095 RmPlugInID *pRmPlugInID = NULL );
00096
00097
00098 RmNode* GetEditNode() { return( m_pVariable ); }
00099
00100
00101
00102 void ShowSetup();
00103 void InitializeControls( bool bInitializeAll );
00104
00105 bool GetIsSetupShown() { return( m_bShowSetup ); }
00106 void SetIsSetupShown( bool bShowSetup ) { m_bShowSetup = bShowSetup; }
00107
00108 SetupOrientationType GetSetupOrientation() { return( m_setupOrientation ); }
00109 void SetSetupOrientation( SetupOrientationType setupOrientation ) { m_setupOrientation = setupOrientation; }
00110
00111 protected:
00112
00113
00114 virtual void DoDataExchange(CDataExchange* pDX);
00115 virtual BOOL OnInitDialog();
00116 virtual BOOL PreTranslateMessage(MSG* pMsg);
00117
00118
00119
00120 afx_msg void OnSize(UINT nType, int cx, int cy);
00121 afx_msg void OnValueControlChange( UINT uID );
00122 afx_msg void OnMinControlChange();
00123 afx_msg void OnMaxControlChange();
00124 afx_msg void OnBnClickedShowSetupCheck();
00125 afx_msg void OnBnClickedClampCheck();
00126 afx_msg void OnDestroy();
00127 afx_msg void OnEnKillfocusRowsEdit();
00128 afx_msg void OnEnKillfocusColumnsEdit();
00129 afx_msg void OnDeltaposRowsSpin(NMHDR *pNMHDR, LRESULT *pResult);
00130 afx_msg void OnDeltaposColumnsSpin(NMHDR *pNMHDR, LRESULT *pResult);
00131 afx_msg void OnBnClickedActionButton();
00132 afx_msg LRESULT OnValueSliderControlUpdated( WPARAM wParam, LPARAM lParam );
00133 afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
00134
00135
00136 DECLARE_MESSAGE_MAP()
00137
00138 private:
00139
00140
00141 void SendChangeMessage( int nMessage );
00142
00143
00144 void ShowValues();
00145
00146
00147 void DeleteValueControls();
00148 void RepositionValueControls( CRect *pValueControlActualBoundingRect,
00149 CRect *pValueControlMinBoundingRect );
00150
00151 void CalculateIdealDlgRect( CRect *pValueControlBoundingRect,
00152 CRect *pIdealDlgRect );
00153
00154
00155 void RepositionDialogControls();
00156
00157
00158 int FloatToInt( float fValue )
00159 {
00160 return( ( fValue >= 0.0f ) ? ( int )( fValue + 0.5f ) : ( int )( fValue - 0.5f ) );
00161
00162 }
00163
00164
00165
00166
00167
00168
00169
00170 RmDynamicVariable::DynamicVariableType GetDynamicVariableType();
00171
00172
00173 void SetIsNormalized( bool bIsNormalized );
00174 bool IsNormalized();
00175
00176
00177 int GetNumRows();
00178 int GetNumColumns();
00179 void SetNumRows( int nRows );
00180 void SetNumColumns( int nColumns );
00181 bool IsFixedSize();
00182
00183
00184 void SetIsClamped( bool bIsClamped );
00185 bool IsClamped();
00186
00187
00188 void SetFloatMinMax( float fMin, float fMax, bool bUpdateDatabase );
00189 void SetIntegerMinMax( int nMin, int nMax, bool bUpdateDatabase );
00190 void SetBooleanMinMax( BOOL bMin, BOOL bMax, bool bUpdateDatabase );
00191
00192 void GetFloatMinMax( float &fMin, float &fMax );
00193 void GetIntegerMinMax( int &nMin, int &nMax );
00194 void GetBooleanMinMax( BOOL &bMin, BOOL &bMax );
00195
00196
00197 void SetFloatData( int nRow, int nCol, float fData, bool bUpdateDatabase );
00198 void SetIntegerData( int nRow, int nCol, int nData, bool bUpdateDatabase );
00199 void SetBooleanData( int nRow, int nCol, BOOL bData, bool bUpdateDatabase );
00200
00201
00202 float GetFloatData( int nRow, int nCol );
00203 int GetIntegerData( int nRow, int nCol );
00204 BOOL GetBooleanData( int nRow, int nCol );
00205
00206 public:
00207
00208
00209 enum { IDD = IDD_RM_VARIABLE_EDIT_DIALOG };
00210 CRmSetupButton m_checkShowSetup;
00211 CButton m_checkClamp;
00212 CButton m_btnAction;
00213 CStatic m_staticSetupGroup;
00214 CStatic m_staticValuesGroup;
00215 CStatic m_staticRows;
00216 CStatic m_staticColumns;
00217 CStatic m_staticMinimum;
00218 CStatic m_staticMaximum;
00219 CEdit m_editRows;
00220 CEdit m_editColumns;
00221 CRmSliderEdit m_editMinimum;
00222 CRmSliderEdit m_editMaximum;
00223 CEdit m_editValueControlPlacement;
00224 CEdit m_editValueLabelPlacement;
00225 CStatic m_scrollWindowStatic;
00226 int m_nNumRows;
00227 int m_nNumColumns;
00228
00229
00230 protected:
00231
00232 bool m_bShowSetup;
00233 bool m_bAllowSetupOption;
00234 bool m_bValidClampType;
00235 bool m_bValidActionType;
00236
00237 private:
00238
00239 RmVariable *m_pVariable;
00240 RmPlugInID *m_pRmPlugInID;
00241
00242
00243
00244 SetupOrientationType m_setupOrientation;
00245
00246 bool m_bInitializingDialog;
00247
00248 int m_nShowSetupGroupHeight;
00249 int m_nShowSetupGroupWidth;
00250 int m_nHideSetupGroupHeight;
00251 int m_nHideSetupGroupWidth;
00252
00253 int m_nScrollWindowToGroupLeft;
00254 int m_nScrollWindowToGroupTop;
00255 int m_nScrollWindowToGroupRight;
00256 int m_nScrollWindowToGroupBottom;
00257
00258 CPoint m_firstValueControlOffset;
00259 CPoint m_firstValueLabelOffset;
00260 CPoint m_valueControlSize;
00261 CPoint m_valueLabelSize;
00262 int m_nLabelControlSeperation;
00263
00264 RmControlPlacementContainer m_setupControlPlacementContainer;
00265
00266
00267 int m_nNumAllocatedRows;
00268 int m_nNumAllocatedColumns;
00269 CWnd **m_pValueControlArray;
00270 CWnd **m_pValueLabelArray;
00271 CRect m_lastValueControlActualBoundingRect;
00272 CRect m_lastValueControlMinBoundingRect;
00273
00274 #if RM_INCLUDE_SCROLLING_VALUE_CONTROL_WINDOW
00275 CRmScrollWnd m_valueControlScrollWindow;
00276 #endif // RM_INCLUDE_SCROLLING_VALUE_CONTROL_WINDOW
00277
00278 CWnd m_scrollChildWindow;
00279
00280 CToolTipCtrl m_toolTipCtrl;
00281
00282 };
00283
00284
00285 #endif // _RM_MFC_UTILITIES_VARIABLE_EDIT_CTRL_H_