bbtkWxGUIOutputMessages.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkWxGUIOutputMessages.cxx,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:15 $
00006   Version:   $Revision: 1.3 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
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, //ID_OutputText,
00067                      _T(""),wxDefaultPosition,
00068                      wxDefaultSize,
00069                      wxTE_READONLY |
00070                      wxTE_MULTILINE );
00071  
00072     wxFont* FixedFont = new wxFont(10,
00073                                    wxFONTFAMILY_MODERN,
00074                                    wxFONTSTYLE_NORMAL,
00075                                    wxFONTWEIGHT_NORMAL,
00076                                    false);
00077 
00078    mwxOutputTextAttr = new wxTextAttr;
00079    mwxOutputTextAttr->SetFont(*FixedFont);
00080    sizer->Add ( mwxOutputText, 1, wxGROW);
00081    
00082    // Redirection of std::cout to mwxTextHistory and printf
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    
00098   } 
00099 
00100   void WxGUIOutputMessages::Print(const std::string& message, 
00101                                   const wxColor* col)
00102   {
00103     if (col != 0)
00104       {
00105         mwxOutputTextAttr->SetTextColour(*col);
00106         mwxOutputText->SetDefaultStyle(*mwxOutputTextAttr);
00107       }
00108     mwxOutputText->AppendText(std2wx(message));
00109     if (col != 0)
00110       {
00111         mwxOutputTextAttr->SetTextColour(*wxBLACK);
00112         mwxOutputText->SetDefaultStyle(*mwxOutputTextAttr);
00113       }
00114   }
00115 
00116 
00117 }
00118 
00119 #endif

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6