1/*
2 * Copyright 2011-2015, Rene Gollent, rene@gollent.com. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef INSPECTOR_WINDOW_H
6#define INSPECTOR_WINDOW_H
7
8
9#include <Window.h>
10
11#include "ExpressionInfo.h"
12#include "MemoryView.h"
13#include "Team.h"
14#include "TeamMemoryBlock.h"
15#include "Types.h"
16
17
18class BButton;
19class BMenuField;
20class BMessenger;
21class BStringView;
22class BTextControl;
23class GuiTeamUiSettings;
24class SourceLanguage;
25class UserInterfaceListener;
26
27
28class InspectorWindow : public BWindow, private Team::Listener,
29	private TeamMemoryBlock::Listener,	private MemoryView::Listener,
30	private ExpressionInfo::Listener {
31public:
32								InspectorWindow(::Team* team,
33									UserInterfaceListener* listener,
34									BHandler* target);
35	virtual						~InspectorWindow();
36
37	static	InspectorWindow*	Create(::Team* team,
38									UserInterfaceListener* listener,
39									BHandler* target);
40										// throws
41
42	virtual void				MessageReceived(BMessage* message);
43	virtual bool				QuitRequested();
44
45	// Team::Listener
46	virtual	void				ThreadStateChanged(
47									const Team::ThreadEvent& event);
48
49	virtual	void				MemoryChanged(
50									const Team::MemoryChangedEvent& event);
51
52	// TeamMemoryBlock::Listener
53	virtual void				MemoryBlockRetrieved(TeamMemoryBlock* block);
54	virtual void				MemoryBlockRetrievalFailed(
55									TeamMemoryBlock* block, status_t result);
56
57	// MemoryView::Listener
58	virtual	void				TargetAddressChanged(target_addr_t address);
59	virtual	void				HexModeChanged(int32 newMode);
60	virtual	void				EndianModeChanged(int32 newMode);
61	virtual	void				TextModeChanged(int32 newMode);
62
63	// ExpressionInfo::Listener
64	virtual	void				ExpressionEvaluated(ExpressionInfo* info,
65									status_t result, ExpressionResult* value);
66
67			status_t			LoadSettings(
68									const GuiTeamUiSettings& settings);
69			status_t			SaveSettings(
70									BMessage& settings);
71
72private:
73	void						_Init();
74
75	void						_LoadMenuFieldMode(BMenuField* field,
76									const char* name,
77									const BMessage& settings);
78	status_t					_SaveMenuFieldMode(BMenuField* field,
79									const char* name,
80									BMessage& settings);
81
82	void						_SetToAddress(target_addr_t address);
83	void						_SetCurrentBlock(TeamMemoryBlock* block);
84
85	void						_SetEditMode(bool enabled);
86
87	bool						_GetWritableState() const;
88
89	void						_UpdateWritableOptions();
90
91	void						_UpdateWritableIndicator();
92	const char*					_GetCurrentWritableIndicator() const;
93
94private:
95	UserInterfaceListener*		fListener;
96	BTextControl*				fAddressInput;
97	BMenuField*					fHexMode;
98	BMenuField*					fEndianMode;
99	BMenuField*					fTextMode;
100	BStringView*				fWritableBlockIndicator;
101	MemoryView*					fMemoryView;
102	BButton*					fPreviousBlockButton;
103	BButton*					fNextBlockButton;
104	BButton*					fEditBlockButton;
105	BButton*					fCommitBlockButton;
106	BButton*					fRevertBlockButton;
107	TeamMemoryBlock*			fCurrentBlock;
108	target_addr_t				fCurrentAddress;
109	::Team*						fTeam;
110	SourceLanguage*				fLanguage;
111	ExpressionInfo*				fExpressionInfo;
112	BHandler*					fTarget;
113};
114
115#endif // INSPECTOR_WINDOW_H
116