1 /* 2 Copyright (C) 1998,1999,2000,2001,2002,2003,2004 3 T. Scott Dattalo and Ralf Forsberg 4 5 This file is part of gpsim. 6 7 gpsim is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2, or (at your option) 10 any later version. 11 12 gpsim is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with gpsim; see the file COPYING. If not, write to 19 the Free Software Foundation, 59 Temple Place - Suite 330, 20 Boston, MA 02111-1307, USA. */ 21 22 23 #ifndef __GUI_REGWIN_H__ 24 #define __GUI_REGWIN_H__ 25 26 #include "gui_object.h" 27 #include "gui_register.h" 28 #include "gtkextra/gtksheet.h" 29 30 #include <string> 31 32 class GUI_Processor; 33 34 //====================================================================== 35 // The register window 36 // 37 #define REGISTERS_PER_ROW 16 38 #define MAX_ROWS ((MAX_REGISTERS)/(REGISTERS_PER_ROW)) 39 40 // Base class for RAM_RegisterWindow and EEPROM_RegisterWindow 41 42 class Register_Window : public GUI_Object 43 { 44 public: 45 46 // This array is indexed with row, and gives the address of the 47 // first cell in the given row. 48 int row_to_address[MAX_ROWS]; 49 50 std::string normalfont_string; 51 PangoFontDescription *normalfont; 52 53 GtkStyle *current_line_number_style; 54 GtkStyle *breakpoint_line_number_style; 55 56 REGISTER_TYPE type; 57 GUIRegisterList *registers; 58 GtkSheet *register_sheet; 59 60 RegisterMemoryAccess *rma; // Apointer to the Processor's rma or ema. 61 62 GtkWidget *entry; 63 GtkWidget *location; 64 GtkWidget *popup_menu; 65 66 int registers_loaded; // non zero when registers array is loaded 67 68 69 virtual void Build(); 70 int LoadStyles(); 71 int SettingsDialog(); 72 void UpdateStyle(); 73 void SetRegisterSize(); 74 virtual void Update(); 75 virtual void UpdateASCII(int row); 76 virtual void UpdateLabel(); 77 virtual void UpdateEntry(); 78 virtual void UpdateLabelEntry(); 79 virtual void SelectRegister(Value *); 80 virtual void SelectRegister(int reg_number); 81 virtual void NewProcessor(GUI_Processor *gp); 82 virtual GUIRegister *getRegister(int row, int col); 83 virtual gboolean UpdateRegisterCell(int reg_number); 84 GUIRegister *operator [] (int address); 85 int column_width(int col); 86 int row_height(int row); 87 88 protected: 89 Register_Window(GUI_Processor *gp, REGISTER_TYPE type, const char *name); 90 91 private: 92 GtkWidget *build_menu(); 93 void do_popup(GtkWidget *widget, GdkEventButton *event); 94 static gboolean button_press(GtkWidget *widget, GdkEventButton *event, 95 Register_Window *rw); 96 static gboolean popup_menu_handler(GtkWidget *widget, Register_Window *rw); 97 98 // Formatting 99 int register_size; // The size (in bytes) of a single register 100 int char_width; // nominal character width. 101 int char_height; // nominal character height 102 int chars_per_column; // width of 1 column 103 }; 104 105 class RAM_RegisterWindow : public Register_Window 106 { 107 public: 108 explicit RAM_RegisterWindow(GUI_Processor *gp); 109 virtual void NewProcessor(GUI_Processor *gp); 110 virtual void Update(); 111 }; 112 113 class EEPROM_RegisterWindow : public Register_Window 114 { 115 public: 116 explicit EEPROM_RegisterWindow(GUI_Processor *gp); 117 virtual void NewProcessor(GUI_Processor *gp); 118 }; 119 120 121 #endif // __GUI_REGWIN_H__ 122