PageRenderTime 90ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/gecko_sdk/idl/nsIPromptService.idl

http://firefox-mac-pdf.googlecode.com/
IDL | 380 lines | 75 code | 19 blank | 286 comment | 0 complexity | 6b93a57e40f7e44c487cc65036a446e9 MD5 | raw file
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 2001
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #include "nsISupports.idl"
  38. interface nsIDOMWindow;
  39. /**
  40. * This is the interface to the embeddable prompt service; the service that
  41. * implements nsIPrompt. Its interface is designed to be just nsIPrompt, each
  42. * method modified to take a parent window parameter.
  43. *
  44. * Accesskeys can be attached to buttons and checkboxes by inserting an &
  45. * before the accesskey character in the checkbox message or button title. For
  46. * a real &, use && instead. (A "button title" generally refers to the text
  47. * label of a button.)
  48. *
  49. * One note: in all cases, the parent window parameter can be null. However,
  50. * these windows are all intended to have parents. So when no parent is
  51. * specified, the implementation should try hard to find a suitable foster
  52. * parent.
  53. *
  54. * Implementations are free to choose how they present the various button
  55. * types. For example, while prompts that give the user a choice between OK
  56. * and Cancel are required to return a boolean value indicating whether or not
  57. * the user accepted the prompt (pressed OK) or rejected the prompt (pressed
  58. * Cancel), the implementation of this interface could very well speak the
  59. * prompt to the user instead of rendering any visual user-interface. The
  60. * standard button types are merely idioms used to convey the nature of the
  61. * choice the user is to make.
  62. *
  63. * Because implementations of this interface may loosely interpret the various
  64. * button types, it is advised that text messages passed to these prompts do
  65. * not refer to the button types by name. For example, it is inadvisable to
  66. * tell the user to "Press OK to proceed." Instead, such a prompt might be
  67. * rewritten to ask the user: "Would you like to proceed?"
  68. *
  69. * @status FROZEN
  70. */
  71. [scriptable, uuid(1630C61A-325E-49ca-8759-A31B16C47AA5)]
  72. interface nsIPromptService : nsISupports
  73. {
  74. /**
  75. * Puts up an alert dialog with an OK button.
  76. *
  77. * @param aParent
  78. * The parent window or null.
  79. * @param aDialogTitle
  80. * Text to appear in the title of the dialog.
  81. * @param aText
  82. * Text to appear in the body of the dialog.
  83. */
  84. void alert(in nsIDOMWindow aParent,
  85. in wstring aDialogTitle,
  86. in wstring aText);
  87. /**
  88. * Puts up an alert dialog with an OK button and a labeled checkbox.
  89. *
  90. * @param aParent
  91. * The parent window or null.
  92. * @param aDialogTitle
  93. * Text to appear in the title of the dialog.
  94. * @param aText
  95. * Text to appear in the body of the dialog.
  96. * @param aCheckMsg
  97. * Text to appear with the checkbox.
  98. * @param aCheckState
  99. * Contains the initial checked state of the checkbox when this method
  100. * is called and the final checked state after this method returns.
  101. */
  102. void alertCheck(in nsIDOMWindow aParent,
  103. in wstring aDialogTitle,
  104. in wstring aText,
  105. in wstring aCheckMsg,
  106. inout boolean aCheckState);
  107. /**
  108. * Puts up a dialog with OK and Cancel buttons.
  109. *
  110. * @param aParent
  111. * The parent window or null.
  112. * @param aDialogTitle
  113. * Text to appear in the title of the dialog.
  114. * @param aText
  115. * Text to appear in the body of the dialog.
  116. *
  117. * @return true for OK, false for Cancel
  118. */
  119. boolean confirm(in nsIDOMWindow aParent,
  120. in wstring aDialogTitle,
  121. in wstring aText);
  122. /**
  123. * Puts up a dialog with OK and Cancel buttons and a labeled checkbox.
  124. *
  125. * @param aParent
  126. * The parent window or null.
  127. * @param aDialogTitle
  128. * Text to appear in the title of the dialog.
  129. * @param aText
  130. * Text to appear in the body of the dialog.
  131. * @param aCheckMsg
  132. * Text to appear with the checkbox.
  133. * @param aCheckState
  134. * Contains the initial checked state of the checkbox when this method
  135. * is called and the final checked state after this method returns.
  136. *
  137. * @return true for OK, false for Cancel
  138. */
  139. boolean confirmCheck(in nsIDOMWindow aParent,
  140. in wstring aDialogTitle,
  141. in wstring aText,
  142. in wstring aCheckMsg,
  143. inout boolean aCheckState);
  144. /**
  145. * Button Flags
  146. *
  147. * The following flags are combined to form the aButtonFlags parameter passed
  148. * to confirmEx. See confirmEx for more information on how the flags may be
  149. * combined.
  150. */
  151. /**
  152. * Button Position Flags
  153. */
  154. const unsigned long BUTTON_POS_0 = 1;
  155. const unsigned long BUTTON_POS_1 = 1 << 8;
  156. const unsigned long BUTTON_POS_2 = 1 << 16;
  157. /**
  158. * Button Title Flags (used to set the labels of buttons in the prompt)
  159. */
  160. const unsigned long BUTTON_TITLE_OK = 1;
  161. const unsigned long BUTTON_TITLE_CANCEL = 2;
  162. const unsigned long BUTTON_TITLE_YES = 3;
  163. const unsigned long BUTTON_TITLE_NO = 4;
  164. const unsigned long BUTTON_TITLE_SAVE = 5;
  165. const unsigned long BUTTON_TITLE_DONT_SAVE = 6;
  166. const unsigned long BUTTON_TITLE_REVERT = 7;
  167. const unsigned long BUTTON_TITLE_IS_STRING = 127;
  168. /**
  169. * Button Default Flags (used to select which button is the default one)
  170. */
  171. const unsigned long BUTTON_POS_0_DEFAULT = 0;
  172. const unsigned long BUTTON_POS_1_DEFAULT = 1 << 24;
  173. const unsigned long BUTTON_POS_2_DEFAULT = 1 << 25;
  174. /**
  175. * Causes the buttons to be initially disabled. They are enabled after a
  176. * timeout expires. The implementation may interpret this loosely as the
  177. * intent is to ensure that the user does not click through a security dialog
  178. * too quickly. Strictly speaking, the implementation could choose to ignore
  179. * this flag.
  180. */
  181. const unsigned long BUTTON_DELAY_ENABLE = 1 << 26;
  182. /**
  183. * Selects the standard set of OK/Cancel buttons.
  184. */
  185. const unsigned long STD_OK_CANCEL_BUTTONS = (BUTTON_TITLE_OK * BUTTON_POS_0) +
  186. (BUTTON_TITLE_CANCEL * BUTTON_POS_1);
  187. /**
  188. * Selects the standard set of Yes/No buttons.
  189. */
  190. const unsigned long STD_YES_NO_BUTTONS = (BUTTON_TITLE_YES * BUTTON_POS_0) +
  191. (BUTTON_TITLE_NO * BUTTON_POS_1);
  192. /**
  193. * Puts up a dialog with up to 3 buttons and an optional, labeled checkbox.
  194. *
  195. * @param aParent
  196. * The parent window or null.
  197. * @param aDialogTitle
  198. * Text to appear in the title of the dialog.
  199. * @param aText
  200. * Text to appear in the body of the dialog.
  201. * @param aButtonFlags
  202. * A combination of Button Flags.
  203. * @param aButton0Title
  204. * Used when button 0 uses TITLE_IS_STRING
  205. * @param aButton1Title
  206. * Used when button 1 uses TITLE_IS_STRING
  207. * @param aButton2Title
  208. * Used when button 2 uses TITLE_IS_STRING
  209. * @param aCheckMsg
  210. * Text to appear with the checkbox. Null if no checkbox.
  211. * @param aCheckState
  212. * Contains the initial checked state of the checkbox when this method
  213. * is called and the final checked state after this method returns.
  214. *
  215. * @return index of the button pressed.
  216. *
  217. * Buttons are numbered 0 - 2. The implementation can decide whether the
  218. * sequence goes from right to left or left to right. Button 0 is the
  219. * default button unless one of the Button Default Flags is specified.
  220. *
  221. * A button may use a predefined title, specified by one of the Button Title
  222. * Flags values. Each title value can be multiplied by a position value to
  223. * assign the title to a particular button. If BUTTON_TITLE_IS_STRING is
  224. * used for a button, the string parameter for that button will be used. If
  225. * the value for a button position is zero, the button will not be shown.
  226. *
  227. * In general, aButtonFlags is constructed per the following example:
  228. *
  229. * aButtonFlags = (BUTTON_POS_0) * (BUTTON_TITLE_AAA) +
  230. * (BUTTON_POS_1) * (BUTTON_TITLE_BBB) +
  231. * BUTTON_POS_1_DEFAULT;
  232. *
  233. * where "AAA" and "BBB" correspond to one of the button titles.
  234. */
  235. PRInt32 confirmEx(in nsIDOMWindow aParent,
  236. in wstring aDialogTitle,
  237. in wstring aText,
  238. in unsigned long aButtonFlags,
  239. in wstring aButton0Title,
  240. in wstring aButton1Title,
  241. in wstring aButton2Title,
  242. in wstring aCheckMsg,
  243. inout boolean aCheckState);
  244. /**
  245. * Puts up a dialog with an edit field and an optional, labeled checkbox.
  246. *
  247. * @param aParent
  248. * The parent window or null.
  249. * @param aDialogTitle
  250. * Text to appear in the title of the dialog.
  251. * @param aText
  252. * Text to appear in the body of the dialog.
  253. * @param aValue
  254. * Contains the default value for the dialog field when this method
  255. * is called (null value is ok). Upon return, if the user pressed
  256. * OK, then this parameter contains a newly allocated string value.
  257. * Otherwise, the parameter's value is unmodified.
  258. * @param aCheckMsg
  259. * Text to appear with the checkbox. If null, check box will not be shown.
  260. * @param aCheckState
  261. * Contains the initial checked state of the checkbox when this method
  262. * is called and the final checked state after this method returns.
  263. *
  264. * @return true for OK, false for Cancel.
  265. */
  266. boolean prompt(in nsIDOMWindow aParent,
  267. in wstring aDialogTitle,
  268. in wstring aText,
  269. inout wstring aValue,
  270. in wstring aCheckMsg,
  271. inout boolean aCheckState);
  272. /**
  273. * Puts up a dialog with an edit field, a password field, and an optional,
  274. * labeled checkbox.
  275. *
  276. * @param aParent
  277. * The parent window or null.
  278. * @param aDialogTitle
  279. * Text to appear in the title of the dialog.
  280. * @param aText
  281. * Text to appear in the body of the dialog.
  282. * @param aUsername
  283. * Contains the default value for the username field when this method
  284. * is called (null value is ok). Upon return, if the user pressed OK,
  285. * then this parameter contains a newly allocated string value.
  286. * Otherwise, the parameter's value is unmodified.
  287. * @param aPassword
  288. * Contains the default value for the password field when this method
  289. * is called (null value is ok). Upon return, if the user pressed OK,
  290. * then this parameter contains a newly allocated string value.
  291. * Otherwise, the parameter's value is unmodified.
  292. * @param aCheckMsg
  293. * Text to appear with the checkbox. If null, check box will not be shown.
  294. * @param aCheckState
  295. * Contains the initial checked state of the checkbox when this method
  296. * is called and the final checked state after this method returns.
  297. *
  298. * @return true for OK, false for Cancel.
  299. */
  300. boolean promptUsernameAndPassword(in nsIDOMWindow aParent,
  301. in wstring aDialogTitle,
  302. in wstring aText,
  303. inout wstring aUsername,
  304. inout wstring aPassword,
  305. in wstring aCheckMsg,
  306. inout boolean aCheckState);
  307. /**
  308. * Puts up a dialog with a password field and an optional, labeled checkbox.
  309. *
  310. * @param aParent
  311. * The parent window or null.
  312. * @param aDialogTitle
  313. * Text to appear in the title of the dialog.
  314. * @param aText
  315. * Text to appear in the body of the dialog.
  316. * @param aPassword
  317. * Contains the default value for the password field when this method
  318. * is called (null value is ok). Upon return, if the user pressed OK,
  319. * then this parameter contains a newly allocated string value.
  320. * Otherwise, the parameter's value is unmodified.
  321. * @param aCheckMsg
  322. * Text to appear with the checkbox. If null, check box will not be shown.
  323. * @param aCheckState
  324. * Contains the initial checked state of the checkbox when this method
  325. * is called and the final checked state after this method returns.
  326. *
  327. * @return true for OK, false for Cancel.
  328. */
  329. boolean promptPassword(in nsIDOMWindow aParent,
  330. in wstring aDialogTitle,
  331. in wstring aText,
  332. inout wstring aPassword,
  333. in wstring aCheckMsg,
  334. inout boolean aCheckState);
  335. /**
  336. * Puts up a dialog box which has a list box of strings from which the user
  337. * may make a single selection.
  338. *
  339. * @param aParent
  340. * The parent window or null.
  341. * @param aDialogTitle
  342. * Text to appear in the title of the dialog.
  343. * @param aText
  344. * Text to appear in the body of the dialog.
  345. * @param aCount
  346. * The length of the aSelectList array parameter.
  347. * @param aSelectList
  348. * The list of strings to display.
  349. * @param aOutSelection
  350. * Contains the index of the selected item in the list when this
  351. * method returns true.
  352. *
  353. * @return true for OK, false for Cancel.
  354. */
  355. boolean select(in nsIDOMWindow aParent,
  356. in wstring aDialogTitle,
  357. in wstring aText,
  358. in PRUint32 aCount,
  359. [array, size_is(aCount)] in wstring aSelectList,
  360. out long aOutSelection);
  361. };