00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CARCHCONSOLEWINDOWS_H
00016 #define CARCHCONSOLEWINDOWS_H
00017
00018 #define WIN32_LEAN_AND_MEAN
00019
00020 #include "IArchConsole.h"
00021 #include "IArchMultithread.h"
00022 #include "stddeque.h"
00023 #include <windows.h>
00024
00025 #define ARCH_CONSOLE CArchConsoleWindows
00026
00028 class CArchConsoleWindows : public IArchConsole {
00029 public:
00030 CArchConsoleWindows(void*);
00031 virtual ~CArchConsoleWindows();
00032
00033
00034 virtual void openConsole(const char* title);
00035 virtual void closeConsole();
00036 virtual void showConsole(bool showIfEmpty);
00037 virtual void writeConsole(const char*);
00038 virtual const char* getNewlineForConsole();
00039
00040 private:
00041 void clearBuffer();
00042 void appendBuffer(const char*);
00043 void setSize(int width, int height);
00044
00045 LRESULT wndProc(HWND, UINT, WPARAM, LPARAM);
00046 static LRESULT CALLBACK
00047 staticWndProc(HWND, UINT, WPARAM, LPARAM);
00048 void threadMainLoop();
00049 static void* threadEntry(void*);
00050
00051 private:
00052 typedef std::deque<std::string> MessageBuffer;
00053
00054 static CArchConsoleWindows* s_instance;
00055 static HINSTANCE s_appInstance;
00056
00057
00058 CArchMutex m_mutex;
00059 CArchCond m_condVar;
00060 bool m_ready;
00061 CArchThread m_thread;
00062
00063
00064 HWND m_frame;
00065 HWND m_hwnd;
00066 LONG m_wChar;
00067 LONG m_hChar;
00068 bool m_show;
00069
00070
00071 size_t m_maxLines;
00072 size_t m_maxCharacters;
00073 size_t m_numCharacters;
00074 MessageBuffer m_buffer;
00075 };
00076
00077 #endif