Humble Framework for SkyOS


Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

HApp Class Reference
[Graphical User Interface]

#include <HApp.h>

Inheritance diagram for HApp:

HWindow< HApp > HWidget HColorable HObjNoCopy HObj HObj

Detailed Description

Represents the entire application. When the application is first started up, a single HApp-derived object is created and stored in the global variable theApp, which will exist for as long as the application is running; consequently, the HApp::Init(), HApp::Run() and HApp::Kill() methods are typically called from a standard C/C++ main() routine.

Definition at line 48 of file HApp.h.

Public Member Functions

ErrCode Destroy (void)
 Destroys the application window.
ErrCode Draw (HRect &rDirty)
 Draws the client area of the main application window.
virtual ErrCode Init (int32 argc, TextPtr argv[])
 Initializes the application.
virtual void Kill (ErrCode ec)
 Shuts down the application.
int32 Main (int32 argc, TextPtr argv[])
 Runs the application.
bool Quit (bool bForced=false)
 Quits the application, causing the main message loop to exit.
ErrCode Show (void) const
 Makes the application window visible.
ErrCode UpdateLayout (void)
 Repositions all widgets within the main application window.
virtual StringPtr GetAppName (void) const
 Returns the name of the application as a string.
ErrCode ExtractResource (StringPtr pstrSrc, StringPtr pstrDst=NULL)
 Extracts a named resource to the file system.

Protected Member Functions

END_MSG_MAP bool onDestroy (const s_gi_msg &msg, HRESULT &hr)
 Handler for the MSG_DESTROY message.
virtual ErrCode parseCmdLine (int32 argc, TextPtr argv[])
 Handles the parsing of the command line arguments.

Protected Attributes

s_gi_msg m_msgLast
 Last message processed by app.
HLayout m_layout
 The top-level layout manager.
HMenuBar m_menuBar
 The application menu bar.


Member Function Documentation

END_MSG_MAP bool HApp::onDestroy const s_gi_msg &  msg,
HRESULT &  hr
[protected]
 

Standard handler for the MSG_DESTROY message, which is called when the top-level window is destroyed, either by the user clicking in the "close box" or programmatically through a called to GI_destroy_window().

Returns:
true if user approved quit, false otherwise
Parameters:
msg MSG_DESTROY message received by window procedure
[out] hr S_OK on success, error code otherwise

Definition at line 92 of file HApp.h.

virtual ErrCode HApp::parseCmdLine int32  argc,
TextPtr  argv[]
[protected, virtual]
 

Subclasses that want to process command line arguments should override this method.

Returns:
Always NO_ERROR
Parameters:
argc count of command-line arguments
argv[] array of pointers to command-line arguments

Definition at line 116 of file HApp.h.

ErrCode HApp::Destroy void   )  [virtual]
 

Overrides the HWindow::Destroy() method because we actually destroy the parent window (frame?).

Returns:
NO_ERROR on success, error code otherwise

Reimplemented from HWidget.

Definition at line 128 of file HApp.h.

ErrCode HApp::Draw HRect rDirty  )  [virtual]
 

Draws the contents of the window by letting the top-level widget container (m_layout) handle all of the drawing.

Returns:
NO_ERROR on success, error code otherwise
Parameters:
rDirty Area of the client to be redrawn

Reimplemented from HWidget.

Definition at line 153 of file HApp.h.

virtual ErrCode HApp::Init int32  argc,
TextPtr  argv[]
[virtual]
 

Performs all once-only startup processing, including the handling of any command-line arguments, prior to starting the main event loop. Subclasses that override this method MUST call this function prior to executing any startup code of their own:

        HError
        MyApp::Init(int32 argc, TextPtr argv[])
            {
            ErrCode     ec = HError::NoError();
   
            if ((ec = base_class::Init(argc, argv)) != NO_ERROR)
                return ec;  // HError::GetLastError() has more info
            //
            // Custom initialization code goes here
            //
            return ec;
            }
Returns:
NO_ERROR to start main event loop, error code otherwise
Parameters:
argc count of command-line arguments
argv[] array of pointers to command-line arguments

Definition at line 192 of file HApp.h.

virtual void HApp::Kill ErrCode  ec  )  [virtual]
 

Performs all once-only termination processing before the application exits. Since this function may be called when the application is in an unstable state, it should be as "lean and mean" as possible.

Parameters:
ec Error condition

Definition at line 233 of file HApp.h.

int32 HApp::Main int32  argc,
TextPtr  argv[]
 

This method is a replacement for the generic C/C++ main() function, and effectively runs the entire application. It first calls the HApp::Init() method to initialize everything, then enters the main event loop; once this loop exits, the HApp::Kill() method is invoked to clean up everything.

Returns:
Zero on success or error level to return to OS
Parameters:
argc Count of command-line arguments
argv Array of ptrs to command-line arguments

Definition at line 256 of file HApp.h.

bool HApp::Quit bool  bForced = false  ) 
 

This method posts a WM_QUIT message to the application, causing the main message loop—in HApp::Main()—to exit. Returning a false value from this method indicates that the user wishes to cancel the quit action; of course, if the bForced parameter is true, this method will always return true.

Returns:
true if quitting, false if canceled
Parameters:
bForced true to force exit, false to ask user for permission

Definition at line 330 of file HApp.h.

ErrCode HApp::Show void   )  const [virtual]
 

Overrides the HWidget::Show() method to use GI_ShowApplicationWindow() instead of GI_show().

Returns:
NO_ERROR on success, error code otherwise

Reimplemented from HWidget.

Definition at line 352 of file HApp.h.

ErrCode HApp::UpdateLayout void   )  [virtual]
 

Returns:
NO_ERROR on success, error code otherwise

Reimplemented from HWindow< HApp >.

Definition at line 379 of file HApp.h.

virtual StringPtr HApp::GetAppName void   )  const [virtual]
 

This function should return the name of the application as a human-readable string, i.e., "SuperWidget v1.0". This string is used by the framework as the default title for windows and dialog boxes. All classes derived from HApp MUST implement this method

Returns:
A human-readable string containing the application name

Definition at line 403 of file HApp.h.

ErrCode HApp::ExtractResource StringPtr  pstrSrc,
StringPtr  pstrDst = NULL
 

See also:
HZipFile::Extract()
This method extracts a resource by name and writes it out to the file system.

Returns:
NO_ERROR on success, error code otherwise
Parameters:
pstrSrc File name inside .zip archive
pstrDst [optional] File name to copy to

Definition at line 419 of file HApp.h.


The documentation for this class was generated from the following file:
 

2006.01.09-16:37