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 <vector>
00023 #include <map>
00024 
00025 #include <gtkmm.h>
00026 
00027 #include <bit/bit.h>
00028 
00029 namespace bitGtk
00030   {
00031 
00035   class BufferTable : public Gtk::HBox
00036     {
00037     public:
00038       BufferTable();
00039 
00040       ~BufferTable();
00041 
00042       void set_record(bit::FieldBase::pointer record);
00043 
00044       void set_buffer(bit::RecordBuffer::pointer buffer);
00045 
00046       void set_bit_width(size_t w);
00047 
00048       void enable_tooltips(bool b=true);
00049 
00050       void enable_highlighter(bool b=true);
00051       void set_bg_color(std::string s);
00052 
00053       void add_color_set(std::string normal_color, std::string highlight_color="yellow");
00054       void clear_color_sets();
00055 
00056     protected:
00057       struct FieldBox
00058         {
00059           FieldBox() { }
00060           std::vector<Gtk::Label*> m_field_labels;
00061           std::vector<Gtk::EventBox*> m_field_event_boxes;
00062           std::vector<Gtk::Label*> m_value_labels;
00063           std::vector<Gtk::EventBox*> m_value_event_boxes;
00064           std::vector<Gtk::VBox*> m_highlight_boxes;
00065         };
00066 
00067       std::map<bit::FieldBase::pointer, FieldBox > m_fieldbox;
00068 
00069       bit::RecordBuffer::pointer m_buffer;
00070       bit::FieldBase::pointer m_record;
00071       std::list<std::pair<Gdk::Color, Gdk::Color> > m_colors;
00072       Gtk::Tooltips m_tooltips;
00073       bool m_highlighter_enabled;
00074       Gdk::Color m_bg_color;
00075 
00076       size_t m_display_bit_width;
00077       Gtk::Table* m_table;
00078       Gtk::EventBox m_tablebox;
00079       Gtk::EventBox m_tableboxouter;
00080 
00081       void on_record_changed();
00082       void on_field_value_changed(bit::FieldBuffer);
00083 
00084       void set_field_value( bit::FieldBase::pointer field );
00085       void load_all_field_values();
00086       void load_all_field_values( bit::FieldBase::pointer );
00087 
00088       void create_table();
00089       void setup_table();
00090       void create_fieldboxes(bit::FieldBase::pointer fb);
00091       void add_fieldbox(bit::FieldBase::pointer, unsigned left, unsigned right, unsigned top, unsigned bottom, Gdk::Color bg, Gdk::Color hl);
00092 
00093       bool on_enter(GdkEventCrossing*, bit::FieldBase::pointer);
00094       bool on_leave(GdkEventCrossing*, bit::FieldBase::pointer);
00095 
00096     };
00097 
00098 }
00099 
00100 #endif

Generated on Mon Mar 12 22:06:05 2007 by  doxygen 1.5.1