1 /* 2 * Copyright 2001-2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Erik Jaesler (erik@cgsoftware.com) 7 */ 8 #ifndef _APPLICATION_H 9 #define _APPLICATION_H 10 11 12 #include <BeBuild.h> 13 #include <AppDefs.h> // For convenience 14 #include <InterfaceDefs.h> 15 #include <Looper.h> 16 #include <Messenger.h> 17 #include <Point.h> 18 #include <Rect.h> 19 20 21 class BCursor; 22 class BList; 23 class BWindow; 24 class BResources; 25 class BMessageRunner; 26 class BServer; 27 28 namespace BPrivate { 29 class PortLink; 30 class ServerMemoryAllocator; 31 } 32 33 34 class BApplication : public BLooper { 35 public: 36 BApplication(const char* signature); 37 BApplication(const char* signature, status_t* error); 38 virtual ~BApplication(); 39 40 // Archiving 41 BApplication(BMessage* data); 42 static BArchivable* Instantiate(BMessage* data); 43 virtual status_t Archive(BMessage* data, bool deep = true) const; 44 45 status_t InitCheck() const; 46 47 // App control and System Message handling 48 virtual thread_id Run(); 49 virtual void Quit(); 50 virtual bool QuitRequested(); 51 virtual void Pulse(); 52 virtual void ReadyToRun(); 53 virtual void MessageReceived(BMessage* msg); 54 virtual void ArgvReceived(int32 argc, char** argv); 55 virtual void AppActivated(bool active); 56 virtual void RefsReceived(BMessage* message); 57 virtual void AboutRequested(); 58 59 // Scripting 60 virtual BHandler* ResolveSpecifier(BMessage* msg, 61 int32 index, 62 BMessage* specifier, 63 int32 form, 64 const char* property); 65 66 // Cursor control, window/looper list, and app info 67 void ShowCursor(); 68 void HideCursor(); 69 void ObscureCursor(); 70 bool IsCursorHidden() const; 71 void SetCursor(const void* cursor); 72 void SetCursor(const BCursor* cursor, bool sync = true); 73 int32 CountWindows() const; 74 BWindow* WindowAt(int32 index) const; 75 int32 CountLoopers() const; 76 BLooper* LooperAt(int32 index) const; 77 bool IsLaunching() const; 78 status_t GetAppInfo(app_info* info) const; 79 static BResources* AppResources(); 80 81 virtual void DispatchMessage(BMessage* message, 82 BHandler* handler); 83 void SetPulseRate(bigtime_t rate); 84 85 // More scripting 86 virtual status_t GetSupportedSuites(BMessage* data); 87 88 89 // Private or reserved 90 virtual status_t Perform(perform_code d, void* arg); 91 92 class Private; 93 94 private: 95 typedef BLooper _inherited; 96 97 friend class Private; 98 friend class BServer; 99 100 BApplication(const char* signature, bool initGUI, 101 status_t* error); 102 BApplication(uint32 signature); 103 BApplication(const BApplication&); 104 BApplication& operator=(const BApplication&); 105 106 virtual void _ReservedApplication1(); 107 virtual void _ReservedApplication2(); 108 virtual void _ReservedApplication3(); 109 virtual void _ReservedApplication4(); 110 virtual void _ReservedApplication5(); 111 virtual void _ReservedApplication6(); 112 virtual void _ReservedApplication7(); 113 virtual void _ReservedApplication8(); 114 115 virtual bool ScriptReceived(BMessage* msg, int32 index, 116 BMessage* specifier, int32 form, 117 const char* property); 118 void _InitData(const char* signature, bool initGUI, 119 status_t* error); 120 void BeginRectTracking(BRect r, bool trackWhole); 121 void EndRectTracking(); 122 status_t _SetupServerAllocator(); 123 status_t _InitGUIContext(); 124 status_t _ConnectToServer(); 125 /* void send_drag( BMessage* msg, 126 int32 vs_token, 127 BPoint offset, 128 BRect drag_rect, 129 BHandler* reply_to); 130 void send_drag( BMessage* msg, 131 int32 vs_token, 132 BPoint offset, 133 int32 bitmap_token, 134 drawing_mode dragMode, 135 BHandler* reply_to); 136 void write_drag(_BSession_* session, BMessage* a_message); 137 */ bool _QuitAllWindows(bool force); 138 bool _WindowQuitLoop(bool quitFilePanels, bool force); 139 void _ArgvReceived(BMessage* message); 140 141 uint32 InitialWorkspace(); 142 int32 _CountWindows(bool includeMenus) const; 143 BWindow* _WindowAt(uint32 index, bool includeMenus) const; 144 145 static BResources* sAppResources; 146 static BLocker sAppResourcesLock; 147 148 const char* fAppName; 149 BPrivate::PortLink* fServerLink; 150 BPrivate::ServerMemoryAllocator* fServerAllocator; 151 152 void* fCursorData; 153 bigtime_t fPulseRate; 154 uint32 fInitialWorkspace; 155 //_drag_data_* fDraggedMessage; 156 BMessageRunner* fPulseRunner; 157 status_t fInitError; 158 void* fServerReadOnlyMemory; 159 uint32 _reserved[12]; 160 161 bool fReadyToRunCalled; 162 }; 163 164 // Global Objects 165 166 extern _IMPEXP_BE BApplication* be_app; 167 extern _IMPEXP_BE BMessenger be_app_messenger; 168 169 #endif // _APPLICATION_H 170