/
Dialog.h
353 lines (320 loc) · 13.8 KB
/
Dialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*
* Copyright (C) 2005-2013 Team XBMC
* http://www.xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#include <vector>
#include "WindowException.h"
#include "AddonClass.h"
#include "AddonString.h"
#include "ApplicationMessenger.h"
#include "dialogs/GUIDialogProgress.h"
#include "dialogs/GUIDialogExtendedProgressBar.h"
#include "Alternative.h"
namespace XBMCAddon
{
namespace xbmcgui
{
/**
* Dialog class (Duh!)
*/
class Dialog : public AddonClass
{
public:
Dialog() : AddonClass("Dialog") {}
virtual ~Dialog();
/**
* yesno(heading, line1[, line2, line3]) -- Show a dialog 'YES/NO'.
*
* heading : string or unicode - dialog heading.
* line1 : string or unicode - line #1 text.
* line2 : [opt] string or unicode - line #2 text.
* line3 : [opt] string or unicode - line #3 text.
* nolabel : [opt] label to put on the no button.
* yeslabel : [opt] label to put on the yes button.
*
* *Note, Returns True if 'Yes' was pressed, else False.
*
* example:
* - dialog = xbmcgui.Dialog()
* - ret = dialog.yesno('XBMC', 'Do you want to exit this script?')\n
*/
bool yesno(const String& heading, const String& line1,
const String& line2 = emptyString,
const String& line3 = emptyString,
const String& nolabel = emptyString,
const String& yeslabel = emptyString) throw (WindowException);
/**
* select(heading, list) -- Show a select dialog.
*
* heading : string or unicode - dialog heading.
* list : string list - list of items.
* autoclose : [opt] integer - milliseconds to autoclose dialog. (default=do not autoclose)
*
* *Note, Returns the position of the highlighted item as an integer.
*
* example:
* - dialog = xbmcgui.Dialog()
* - ret = dialog.select('Choose a playlist', ['Playlist #1', 'Playlist #2, 'Playlist #3'])\n
*/
int select(const String& heading, const std::vector<String>& list, int autoclose=0) throw (WindowException);
/**
* ok(heading, line1[, line2, line3]) -- Show a dialog 'OK'.
*
* heading : string or unicode - dialog heading.
* line1 : string or unicode - line #1 text.
* line2 : [opt] string or unicode - line #2 text.
* line3 : [opt] string or unicode - line #3 text.
*
* *Note, Returns True if 'Ok' was pressed, else False.
*
* example:
* - dialog = xbmcgui.Dialog()
* - ok = dialog.ok('XBMC', 'There was an error.')\n
*/
bool ok(const String& heading, const String& line1,
const String& line2 = emptyString,
const String& line3 = emptyString) throw (WindowException);
/**
* browse(type, heading, shares[, mask, useThumbs, treatAsFolder, default, enableMultiple]) -- Show a 'Browse' dialog.
*
* type : integer - the type of browse dialog.
* heading : string or unicode - dialog heading.
* shares : string or unicode - from sources.xml. (i.e. 'myprograms')
* mask : [opt] string or unicode - '|' separated file mask. (i.e. '.jpg|.png')
* useThumbs : [opt] boolean - if True autoswitch to Thumb view if files exist.
* treatAsFolder : [opt] boolean - if True playlists and archives act as folders.
* default : [opt] string - default path or file.
*
* enableMultiple : [opt] boolean - if True multiple file selection is enabled.
* Types:
* 0 : ShowAndGetDirectory
* 1 : ShowAndGetFile
* 2 : ShowAndGetImage
* 3 : ShowAndGetWriteableDirectory
*
* *Note, If enableMultiple is False (default): returns filename and/or path as a string
* to the location of the highlighted item, if user pressed 'Ok' or a masked item
* was selected. Returns the default value if dialog was canceled.
* If enableMultiple is True: returns tuple of marked filenames as a strin
* if user pressed 'Ok' or a masked item was selected. Returns empty tuple if dialog was canceled.
*
* If type is 0 or 3 the enableMultiple parameter is ignore
*
* example:
* - dialog = xbmcgui.Dialog()
* - fn = dialog.browse(3, 'XBMC', 'files', '', False, False, False, 'special://masterprofile/script_data/XBMC Lyrics')
*/
Alternative<String, std::vector<String> > browse(int type, const String& heading, const String& s_shares,
const String& mask = emptyString, bool useThumbs = false,
bool treatAsFolder = false, const String& defaultt = emptyString,
bool enableMultiple = false) throw (WindowException);
/**
* browse(type, heading, shares[, mask, useThumbs, treatAsFolder, default]) -- Show a 'Browse' dialog.
*
* type : integer - the type of browse dialog.
* heading : string or unicode - dialog heading.
* shares : string or unicode - from sources.xml. (i.e. 'myprograms')
* mask : [opt] string or unicode - '|' separated file mask. (i.e. '.jpg|.png')
* useThumbs : [opt] boolean - if True autoswitch to Thumb view if files exist (default=false).
* treatAsFolder : [opt] boolean - if True playlists and archives act as folders (default=false).
* default : [opt] string - default path or file.
*
* Types:
* 0 : ShowAndGetDirectory
* 1 : ShowAndGetFile
* 2 : ShowAndGetImage
* 3 : ShowAndGetWriteableDirectory
*
* *Note, Returns filename and/or path as a string to the location of the highlighted item,
* if user pressed 'Ok' or a masked item was selected.
* Returns the default value if dialog was canceled.
*
* example:
* - dialog = xbmcgui.Dialog()
* - fn = dialog.browse(3, 'XBMC', 'files', '', False, False, 'special://masterprofile/script_data/XBMC Lyrics')\n
*/
String browseSingle(int type, const String& heading, const String& shares,
const String& mask = emptyString, bool useThumbs = false,
bool treatAsFolder = false,
const String& defaultt = emptyString ) throw (WindowException);
/**
* browse(type, heading, shares[, mask, useThumbs, treatAsFolder, default]) -- Show a 'Browse' dialog.
*
* type : integer - the type of browse dialog.
* heading : string or unicode - dialog heading.
* shares : string or unicode - from sources.xml. (i.e. 'myprograms')
* mask : [opt] string or unicode - '|' separated file mask. (i.e. '.jpg|.png')
* useThumbs : [opt] boolean - if True autoswitch to Thumb view if files exist (default=false).
* treatAsFolder : [opt] boolean - if True playlists and archives act as folders (default=false).
* default : [opt] string - default path or file.
*
* Types:
* 1 : ShowAndGetFile
* 2 : ShowAndGetImage
*
* *Note,
* returns tuple of marked filenames as a string,"
* if user pressed 'Ok' or a masked item was selected. Returns empty tuple if dialog was canceled.
*
* example:
* - dialog = xbmcgui.Dialog()
* - fn = dialog.browseMultiple(2, 'XBMC', 'files', '', False, False, 'special://masterprofile/script_data/XBMC Lyrics')\n
*/
std::vector<String> browseMultiple(int type, const String& heading, const String& shares,
const String& mask = emptyString, bool useThumbs = false,
bool treatAsFolder = false,
const String& defaultt = emptyString ) throw (WindowException);
/**
* numeric(type, heading[, default]) -- Show a 'Numeric' dialog.
*
* type : integer - the type of numeric dialog.
* heading : string or unicode - dialog heading.
* default : [opt] string - default value.
*
* Types:
* 0 : ShowAndGetNumber (default format: #)
* 1 : ShowAndGetDate (default format: DD/MM/YYYY)
* 2 : ShowAndGetTime (default format: HH:MM)
* 3 : ShowAndGetIPAddress (default format: #.#.#.#)
*
* *Note, Returns the entered data as a string.
* Returns the default value if dialog was canceled.
*
* example:
* - dialog = xbmcgui.Dialog()
* - d = dialog.numeric(1, 'Enter date of birth')\n
*/
String numeric(int type, const String& heading, const String& defaultt = emptyString);
};
/**
* DialogProgress class (Duh!)
*/
class DialogProgress : public AddonClass
{
CGUIDialogProgress* dlg;
protected:
virtual void deallocating();
public:
DialogProgress() : AddonClass("DialogProgress"), dlg(NULL) {}
virtual ~DialogProgress();
/**
* create(heading[, line1, line2, line3]) -- Create and show a progress dialog.
*
* heading : string or unicode - dialog heading.
* line1 : [opt] string or unicode - line #1 text.
* line2 : [opt] string or unicode - line #2 text.
* line3 : [opt] string or unicode - line #3 text.
*
* *Note, Use update() to update lines and progressbar.
*
* example:
* - pDialog = xbmcgui.DialogProgress()
* - pDialog.create('XBMC', 'Initializing script...')
*/
void create(const String& heading, const String& line1 = emptyString,
const String& line2 = emptyString,
const String& line3 = emptyString) throw (WindowException);
/**
* update(percent[, line1, line2, line3]) -- Update's the progress dialog.
*
* percent : integer - percent complete. (0:100)
* line1 : [opt] string or unicode - line #1 text.
* line2 : [opt] string or unicode - line #2 text.
* line3 : [opt] string or unicode - line #3 text.
*
* *Note, If percent == 0, the progressbar will be hidden.
*
* example:
* - pDialog.update(25, 'Importing modules...')
*/
void update(int percent, const String& line1 = emptyString,
const String& line2 = emptyString,
const String& line3 = emptyString) throw (WindowException);
/**
* close() -- Close the progress dialog.
*
* example:
* - pDialog.close()
*/
void close();
/**
* iscanceled() -- Returns True if the user pressed cancel.
*
* example:
* - if (pDialog.iscanceled()): return
*/
bool iscanceled();
};
/**
* DialogProgressBG class
*/
class DialogProgressBG : public AddonClass
{
CGUIDialogExtendedProgressBar* dlg;
CGUIDialogProgressBarHandle* handle;
protected:
virtual void deallocating();
public:
DialogProgressBG() : AddonClass("DialogProgressBG"), dlg(NULL), handle(NULL) {}
virtual ~DialogProgressBG();
/**
* create(heading[, message]) -- Create and show a background progress dialog.\n
*\n
* heading : string or unicode - dialog heading\n
* message : [opt] string or unicode - message text\n
*\n
* *Note, 'heading' is used for the dialog's id. Use a unique heading.\n
* Use update() to update heading, message and progressbar.\n
*\n
* example:\n
* - pDialog = xbmcgui.DialogProgressBG()\n
* - pDialog.create('Movie Trailers', 'Downloading Monsters Inc. ...')\n
*/
void create(const String& heading, const String& message = emptyString) throw (WindowException);
/**
* update([percent, heading, message]) -- Updates the background progress dialog.\n
*\n
* percent : [opt] integer - percent complete. (0:100)\n
* heading : [opt] string or unicode - dialog heading\n
* message : [opt] string or unicode - message text\n
*\n
* *Note, To clear heading or message, you must pass a blank character.\n
*\n
* example:\n
* - pDialog.update(25, message='Downloading Finding Nemo ...')\n
*/
void update(int percent = 0, const String& heading = emptyString, const String& message = emptyString) throw (WindowException);
/**
* close() -- Close the background progress dialog\n
*\n
* example:\n
* - pDialog.close()\n
*/
void close();
/**
* isFinished() -- Returns True if the background dialog is active.\n
*\n
* example:\n
* - if (pDialog.isFinished()): return\n
*/
bool isFinished();
};
}
}