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: Application.h 23 // Author: Erik Jaesler (erik@cgsoftware.com) 24 // Description: BApplication class is the center of the application 25 // universe. The global be_app and be_app_messenger 26 // variables are defined here as well. 27 //------------------------------------------------------------------------------ 28 29 #ifndef _APPLICATION_H 30 #define _APPLICATION_H 31 32 // Standard Includes ----------------------------------------------------------- 33 34 // System Includes ------------------------------------------------------------- 35 #include <BeBuild.h> 36 #include <AppDefs.h> // For convenience 37 #include <InterfaceDefs.h> 38 #include <Looper.h> 39 #include <Messenger.h> 40 #include <Point.h> 41 #include <Rect.h> 42 43 // Project Includes ------------------------------------------------------------ 44 45 // Local Includes -------------------------------------------------------------- 46 47 // Local Defines --------------------------------------------------------------- 48 49 // Globals --------------------------------------------------------------------- 50 51 class BCursor; 52 class BList; 53 class BWindow; 54 class _BSession_; 55 class BResources; 56 class BMessageRunner; 57 struct _server_heap_; 58 struct _drag_data_; 59 namespace BPrivate { class BAppServerLink; } 60 61 62 // BApplication class ---------------------------------------------------------- 63 class BApplication : public BLooper { 64 65 public: 66 BApplication(const char* signature); 67 BApplication(const char* signature, 68 status_t* error); 69 virtual ~BApplication(); 70 71 // Archiving 72 BApplication(BMessage* data); 73 static BArchivable* Instantiate(BMessage* data); 74 virtual status_t Archive(BMessage* data, bool deep = true) const; 75 76 status_t InitCheck() const; 77 78 // App control and System Message handling 79 virtual thread_id Run(); 80 virtual void Quit(); 81 virtual bool QuitRequested(); 82 virtual void Pulse(); 83 virtual void ReadyToRun(); 84 virtual void MessageReceived(BMessage* msg); 85 virtual void ArgvReceived(int32 argc, char** argv); 86 virtual void AppActivated(bool active); 87 virtual void RefsReceived(BMessage* message); 88 virtual void AboutRequested(); 89 90 // Scripting 91 virtual BHandler* ResolveSpecifier(BMessage* msg, 92 int32 index, 93 BMessage* specifier, 94 int32 form, 95 const char* property); 96 97 // Cursor control, window/looper list, and app info 98 void ShowCursor(); 99 void HideCursor(); 100 void ObscureCursor(); 101 bool IsCursorHidden() const; 102 void SetCursor(const void* cursor); 103 void SetCursor(const BCursor* cursor, bool sync = true); 104 int32 CountWindows() const; 105 BWindow* WindowAt(int32 index) const; 106 int32 CountLoopers() const; 107 BLooper* LooperAt(int32 index) const; 108 bool IsLaunching() const; 109 status_t GetAppInfo(app_info* info) const; 110 static BResources* AppResources(); 111 112 virtual void DispatchMessage(BMessage* message, 113 BHandler* handler); 114 void SetPulseRate(bigtime_t rate); 115 116 // More scripting 117 virtual status_t GetSupportedSuites(BMessage* data); 118 119 120 // Private or reserved --------------------------------------------------------- 121 virtual status_t Perform(perform_code d, void* arg); 122 123 private: 124 125 typedef BLooper _inherited; 126 127 friend class BWindow; 128 friend class BView; 129 friend class BBitmap; 130 friend class BScrollBar; 131 friend class BPrivateScreen; 132 friend class BPrivate::BAppServerLink; 133 friend void _toggle_handles_(bool); 134 135 BApplication(uint32 signature); 136 BApplication(const BApplication&); 137 BApplication& operator=(const BApplication&); 138 139 virtual void _ReservedApplication1(); 140 virtual void _ReservedApplication2(); 141 virtual void _ReservedApplication3(); 142 virtual void _ReservedApplication4(); 143 virtual void _ReservedApplication5(); 144 virtual void _ReservedApplication6(); 145 virtual void _ReservedApplication7(); 146 virtual void _ReservedApplication8(); 147 148 virtual bool ScriptReceived(BMessage* msg, 149 int32 index, 150 BMessage* specifier, 151 int32 form, 152 const char* property); 153 void run_task(); 154 void InitData(const char* signature, status_t* error); 155 void BeginRectTracking(BRect r, bool trackWhole); 156 void EndRectTracking(); 157 void get_scs(); 158 void setup_server_heaps(); 159 void* rw_offs_to_ptr(uint32 offset); 160 void* ro_offs_to_ptr(uint32 offset); 161 void* global_ro_offs_to_ptr(uint32 offset); 162 void connect_to_app_server(); 163 void send_drag( BMessage* msg, 164 int32 vs_token, 165 BPoint offset, 166 BRect drag_rect, 167 BHandler* reply_to); 168 void send_drag( BMessage* msg, 169 int32 vs_token, 170 BPoint offset, 171 int32 bitmap_token, 172 drawing_mode dragMode, 173 BHandler* reply_to); 174 void write_drag(_BSession_* session, BMessage* a_message); 175 bool quit_all_windows(bool force); 176 bool window_quit_loop(bool, bool); 177 void do_argv(BMessage* msg); 178 #ifndef FIX_FOR_4_6 179 void SetAppCursor(); 180 #endif 181 uint32 InitialWorkspace(); 182 int32 count_windows(bool incl_menus) const; 183 BWindow* window_at(uint32 index, bool incl_menus) const; 184 status_t get_window_list(BList* list, bool incl_menus) const; 185 static int32 async_quit_entry(void*); 186 static BResources* _app_resources; 187 static BLocker _app_resources_lock; 188 189 const char* fAppName; 190 int32 fServerFrom; 191 int32 fServerTo; 192 #ifndef FIX_FOR_4_6 193 void* fCursorData; 194 #else 195 void* _unused1; 196 #endif 197 _server_heap_* fServerHeap; 198 bigtime_t fPulseRate; 199 uint32 fInitialWorkspace; 200 _drag_data_* fDraggedMessage; 201 BMessageRunner* fPulseRunner; 202 status_t fInitError; 203 uint32 _reserved[11]; 204 205 bool fReadyToRunCalled; 206 }; 207 //------------------------------------------------------------------------------ 208 209 210 // Global Objects -------------------------------------------------------------- 211 212 extern _IMPEXP_BE BApplication* be_app; 213 extern _IMPEXP_BE BMessenger be_app_messenger; 214 215 //------------------------------------------------------------------------------ 216 217 #endif // _APPLICATION_H 218 219 /* 220 * $Log $ 221 * 222 * $Id $ 223 * 224 */ 225 226