Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/gtk-stats/gtkStatsWindow.cxx

Go to the documentation of this file.
00001 // Filename: gtkStatsWindow.cxx
00002 // Created by:  drose (14Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "gtkStatsWindow.h"
00020 #include "gtkStatsMonitor.h"
00021 #include "gtkStatsStripWindow.h"
00022 #include "gtkStatsPianoWindow.h"
00023 
00024 using Gtk::Menu_Helpers::MenuElem;
00025 using Gtk::Menu_Helpers::SeparatorElem;
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: GtkStatsWindow::Constructor
00029 //       Access: Public
00030 //  Description:
00031 ////////////////////////////////////////////////////////////////////
00032 GtkStatsWindow::
00033 GtkStatsWindow(GtkStatsMonitor *monitor) : _monitor(monitor) {
00034   _monitor->add_window(this);
00035   update_title();
00036   setup();
00037 
00038   _main_box = new Gtk::VBox;
00039   _main_box->show();
00040   add(*manage(_main_box));
00041 
00042   _menu = manage(new Gtk::MenuBar);
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: GtkStatsWindow::destruct
00047 //       Access: Public, Virtual
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 bool GtkStatsWindow::
00051 destruct() {
00052   if (BasicGtkWindow::destruct()) {
00053     _monitor->remove_window(this);
00054     _monitor.clear();
00055     return true;
00056   }
00057   return false;
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: GtkStatsWindow::update_title
00062 //       Access: Public, Virtual
00063 //  Description: Sets the title bar appropriately, once the client's
00064 //               information is known.
00065 ////////////////////////////////////////////////////////////////////
00066 void GtkStatsWindow::
00067 update_title() {
00068   if (_monitor->is_client_known()) {
00069     string title =
00070       _monitor->get_client_progname() + " from " + _monitor->get_client_hostname();
00071     if (!_monitor->is_alive()) {
00072       title += " (closed)";
00073     }
00074     set_title(title);
00075   }
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //     Function: GtkStatsWindow::mark_dead
00080 //       Access: Public, Virtual
00081 //  Description: Called when the client's connection has been lost,
00082 //               this should update the window in some obvious way to
00083 //               indicate that the window is no longer live.
00084 ////////////////////////////////////////////////////////////////////
00085 void GtkStatsWindow::
00086 mark_dead() {
00087   update_title();
00088 }
00089 
00090 ////////////////////////////////////////////////////////////////////
00091 //     Function: GtkStatsWindow::new_collector
00092 //       Access: Public, Virtual
00093 //  Description: Called when a new collector has become known, in case
00094 //               the window cares.
00095 ////////////////////////////////////////////////////////////////////
00096 void GtkStatsWindow::
00097 new_collector() {
00098 }
00099 
00100 ////////////////////////////////////////////////////////////////////
00101 //     Function: GtkStatsWindow::idle
00102 //       Access: Public, Virtual
00103 //  Description:
00104 ////////////////////////////////////////////////////////////////////
00105 void GtkStatsWindow::
00106 idle() {
00107   if (_monitor->_new_collector) {
00108     new_collector();
00109   }
00110 }
00111 
00112 ////////////////////////////////////////////////////////////////////
00113 //     Function: GtkStatsWindow::setup_menu
00114 //       Access: Protected, Virtual
00115 //  Description:
00116 ////////////////////////////////////////////////////////////////////
00117 void GtkStatsWindow::
00118 setup_menu() {
00119   _file_menu = new Gtk::Menu;
00120 
00121   _file_menu->items().push_back
00122     (MenuElem("New strip chart",
00123               slot(this, &GtkStatsWindow::menu_open_strip_chart)));
00124   _file_menu->items().push_back
00125     (MenuElem("New piano roll",
00126               slot(this, &GtkStatsWindow::menu_open_piano_roll)));
00127 
00128   /*
00129   _file_menu->items().push_back
00130     (MenuElem("New window",
00131               slot(this, &GtkStatsWindow::menu_new_window)));
00132   */
00133 
00134   _file_menu->items().push_back(SeparatorElem());
00135 
00136   _file_menu->items().push_back
00137     (MenuElem("Disconnect from client",
00138               slot(this, &GtkStatsWindow::menu_disconnect)));
00139   _file_menu->items().push_back
00140     (MenuElem("Close window",
00141               slot(this, &GtkStatsWindow::menu_close_window)));
00142   _file_menu->items().push_back
00143     (MenuElem("Close all windows this client",
00144               slot(this, &GtkStatsWindow::menu_close_all_windows)));
00145 
00146   _menu->items().push_back(MenuElem("File", *manage(_file_menu)));
00147   _menu->show();
00148   _main_box->pack_start(*_menu, false, false);
00149 }
00150 
00151 ////////////////////////////////////////////////////////////////////
00152 //     Function: GtkStatsWindow::menu_open_strip_chart
00153 //       Access: Protected
00154 //  Description: Open up a new strip-chart style window for the main
00155 //               thread.
00156 ////////////////////////////////////////////////////////////////////
00157 void GtkStatsWindow::
00158 menu_open_strip_chart() {
00159   new GtkStatsStripWindow(_monitor, 0, 0, false, 400, 100);
00160 }
00161 
00162 ////////////////////////////////////////////////////////////////////
00163 //     Function: GtkStatsWindow::menu_open_piano_roll
00164 //       Access: Protected
00165 //  Description: Open up a new piano-roll style window for the main
00166 //               thread.
00167 ////////////////////////////////////////////////////////////////////
00168 void GtkStatsWindow::
00169 menu_open_piano_roll() {
00170   new GtkStatsPianoWindow(_monitor, 0, 400, 100);
00171 }
00172 
00173 ////////////////////////////////////////////////////////////////////
00174 //     Function: GtkStatsWindow::menu_new_window
00175 //       Access: Protected, Virtual
00176 //  Description:
00177 ////////////////////////////////////////////////////////////////////
00178 void GtkStatsWindow::
00179 menu_new_window() {
00180 }
00181 
00182 ////////////////////////////////////////////////////////////////////
00183 //     Function: GtkStatsWindow::menu_close_window
00184 //       Access: Protected
00185 //  Description:
00186 ////////////////////////////////////////////////////////////////////
00187 void GtkStatsWindow::
00188 menu_close_window() {
00189   destruct();
00190 }
00191 
00192 ////////////////////////////////////////////////////////////////////
00193 //     Function: GtkStatsWindow::menu_close_all_windows
00194 //       Access: Protected
00195 //  Description:
00196 ////////////////////////////////////////////////////////////////////
00197 void GtkStatsWindow::
00198 menu_close_all_windows() {
00199   _monitor->close_all_windows();
00200 }
00201 
00202 ////////////////////////////////////////////////////////////////////
00203 //     Function: GtkStatsWindow::menu_disconnect
00204 //       Access: Protected
00205 //  Description:
00206 ////////////////////////////////////////////////////////////////////
00207 void GtkStatsWindow::
00208 menu_disconnect() {
00209   _monitor->close();
00210 }

Generated on Fri May 2 03:20:04 2003 for Panda-Tool by doxygen1.3