1 /* 2 * PROJECT: PAINT for ReactOS 3 * LICENSE: LGPL 4 * FILE: base/applications/mspaint/dialogs.cpp 5 * PURPOSE: Window procedures of the dialog windows plus launching functions 6 * PROGRAMMERS: Benedikt Freisen 7 */ 8 9 /* INCLUDES *********************************************************/ 10 11 #include "precomp.h" 12 13 #include "dialogs.h" 14 15 #include <winnls.h> 16 17 /* GLOBALS **********************************************************/ 18 19 CMirrorRotateDialog mirrorRotateDialog; 20 CAttributesDialog attributesDialog; 21 CStretchSkewDialog stretchSkewDialog; 22 23 /* FUNCTIONS ********************************************************/ 24 25 LRESULT CMirrorRotateDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 26 { 27 CheckDlgButton(IDD_MIRRORROTATERB1, BST_CHECKED); 28 CheckDlgButton(IDD_MIRRORROTATERB4, BST_CHECKED); 29 return 0; 30 } 31 32 LRESULT CMirrorRotateDialog::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 33 { 34 EndDialog(0); 35 return 0; 36 } 37 38 LRESULT CMirrorRotateDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 39 { 40 if (IsDlgButtonChecked(IDD_MIRRORROTATERB1)) 41 EndDialog(1); 42 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB2)) 43 EndDialog(2); 44 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB4)) 45 EndDialog(3); 46 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB5)) 47 EndDialog(4); 48 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB6)) 49 EndDialog(5); 50 return 0; 51 } 52 53 LRESULT CMirrorRotateDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 54 { 55 EndDialog(0); 56 return 0; 57 } 58 59 LRESULT CMirrorRotateDialog::OnRadioButton3(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 60 { 61 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB4), TRUE); 62 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB5), TRUE); 63 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB6), TRUE); 64 return 0; 65 } 66 67 LRESULT CMirrorRotateDialog::OnRadioButton12(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 68 { 69 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB4), FALSE); 70 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB5), FALSE); 71 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB6), FALSE); 72 return 0; 73 } 74 75 76 77 LRESULT CAttributesDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 78 { 79 newWidth = imageModel.GetWidth(); 80 newHeight = imageModel.GetHeight(); 81 82 CheckDlgButton(IDD_ATTRIBUTESRB3, BST_CHECKED); 83 CheckDlgButton(IDD_ATTRIBUTESRB5, BST_CHECKED); 84 SetDlgItemInt(IDD_ATTRIBUTESEDIT1, newWidth, FALSE); 85 SetDlgItemInt(IDD_ATTRIBUTESEDIT2, newHeight, FALSE); 86 87 if (isAFile) 88 { 89 TCHAR date[100]; 90 TCHAR temp[100]; 91 GetDateFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, date, SIZEOF(date)); 92 GetTimeFormat(LOCALE_USER_DEFAULT, 0, &fileTime, NULL, temp, SIZEOF(temp)); 93 _tcscat(date, _T(" ")); 94 _tcscat(date, temp); 95 CString strSize; 96 strSize.Format(IDS_FILESIZE, fileSize); 97 SetDlgItemText(IDD_ATTRIBUTESTEXT6, date); 98 SetDlgItemText(IDD_ATTRIBUTESTEXT7, strSize); 99 } 100 CString strRes; 101 strRes.Format(IDS_PRINTRES, fileHPPM, fileVPPM); 102 SetDlgItemText(IDD_ATTRIBUTESTEXT8, strRes); 103 return 0; 104 } 105 106 LRESULT CAttributesDialog::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 107 { 108 EndDialog(0); 109 return 0; 110 } 111 112 LRESULT CAttributesDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 113 { 114 EndDialog(1); 115 return 0; 116 } 117 118 LRESULT CAttributesDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 119 { 120 EndDialog(0); 121 return 0; 122 } 123 124 LRESULT CAttributesDialog::OnDefault(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 125 { 126 newWidth = imageModel.GetWidth(); 127 newHeight = imageModel.GetHeight(); 128 CheckDlgButton(IDD_ATTRIBUTESRB3, BST_CHECKED); 129 CheckDlgButton(IDD_ATTRIBUTESRB5, BST_CHECKED); 130 SetDlgItemInt(IDD_ATTRIBUTESEDIT1, newWidth, FALSE); 131 SetDlgItemInt(IDD_ATTRIBUTESEDIT2, newHeight, FALSE); 132 return 0; 133 } 134 135 LRESULT CAttributesDialog::OnRadioButton1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 136 { 137 CString strNum; 138 strNum.Format(_T("%.3lf"), newWidth / (0.0254 * fileHPPM)); 139 SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum); 140 strNum.Format(_T("%.3lf"), newHeight / (0.0254 * fileVPPM)); 141 SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum); 142 return 0; 143 } 144 145 LRESULT CAttributesDialog::OnRadioButton2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 146 { 147 CString strNum; 148 strNum.Format(_T("%.3lf"), newWidth * 100.0 / fileHPPM); 149 SetDlgItemText(IDD_ATTRIBUTESEDIT1, strNum); 150 strNum.Format(_T("%.3lf"), newHeight * 100.0 / fileVPPM); 151 SetDlgItemText(IDD_ATTRIBUTESEDIT2, strNum); 152 return 0; 153 } 154 155 LRESULT CAttributesDialog::OnRadioButton3(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 156 { 157 SetDlgItemInt(IDD_ATTRIBUTESEDIT1, newWidth, FALSE); 158 SetDlgItemInt(IDD_ATTRIBUTESEDIT2, newHeight, FALSE); 159 return 0; 160 } 161 162 LRESULT CAttributesDialog::OnEdit1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 163 { 164 if (Edit_GetModify(hWndCtl)) 165 { 166 TCHAR tempS[100]; 167 if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1)) 168 { 169 GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS)); 170 newWidth = max(1, (int) (_tcstod(tempS, NULL) * fileHPPM * 0.0254)); 171 } 172 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2)) 173 { 174 GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS)); 175 newWidth = max(1, (int) (_tcstod(tempS, NULL) * fileHPPM / 100)); 176 } 177 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3)) 178 { 179 GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS)); 180 newWidth = max(1, _tstoi(tempS)); 181 } 182 Edit_SetModify(hWndCtl, FALSE); 183 } 184 return 0; 185 } 186 187 LRESULT CAttributesDialog::OnEdit2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 188 { 189 if (Edit_GetModify(hWndCtl)) 190 { 191 TCHAR tempS[100]; 192 if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1)) 193 { 194 GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS)); 195 newHeight = max(1, (int) (_tcstod(tempS, NULL) * fileVPPM * 0.0254)); 196 } 197 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2)) 198 { 199 GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS)); 200 newHeight = max(1, (int) (_tcstod(tempS, NULL) * fileVPPM / 100)); 201 } 202 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3)) 203 { 204 GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS)); 205 newHeight = max(1, _tstoi(tempS)); 206 } 207 Edit_SetModify(hWndCtl, FALSE); 208 } 209 return 0; 210 } 211 212 213 214 LRESULT CStretchSkewDialog::OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 215 { 216 SetDlgItemInt(IDD_STRETCHSKEWEDITHSTRETCH, 100, FALSE); 217 SetDlgItemInt(IDD_STRETCHSKEWEDITVSTRETCH, 100, FALSE); 218 SetDlgItemInt(IDD_STRETCHSKEWEDITHSKEW, 0, FALSE); 219 SetDlgItemInt(IDD_STRETCHSKEWEDITVSKEW, 0, FALSE); 220 return 0; 221 } 222 223 LRESULT CStretchSkewDialog::OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 224 { 225 EndDialog(0); 226 return 0; 227 } 228 229 LRESULT CStretchSkewDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 230 { 231 CString strrcIntNumbers; 232 CString strrcPercentage; 233 CString strrcAngle; 234 BOOL tr1, tr2, tr3, tr4; 235 236 strrcIntNumbers.LoadString(hProgInstance, IDS_INTNUMBERS); 237 strrcPercentage.LoadString(hProgInstance, IDS_PERCENTAGE); 238 strrcAngle.LoadString(hProgInstance, IDS_ANGLE); 239 240 percentage.x = GetDlgItemInt(IDD_STRETCHSKEWEDITHSTRETCH, &tr1, FALSE); 241 percentage.y = GetDlgItemInt(IDD_STRETCHSKEWEDITVSTRETCH, &tr2, FALSE); 242 angle.x = GetDlgItemInt(IDD_STRETCHSKEWEDITHSKEW, &tr3, TRUE); 243 angle.y = GetDlgItemInt(IDD_STRETCHSKEWEDITVSKEW, &tr4, TRUE); 244 245 if (!(tr1 && tr2 && tr3 && tr4)) 246 MessageBox(strrcIntNumbers, NULL, MB_ICONEXCLAMATION); 247 else if (percentage.x < 1 || percentage.x > 500 || percentage.y < 1 || percentage.y > 500) 248 MessageBox(strrcPercentage, NULL, MB_ICONEXCLAMATION); 249 else if (angle.x < -89 || angle.x > 89 || angle.y < -89 || angle.y > 89) 250 MessageBox(strrcAngle, NULL, MB_ICONEXCLAMATION); 251 else 252 EndDialog(1); 253 return 0; 254 } 255 256 LRESULT CStretchSkewDialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 257 { 258 EndDialog(0); 259 return 0; 260 } 261