bbtkWxGUIOutputMessages.cxx
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00048 #ifdef _USE_WXWIDGETS_
00049
00050 #include "bbtkWxGUIOutputMessages.h"
00051 #include "bbtkMessageManager.h"
00052 #include "bbtkConfigurationFile.h"
00053 #include "bbtkWxStreamRedirector.h"
00054
00055 namespace bbtk
00056 {
00057
00058
00059 WxGUIOutputMessages::WxGUIOutputMessages(wxWindow *parent, WxGUIOutputMessagesUser* user)
00060 : wxPanel(parent,-1),
00061 mUser(user)
00062 {
00063 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
00064 mwxOutputText =
00065 new wxTextCtrl(this,
00066 -1,
00067 _T(""),wxDefaultPosition,
00068 wxDefaultSize,
00069 wxTE_READONLY |
00070 wxTE_MULTILINE );
00071
00072 mFixedFont = new wxFont(10,
00073 wxFONTFAMILY_MODERN,
00074 wxFONTSTYLE_NORMAL,
00075 wxFONTWEIGHT_NORMAL,
00076 false);
00077
00078 mwxOutputTextAttr = new wxTextAttr;
00079 mwxOutputTextAttr->SetFont(*mFixedFont);
00080 sizer->Add ( mwxOutputText, 1, wxGROW);
00081
00082
00083 mRedirect_cout =
00084 new WxStreamRedirector(std::cout,mwxOutputText,*wxBLACK,true);
00085 mRedirect_cerr =
00086 new WxStreamRedirector(std::cerr,mwxOutputText,*wxGREEN,true);
00087
00088 SetSizer(sizer);
00089 SetAutoLayout(true);
00090 Layout();
00091 }
00092
00093 WxGUIOutputMessages::~WxGUIOutputMessages()
00094 {
00095 delete mRedirect_cout;
00096 delete mRedirect_cerr;
00097 delete mwxOutputTextAttr;
00098 delete mFixedFont;
00099 }
00100
00101 void WxGUIOutputMessages::Print(const std::string& message,
00102 const wxColor* col)
00103 {
00104 if (col != 0)
00105 {
00106 mwxOutputTextAttr->SetTextColour(*col);
00107 mwxOutputText->SetDefaultStyle(*mwxOutputTextAttr);
00108 }
00109 mwxOutputText->AppendText(std2wx(message));
00110 if (col != 0)
00111 {
00112 mwxOutputTextAttr->SetTextColour(*wxBLACK);
00113 mwxOutputText->SetDefaultStyle(*mwxOutputTextAttr);
00114 }
00115 }
00116
00117
00118 }
00119
00120 #endif