#ifndef CLASS_DISPLAY_HPP
#define CLASS_DISPLAY_HPP

/*
**
** Display.hpp
**
** (c) 1999 Didier Levet
**
** Fonctions d'affichage
**
**
*/

#ifndef  _INCLUDE_IOSTREAM_H
#include <fstream.h>
#endif

#ifndef  CLIB_LOCALE_PROTOS_H
#include <clib/locale_protos.h>
#endif

#ifndef  CLIB_DOS_PROTOS_H
#include <clib/dos_protos.h>
#endif


#ifndef STRING
typedef const char *STRING;
#endif


STRING GetString(long iStringID);


//----------------------------------------------------------------------------------------------------
//======================================== class LocalStrings ========================================
//----------------------------------------------------------------------------------------------------

class LocalStrings
{
    public:

        LocalStrings();
        ~LocalStrings();

        STRING read(long stringID, char *defString)
        {
            if (pCatalog) return (::GetCatalogStr(pCatalog, stringID, defString));
            else          return (defString);
        }

    private:

        struct Locale  *pLocaleBase;
        struct Catalog *pCatalog;
};


//----------------------------------------------------------------------------------------------------
//========================================== class Display ===========================================
//----------------------------------------------------------------------------------------------------
//
// La classe "Display" est une classe virtuelle. Elle sert de base (ou de HAL) en proposant toutes les
// fonctions d'affichage, que le fonctionnement de Pegase se fasse en mode CLI ou en mode WB.

class PegaseConfigC;
class FileInfosC;
class EncoderConfigC;


class Display
{
    public:

        Display() : bFromWB(FALSE), bDisableAnim(FALSE) {}
        virtual ~Display() {}

        void PrintErrorMsg(STRING msg);
        void PrintDOSError(int errCode);
        void DisplayBanner();
        void ShowConfig(const PegaseConfigC& rCfg);
        void ShowEncodingInfos(const EncoderConfigC *pConfig);
        void ShowCurrentJob(const FileInfosC *fi);

        int  UpdateProgression(ULONG val, FileInfosC *fi);
        void ResetAnimVal() {mAnimVal = mDotsDelay = 0;}

        virtual operator ostream& () = 0;
        virtual ostream& out() = 0;

    protected:

        int   bFromWB;              // TRUE si démarrage en mode WorkBench.
        int   bDisableAnim;
        ULONG mAnimVal;
        ULONG mDotsDelay;
};

extern Display *display;


//----------------------------------------------------------------------------------------------------
//========================================= class CLIDisplay =========================================
//----------------------------------------------------------------------------------------------------

class CLIDisplay : public Display
{
    public:

        CLIDisplay();

        operator ostream& () { return cout; }
        ostream& out()       { return cout; }
};


//----------------------------------------------------------------------------------------------------
//========================================= class WBDisplay ==========================================
//----------------------------------------------------------------------------------------------------

class WBDisplay : public Display
{
    public:

        WBDisplay();
        ~WBDisplay();

        operator ostream& () { return *ostr; }
        ostream& out()       { return *ostr; }

    protected:

        ofstream    *ostr;
};


#endif  // CLASS_DISPLAY_HPP

