00001 #include "vgui_qt_statusbar.h" 00002 00003 00004 #include <QStatusBar> 00005 00006 vgui_qt_statusbar::vgui_qt_statusbar(QMainWindow *parent) 00007 : statusbuf(new vgui_statusbuf(this)), 00008 out(statusbuf), 00009 parent_(parent) 00010 { 00011 } 00012 00013 00014 vgui_qt_statusbar::~vgui_qt_statusbar() 00015 { 00016 delete statusbuf; 00017 } 00018 00019 //static int context_id = 1; 00020 00021 int vgui_qt_statusbar::write(const char* text, int n) 00022 { 00023 static bool start_new = false; 00024 if (n == 1) { 00025 if (text[0] == '\n') { 00026 // We are at the end of the message. Set a bool so we know next time 00027 // to clear the buffer before we start a new message. 00028 start_new = true; 00029 } 00030 else if (start_new){ 00031 parent_->statusBar()->showMessage(linebuffer.c_str()); 00032 linebuffer = ""; 00033 linebuffer += text[0]; 00034 start_new = false; 00035 } 00036 else 00037 linebuffer += text[0]; 00038 } 00039 else { 00040 linebuffer.append(text, n); 00041 if (linebuffer.find('\n')) 00042 { 00043 parent_->statusBar()->showMessage(linebuffer.c_str()); 00044 linebuffer = ""; 00045 } 00046 } 00047 return n; 00048 } 00049 00050 00051 int vgui_qt_statusbar::write(const char* text) 00052 { 00053 linebuffer = text; 00054 parent_->statusBar()->showMessage(linebuffer.c_str()); 00055 return 1; 00056 }
1.7.5.1