1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: Alert.h 23 // Author: Erik Jaesler (erik@cgsoftware.com) 24 // Description: BAlert displays a modal alert window. 25 //------------------------------------------------------------------------------ 26 27 #ifndef _ALERT_H 28 #define _ALERT_H 29 30 // Standard Includes ----------------------------------------------------------- 31 32 // System Includes ------------------------------------------------------------- 33 #include <BeBuild.h> 34 #include <Window.h> 35 36 // Project Includes ------------------------------------------------------------ 37 38 // Local Includes -------------------------------------------------------------- 39 40 // Local Defines --------------------------------------------------------------- 41 42 // Globals --------------------------------------------------------------------- 43 44 class BBitmap; 45 class BButton; 46 class BInvoker; 47 class BTextView; 48 49 // enum for flavors of alert --------------------------------------------------- 50 enum alert_type { 51 B_EMPTY_ALERT = 0, 52 B_INFO_ALERT, 53 B_IDEA_ALERT, 54 B_WARNING_ALERT, 55 B_STOP_ALERT 56 }; 57 58 59 enum button_spacing { 60 B_EVEN_SPACING = 0, 61 B_OFFSET_SPACING 62 }; 63 64 // BAlert class ---------------------------------------------------------------- 65 class BAlert : public BWindow 66 { 67 public: 68 69 BAlert( const char *title, 70 const char *text, 71 const char *button1, 72 const char *button2 = NULL, 73 const char *button3 = NULL, 74 button_width width = B_WIDTH_AS_USUAL, 75 alert_type type = B_INFO_ALERT); 76 BAlert( const char *title, 77 const char *text, 78 const char *button1, 79 const char *button2, 80 const char *button3, 81 button_width width, 82 button_spacing spacing, 83 alert_type type = B_INFO_ALERT); 84 virtual ~BAlert(); 85 86 // Archiving 87 BAlert(BMessage *data); 88 static BArchivable *Instantiate(BMessage *data); 89 virtual status_t Archive(BMessage *data, bool deep = true) const; 90 91 // BAlert guts 92 void SetShortcut(int32 button_index, char key); 93 char Shortcut(int32 button_index) const; 94 95 int32 Go(); 96 status_t Go(BInvoker *invoker); 97 98 virtual void MessageReceived(BMessage *an_event); 99 virtual void FrameResized(float new_width, float new_height); 100 BButton *ButtonAt(int32 index) const; 101 BTextView *TextView() const; 102 103 virtual BHandler *ResolveSpecifier(BMessage *msg, 104 int32 index, 105 BMessage *specifier, 106 int32 form, 107 const char *property); 108 virtual status_t GetSupportedSuites(BMessage *data); 109 110 virtual void DispatchMessage(BMessage *msg, BHandler *handler); 111 virtual void Quit(); 112 virtual bool QuitRequested(); 113 114 static BPoint AlertPosition(float width, float height); 115 116 // Private or reserved --------------------------------------------------------- 117 virtual status_t Perform(perform_code d, void *arg); 118 119 private: 120 friend class _BAlertFilter_; 121 122 virtual void _ReservedAlert1(); 123 virtual void _ReservedAlert2(); 124 virtual void _ReservedAlert3(); 125 126 void InitObject(const char *text, 127 const char *button1, 128 const char *button2 = NULL, 129 const char *button3 = NULL, 130 button_width width = B_WIDTH_AS_USUAL, 131 button_spacing spacing = B_EVEN_SPACING, 132 alert_type type = B_INFO_ALERT); 133 BBitmap *InitIcon(); 134 135 sem_id fAlertSem; 136 int32 fAlertVal; 137 BButton *fButtons[3]; 138 BTextView *fTextView; 139 char fKeys[3]; 140 alert_type fMsgType; 141 button_width fButtonWidth; 142 BInvoker *fInvoker; 143 uint32 _reserved[4]; 144 }; 145 //------------------------------------------------------------------------------ 146 147 #endif // _ALERT_H 148 149 /* 150 * $Log $ 151 * 152 * $Id $ 153 * 154 */ 155 156