ReactOS  0.4.11-dev-946-g431643b
dialogs.cpp
Go to the documentation of this file.
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 
22 
23 /* FUNCTIONS ********************************************************/
24 
26 {
29  return 0;
30 }
31 
33 {
34  EndDialog(0);
35  return 0;
36 }
37 
38 LRESULT CMirrorRotateDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
39 {
41  EndDialog(1);
43  EndDialog(2);
45  EndDialog(3);
47  EndDialog(4);
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 {
64  return 0;
65 }
66 
67 LRESULT CMirrorRotateDialog::OnRadioButton12(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
68 {
72  return 0;
73 }
74 
75 
76 
78 {
79  newWidth = imageModel.GetWidth();
80  newHeight = imageModel.GetHeight();
81 
86 
87  if (isAFile)
88  {
89  TCHAR date[100];
90  TCHAR temp[100];
93  _tcscat(date, _T(" "));
94  _tcscat(date, temp);
95  CString strSize;
96  strSize.Format(IDS_FILESIZE, fileSize);
99  }
100  CString strRes;
103  return 0;
104 }
105 
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();
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));
140  strNum.Format(_T("%.3lf"), newHeight / (0.0254 * fileVPPM));
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);
150  strNum.Format(_T("%.3lf"), newHeight * 100.0 / fileVPPM);
152  return 0;
153 }
154 
155 LRESULT CAttributesDialog::OnRadioButton3(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
156 {
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];
168  {
169  GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS));
170  newWidth = max(1, (int) (_tcstod(tempS, NULL) * fileHPPM * 0.0254));
171  }
173  {
174  GetDlgItemText(IDD_ATTRIBUTESEDIT1, tempS, SIZEOF(tempS));
175  newWidth = max(1, (int) (_tcstod(tempS, NULL) * fileHPPM / 100));
176  }
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];
193  {
194  GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS));
195  newHeight = max(1, (int) (_tcstod(tempS, NULL) * fileVPPM * 0.0254));
196  }
198  {
199  GetDlgItemText(IDD_ATTRIBUTESEDIT2, tempS, SIZEOF(tempS));
200  newHeight = max(1, (int) (_tcstod(tempS, NULL) * fileVPPM / 100));
201  }
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 
215 {
220  return 0;
221 }
222 
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);
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 }
BOOL isAFile
Definition: main.cpp:53
#define IDD_ATTRIBUTESEDIT1
Definition: definitions.h:164
#define IDD_MIRRORROTATERB4
Definition: definitions.h:159
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define IDS_INTNUMBERS
Definition: definitions.h:234
#define max(a, b)
Definition: svc.c:63
#define IDD_ATTRIBUTESRB3
Definition: definitions.h:179
#define Edit_GetModify(hwndCtl)
Definition: windowsx.h:65
#define TRUE
Definition: types.h:120
int fileSize
Definition: main.cpp:54
#define _tstoi
Definition: tchar.h:598
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: dialogs.cpp:32
#define IDD_MIRRORROTATERB1
Definition: definitions.h:156
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:118
#define IDD_ATTRIBUTESTEXT8
Definition: definitions.h:173
#define LOCALE_USER_DEFAULT
LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: dialogs.cpp:25
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:668
LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: dialogs.cpp:214
GLfloat angle
Definition: glext.h:10853
#define IDS_PRINTRES
Definition: definitions.h:232
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
UINT_PTR WPARAM
Definition: windef.h:207
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define IDS_PERCENTAGE
Definition: definitions.h:235
SYSTEMTIME fileTime
Definition: main.cpp:57
#define SIZEOF(_ar)
Definition: calc.h:48
CMirrorRotateDialog mirrorRotateDialog
Definition: dialogs.cpp:19
#define IDD_MIRRORROTATERB2
Definition: definitions.h:157
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_FILESIZE
Definition: definitions.h:231
LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: dialogs.cpp:77
LRESULT OnRadioButton3(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:155
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
int fileHPPM
Definition: main.cpp:55
CStretchSkewDialog stretchSkewDialog
Definition: dialogs.cpp:21
LRESULT OnRadioButton2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:145
UINT WINAPI IsDlgButtonChecked(_In_ HWND, _In_ int)
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetDlgItemText
Definition: winuser.h:5651
#define _tcstod
Definition: xmlstorage.h:197
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDD_STRETCHSKEWEDITVSTRETCH
Definition: definitions.h:191
LRESULT OnRadioButton3(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:59
unsigned int UINT
Definition: ndis.h:50
unsigned short WORD
Definition: ntddk_ex.h:93
#define IDD_STRETCHSKEWEDITHSTRETCH
Definition: definitions.h:187
#define SetDlgItemText
Definition: winuser.h:5715
int GetWidth()
Definition: history.cpp:195
CAttributesDialog attributesDialog
Definition: dialogs.cpp:20
int GetHeight()
Definition: history.cpp:200
#define IDD_ATTRIBUTESRB1
Definition: definitions.h:177
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: dialogs.cpp:106
ImageModel imageModel
Definition: main.cpp:32
#define MessageBox
Definition: winuser.h:5688
static stack_node_t temp
Definition: rpn.c:18
HINSTANCE hProgInstance
Definition: main.cpp:50
#define Edit_SetModify(hwndCtl, fModified)
Definition: windowsx.h:80
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define IDS_ANGLE
Definition: definitions.h:236
#define GetTimeFormat
Definition: winnls.h:1157
LRESULT OnRadioButton1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:135
#define IDD_ATTRIBUTESEDIT2
Definition: definitions.h:165
LRESULT OnClose(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
Definition: dialogs.cpp:223
#define GetDateFormat
Definition: winnls.h:1152
#define IDD_STRETCHSKEWEDITHSKEW
Definition: definitions.h:196
__u16 date
Definition: mkdosfs.c:366
LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:229
LRESULT OnEdit1(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:162
#define BST_CHECKED
Definition: winuser.h:197
LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:112
#define IDD_MIRRORROTATERB5
Definition: definitions.h:160
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
#define IDD_STRETCHSKEWEDITVSKEW
Definition: definitions.h:200
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:506
LRESULT OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:38
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:256
#define IDD_ATTRIBUTESTEXT7
Definition: definitions.h:172
LONG_PTR LRESULT
Definition: windef.h:209
#define IDD_ATTRIBUTESTEXT6
Definition: definitions.h:171
LRESULT OnRadioButton12(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:67
#define IDD_MIRRORROTATERB6
Definition: definitions.h:161
LRESULT OnDefault(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:124
LPARAM lParam
Definition: combotst.c:139
#define IDD_ATTRIBUTESRB5
Definition: definitions.h:181
int fileVPPM
Definition: main.cpp:56
LRESULT OnEdit2(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:187
LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL &bHandled)
Definition: dialogs.cpp:53
#define IDD_ATTRIBUTESRB2
Definition: definitions.h:178