]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2000, Red Hat, Inc. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by DJ Delorie <dj@cygnus.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | /* The purpose of this file is to provide common functionality for | |
17 | all the dialogs in the program. */ | |
18 | ||
19 | #include "win32.h" | |
20 | #include <stdio.h> | |
21 | #include <stdlib.h> | |
22 | #include "dialog.h" | |
23 | #include "LogFile.h" | |
24 | #include "mount.h" | |
25 | ||
26 | char * | |
27 | eget (HWND h, int id, char *var) | |
28 | { | |
29 | char tmp[4000]; | |
30 | if (var && var != get_root_dir ().c_str()) | |
31 | { | |
32 | delete [] var; | |
33 | var = NULL; | |
34 | } | |
35 | if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0) | |
36 | { | |
37 | var = new char [strlen (tmp) + 1]; | |
38 | var [strlen (tmp)] = '\0'; | |
39 | strcpy (var, tmp); | |
40 | } | |
41 | return var; | |
42 | } | |
43 | ||
44 | std::string | |
45 | egetString (HWND h, int id) | |
46 | { | |
47 | std::string aString; | |
48 | char tmp[4000]; | |
49 | if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0) | |
50 | aString = std::string (tmp); | |
51 | return aString; | |
52 | } | |
53 | ||
54 | int | |
55 | eget (HWND h, int id) | |
56 | { | |
57 | BOOL s; | |
58 | int r = GetDlgItemInt (h, id, &s, TRUE); | |
59 | return r; | |
60 | } | |
61 | ||
62 | void | |
63 | eset (HWND h, int id, const char *val) | |
64 | { | |
65 | SetDlgItemText (h, id, val); | |
66 | } | |
67 | ||
68 | void | |
69 | eset (HWND h, int id, const std::string aString) | |
70 | { | |
71 | SetDlgItemText (h, id, aString.c_str()); | |
72 | } | |
73 | ||
74 | void | |
75 | eset (HWND h, int id, const std::wstring &aString) | |
76 | { | |
77 | SetDlgItemTextW (h, id, aString.c_str()); | |
78 | } | |
79 | ||
80 | void | |
81 | eset (HWND h, int id, int val) | |
82 | { | |
83 | SetDlgItemInt (h, id, (UINT) val, TRUE); | |
84 | } | |
85 | ||
86 | int | |
87 | rbget (HWND h, int *ids) | |
88 | { | |
89 | int i; | |
90 | for (i = 0; ids[i]; i++) | |
91 | if (IsDlgButtonChecked (h, ids[i]) == BST_CHECKED) | |
92 | return ids[i]; | |
93 | return 0; | |
94 | } | |
95 | ||
96 | void | |
97 | rbset (HWND h, int *ids, int id) | |
98 | { | |
99 | int i; | |
100 | for (i = 0; ids[i]; i++) | |
101 | CheckDlgButton (h, ids[i], id == ids[i] ? BST_CHECKED : BST_UNCHECKED); | |
102 | } |