1 |
dpavlin |
1 |
/* |
2 |
|
|
* PearPC |
3 |
|
|
* gui.cc |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License version 2 as |
9 |
|
|
* published by the Free Software Foundation. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include <cstdlib> |
22 |
|
|
|
23 |
|
|
#include "system/ui/gui.h" |
24 |
|
|
|
25 |
|
|
#define WIN32_LEAN_AND_MEAN |
26 |
|
|
#include <windows.h> |
27 |
|
|
#include <windowsx.h> |
28 |
|
|
#include <commdlg.h> |
29 |
|
|
|
30 |
|
|
void sys_gui_init() |
31 |
|
|
{ |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing) |
35 |
|
|
{ |
36 |
|
|
char *filename = (char*)malloc(1024); |
37 |
|
|
filename[0] = 0; |
38 |
|
|
OPENFILENAME ofn; |
39 |
|
|
ofn.lStructSize = sizeof ofn; |
40 |
|
|
// ofn.hwndOwner = hwndDlg; |
41 |
|
|
ofn.hwndOwner = NULL; |
42 |
|
|
ofn.hInstance = 0; |
43 |
|
|
String filter(filespecname); |
44 |
|
|
filter.appendChar(0); |
45 |
|
|
filter += filespec; |
46 |
|
|
filter.appendChar(0); |
47 |
|
|
filter.appendChar(0); |
48 |
|
|
ofn.lpstrFilter = filter.contentChar(); |
49 |
|
|
ofn.lpstrCustomFilter = NULL; |
50 |
|
|
ofn.nMaxCustFilter = 0; |
51 |
|
|
ofn.nFilterIndex = 1; |
52 |
|
|
ofn.lpstrFile = filename; |
53 |
|
|
ofn.nMaxFile = 1024; |
54 |
|
|
ofn.lpstrFileTitle = NULL; |
55 |
|
|
ofn.nMaxFileTitle = 0; |
56 |
|
|
ofn.lpstrInitialDir = NULL; |
57 |
|
|
ofn.lpstrTitle = title.contentChar(); |
58 |
|
|
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | (existing ? OFN_FILEMUSTEXIST : 0); |
59 |
|
|
ofn.nFileOffset = 0; |
60 |
|
|
ofn.nFileExtension = 0; |
61 |
|
|
ofn.lpstrDefExt = NULL; |
62 |
|
|
ofn.lCustData = 0; |
63 |
|
|
ofn.lpfnHook = NULL; |
64 |
|
|
ofn.lpTemplateName = NULL; |
65 |
|
|
if (GetOpenFileName(&ofn)) { |
66 |
|
|
ret.assign(filename); |
67 |
|
|
free(filename); |
68 |
|
|
return true; |
69 |
|
|
} |
70 |
|
|
free(filename); |
71 |
|
|
return false; |
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
int sys_gui_messagebox(const String &title, const String &text, int buttons) |
75 |
|
|
{ |
76 |
|
|
|
77 |
|
|
} |