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