IApplication



Describes minimum required functionality of application object. The main goal of IApplication instance is to control all windows and forms, store global helper interfaces allowing to access commonly used values like mouse pointer position or style list, store platform related functionality either directly or through interfaces(like IKeyboard).

You can find more information in comments below.

class IApplication
{
protected:
    PlatformHandle m_hHandle;
    String m_sApplicationFileName;
    String m_sApplicationDirectory;
    String m_sModuleFileName;
    String m_sModuleDirectory;
    bool m_bDialogBoxes;
    bool m_bGlobal;
    IForm *m_pMainForm;
    IKeyboard *m_pKeyboard;
    IMouse *m_pMouse;
    ITranslate *m_pTranslate;
    IStyles *m_pStyles;
    IScreen *m_pScreen;
    ISystem *m_pSystem;
    IPicture *m_pPicture;
    IDialogs *m_pDialogs;
    IFileSystem *m_pFileSystem;
    INetwork *m_pNetwork;
    IEditor *m_pEditor;
    IDb *m_pDb;
public:
    PlatformHandle const &Handle;
    String const &ApplicationFileName; // Application file name without path. Use to get *.exe file name 
    String const &ApplicationDirectory; // Application directory name with directory separator at the end. Use to get *.exe directory name 
    String const &ModuleFileName; // Module file name without path. Use to get *.dll(if application is created in dll) or *.exe file name 
    String const &ModuleDirectory; // Module directory name with directory separator at the end. Use to get *.dll(if application is created in dll) or *.exe directory name 
    bool const &DialogBoxes; // True if application should try to use forms in form of dialog boxes if possible. All forms from standard packages can do it. By default return false which means standard standalone forms will be used 
    bool const &Global; // Whether this application object controls entire application. By default true, which means application will be closed automatically when last form/window is closed. False should be returned only if the application is actually a part of bigger one and is used to show/manage as build-in interface of that bigger application. The example where application returns FALSE is integration of Form Builder with Visual Studio 
    IForm* const &MainForm; // Main form 
    IKeyboard* const &Keyboard; // Keyboard interface 
    IMouse* const &Mouse; // Mouse interface 
    ITranslate* const &Translate; // Translation interface 
    IStyles* const &Styles; // Styles interface 
    IScreen* const &Screen; // Screen interface 
    ISystem* const &System; // System interface 
    IPicture* const &Picture; // Picture interface 
    IDialogs* const &Dialogs; // System dialogs interface 
    IFileSystem* const &FileSystem; // Interface for working with file system 
    INetwork* const &Network; // Interfaces for working with network connections 
    IEditor* const &Editor; // Editor. Return nullptr almost always. Return instance of editor when the code is running under Form Builder 
    IDb* const &Db{ m_pDb }; // DataBase manager 

    void(*OnIdle)(); // Idle event callback. Called each time when application do nothing 

    virtual int getWindowCount() = 0; // Return count of registered windows in application 
    virtual IWindow *getWindow(const int index) = 0; // Return window by index 
    virtual IForm *getWindowForm(const int index) = 0; // Return form of window specified by index 

    virtual bool setMainForm(IForm *value) = 0; // Set main form 

    virtual int Run() = 0; // Run application. Return exit code(use it to return from WinMain) 
    virtual void ProcessMessages() = 0; // Receive and process all available for application messages from system 
    virtual void RepaintAll() = 0; // Repaint all visible forms 
    virtual IApplicationService *QueryService() = 0; // Return service 
    virtual IThread *CreateThread(const bool paused, IThreadListener *listener) = 0; // Create thread. Return nullptr if failed 

    template<class TForm> void CreateForm(TForm **var); // Create a form 
};

extern IApplication *Application; // Global variable filled when application instance is created or by GetPackage function in package. Only one instance should exists in entire application.
Namespace: nitisa
Include: Nitisa/Interfaces/IApplication.h