Alexey Zavyalov: Add functionally Numbers, Currency, Time, Date tabs. Fix some bugs.
[reactos.git] / reactos / dll / cpl / intl_new / nums.c
1 /*
2 * PROJECT: ReactOS International Control Panel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/intl/nums.c
5 * PURPOSE: ReactOS International Control Panel
6 * PROGRAMMERS: Alexey Zavyalov (gen_x@mail.ru)
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #include <windows.h>
12 #include <commctrl.h>
13 #include <cpl.h>
14
15 #include "intl.h"
16 #include "resource.h"
17
18 /* GLOBALS ******************************************************************/
19
20 #define SAMPLE_NUMBER L"123456789"
21 #define SAMPLE_NEG_NUMBER L"-123456789"
22 #define MAX_NUM_SEP_SAMPLES 2
23 #define MAX_FRAC_NUM_SAMPLES 9
24 #define MAX_FIELD_SEP_SAMPLES 1
25 #define MAX_FIELD_DIG_SAMPLES 3
26 #define MAX_NEG_SIGN_SAMPLES 1
27 #define MAX_NEG_NUMBERS_SAMPLES 5
28 #define MAX_LEAD_ZEROES_SAMPLES 2
29 #define MAX_LIST_SEP_SAMPLES 1
30 #define MAX_UNITS_SYS_SAMPLES 2
31 #define EOLN_SIZE sizeof(WCHAR)
32
33 /* FUNCTIONS ****************************************************************/
34
35 /* Init system of units control box */
36 VOID
37 InitUnitsSysCB(HWND hwndDlg)
38 {
39 WCHAR wszUnitsSysSamples[MAX_UNITS_SYS_SAMPLES][MAX_SAMPLES_STR_SIZE]=
40 {
41 L"Metrics",
42 L"Americans"
43 };
44
45 int nCBIndex;
46 int nRetCode;
47
48 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
49 WCHAR wszUnitsSys[MAX_SAMPLES_STR_SIZE];
50
51 /* Get current system of units */
52 GetLocaleInfoW(LOCALE_USER_DEFAULT,
53 LOCALE_IMEASURE,
54 wszUnitsSys,
55 dwValueSize);
56
57 /* Clear all box content */
58 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMUNITSSYS_COMBO),
59 CB_RESETCONTENT,
60 (WPARAM)0,
61 (LPARAM)0);
62
63 /* Create list of standart system of units */
64 for(nCBIndex=0;nCBIndex<MAX_UNITS_SYS_SAMPLES;nCBIndex++)
65 {
66 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMUNITSSYS_COMBO),
67 CB_ADDSTRING,
68 nCBIndex,
69 (LPARAM)wszUnitsSysSamples[nCBIndex]);
70 }
71
72 /* Set current item to value from registry */
73 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMUNITSSYS_COMBO),
74 CB_SETCURSEL,
75 (WPARAM)_wtoi(wszUnitsSys),
76 (LPARAM)0);
77 }
78
79 /* Init elements list separator control box */
80 VOID
81 InitListSepCB(HWND hwndDlg)
82 {
83 WCHAR wszListSepSamples[MAX_LIST_SEP_SAMPLES][MAX_SAMPLES_STR_SIZE]=
84 {
85 L";"
86 };
87
88 int nCBIndex;
89 int nRetCode;
90
91 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
92 WCHAR wszListSep[MAX_SAMPLES_STR_SIZE];
93
94 /* Get current list separator */
95 GetLocaleInfoW(LOCALE_USER_DEFAULT,
96 LOCALE_SLIST,
97 wszListSep,
98 dwValueSize);
99
100 /* Clear all box content */
101 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMELEMLISTSEP_COMBO),
102 CB_RESETCONTENT,
103 (WPARAM)0,
104 (LPARAM)0);
105
106 /* Create standart list of signs */
107 for(nCBIndex=0;nCBIndex<MAX_LIST_SEP_SAMPLES;nCBIndex++)
108 {
109 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMELEMLISTSEP_COMBO),
110 CB_ADDSTRING,
111 nCBIndex,
112 (LPARAM)wszListSepSamples[nCBIndex]);
113 }
114
115 /* Set current item to value from registry */
116 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMELEMLISTSEP_COMBO),
117 CB_SELECTSTRING,
118 -1,
119 (LPARAM)(LPCSTR)wszListSep);
120
121 /* if is not success, add new value to list and select them */
122 if(nRetCode == CB_ERR)
123 {
124 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMELEMLISTSEP_COMBO),
125 CB_ADDSTRING,
126 MAX_LIST_SEP_SAMPLES+1,
127 (LPARAM)wszListSep);
128 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMELEMLISTSEP_COMBO),
129 CB_SELECTSTRING,
130 -1,
131 (LPARAM)(LPCSTR)wszListSep);
132 }
133 }
134
135 /* Init leading zeroes control box */
136 VOID
137 InitLeadingZeroesCB(HWND hwndDlg)
138 {
139 WCHAR wszLeadNumFmtSamples[MAX_LEAD_ZEROES_SAMPLES][MAX_SAMPLES_STR_SIZE]=
140 {
141 L",7",
142 L"0,7"
143 };
144
145 int nCBIndex;
146 int nRetCode;
147
148 WCHAR wszLeadNumFmt[MAX_SAMPLES_STR_SIZE];
149 WCHAR wszNumSep[MAX_SAMPLES_STR_SIZE];
150 WCHAR* pwszResultStr;
151 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
152
153 /* Get current leading zeroes format */
154 GetLocaleInfoW(LOCALE_USER_DEFAULT,
155 LOCALE_ILZERO,
156 wszLeadNumFmt,
157 dwValueSize);
158
159 /* Clear all box content */
160 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMLEADZERO_COMBO),
161 CB_RESETCONTENT,
162 (WPARAM)0,
163 (LPARAM)0);
164
165 /* Get current decimal separator */
166 GetLocaleInfoW(LOCALE_USER_DEFAULT,
167 LOCALE_SDECIMAL,
168 wszNumSep,
169 dwValueSize);
170
171 /* Create list of standart leading zeroes formats */
172 for(nCBIndex=0;nCBIndex<MAX_LEAD_ZEROES_SAMPLES;nCBIndex++)
173 {
174 pwszResultStr = ReplaceSubStr(wszLeadNumFmtSamples[nCBIndex],
175 wszNumSep,
176 L",");
177 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMLEADZERO_COMBO),
178 CB_ADDSTRING,
179 nCBIndex,
180 (LPARAM)pwszResultStr);
181 free(pwszResultStr);
182 }
183
184 /* Set current item to value from registry */
185 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMLEADZERO_COMBO),
186 CB_SETCURSEL,
187 (WPARAM)_wtoi(wszLeadNumFmt),
188 (LPARAM)0);
189 }
190
191 /* Init negative numbers format control box */
192 VOID
193 InitNegNumFmtCB(HWND hwndDlg)
194 {
195 WCHAR wszNegNumFmtSamples[MAX_NEG_NUMBERS_SAMPLES][MAX_SAMPLES_STR_SIZE]=
196 {
197 L"(1,1)",
198 L"-1,1",
199 L"- 1,1",
200 L"1,1-",
201 L"1,1 -"
202 };
203
204 int nCBIndex;
205 int nRetCode;
206
207 WCHAR wszNegNumFmt[MAX_SAMPLES_STR_SIZE];
208 WCHAR wszNumSep[MAX_SAMPLES_STR_SIZE];
209 WCHAR wszNegSign[MAX_SAMPLES_STR_SIZE];
210 WCHAR wszNewSample[MAX_SAMPLES_STR_SIZE];
211 WCHAR* pwszResultStr;
212 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
213
214 /* Get current negative numbers format */
215 GetLocaleInfoW(LOCALE_USER_DEFAULT,
216 LOCALE_INEGNUMBER,
217 wszNegNumFmt,
218 dwValueSize);
219
220 /* Clear all box content */
221 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGFMT_COMBO),
222 CB_RESETCONTENT,
223 (WPARAM)0,
224 (LPARAM)0);
225
226 /* Get current decimal separator */
227 GetLocaleInfoW(LOCALE_USER_DEFAULT,
228 LOCALE_SDECIMAL,
229 wszNumSep,
230 dwValueSize);
231
232 /* Get current negative sign */
233 GetLocaleInfoW(LOCALE_USER_DEFAULT,
234 LOCALE_SNEGATIVESIGN,
235 wszNegSign,
236 dwValueSize);
237
238 /* Create standart list of negative numbers formats */
239 for(nCBIndex=0;nCBIndex<MAX_NEG_NUMBERS_SAMPLES;nCBIndex++)
240 {
241 /* Replace standart separator to setted */
242 pwszResultStr = ReplaceSubStr(wszNegNumFmtSamples[nCBIndex],
243 wszNumSep,
244 L",");
245 wcscpy(wszNewSample,pwszResultStr);
246 free(pwszResultStr);
247 /* Replace standart negative sign to setted */
248 pwszResultStr = ReplaceSubStr(wszNewSample,
249 wszNegSign,
250 L"-");
251 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGFMT_COMBO),
252 CB_ADDSTRING,
253 nCBIndex,
254 (LPARAM)pwszResultStr);
255 free(pwszResultStr);
256 }
257
258 /* Set current item to value from registry */
259 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGFMT_COMBO),
260 CB_SETCURSEL,
261 (WPARAM)_wtoi(wszNegNumFmt),
262 (LPARAM)0);
263 }
264
265 /* Init negative sign control box */
266 VOID
267 InitNegSignCB(HWND hwndDlg)
268 {
269 WCHAR wszNegSignSamples[MAX_NEG_SIGN_SAMPLES][MAX_SAMPLES_STR_SIZE]=
270 {
271 L"-"
272 };
273
274 int nCBIndex;
275 int nRetCode;
276
277 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
278 WCHAR wszNegSign[MAX_SAMPLES_STR_SIZE];
279
280 /* Get current negative sign */
281 GetLocaleInfoW(LOCALE_USER_DEFAULT,
282 LOCALE_SNEGATIVESIGN,
283 wszNegSign,
284 dwValueSize);
285
286 /* Clear all box content */
287 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGSIGN_COMBO),
288 CB_RESETCONTENT,
289 (WPARAM)0,
290 (LPARAM)0);
291
292 /* Create standart list of signs */
293 for(nCBIndex=0;nCBIndex<MAX_NEG_SIGN_SAMPLES;nCBIndex++)
294 {
295 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGSIGN_COMBO),
296 CB_ADDSTRING,
297 nCBIndex,
298 (LPARAM)wszNegSignSamples[nCBIndex]);
299 }
300
301 /* Set current item to value from registry */
302 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGSIGN_COMBO),
303 CB_SELECTSTRING,
304 -1,
305 (LPARAM)(LPCSTR)wszNegSign);
306
307 /* if is not success, add new value to list and select them */
308 if(nRetCode == CB_ERR)
309 {
310 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGSIGN_COMBO),
311 CB_ADDSTRING,
312 MAX_NUM_SEP_SAMPLES+1,
313 (LPARAM)wszNegSign);
314 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGSIGN_COMBO),
315 CB_SELECTSTRING,
316 -1,
317 (LPARAM)(LPCSTR)wszNegSign);
318 }
319 }
320
321 /* Init number of digidts in field control box */
322 VOID
323 InitFieldDigNumCB(HWND hwndDlg)
324 {
325 WCHAR wszFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES][MAX_SAMPLES_STR_SIZE]=
326 {
327 L"0;0",
328 L"3;0",
329 L"3;2;0"
330 };
331
332 int nCBIndex;
333 int nRetCode;
334
335 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
336 WCHAR wszFieldDigNum[MAX_SAMPLES_STR_SIZE];
337 WCHAR* pwszFieldDigNumSmpl;
338
339 /* Get current field digits num */
340 GetLocaleInfoW(LOCALE_USER_DEFAULT,
341 LOCALE_SGROUPING,
342 wszFieldDigNum,
343 dwValueSize);
344
345 /* Clear all box content */
346 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDIGFIELD_COMBO),
347 CB_RESETCONTENT,
348 (WPARAM)0,
349 (LPARAM)0);
350
351 /* Create standart list of field digits num */
352 for(nCBIndex=0;nCBIndex<MAX_FIELD_DIG_SAMPLES;nCBIndex++)
353 {
354
355 pwszFieldDigNumSmpl=InsSpacesFmt(SAMPLE_NUMBER,wszFieldDigNumSamples[nCBIndex]);
356 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDIGFIELD_COMBO),
357 CB_ADDSTRING,
358 nCBIndex,
359 (LPARAM)pwszFieldDigNumSmpl);
360 free(pwszFieldDigNumSmpl);
361 }
362
363 pwszFieldDigNumSmpl=InsSpacesFmt(SAMPLE_NUMBER,wszFieldDigNum);
364 /* Set current item to value from registry */
365 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDIGFIELD_COMBO),
366 CB_SELECTSTRING,
367 -1,
368 (LPARAM)(LPCSTR)pwszFieldDigNumSmpl);
369
370 /* if is not success, add new value to list and select them */
371 if(nRetCode == CB_ERR)
372 {
373 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDIGFIELD_COMBO),
374 CB_ADDSTRING,
375 MAX_FIELD_DIG_SAMPLES+1,
376 (LPARAM)pwszFieldDigNumSmpl);
377 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDIGFIELD_COMBO),
378 CB_SELECTSTRING,
379 -1,
380 (LPARAM)(LPCSTR)pwszFieldDigNumSmpl);
381 }
382
383 free(pwszFieldDigNumSmpl);
384 }
385
386 /* Init field separator control box */
387 VOID
388 InitNumFieldSepCB(HWND hwndDlg)
389 {
390 WCHAR wszFieldSepSamples[MAX_FIELD_SEP_SAMPLES][MAX_SAMPLES_STR_SIZE]=
391 {
392 L" "
393 };
394
395 int nCBIndex;
396 int nRetCode;
397
398 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
399 WCHAR wszFieldSep[MAX_SAMPLES_STR_SIZE];
400
401 /* Get current field separator */
402 GetLocaleInfoW(LOCALE_USER_DEFAULT,
403 LOCALE_STHOUSAND,
404 wszFieldSep,
405 dwValueSize);
406
407 /* Clear all box content */
408 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFIELDSEP_COMBO),
409 CB_RESETCONTENT,
410 (WPARAM)0,
411 (LPARAM)0);
412
413 /* Create standart list of field separators */
414 for(nCBIndex=0;nCBIndex<MAX_FIELD_SEP_SAMPLES;nCBIndex++)
415 {
416 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFIELDSEP_COMBO),
417 CB_ADDSTRING,
418 nCBIndex,
419 (LPARAM)wszFieldSepSamples[nCBIndex]);
420 }
421
422 /* Set current item to value from registry */
423 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFIELDSEP_COMBO),
424 CB_SELECTSTRING,
425 -1,
426 (LPARAM)(LPCSTR)wszFieldSep);
427
428 /* if is not success, add new value to list and select them */
429 if(nRetCode == CB_ERR)
430 {
431 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFIELDSEP_COMBO),
432 CB_ADDSTRING,
433 MAX_FIELD_SEP_SAMPLES+1,
434 (LPARAM)wszFieldSep);
435 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFIELDSEP_COMBO),
436 CB_SELECTSTRING,
437 -1,
438 (LPARAM)(LPCSTR)wszFieldSep);
439 }
440 }
441
442 /* Init number of fractional symbols control box */
443 VOID
444 InitNumOfFracSymbCB(HWND hwndDlg)
445 {
446 int nCBIndex;
447 int nRetCode;
448
449 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
450 WCHAR wszFracNum[MAX_SAMPLES_STR_SIZE];
451 WCHAR wszFracCount[MAX_SAMPLES_STR_SIZE];
452
453 /* Get current number of fractional symbols */
454 GetLocaleInfoW(LOCALE_USER_DEFAULT,
455 LOCALE_IDIGITS,
456 wszFracNum,
457 dwValueSize);
458
459 /* Clear all box content */
460 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFRACSYBMS_COMBO),
461 CB_RESETCONTENT,
462 (WPARAM)0,
463 (LPARAM)0);
464
465 /* Create standart list of fractional symbols */
466 for(nCBIndex=0;nCBIndex<MAX_FRAC_NUM_SAMPLES;nCBIndex++)
467 {
468 /* convert to wide char */
469 _itow(nCBIndex,wszFracCount,DECIMAL_RADIX);
470
471 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFRACSYBMS_COMBO),
472 CB_ADDSTRING,
473 nCBIndex,
474 (LPARAM)wszFracCount);
475 }
476
477 /* Set current item to value from registry */
478 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFRACSYBMS_COMBO),
479 CB_SETCURSEL,
480 (WPARAM)_wtoi(wszFracNum),
481 (LPARAM)0);
482 }
483
484 /* Init num decimal separator control box */
485 VOID
486 InitNumDecimalSepCB(HWND hwndDlg)
487 {
488 WCHAR wszNumSepSamples[MAX_NUM_SEP_SAMPLES][MAX_SAMPLES_STR_SIZE]=
489 {
490 L",",
491 L"."
492 };
493
494 int nCBIndex;
495 int nRetCode;
496
497 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
498 WCHAR wszNumSep[MAX_SAMPLES_STR_SIZE];
499
500 /* Get current decimal separator */
501 GetLocaleInfoW(LOCALE_USER_DEFAULT,
502 LOCALE_SDECIMAL,
503 wszNumSep,
504 dwValueSize);
505
506 /* Clear all box content */
507 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDECIMALSEP_COMBO),
508 CB_RESETCONTENT,
509 (WPARAM)0,
510 (LPARAM)0);
511
512 /* Create standart list of decimal separators */
513 for(nCBIndex=0;nCBIndex<MAX_NUM_SEP_SAMPLES;nCBIndex++)
514 {
515 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDECIMALSEP_COMBO),
516 CB_ADDSTRING,
517 nCBIndex,
518 (LPARAM)wszNumSepSamples[nCBIndex]);
519 }
520
521 /* Set current item to value from registry */
522 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDECIMALSEP_COMBO),
523 CB_SELECTSTRING,
524 -1,
525 (LPARAM)(LPCSTR)wszNumSep);
526
527 /* if is not success, add new value to list and select them */
528 if(nRetCode == CB_ERR)
529 {
530 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDECIMALSEP_COMBO),
531 CB_ADDSTRING,
532 MAX_NUM_SEP_SAMPLES+1,
533 (LPARAM)wszNumSep);
534 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDECIMALSEP_COMBO),
535 CB_SELECTSTRING,
536 -1,
537 (LPARAM)(LPCSTR)wszNumSep);
538 }
539 }
540
541 /* Set units system */
542 BOOL
543 SetNumUnitsSys(HWND hwndDlg)
544 {
545 WCHAR wszUnitsSys[MAX_SAMPLES_STR_SIZE];
546 INT nCurrSel;
547
548 /* Get setted units system */
549 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_NUMUNITSSYS_COMBO),
550 CB_GETCURSEL,
551 (WPARAM)0,
552 (LPARAM)0);
553
554 /* convert to wide char */
555 _itow(nCurrSel,wszUnitsSys,DECIMAL_RADIX);
556
557 /* Save units system */
558 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, wszUnitsSys);
559
560 return TRUE;
561 }
562
563 /* Set elements list separator */
564 BOOL
565 SetNumListSep(HWND hwndDlg)
566 {
567 WCHAR wszListSep[MAX_SAMPLES_STR_SIZE];
568
569 /* Get setted list separator */
570 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMELEMLISTSEP_COMBO),
571 WM_GETTEXT,
572 (WPARAM)MAX_SAMPLES_STR_SIZE,
573 (LPARAM)(LPCSTR)wszListSep);
574
575 /* Save list separator */
576 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SLIST, wszListSep);
577
578 return TRUE;
579 }
580
581 /* Set leading zero */
582 BOOL
583 SetNumLeadZero(HWND hwndDlg)
584 {
585 WCHAR wszLeadZero[MAX_SAMPLES_STR_SIZE];
586 INT nCurrSel;
587
588 /* Get setted leading zero format */
589 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_NUMLEADZERO_COMBO),
590 CB_GETCURSEL,
591 (WPARAM)0,
592 (LPARAM)0);
593
594 /* convert to wide char */
595 _itow(nCurrSel,wszLeadZero,DECIMAL_RADIX);
596
597 /* Save leading zero format */
598 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ILZERO, wszLeadZero);
599
600 return TRUE;
601 }
602
603 /* Set negative sum format */
604 BOOL
605 SetNegSumFmt(HWND hwndDlg)
606 {
607 WCHAR wszNegSumFmt[MAX_SAMPLES_STR_SIZE];
608 INT nCurrSel;
609
610 /* Get setted negative sum format */
611 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGFMT_COMBO),
612 CB_GETCURSEL,
613 (WPARAM)0,
614 (LPARAM)0);
615
616 /* convert to wide char */
617 _itow(nCurrSel,wszNegSumFmt,DECIMAL_RADIX);
618
619 /* Save negative sum format */
620 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_INEGNUMBER, wszNegSumFmt);
621
622 return TRUE;
623 }
624
625 /* Set negative sign */
626 BOOL
627 SetNumNegSign(HWND hwndDlg)
628 {
629 WCHAR wszNegSign[MAX_SAMPLES_STR_SIZE];
630
631 /* Get setted negative sign */
632 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMNEGSIGN_COMBO),
633 WM_GETTEXT,
634 (WPARAM)MAX_SAMPLES_STR_SIZE,
635 (LPARAM)(LPCSTR)wszNegSign);
636
637 /* Save negative sign */
638 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SNEGATIVESIGN, wszNegSign);
639
640 return TRUE;
641 }
642
643 /* Set number of digidts in field */
644 BOOL
645 SetFieldDigNum(HWND hwndDlg)
646 {
647 WCHAR wszFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES][MAX_SAMPLES_STR_SIZE]=
648 {
649 L"0;0",
650 L"3;0",
651 L"3;2;0"
652 };
653
654 int nCurrSel;
655
656 /* Get setted number of digidts in field */
657 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDIGFIELD_COMBO),
658 CB_GETCURSEL,
659 (WPARAM)0,
660 (LPARAM)0);
661
662 /* Save number of digidts in field */
663 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SGROUPING, wszFieldDigNumSamples[nCurrSel]);
664
665 return TRUE;
666 }
667
668 /* Set field separator */
669 BOOL
670 SetNumFieldSep(HWND hwndDlg)
671 {
672 WCHAR wszFieldSep[MAX_SAMPLES_STR_SIZE];
673
674 /* Get setted field separator */
675 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFIELDSEP_COMBO),
676 WM_GETTEXT,
677 (WPARAM)MAX_SAMPLES_STR_SIZE,
678 (LPARAM)(LPCSTR)wszFieldSep);
679
680 /* Save field separator */
681 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_STHOUSAND, wszFieldSep);
682
683 return TRUE;
684 }
685
686 /* Set number of fractional symbols */
687 BOOL
688 SetFracSymNum(HWND hwndDlg)
689 {
690 WCHAR wszFracSymNum[MAX_SAMPLES_STR_SIZE];
691 INT nCurrSel;
692
693 /* Get setted number of fractional symbols */
694 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_NUMFRACSYBMS_COMBO),
695 CB_GETCURSEL,
696 (WPARAM)0,
697 (LPARAM)0);
698
699 /* convert to wide char */
700 _itow(nCurrSel,wszFracSymNum,DECIMAL_RADIX);
701
702 /* Save number of fractional symbols */
703 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IDIGITS, wszFracSymNum);
704
705 return TRUE;
706 }
707
708 /* Set num decimal separator */
709 BOOL
710 SetNumDecimalSep(HWND hwndDlg)
711 {
712 WCHAR wszDecimalSep[MAX_SAMPLES_STR_SIZE];
713
714 /* Get setted decimal separator */
715 SendMessageW(GetDlgItem(hwndDlg, IDC_NUMDECIMALSEP_COMBO),
716 WM_GETTEXT,
717 (WPARAM)MAX_SAMPLES_STR_SIZE,
718 (LPARAM)(LPCSTR)wszDecimalSep);
719
720 /* Save decimal separator */
721 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDECIMAL, wszDecimalSep);
722
723 return TRUE;
724 }
725
726 /* Update all numbers locale samples */
727 static
728 VOID
729 UpdateNumSamples(HWND hwndDlg,
730 LCID lcidLocale)
731 {
732 WCHAR OutBuffer[MAX_FMT_SIZE];
733
734 /* Get positive number format sample */
735 GetNumberFormatW(lcidLocale,
736 0,
737 SAMPLE_NUMBER,
738 NULL,
739 OutBuffer,
740 MAX_FMT_SIZE);
741
742 SendMessageW(GetDlgItem(hwndDlg, IDC_NUM_EDIT),
743 WM_SETTEXT,
744 0,
745 (LPARAM)OutBuffer);
746
747 /* Get positive number format sample */
748 GetNumberFormatW(lcidLocale,
749 0,
750 SAMPLE_NEG_NUMBER,
751 NULL,
752 OutBuffer,
753 MAX_FMT_SIZE);
754
755 SendMessageW(GetDlgItem(hwndDlg, IDC_NEGNUM_EDIT),
756 WM_SETTEXT,
757 0,
758 (LPARAM)OutBuffer);
759 }
760
761 /* Numbers options setup page dialog callback */
762 INT_PTR
763 CALLBACK
764 NumsOptsSetProc(HWND hwndDlg,
765 UINT uMsg,
766 WPARAM wParam,
767 LPARAM lParam)
768 {
769 UNREFERENCED_PARAMETER(lParam);
770 UNREFERENCED_PARAMETER(wParam);
771 UNREFERENCED_PARAMETER(hwndDlg);
772 switch(uMsg)
773 {
774 case WM_INITDIALOG:
775 {
776 /* Init combo boxes */
777 InitNumDecimalSepCB(hwndDlg);
778 InitNumOfFracSymbCB(hwndDlg);
779 InitNumFieldSepCB(hwndDlg);
780 InitFieldDigNumCB(hwndDlg);
781 InitNegSignCB(hwndDlg);
782 InitNegNumFmtCB(hwndDlg);
783 InitLeadingZeroesCB(hwndDlg);
784 InitListSepCB(hwndDlg);
785 InitUnitsSysCB(hwndDlg);
786
787 UpdateNumSamples(hwndDlg, LOCALE_USER_DEFAULT);
788 }
789 break;
790
791 case WM_COMMAND:
792 {
793 switch (LOWORD(wParam))
794 {
795 case IDC_NUMDECIMALSEP_COMBO:
796 case IDC_NUMFRACSYBMS_COMBO:
797 case IDC_NUMFIELDSEP_COMBO:
798 case IDC_NUMDIGFIELD_COMBO:
799 case IDC_NUMNEGSIGN_COMBO:
800 case IDC_NUMNEGFMT_COMBO:
801 case IDC_NUMLEADZERO_COMBO:
802 case IDC_NUMELEMLISTSEP_COMBO:
803 case IDC_NUMUNITSSYS_COMBO:
804 case IDC_NUMREGDIG_COMBO:
805 case IDC_NUMDIGREPL_COMBO:
806 {
807 if (HIWORD(wParam) == CBN_SELCHANGE ||
808 HIWORD(wParam) == CBN_EDITCHANGE)
809 {
810 /* Set "Apply" button enabled */
811 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
812 }
813 }
814 break;
815 }
816 }
817 break;
818
819 case WM_NOTIFY:
820 {
821 LPNMHDR lpnm = (LPNMHDR)lParam;
822 /* If push apply button */
823 if (lpnm->code == (UINT)PSN_APPLY)
824 {
825 if(!SetNumDecimalSep(hwndDlg)) break;
826 if(!SetFracSymNum(hwndDlg)) break;
827 if(!SetNumFieldSep(hwndDlg)) break;
828 if(!SetFieldDigNum(hwndDlg)) break;
829 if(!SetNumNegSign(hwndDlg)) break;
830 if(!SetNegSumFmt(hwndDlg)) break;
831 if(!SetNumLeadZero(hwndDlg)) break;
832 if(!SetNumListSep(hwndDlg)) break;
833 if(!SetNumUnitsSys(hwndDlg)) break;
834
835 /* Update sum format combo boxes */
836 InitLeadingZeroesCB(hwndDlg);
837 InitNegNumFmtCB(hwndDlg);
838
839 /* FIXME: */
840 _sleep(15);
841 /* Update sum format samples */
842 UpdateNumSamples(hwndDlg, LOCALE_USER_DEFAULT);
843 }
844 }
845 break;
846 }
847 return FALSE;
848 }
849
850
851 /* EOF */