buffertable.h

00001 /***************************************************************************
00002  *   Copyright (C) 2001 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation version 2.1.                *
00008  *                                                                         *
00009  *   This program is distributed in the hope that it will be useful,       *
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00012  *   GNU General Public License for more details.                          *
00013  *                                                                         *
00014  *   You should have received a copy of the GNU Lesser General Public      *
00015  *   License along with this library; if not, write to the                 *
00016  *   Free Software Foundation, Inc.,                                       *
00017  *   51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA              *
00018  ***************************************************************************/
00019 #ifndef BIT_GTKBUFFERTABLE_H
00020 #define BIT_GTKBUFFERTABLE_H
00021 
00022 #include <gtkmm.h>
00023 #include <vector>
00024 #include <map>
00025 #include <bit/bit.h>
00026 
00027 namespace bitGtk
00028   {
00029 
00033   class BufferTable : public Gtk::HBox
00034     {
00035     public:
00036       BufferTable();
00037 
00038       ~BufferTable();
00039 
00040       void set_record(bit::FieldBase::pointer record);
00041 
00042       void set_buffer(bit::RecordBuffer& buffer);
00043 
00044       void set_bit_width(size_t w);
00045 
00046       void enable_tooltips(bool b=true);
00047 
00048       void enable_highlighter(bool b=true);
00049       void set_bg_color(std::string s);
00050 
00051       void add_color_set(std::string normal_color, std::string highlight_color="yellow");
00052       void clear_color_sets();
00053 
00054     protected:
00055       typedef struct FieldBox
00056         {
00057           std::vector<Gtk::Label*> m_field_labels;
00058           std::vector<Gtk::EventBox*> m_field_event_boxes;
00059           std::vector<Gtk::Label*> m_value_labels;
00060           std::vector<Gtk::EventBox*> m_value_event_boxes;
00061           std::vector<Gtk::VBox*> m_highlight_boxes;
00062         }
00063       FieldBox;
00064 
00065       std::map<bit::FieldBase::pointer, FieldBox > m_fieldbox;
00066 
00067       bit::RecordBuffer* m_buffer;
00068       bit::FieldBase::pointer m_record;
00069       std::list<std::pair<Gdk::Color, Gdk::Color> > m_colors;
00070       Gtk::Tooltips m_tooltips;
00071       bool m_highlighter_enabled;
00072       Gdk::Color m_bg_color;
00073 
00074       size_t m_display_bit_width;
00075       Gtk::Table* m_table;
00076       Gtk::EventBox m_tablebox;
00077       Gtk::EventBox m_tableboxouter;
00078 
00079       void on_record_changed();
00080       void on_field_value_changed(bit::FieldBuffer);
00081 
00082       void set_field_value( bit::FieldBase::pointer field );
00083       void load_all_field_values();
00084       void load_all_field_values( bit::FieldBase::pointer );
00085 
00086       void create_table();
00087       void setup_table();
00088       void create_fieldboxes(bit::FieldBase::pointer fb);
00089       void add_fieldbox(bit::FieldBase::pointer, unsigned left, unsigned right, unsigned top, unsigned bottom, Gdk::Color bg, Gdk::Color hl);
00090 
00091       bool on_enter(GdkEventCrossing*, bit::FieldBase::pointer);
00092       bool on_leave(GdkEventCrossing*, bit::FieldBase::pointer);
00093 
00094     };
00095 
00096 }
00097 
00098 #endif

Generated on Thu Jul 6 15:47:55 2006 by  doxygen 1.4.6