D:/Zythum/DinoKod/Common/Console.h

00001 //---------------------------------------------------------------------------------------------
00002 //      This file is a part of "DinoKod".
00003 //      Copyright © 2003 Dino Productions. All Rights Reserved.
00004 //      
00005 //      File                    : Console.h
00006 //      Author                  : Sebastien LEIX        sebastien.leix@wanadoo.fr
00007 //      Date                    : 07/09/2002
00008 //      Modification    :
00009 //
00010 //---------------------------------------------------------------------------------------------
00011 #ifndef __KCONSOLE_H__
00012 #define __KCONSOLE_H__
00013 
00014 #include "Common/CommonDll.h"
00015 #include "Common/Types.h"
00016 #include "Common/List.h"
00017 #ifdef _WIN32
00018 #include <windows.h>
00019 #endif // _WIN32
00020 
00021 #define KENDL           "\r\n"
00022 
00023 //---------------------------------------------------------------------------------------------------------------------
00024 typedef enum _KCMESSAGETYPE
00025 {
00026         KCMT_NORMAL,
00027         KCMT_WARNING,
00028         KCMT_ERROR
00029 } KCMESSAGETYPE;
00030 
00031 //---------------------------------------------------------------------------------------------------------------------
00032 class COMMON_API KOutputConsole
00033 {
00034 public:
00035         virtual void                    Write( char* pString )=0;
00036 };
00037 
00038 //---------------------------------------------------------------------------------------------------------------------
00039 class COMMON_API KConsole
00040 {
00041 private:
00042         KList<KOutputConsole*>  m_OutputConsole;
00043 
00044 protected:
00045         HANDLE                                  m_hConsole;
00046         HANDLE                                  m_hLogFile;
00047         HWND                                    m_hParent;
00048         KCMESSAGETYPE                   m_CurrentType;
00049         bool                                    m_bNewLine;
00050         HMODULE                                 m_hModuleRichEdit;
00051 
00052         void                                    Write( char* pString, KCMESSAGETYPE Type = KCMT_NORMAL );
00053 
00054         // Console graphique
00055         bool                                    m_bGraphic;
00056         HWND                                    m_hWnd;
00057         HWND                                    m_hEdit;
00058 
00059         bool                                    CreateGraphic( HINSTANCE hInstance, HWND hFather = NULL, bool bCreateWindow = true );
00060         static LRESULT CALLBACK WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
00061                                                         
00062 public:                                         
00063                                                         KConsole();
00064                                                         
00065         bool                                    Create( char* pName = NULL, bool bGraphic = false, HINSTANCE hInstance = NULL, HWND hFather = NULL, bool bCreateWindow = true );
00066         bool                                    Close();
00067                                                         
00068         void                                    SetTitle( char* pTitle );
00069         void                                    Printf(const char *text, ... );
00070         void                                    SetTextAttribut( s16 Attribut );
00071         void                                    SetCursorPos( u16 x, u16 y );
00072         KPt                                             GetCursorPos();
00073         void                                    Printf( u16 x, u16 y, u16 Attribut, const char *text, ... );
00074                                                         
00075         KConsole&                               operator <<( KStr sString );
00076         KConsole&                               operator <<( float Value );
00077         KConsole&                               operator <<( int Value );
00078         KConsole&                               operator <<( unsigned int Value );
00079         KConsole&                               operator <<( long Value )                       { return operator <<( (int)Value );             }
00080         KConsole&                               operator <<( unsigned long Value )      { return operator <<( (unsigned int)Value );    }
00081         KConsole&                               operator <<( KCMESSAGETYPE Type );
00082 
00083         void                                    RegisterConsole( KOutputConsole* pConsole );
00084         void                                    UnregisterConsole( KOutputConsole* pConsole );
00085 
00086         void                                    SetParentWindow( HWND hWnd );
00087         HWND                                    GethWindow()    { return m_hWnd;                }
00088         HWND                                    GethEdit()              { return m_hEdit;               }
00089         void                                    SetBackGroundColor( KCOLOR Color );
00090 };
00091 
00092 extern COMMON_API KConsole              g_Console;
00093 
00094 #endif // __KCONSOLE_H__

Generated on Sun Mar 25 20:02:10 2007 for Zythum Project by  doxygen 1.5.1-p1