00001
00002
00003
00004
00012 #include "ContrastDLG.h"
00013
00014
00015 #ifdef _DEBUG
00016 #define new DEBUG_NEW
00017 #undef THIS_FILE
00018 static char THIS_FILE[] = __FILE__;
00019 #endif
00020
00021
00022 using namespace jbxl;
00023 using namespace jbxwl;
00024
00025
00027
00028
00029 CContrastDLG::CContrastDLG(CExView* pview, BOOL rndr, CWnd* pParent )
00030 : CDialog(CContrastDLG::IDD, pParent)
00031 {
00032
00033
00034
00035
00036 pView = pview;
00037 render = rndr;
00038
00039 oMin = cMin = pView->cMin;
00040 oMax = cMax = pView->cMax;
00041 vMin = pView->vMin;
00042 vMax = pView->vMax;
00043 base = pView->pDoc->base + TempBase;
00044 }
00045
00046
00047 void CContrastDLG::DoDataExchange(CDataExchange* pDX)
00048 {
00049 CDialog::DoDataExchange(pDX);
00050
00051
00052
00053 }
00054
00055
00056
00057 BEGIN_MESSAGE_MAP(CContrastDLG, CDialog)
00058
00059 ON_EN_CHANGE(IDC_CNT_CNTMIN, OnChangeCntCntMin)
00060 ON_EN_CHANGE(IDC_CNT_CNTMAX, OnChangeCntCntMax)
00061 ON_WM_HSCROLL()
00062
00063 END_MESSAGE_MAP()
00064
00065
00066
00068
00069
00070 BOOL CContrastDLG::OnInitDialog()
00071 {
00072 TCHAR buf[LNAME];
00073
00074 cMinEBox = (CEdit*)GetDlgItem(IDC_CNT_CNTMIN);
00075 cMaxEBox = (CEdit*)GetDlgItem(IDC_CNT_CNTMAX);
00076 cMinSldr = (CSliderCtrl*)GetDlgItem(IDC_CNT_SLIDER_CNTMIN);
00077 cMaxSldr = (CSliderCtrl*)GetDlgItem(IDC_CNT_SLIDER_CNTMAX);
00078
00079 cMinSldr->SetRange(vMin-base, vMax-base);
00080 cMaxSldr->SetRange(vMin-base, vMax-base);
00081 if (cMin-base==0) cMinSldr->SetPos(1);
00082 if (cMax-base==0) cMaxSldr->SetPos(1);
00083 cMinSldr->SetPos(cMin-base);
00084 cMaxSldr->SetPos(cMax-base);
00085
00086 sntprintf(buf, LNAME, _T("%d"), oMin-base);
00087 cMinEBox->SetWindowText(buf);
00088
00089 sntprintf(buf, LNAME, _T("%d"), oMax-base);
00090 cMaxEBox->SetWindowText(buf);
00091
00092 return TRUE;
00093 }
00094
00095
00096
00097 void CContrastDLG::OnChangeCntCntMin()
00098 {
00099 TCHAR buf[LNAME];
00100
00101 cMinEBox->GetWindowText(buf, LNAME);
00102 cMin = ttoi(buf) + base;
00103
00104
00105
00106
00107
00108 if (cMin<vMin || cMin>vMax) {
00109 if (cMin<vMin) cMin = vMin;
00110 if (cMin>vMax) cMin = vMax;
00111 if (cMin==cMax) cMin = cMax - 1;
00112 sntprintf(buf, LNAME, _T("%d"), cMin-base);
00113 cMinEBox->SetWindowText(buf);
00114 cMinEBox->UpdateWindow();
00115 }
00116
00117 cMinSldr->SetPos(cMin-base);
00118 pView->cMin = cMin;
00119
00120 if (render) {
00121 pView->prevSBpos = -1;
00122 pView->SetNewSurface(0);
00123 pView->ExecRender();
00124 }
00125 }
00126
00127
00128
00129 void CContrastDLG::OnChangeCntCntMax()
00130 {
00131 TCHAR buf[LNAME];
00132
00133 cMaxEBox->GetWindowText(buf, LNAME);
00134 cMax = ttoi(buf) + base;
00135
00136
00137
00138
00139
00140 if (cMax<vMin || cMax>vMax) {
00141 if (cMax>vMax) cMax = vMax;
00142 if (cMax<vMin) cMax = vMin;
00143 if (cMax==cMin) cMax = cMin + 1;
00144 sntprintf(buf, LNAME, _T("%d"), cMax-base);
00145 cMaxEBox->SetWindowText(buf);
00146 cMaxEBox->UpdateWindow();
00147 }
00148
00149 cMaxSldr->SetPos(cMax-base);
00150 pView->cMax = cMax;
00151
00152 if (render) {
00153 pView->prevSBpos = -1;
00154 pView->SetNewSurface(0);
00155 pView->ExecRender();
00156 }
00157 }
00158
00159
00160
00161 void CContrastDLG::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
00162 {
00163 TCHAR buf[LNAME];
00164
00165 if (cMaxSldr==(CSliderCtrl*)pScrollBar) {
00166 cMax= cMaxSldr->GetPos() + base;
00167 pView->cMax = cMax;
00168 sntprintf(buf, LNAME, _T("%d"), cMax-base);
00169 cMaxEBox->SetWindowText(buf);
00170 cMaxEBox->UpdateWindow();
00171 }
00172 else {
00173 cMin = cMinSldr->GetPos() + base;
00174 pView->cMin = cMin;
00175 sntprintf(buf, LNAME, _T("%d"), cMin-base);
00176 cMinEBox->SetWindowText(buf);
00177 cMinEBox->UpdateWindow();
00178 }
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 }
00189
00190
00191
00192 void CContrastDLG::OnOK()
00193 {
00194
00195 CDialog::OnOK();
00196
00197 if (render) {
00198 pView->prevSBpos = -1;
00199 pView->SetNewSurface(0);
00200 pView->ExecRender();
00201 }
00202 }
00203
00204
00205
00206 void CContrastDLG::OnCancel()
00207 {
00208 CDialog::OnCancel();
00209
00210 pView->cMax = oMax;
00211 pView->cMin = oMin;
00212
00213 if (render) {
00214 pView->prevSBpos = -1;
00215 pView->SetNewSurface(0);
00216 pView->ExecRender();
00217 }
00218 }
00219