summaryrefslogtreecommitdiffstats
path: root/src/gui/symbolviewer.h
blob: a85253fb9cd2935ce230e36cd4fdcc4853518195 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/***************************************************************************
 *   Copyright (C) 2005 by David Saxton                                    *
 *   david@bluehaze.org                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef NO_GPSIM

#ifndef SYMBOLVIEWER_H
#define SYMBOLVIEWER_H

#include <tdelistview.h>
#include <tqguardedptr.h>

class KComboBox;
class RegisterInfo;
class RegisterSet;
class SymbolViewer;
namespace KateMDI { class ToolView; }


/**
@author David Saxton
*/
class SymbolViewer : public TQWidget
{
	Q_OBJECT
  
	public:
		static SymbolViewer * self( KateMDI::ToolView * parent = 0l );
		static TQString toolViewIdentifier() { return "SymbolViewer"; }
		~SymbolViewer();
		
		enum Radix
		{
			Binary = 2,
			Octal = 8,
			Decimal = 10,
			Hexadecimal = 16
		};
		
		Radix valueRadix() const { return m_valueRadix; }
		
		TDEListView * symbolList() const { return m_pSymbolList; }
		/**
		 * Write the current properties (such as currently selected radix) to
		 * the config.
		 */
		void saveProperties( TDEConfig * config );
		/**
		 * Reads the properties (such as the last selected radix) from the
		 * config file.
		 */
		void readProperties( TDEConfig * config );
		
		void setContext( GpsimProcessor * gpsim );
		/** 
		 * Converts the value to a string for display according to the currently
		 * selected radix.
		 */
		TQString toDisplayString( unsigned value ) const;
		
	signals:
		void valueRadixChanged( SymbolViewer::Radix newRadix );
		
	public slots:
		void selectRadix( int selectIndex );
		
	protected:
		TQGuardedPtr<GpsimProcessor> m_pGpsim;
		RegisterSet * m_pCurrentContext;
		TDEListView * m_pSymbolList;
		Radix m_valueRadix;

	private:
		SymbolViewer( KateMDI::ToolView * parent );
		static SymbolViewer * m_pSelf;
		KComboBox * m_pRadixCombo;
};


class SymbolViewerItem : public TQObject, public TDEListViewItem
{
	Q_OBJECT
  
	public:
		SymbolViewerItem( SymbolViewer * symbolViewer, RegisterInfo * registerInfo );
		
	public slots:
		void valueChanged( unsigned newValue );
		void radixChanged();
		
	protected:
		RegisterInfo * m_pRegisterInfo;
		SymbolViewer * m_pSymbolViewer;
};

#endif

#endif