core/vgui/impl/gtk2/vgui_gtk2_statusbar.cxx
Go to the documentation of this file.
00001 // This is core/vgui/impl/gtk2/vgui_gtk2_statusbar.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \author Philip C. Pritchett, RRG, University of Oxford
00008 // \date   21 Nov 99
00009 // \brief  See vgui_gtk2_statusbar.h for a description of this file.
00010 //-----------------------------------------------------------------------------
00011 
00012 #include "vgui_gtk2_statusbar.h"
00013 
00014 vgui_gtk2_statusbar::vgui_gtk2_statusbar()
00015   : statusbuf(new vgui_statusbuf(this))
00016   , out(statusbuf)
00017 {
00018 }
00019 
00020 
00021 vgui_gtk2_statusbar::~vgui_gtk2_statusbar()
00022 {
00023 //  if (widget)
00024 //    gtk_widget_destroy(widget);
00025   delete statusbuf;
00026 }
00027 
00028 static int context_id = 1;
00029 
00030 int vgui_gtk2_statusbar::write(const char* text, int n) {
00031   if (n == 1) {
00032     if (text[0] == '\n') {
00033       gtk_statusbar_pop(GTK_STATUSBAR(widget), context_id);
00034       gtk_statusbar_push(GTK_STATUSBAR(widget), context_id, linebuffer.c_str() );
00035       linebuffer = "";
00036     }
00037     else
00038       linebuffer += text[0];
00039   }
00040   else {
00041     linebuffer.append(text, n);
00042     if (linebuffer.find('\n')) {
00043       gtk_statusbar_pop(GTK_STATUSBAR(widget), context_id);
00044       gtk_statusbar_push(GTK_STATUSBAR(widget), context_id, linebuffer.c_str() );
00045       linebuffer = "";
00046     }
00047   }
00048   return n;
00049 }
00050 
00051 
00052 int vgui_gtk2_statusbar::write(const char* text) {
00053 
00054   gtk_statusbar_pop(GTK_STATUSBAR(widget), context_id);
00055   gtk_statusbar_push(GTK_STATUSBAR(widget), context_id, text );
00056   return 1;
00057 }