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

pandatool/src/gtk-stats/gtkStatsGuide.cxx

Go to the documentation of this file.
00001 // Filename: gtkStatsGuide.cxx
00002 // Created by:  drose (16Jul00)
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 "gtkStatsGuide.h"
00020 
00021 #include <pStatStripChart.h>
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //     Function: GtkStatsGuide::Constructor
00025 //       Access: Public
00026 //  Description:
00027 ////////////////////////////////////////////////////////////////////
00028 GtkStatsGuide::
00029 GtkStatsGuide(PStatStripChart *chart) :
00030   _chart(chart)
00031 {
00032   set_events(GDK_EXPOSURE_MASK);
00033 
00034   // Choose a suitable minimum width.  This requires knowing what the
00035   // font will be.
00036   Gdk_Font font = get_style()->gtkobj()->font;
00037   int text_width = font.string_width("0000");
00038   set_usize(text_width, 0);
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: GtkStatsGuide::configure_event_impl
00043 //       Access: Private, Virtual
00044 //  Description: Creates a new backing pixmap of the appropriate size.
00045 ////////////////////////////////////////////////////////////////////
00046 gint GtkStatsGuide::
00047 configure_event_impl(GdkEventConfigure *) {
00048   Gdk_Window window = get_window();
00049 
00050   return true;
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: GtkStatsGuide::expose_event_impl
00055 //       Access: Private, Virtual
00056 //  Description: Redraw the text.  We don't bother with clipping
00057 //               regions here, but just draw the whole thing every
00058 //               time.
00059 ////////////////////////////////////////////////////////////////////
00060 gint GtkStatsGuide::
00061 expose_event_impl(GdkEventExpose *event) {
00062   Gdk_GC fg_gc =
00063     get_style()->gtkobj()->fg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))];
00064   Gdk_GC bg_gc =
00065     get_style()->gtkobj()->bg_gc[GTK_WIDGET_STATE (GTK_WIDGET(gtkobj()))];
00066 
00067   if (fg_gc && bg_gc) {
00068     Gdk_Window window = get_window();
00069     window.draw_rectangle(bg_gc, true, 0, 0, width(), height());
00070     
00071     Gdk_Font font = fg_gc.get_font();
00072     int text_ascent = font.ascent();
00073     
00074     int num_guide_bars = _chart->get_num_guide_bars();
00075     for (int i = 0; i < num_guide_bars; i++) {
00076       const PStatStripChart::GuideBar &bar = _chart->get_guide_bar(i);
00077       int y = _chart->height_to_pixel(bar._height);
00078       
00079       if (y >= 5) {
00080         // Only draw it if it's not too close to the top.
00081         window.draw_string(font, fg_gc, 0, y + text_ascent / 2,
00082                            bar._label);
00083       }
00084     }
00085   }
00086 
00087   return false;
00088 }

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