InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CAlert.h
1 //========================================================================================
2 //
3 // $File$
4 //
5 // Owner: Tom Taylor
6 //
7 // $Author$
8 //
9 // $DateTime$
10 //
11 // $Revision$
12 //
13 // $Change$
14 //
15 // Copyright 1997-2010 Adobe Systems Incorporated. All rights reserved.
16 //
17 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
18 // with the terms of the Adobe license agreement accompanying it. If you have received
19 // this file from a source other than Adobe, then your use, modification, or
20 // distribution of it requires the prior written permission of Adobe.
21 //
22 //========================================================================================
23 
24 #ifndef __CAlert__
25 #define __CAlert__
26 
27 #include "PMString.h"
28 #include "UIDRef.h"
29 
30 
31 // Common Default String Constants (Don't worry, these get automatically translated)
32 
33 #define kOKString "OK"
34 #define kCancelString "Cancel"
35 #define kYesString "Yes"
36 #define kNoString "No"
37 
38 #define kNotManaged -1
39 
40 #ifdef MACINTOSH
41 #define kSaveButtonString "Save"
42 #define kDontSaveButtonString "Don't Save"
43 #else
44 #define kSaveButtonString kYesString
45 #define kDontSaveButtonString kNoString
46 #endif
47 
48 class AlertImplementation;
49 
52 class CAlert
53 {
54 public:
55  // ----- CAlerts -----
56 
57  // These functions are truly modal CAlerts. When one of these CAlert
58  // function is called, an CAlert is displayed and control isn't returned
59  // to the caller until the user dismisses the CAlert.
60 
64  static void Initialize(AlertImplementation* alertImpl);
65 
70  static void InformationAlert(const PMString& message);
71  static void InformationAlert(const PMString& message, const UIDRef& target, ErrorCode errorCode);
72 
77  static void WarningAlert(const PMString& message);
78  static void WarningAlert(const PMString& message, const UIDRef& target, ErrorCode errorCode);
79 
84  static void ErrorAlert(const PMString& message);
85  static void ErrorAlert(const PMString& message, const UIDRef& target, ErrorCode errorCode);
86 
87  // ----- Flexible Alert Function -----
88 
89  typedef enum { eNoIcon, eInformationIcon, eWarningIcon, eErrorIcon, eQuestionIcon } eAlertIcon;
90 
130  static int16 ModalAlert( const PMString& message,
131  const PMString& button1String,
132  const PMString& button2String,
133  const PMString& button3String,
134  int16 defaultButton,
135  int16 iconID
136  );
137 
138 
145  static int16 ModalAlert( const PMString& message,
146  const PMString& button1String,
147  const PMString& button2String,
148  const PMString& button3String,
149  int16 defaultButton,
150  int16 iconID,
151  const UIDRef& target,
152  const ErrorCode errorCode
153  );
154 
155 
156 
183  static int16 WarningAlertWithDontShowAgain(const PMString& message,
184  int32 dontShowID,
185  bool8 bShowCancelButton = kFalse,
186  int32 iconID = eWarningIcon,
187  const PMString& title = kNullString,
188  const PMString& strOK = kNullString,
189  const PMString& strCancel = kNullString,
190  const int16 returnValueIfHidden = 1 // OK
191  );
192 
207  static int16 AlertWithApplyToAll(bool16 *applyAllState, // pass the initial state, and get the result of the applyall checkbox
208  const PMString& message,
209  const PMString& Button1Str = kNullString,
210  const PMString& Button2Str = kNullString,
211  const PMString& Button3Str = kNullString,
212  const PMString& title = kNullString,
213  int32 iconID = eWarningIcon
214  );
215 
224  static void SetShowAlerts(bool16 showAlerts);
225 
228  static bool16 GetShowAlerts();
229 
235  static bool16 GetShowModalStartupUI( );
236 
239  static bool16 GetIsAlertShown();
240 
243  static void SetLastEventCausedAlert(bool16);
244 
247  static bool16 LastEventCausedAlert();
248 
249 
253  static void StartupErrorAlert(const PMString& message);
254 
257  static void StartupWarningAlert(const PMString& message);
258 
259  // There were only two clients of the old StartupModalAlert and the API is too complex to support
260  // given that all they needed were Yes/No and Yes/No/Cancel.
261 
271  enum { eOKOnly, eYesNo, eOKCancel, eYesNoCancel } eStartupAlertButtonConfig;
272 
273  static int16 StartupModalAlert( const PMString& message,
274  int16 buttonConfig = eOKOnly,
275  int16 defaultButton = 1,
276  int16 iconID = eWarningIcon
277  );
278 
279 
285  static void SetIgnoreRefreshEvent(bool16 val);
286 
289  static bool16 GetIgnoreRefreshEvent();
290 public:
291  static IDThreading::ThreadLocal<bool16> tl_AlertShown;
292 private:
293  static IDThreading::ThreadLocal<bool16> tl_ShowAlerts;
294  static IDThreading::ThreadLocal<bool16> tl_LastEventCausedAlert;
295  static bool16 ts_ShowModalStartupUICookie;
296  static bool16 ts_ShowModalStartupUI;
297  static IDThreading::ThreadLocal<bool16> tl_IgnoreRefreshEvent;
298  static AlertImplementation* ts_AlertImpl;
299 
300 };
301 
302 
303 #endif