2 * PROJECT: PAINT for ReactOS
4 * FILE: base/applications/mspaint/dialogs.cpp
5 * PURPOSE: Window procedures of the dialog windows plus launching functions
6 * PROGRAMMERS: Benedikt Freisen
9 /* INCLUDES *********************************************************/
17 /* GLOBALS **********************************************************/
19 CMirrorRotateDialog mirrorRotateDialog
;
20 CAttributesDialog attributesDialog
;
21 CStretchSkewDialog stretchSkewDialog
;
23 /* FUNCTIONS ********************************************************/
25 LRESULT
CMirrorRotateDialog::OnInitDialog(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
27 CheckDlgButton(IDD_MIRRORROTATERB1
, BST_CHECKED
);
28 CheckDlgButton(IDD_MIRRORROTATERB4
, BST_CHECKED
);
32 LRESULT
CMirrorRotateDialog::OnClose(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
38 LRESULT
CMirrorRotateDialog::OnOk(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
40 if (IsDlgButtonChecked(IDD_MIRRORROTATERB1
))
42 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB2
))
44 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB4
))
46 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB5
))
48 else if (IsDlgButtonChecked(IDD_MIRRORROTATERB6
))
53 LRESULT
CMirrorRotateDialog::OnCancel(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
59 LRESULT
CMirrorRotateDialog::OnRadioButton3(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
61 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB4
), TRUE
);
62 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB5
), TRUE
);
63 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB6
), TRUE
);
67 LRESULT
CMirrorRotateDialog::OnRadioButton12(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
69 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB4
), FALSE
);
70 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB5
), FALSE
);
71 ::EnableWindow(GetDlgItem(IDD_MIRRORROTATERB6
), FALSE
);
77 LRESULT
CAttributesDialog::OnInitDialog(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
79 newWidth
= imageModel
.GetWidth();
80 newHeight
= imageModel
.GetHeight();
82 CheckDlgButton(IDD_ATTRIBUTESRB3
, BST_CHECKED
);
83 CheckDlgButton(IDD_ATTRIBUTESRB5
, BST_CHECKED
);
84 SetDlgItemInt(IDD_ATTRIBUTESEDIT1
, newWidth
, FALSE
);
85 SetDlgItemInt(IDD_ATTRIBUTESEDIT2
, newHeight
, FALSE
);
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(" "));
96 strSize
.Format(IDS_FILESIZE
, fileSize
);
97 SetDlgItemText(IDD_ATTRIBUTESTEXT6
, date
);
98 SetDlgItemText(IDD_ATTRIBUTESTEXT7
, strSize
);
101 strRes
.Format(IDS_PRINTRES
, fileHPPM
, fileVPPM
);
102 SetDlgItemText(IDD_ATTRIBUTESTEXT8
, strRes
);
106 LRESULT
CAttributesDialog::OnClose(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
112 LRESULT
CAttributesDialog::OnOk(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
118 LRESULT
CAttributesDialog::OnCancel(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
124 LRESULT
CAttributesDialog::OnDefault(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
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
);
135 LRESULT
CAttributesDialog::OnRadioButton1(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
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
);
145 LRESULT
CAttributesDialog::OnRadioButton2(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
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
);
155 LRESULT
CAttributesDialog::OnRadioButton3(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
157 SetDlgItemInt(IDD_ATTRIBUTESEDIT1
, newWidth
, FALSE
);
158 SetDlgItemInt(IDD_ATTRIBUTESEDIT2
, newHeight
, FALSE
);
162 LRESULT
CAttributesDialog::OnEdit1(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
164 if (Edit_GetModify(hWndCtl
))
167 if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1
))
169 GetDlgItemText(IDD_ATTRIBUTESEDIT1
, tempS
, SIZEOF(tempS
));
170 newWidth
= max(1, (int) (_tcstod(tempS
, NULL
) * fileHPPM
* 0.0254));
172 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2
))
174 GetDlgItemText(IDD_ATTRIBUTESEDIT1
, tempS
, SIZEOF(tempS
));
175 newWidth
= max(1, (int) (_tcstod(tempS
, NULL
) * fileHPPM
/ 100));
177 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3
))
179 GetDlgItemText(IDD_ATTRIBUTESEDIT1
, tempS
, SIZEOF(tempS
));
180 newWidth
= max(1, _tstoi(tempS
));
182 Edit_SetModify(hWndCtl
, FALSE
);
187 LRESULT
CAttributesDialog::OnEdit2(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
189 if (Edit_GetModify(hWndCtl
))
192 if (IsDlgButtonChecked(IDD_ATTRIBUTESRB1
))
194 GetDlgItemText(IDD_ATTRIBUTESEDIT2
, tempS
, SIZEOF(tempS
));
195 newHeight
= max(1, (int) (_tcstod(tempS
, NULL
) * fileVPPM
* 0.0254));
197 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB2
))
199 GetDlgItemText(IDD_ATTRIBUTESEDIT2
, tempS
, SIZEOF(tempS
));
200 newHeight
= max(1, (int) (_tcstod(tempS
, NULL
) * fileVPPM
/ 100));
202 else if (IsDlgButtonChecked(IDD_ATTRIBUTESRB3
))
204 GetDlgItemText(IDD_ATTRIBUTESEDIT2
, tempS
, SIZEOF(tempS
));
205 newHeight
= max(1, _tstoi(tempS
));
207 Edit_SetModify(hWndCtl
, FALSE
);
214 LRESULT
CStretchSkewDialog::OnInitDialog(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
216 SetDlgItemInt(IDD_STRETCHSKEWEDITHSTRETCH
, 100, FALSE
);
217 SetDlgItemInt(IDD_STRETCHSKEWEDITVSTRETCH
, 100, FALSE
);
218 SetDlgItemInt(IDD_STRETCHSKEWEDITHSKEW
, 0, FALSE
);
219 SetDlgItemInt(IDD_STRETCHSKEWEDITVSKEW
, 0, FALSE
);
223 LRESULT
CStretchSkewDialog::OnClose(UINT nMsg
, WPARAM wParam
, LPARAM lParam
, BOOL
& bHandled
)
229 LRESULT
CStretchSkewDialog::OnOk(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)
231 CString strrcIntNumbers
;
232 CString strrcPercentage
;
234 BOOL tr1
, tr2
, tr3
, tr4
;
236 strrcIntNumbers
.LoadString(hProgInstance
, IDS_INTNUMBERS
);
237 strrcPercentage
.LoadString(hProgInstance
, IDS_PERCENTAGE
);
238 strrcAngle
.LoadString(hProgInstance
, IDS_ANGLE
);
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
);
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
);
256 LRESULT
CStretchSkewDialog::OnCancel(WORD wNotifyCode
, WORD wID
, HWND hWndCtl
, BOOL
& bHandled
)