Application.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 /
00003 /   File:           Application.h
00004 /
00005 /   Description:    BApplication class is the center of the application
00006 /                   universe.  The global be_app and be_app_messenger 
00007 /                   variables are defined here as well.
00008 /
00009 /   Copyright 1995-98, Be Incorporated, All Rights Reserved.
00010 /
00011 *******************************************************************************/
00012 
00013 #ifndef _APPLICATION_H
00014 #define _APPLICATION_H
00015 
00016 #include <BeBuild.h>
00017 #include <AppDefs.h>        /* For convenience */
00018 #include <InterfaceDefs.h>
00019 #include <Rect.h>
00020 #include <Point.h>
00021 #include <Looper.h>
00022 #include <Messenger.h>
00023 #include <stdio.h>
00024 
00025 class BCursor;
00026 class BList;
00027 class BWindow;
00028 class BResources;
00029 class BMessageRunner;
00030 struct _server_heap_;
00031 struct _drag_data_;
00032 struct app_info;
00033 namespace BPrivate {
00034 class AppSession;
00035 }
00036 namespace B {
00037 namespace Interface2 {
00038 class BControl;
00039 class BWindow;
00040 }
00041 }
00042 
00043 /*----- BApplication class --------------------------------------------*/
00044 
00045 class BApplication : public BLooper {
00046 
00047 public:
00048                         BApplication(const char *signature);
00049                         BApplication(const char *signature, status_t *error);
00050                         BApplication(const char *signature, status_t *error, bool connectToAppServer);
00051 virtual                 ~BApplication();
00052 
00053 /* Archiving */
00054                         BApplication(BMessage *data);
00055 static  BArchivable     *Instantiate(BMessage *data);
00056 virtual status_t        Archive(BMessage *data, bool deep = true) const;
00057 
00058         status_t        InitCheck() const;
00059 
00060 /* App control and System Message handling */
00061 virtual thread_id       Run();
00062 virtual void            Quit();
00063 virtual bool            QuitRequested();
00064 virtual void            Pulse();
00065 virtual void            ReadyToRun();
00066 virtual void            MessageReceived(BMessage *msg);
00067 virtual void            ArgvReceived(int32 argc, char **argv);
00068 virtual void            AppActivated(bool active);
00069 virtual void            RefsReceived(BMessage *a_message);
00070 virtual void            AboutRequested();
00071 
00072 /* Scripting */
00073 virtual BHandler        *ResolveSpecifier(BMessage *msg,
00074                                         int32 index,
00075                                         BMessage *specifier,
00076                                         int32 form,
00077                                         const char *property);
00078 
00079 /* Cursor control, window/looper list, and app info */
00080         void            ShowCursor();
00081         void            HideCursor();
00082         void            ObscureCursor();
00083         bool            IsCursorHidden() const;
00084         void            SetCursor(const void *cursor);
00085         void            SetCursor(const BCursor *cursor, bool sync=true);
00086         int32           CountWindows() const;
00087         BWindow         *WindowAt(int32 index) const;
00088         int32           CountLoopers() const;
00089         BLooper         *LooperAt(int32 index) const;
00090         bool            IsLaunching() const;
00091         status_t        GetAppInfo(app_info *info) const;
00092 static  BResources      *AppResources();
00093 
00094 virtual void            DispatchMessage(BMessage *an_event,
00095                                         BHandler *handler);
00096         void            SetPulseRate(bigtime_t rate);
00097 
00098         /*
00099             The callback functions(s) passed to AddInitializer() will be called
00100             when the application's BApplication becomes valid. If the BApplication
00101             is already valid when AddInitializer() is called, the callback will be
00102             called immediately.
00103             RemoveInitializer() removes the callback from the list.
00104         */
00105 static  status_t        AddInitializer(void (*callback)(void));
00106 static  status_t        RemoveInitializer(void (*callback)(void));
00107 
00108 /* More scripting  */
00109 virtual status_t        GetSupportedSuites(BMessage *data);
00110 
00111 
00112 virtual status_t        UISettingsChanged(const BMessage* changes, uint32 flags);
00113 
00114 /*----- Private or reserved -----------------------------------------*/
00115 virtual status_t        Perform(perform_code d, void *arg);
00116 
00117 private:
00118 
00119 typedef BLooper _inherited;
00120 
00121 friend class BWindow;
00122 friend class B::Interface2::BWindow;
00123 friend class BView;
00124 friend class B::Interface2::BControl;
00125 friend class BBitmap;
00126 friend class BScrollBar;
00127 friend class BPrivateScreen;
00128 friend class _BAppServerLink_;
00129 friend void  _toggle_handles_(bool);
00130                         
00131                         BApplication(uint32 signature);
00132                         BApplication(const BApplication &);
00133         BApplication    &operator=(const BApplication &);
00134 
00135 virtual void            _ReservedApplication2();
00136 virtual void            _ReservedApplication3();
00137 virtual void            _ReservedApplication4();
00138 virtual void            _ReservedApplication5();
00139 virtual void            _ReservedApplication6();
00140 virtual void            _ReservedApplication7();
00141 virtual void            _ReservedApplication8();
00142 
00143 virtual bool            ScriptReceived(BMessage *msg,
00144                                         int32 index,
00145                                         BMessage *specifier,
00146                                         int32 form,
00147                                         const char *property);
00148         void            run_task();
00149         void            InitData(const char *signature, status_t *error, bool connectToAppServer);
00150         void            BeginRectTracking(BRect r, bool trackWhole);
00151         void            EndRectTracking();
00152         void            get_scs();
00153         void            setup_server_heaps();
00154         void            *rw_offs_to_ptr(uint32 offset);
00155         void            *ro_offs_to_ptr(uint32 offset);
00156         void            *global_ro_offs_to_ptr(uint32 offset);
00157         void            connect_to_app_server();
00158         void            hmsg_B_PIPESTDOUT_REQUESTED(BMessage *msg);
00159         void            hmsg_B_PIPESTDOUT_RESET(BMessage *msg);
00160         void            send_drag(  BMessage *msg,
00161                                     int32 vs_token,
00162                                     BPoint offset,
00163                                     BRect drag_rect,
00164                                     BMessenger reply_to);
00165         void            send_drag(  BMessage *msg,
00166                                     int32 vs_token,
00167                                     BPoint offset,
00168                                     int32 bitmap_token,
00169                                     drawing_mode dragMode,
00170                                     BMessenger reply_to);
00171         void            write_drag(BPrivate::AppSession *session, BMessage *a_message);
00172         bool            quit_all_windows(bool force);
00173         bool            window_quit_loop(bool, bool);
00174         void            do_argv(BMessage *msg);
00175 #ifndef FIX_FOR_4_6
00176         void            SetAppCursor();
00177 #endif
00178         uint32          InitialWorkspace();
00179         int32           count_windows(bool incl_menus) const;
00180         BWindow         *window_at(uint32 index, bool incl_menus) const;
00181         status_t        get_window_list(BList *list, bool incl_menus) const;
00182 static  int32           async_quit_entry(void *);
00183 static  BResources      *_app_resources;
00184 static  BLocker         _app_resources_lock;
00185 
00186         const char      *fAppName;
00187         int32           fServerFrom;
00188         int32           fServerTo;
00189 #ifndef FIX_FOR_4_6
00190         void            *fCursorData;
00191 #else
00192         void            *_unused1;
00193 #endif
00194         _server_heap_   *fServerHeap;
00195         bigtime_t       fPulseRate;
00196         uint32          fInitialWorkspace;
00197         _drag_data_     *fDraggedMessage;
00198         BMessageRunner  *fPulseRunner;
00199         status_t        fInitError;
00200         
00201         //for rerouting of stdout
00202         struct redirect_struct
00203         {
00204             int oldstdout;
00205             int readfd;
00206         } *fRedirect;
00207         
00208         uint32          _reserved[10];
00209 
00210         bool            fReadyToRunCalled;
00211 };
00212 
00213 /*----- Global Objects -----------------------------------------*/
00214 
00215 extern BApplication *be_app;
00216 extern BMessenger   be_app_messenger;
00217 
00218 /*-------------------------------------------------------------*/
00219 
00220 #endif /* _APPLICATION_H */

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.