core/vgui/vgui_tview_launcher_tableau.cxx
Go to the documentation of this file.
00001 // This is core/vgui/vgui_tview_launcher_tableau.cxx
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005 //:
00006 // \file
00007 // \brief  See vgui_tview_launcher.h for a description of this file.
00008 // \author Philip C. Pritchett, RRG, University of Oxford
00009 // \date   21 Oct 99
00010 //
00011 // \verbatim
00012 //  Modifications
00013 //   04-OCT-2002 K.Y.McGaul - Sort out bug in vgui_event_condition.
00014 //                          - Launch tview in a dialog box instead of window.
00015 // \endverbatim
00016 
00017 
00018 #include "vgui_tview_launcher_tableau.h"
00019 #include <vcl_iostream.h>
00020 #include <vgui/vgui.h>
00021 #include <vgui/vgui_adaptor.h>
00022 #include <vgui/vgui_viewer2D_tableau.h>
00023 #include <vgui/vgui_tview_tableau.h>
00024 #include <vgui/vgui_dialog.h>
00025 
00026 vgui_tview_launcher_tableau::vgui_tview_launcher_tableau()
00027   : c_graph(vgui_key('g'), vgui_SHIFT) { }
00028 
00029 vcl_string vgui_tview_launcher_tableau::type_name() const
00030 {
00031   return "vgui_tview_launcher_tableau";
00032 }
00033 
00034 bool vgui_tview_launcher_tableau::handle(const vgui_event& e)
00035 {
00036   if (c_graph(e)) {
00037     go(e.origin);
00038     return true;
00039   }
00040 
00041   return e.type == vgui_DRAW || e.type == vgui_DRAW_OVERLAY;
00042 }
00043 
00044 static void launch(const void* t)
00045 {
00046   // a static_cast may not cast away const.
00047   void *Pv = const_cast<void*>(t);
00048   static_cast<vgui_tview_launcher_tableau*>(Pv)->go(vgui_adaptor::current);
00049 }
00050 
00051 void vgui_tview_launcher_tableau::get_popup(const vgui_popup_params& /*params*/, vgui_menu &m)
00052 {
00053   m.add("View tableau hierarchy", launch, this);
00054 }
00055 
00056 void vgui_tview_launcher_tableau::go(vgui_adaptor* a)
00057 {
00058   if (!a) {
00059     vcl_cerr << __FILE__ ": a = 0\n";
00060     return;
00061   }
00062   vgui_tview_tableau_new tview(a->get_tableau());
00063   vgui_viewer2D_tableau_new viewer(tview);
00064 
00065   vgui_dialog tview_dialog("Tableau hierarchy");
00066   tview_dialog.inline_tableau(viewer, 300,300);
00067   tview_dialog.set_ok_button("close");
00068   tview_dialog.set_cancel_button(0);
00069   tview_dialog.ask();
00070   this->post_redraw();
00071 }