Drop setting root_scope as a side-effect of read_mounts()
[cygwin-setup.git] / dialog.cc
blob2ca57df8fff7b5557f84707ebd5f7e05ce03301a
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
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.
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
12 * Written by DJ Delorie <dj@cygnus.com>
16 /* The purpose of this file is to provide common functionality for
17 all the dialogs in the program. */
19 #include "win32.h"
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include "dialog.h"
23 #include "LogFile.h"
24 #include "mount.h"
26 char *
27 eget (HWND h, int id, char *var)
29 char tmp[4000];
30 if (var && var != get_root_dir ().c_str())
32 delete [] var;
33 var = NULL;
35 if (GetDlgItemText (h, id, tmp, sizeof (tmp)) > 0)
37 var = new char [strlen (tmp) + 1];
38 var [strlen (tmp)] = '\0';
39 strcpy (var, tmp);
41 return var;
44 std::string
45 egetString (HWND h, int id)
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;
54 int
55 eget (HWND h, int id)
57 BOOL s;
58 int r = GetDlgItemInt (h, id, &s, TRUE);
59 return r;
62 void
63 eset (HWND h, int id, const char *val)
65 SetDlgItemText (h, id, val);
68 void
69 eset (HWND h, int id, const std::string aString)
71 SetDlgItemText (h, id, aString.c_str());
74 void
75 eset (HWND h, int id, const std::wstring &aString)
77 SetDlgItemTextW (h, id, aString.c_str());
80 void
81 eset (HWND h, int id, int val)
83 SetDlgItemInt (h, id, (UINT) val, TRUE);
86 int
87 rbget (HWND h, int *ids)
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;
96 void
97 rbset (HWND h, int *ids, int id)
99 int i;
100 for (i = 0; ids[i]; i++)
101 CheckDlgButton (h, ids[i], id == ids[i] ? BST_CHECKED : BST_UNCHECKED);