Pyro higlevel API
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
os::Application Class Reference

Singleton class representing an application. More...

Inheritance diagram for os::Application:
os::Looper os::Handler

Classes

class  Private
 

Public Member Functions

 Application (const char *pzMimeType)
 
 Application (const char *pzMimeType, AppType_t nType)
 
virtual ~Application ()
 
uint32 GetQualifiers ()
 Returnes the current state of keyboards qualifiers. More...
 
virtual void HandleMessage (Message *pcMessage)
 Handle a message targeted at this handler. More...
 
virtual void __reserved1__ ()
 
virtual void __reserved2__ ()
 
virtual void __reserved3__ ()
 
virtual void __reserved4__ ()
 
virtual void __reserved5__ ()
 
virtual void __reserved6__ ()
 
virtual void __reserved7__ ()
 
virtual void __reserved8__ ()
 
virtual void __reserved9__ ()
 
virtual void __reserved10__ ()
 
void PushCursor (mouse_ptr_mode eMode, void *pImage, int nWidth, int nHeight, const IPoint &cHotSpot=IPoint(0, 0))
 
void PopCursor ()
 
bigtime_t GetIdleTime ()
 
void GetKeyboardConfig (String *pcKeymapName, int *pnKeyDelay, int *pnKeyRepeat)
 
status_t SetKeymap (const char *pzName)
 
status_t SetKeyboardTimings (int nDelay, int nRepeat)
 
int GetScreenModeCount ()
 
int GetScreenModeInfo (int nIndex, screen_mode *psMode)
 
void SetWindowDecorator (const char *pzPath)
 
void CommitColorConfig ()
 
thread_id Run ()
 Entry point for the message loop. More...
 
port_id GetServerPort () const
 
port_id GetAppPort () const
 Return the appserver message port. More...
 
const CatalogGetCatalog () const
 Get the default string catalog. More...
 
void SetCatalog (Catalog *pcCatalog)
 Set the default string catalog. More...
 
bool SetCatalog (const String &cCatalogName)
 Set the default string catalog. More...
 
LocaleGetApplicationLocale () const
 Get current locale. More...
 
void SetApplicationLocale (const Locale &pcLocale)
 Change current locale. More...
 
void RegisterKeyEvent (const os::KeyboardEvent &)
 
void UnregisterKeyEvent (const os::String &cEvent)
 
int GetCurrentKeyShortcuts (std::vector< os::KeyboardEvent > *pcTable)
 
AppType_t GetApplicationType () const
 
- Public Member Functions inherited from os::Looper
 Looper (const String &cName, int nPriority=NORMAL_PRIORITY, int nPortSize=DEFAULT_PORT_SIZE)
 The looper constructor. More...
 
virtual ~Looper ()
 Looper destructor. More...
 
void SetName (const String &cName)
 Rename the looper. More...
 
String GetName () const
 Get the loopers name. More...
 
bool IsPublic () const
 See if the looper's message port is public. More...
 
void SetPublic (bool bPublic)
 Make port public/private. More...
 
port_id GetMsgPort () const
 Obtain the low-level message port used by this looper. More...
 
thread_id GetThread () const
 Obtain the thread id of the looper thread. More...
 
proc_id GetProcess () const
 Obtain the process ID of the loopers thread. More...
 
status_t Lock ()
 Lock the looper object. More...
 
status_t Lock (bigtime_t nTimeout)
 Lock the looper with a timeout. More...
 
status_t SafeLock ()
 Attempt to lock the looper. More...
 
status_t Unlock ()
 Unlock the looper. More...
 
void SetMutex (Locker *pcMutex)
 Set a custom mutex to be used by the looper. More...
 
LockerGetMutex () const
 Get a pointer to the loopers mutex. More...
 
int GetLockCount () const
 Obtain the number of locks held on the looper. More...
 
thread_id GetLockingThread () const
 Obtaing the owner of the looper lock. More...
 
bool IsLocked () const
 Check if the looper lock is owned by the calling thread. More...
 
int Wait () const
 Wait for the looper thread to die. More...
 
status_t PostMessage (uint32 nCode)
 Deliver a message to the looper. More...
 
status_t PostMessage (Message *pcMsg)
 Deliver a message to the looper. More...
 
status_t PostMessage (uint32 cCode, Handler *pcHandler, Handler *pcReplyTo=NULL)
 Deliver a message to the looper. More...
 
status_t PostMessage (Message *pcMsg, Handler *pcHandler, Handler *pcReplyTo=NULL)
 Deliver a message to the looper. More...
 
void SpoolMessages ()
 Drain the low-level message port. More...
 
MessageGetCurrentMessage () const
 Obtain the message currently being processed. More...
 
MessageDetachCurrentMessage ()
 Steal the current message. More...
 
virtual void DispatchMessage (Message *pcMessage, Handler *pcHandler)
 The loopers message handling callback. More...
 
virtual void Started ()
 Called by the looper thread before entering the message loop. More...
 
virtual bool Idle ()
 Hook called each time the message queue is drained. More...
 
MessageQueueGetMessageQueue () const
 Obtain the internal message queue used by the looper. More...
 
virtual bool OkToQuit ()
 Check if it is ok to break the loop. More...
 
virtual void Quit ()
 Unconditionally terminate the looper. More...
 
void Terminate ()
 Unconditionally terminate the looper. More...
 
void AddTimer (Handler *pcTarget, int nID, bigtime_t nTimeout, bool bOneShot=true)
 Add a timer to the looper. More...
 
bool RemoveTimer (Handler *pcTarget, int nID)
 Delete a timer. More...
 
const handler_mapGetHandlerMap () const
 Get the internal handler list. More...
 
void AddHandler (Handler *pcHandler)
 Add a handler to the looper. More...
 
bool RemoveHandler (Handler *pcHandler)
 Remove a handler previously added by AddHandler() More...
 
HandlerFindHandler (const String &cName) const
 Search the looper for a named handler. More...
 
int GetHandlerCount () const
 Obtain the count of handlers added to this looper. More...
 
void SetDefaultHandler (Handler *pcHandler)
 Set the default target for incomming messages. More...
 
HandlerGetDefaultHandler () const
 Obtain the default handler for the looper. More...
 
void AddCommonFilter (MessageFilter *pcFilter)
 
void RemoveCommonFilter (MessageFilter *pcFilter)
 
const MsgFilterListGetCommonFilterList () const
 
- Public Member Functions inherited from os::Handler
 Handler (const String &cName)
 Construct a handler. More...
 
virtual ~Handler ()
 Destructor. More...
 
virtual void TimerTick (int nID)
 Timer dispatch member. More...
 
String GetName () const
 Get the handlers name. More...
 
void SetName (const String &cName)
 Rename the handler. More...
 
LooperGetLooper () const
 Get a pointer to the looper this handler belongs to. More...
 
void SetNextHandler (Handler *pcNextHandler)
 Set a handler that should handle messages this handler is not interrested in. More...
 
HandlerGetNextHandler () const
 Get the next handler in a handler chain. More...
 
void AddFilter (MessageFilter *pcFilter)
 
void RemoveFilter (MessageFilter *pcFilter)
 
const MsgFilterListGetFilterList () const
 
const uint32 GetToken ()
 Get the handlers token. More...
 

Static Public Member Functions

static ApplicationGetInstance ()
 Get the (one and only) instance of the Application class. More...
 
static os::String GetApplicationPath ()
 
- Static Public Member Functions inherited from os::Looper
static LooperGetLooperForThread (thread_id hThread)
 

Friends

class Window
 
class Desktop
 
class Bitmap
 
class Sprite
 
class View
 
class Font
 
class AppserverConfig
 

Additional Inherited Members

- Public Types inherited from os::Looper
typedef std::map< int, Handler * > handler_map
 
- Protected Member Functions inherited from os::Looper
bool FilterMessage (Message *pcMsg, Handler **ppcTarget, std::list< MessageFilter * > *pcFilterList)
 

Detailed Description

Description:
Before you can use any of the classes in the AtheOS API you must instantiate an application object. The application object establish the connection with the appserver, and are responcible for all application level comunication after the connection is established.

os::Application inherit from Looper, but it does behave different from other loopers in the way that it does not spawn a new thread when the Run() member is called. Insetead it steel the thread calling the run member (normally the main thread) and let it run the message loop.

See Also
os::Window, os::View, os::Looper
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Constructor & Destructor Documentation

Application::Application ( const char *  pzMimeType)
os::Application::Application ( const char *  pzMimeType,
AppType_t  nType 
)
Application::~Application ( )
virtual

Member Function Documentation

void Application::__reserved10__ ( )
virtual
void Application::__reserved1__ ( )
virtual
void Application::__reserved2__ ( )
virtual
void Application::__reserved3__ ( )
virtual
void Application::__reserved4__ ( )
virtual
void Application::__reserved5__ ( )
virtual
void Application::__reserved6__ ( )
virtual
void Application::__reserved7__ ( )
virtual
void Application::__reserved8__ ( )
virtual
void Application::__reserved9__ ( )
virtual
void Application::CommitColorConfig ( )
Locale * Application::GetApplicationLocale ( ) const
This function returns the default locale that is used by this application.
Unless you change it using SetApplicationLocale, the application locale will
be the same as the system's default locale (as set by Locale prefs).
See Also
SetApplicationLocale()
Author
Henrik Isaksson (sylla.nosp@m.ble@.nosp@m.isaks.nosp@m.son..nosp@m.tk)

References os::Application::Private::m_cLocale.

Referenced by os::FileRequester::FileRequester(), os::IconDirectoryView::IconDirectoryView(), InfoWin::InfoWin(), MountDialogWin::MountDialogWin(), NewDirWin::NewDirWin(), RenameFileWin::RenameFileWin(), and UnmountThread().

static os::String os::Application::GetApplicationPath ( )
static
AppType_t os::Application::GetApplicationType ( ) const
port_id Application::GetAppPort ( ) const
When contructed the Application class will establish a connection to the
application server. The appserver will create an message port and spawn
a thread that will handle application-level operation on behave of the
Application class. This function returnes the message port that connect
the Application object with the corresponding thread in the application
server
Returns
The message port id for the server side message port connecting this object to the application server.
See Also
Author
Kurt Skauen (kurt..nosp@m.skau.nosp@m.en@c2.nosp@m.i.ne.nosp@m.t)

References os::Application::Private::m_hSrvAppPort.

Referenced by os::Font::GetSupportedCharacters(), and os::Font::SetFamilyAndStyle().

const Catalog * Application::GetCatalog ( ) const
This function returns the string catalog that was set with SetCatalog().
Returns
Pointer to the application's default string catalog
See Also
SetCatalog()
Author
Henrik Isaksson (sylla.nosp@m.ble@.nosp@m.isaks.nosp@m.son..nosp@m.tk)

References os::Application::Private::m_pcCatalog.

Referenced by os::LString::LString().

int Application::GetCurrentKeyShortcuts ( std::vector< os::KeyboardEvent > *  pcTable)
bigtime_t Application::GetIdleTime ( )
Application * Application::GetInstance ( )
static
When the Application class is instantiated it will assign a pointer to
the instance to a static member that can be obtained through this function.
Many other classes expect this function to return a valid pointer, so it
is importen that you instantiate the Application class once (and only once)
before calling any other functions in the native AtheOS API.
Returns
Pointer to the global instance of the Application drived class.
See Also
Author
Kurt Skauen (kurt..nosp@m.skau.nosp@m.en@c2.nosp@m.i.ne.nosp@m.t)

Referenced by os::Desktop::Activate(), os::Font::AddDefaultFont(), os::AppserverConfig::AppserverConfig(), os::Bitmap::Bitmap(), os::CalendarView::CalendarView(), os::AppserverConfig::Commit(), os::DateView::DateView(), os::Desktop::Desktop(), os::Event::Event(), os::FileRequester::FileRequester(), os::Settings::Private::GetAppName(), os::Font::GetBitmapSizes(), os::Font::GetConfigNames(), os::Font::GetDefaultFont(), os::Font::GetFamilyCount(), os::Font::GetFamilyInfo(), os::View::GetQualifiers(), os::Font::GetStringLengths(), os::Font::GetStringWidths(), os::Font::GetStyleCount(), os::Font::GetStyleInfo(), os::Font::GetSupportedCharacters(), os::Font::GetTextExtents(), os::IconView::Private::GetViewFrame(), os::IconDirectoryView::IconDirectoryView(), InfoWin::InfoWin(), os::LString::LString(), os::Desktop::MinimizeAll(), MountDialogWin::MountDialogWin(), os::TextEdit::MouseMove(), os_priv::SplitterSeparator::MouseMove(), os::IconDirectoryView::MouseUp(), os::Sprite::MoveTo(), NewDirWin::NewDirWin(), os::InputBox::Private::Private(), os::ColorRequester::Private::Private(), RenameFileWin::RenameFileWin(), os::Font::Rescan(), os::Desktop::SetColorSpace(), os::Font::SetDefaultFont(), os::Font::SetFamilyAndStyle(), os::DateView::SetMessageTarget(), os::Desktop::SetRefreshRate(), os::Desktop::SetResolution(), os::Desktop::SetScreenMode(), os::Sprite::Sprite(), UnmountThread(), os::Window::Window(), os::Bitmap::~Bitmap(), os::Sprite::~Sprite(), and os::TextEdit::~TextEdit().

void Application::GetKeyboardConfig ( String pcKeymapName,
int *  pnKeyDelay,
int *  pnKeyRepeat 
)
uint32 Application::GetQualifiers ( )
Sends a requester to the appserver to obtain the current
state of keyboard qualifiers.
Returns
A bit mask composed from os::qualifiers decribing which qualifiers currently pressed
See Also
Author
Kurt Skauen (kurt..nosp@m.skau.nosp@m.en@c2.nosp@m.i.ne.nosp@m.t)

References os::Looper::Lock(), os::Application::Private::m_hReplyPort, os::Application::Private::m_hSrvAppPort, and os::Looper::Unlock().

Referenced by os::IconDirectoryView::MouseUp().

int Application::GetScreenModeCount ( )
int Application::GetScreenModeInfo ( int  nIndex,
screen_mode psMode 
)
port_id Application::GetServerPort ( ) const
void Application::HandleMessage ( Message pcMessage)
virtual
Description:
Overload this member to dispatch messages sendt to this handler. When a looper receives a message for one of it's handlers it will call the taget handlers HandleMessage() to allow the handler to dispatch the message.
The message passed in pcMessage is also available through os::Looper::GetCurrentMessage() and os::Looper::DetachCurrentMessage() until this member returns. This is normally not very usefull for HandleMessage() itself but it can be convinient for other members called from HandleMessage() in case they need data from the message that was not passed on from HandleMessage().
The looper will be locked when this member is called. The default implementation of this member will pass the message on to the next handler if one was set with SetNextHandler().
Note
Never do any lenthy operations in any hook members that are called from the looper thread if the looper is involved with the GUI (for example if the looper is a os::Window). The looper will not be able to dispatch messages until the hook returns so spending a long time in this members will make the GUI feel unresponsive.
Parameters
pcMessageThe message that should be handled. This message will be deleted by the looper when HandleMessage() returns unless you detach it with os::Looper::DetachCurrentMessage(),
See Also
os::Looper::DispatchMessage(), os::Looper::DetachCurrentMessage()
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Reimplemented from os::Handler.

References os::__set_default_color(), os::COL_COUNT, os::Message::FindColor32(), os::Message::GetCode(), os::Handler::HandleMessage(), and os::M_COLOR_CONFIG_CHANGED.

void Application::PopCursor ( )
void Application::PushCursor ( mouse_ptr_mode  eMode,
void *  pImage,
int  nWidth,
int  nHeight,
const IPoint cHotSpot = IPoint(0,0) 
)
void Application::RegisterKeyEvent ( const os::KeyboardEvent event)
thread_id Application::Run ( void  )
virtual
The Application class is different from other loopers in that it does not
spawn a new thread when the Run() member is called. Instead the Run() member
directly enter the message loop, and does not return until the message loop
quits.
Returns
The thread id of the thread calling it.
See Also
Author
Kurt Skauen (kurt..nosp@m.skau.nosp@m.en@c2.nosp@m.i.ne.nosp@m.t)

Reimplemented from os::Looper.

References os::Looper::Unlock().

void Application::SetApplicationLocale ( const Locale cLocale)
This function changes the default locale that is used by this application.
Normally, you shouldn't use this function, as the locale will be set
automatically to the system's default locale (as set by Locale prefs).
See Also
GetApplicationLocale()
Author
Henrik Isaksson (sylla.nosp@m.ble@.nosp@m.isaks.nosp@m.son..nosp@m.tk)

References os::Application::Private::m_cLocale.

void Application::SetCatalog ( Catalog pcCatalog)
This function sets the string catalog that is returned by GetCatalog().
See Also
GetCatalog()
Author
Henrik Isaksson (sylla.nosp@m.ble@.nosp@m.isaks.nosp@m.son..nosp@m.tk)

References Resource::AddRef(), os::Looper::Lock(), os::Application::Private::m_pcCatalog, Resource::Release(), and os::Looper::Unlock().

Referenced by SetCatalog().

bool Application::SetCatalog ( const String cCatalogName)
This function sets the string catalog that is returned by GetCatalog().
See Also
GetCatalog()
Author
Henrik Isaksson (sylla.nosp@m.ble@.nosp@m.isaks.nosp@m.son..nosp@m.tk)

References os::String::c_str(), os::Locale::GetLocalizedCatalog(), os::Application::Private::m_cLocale, and SetCatalog().

status_t Application::SetKeyboardTimings ( int  nDelay,
int  nRepeat 
)
status_t Application::SetKeymap ( const char *  pzName)
void Application::SetWindowDecorator ( const char *  pzPath)
void Application::UnregisterKeyEvent ( const os::String cEvent)

Friends And Related Function Documentation

friend class AppserverConfig
friend
friend class Bitmap
friend
friend class Desktop
friend
friend class Font
friend
friend class Sprite
friend
friend class View
friend
friend class Window
friend