/*	Copyright  (c)	Günter Woigk 2012 - 2012
					mailto:kio@little-bat.de

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

	Permission to use, copy, modify, distribute, and sell this software and
	its documentation for any purpose is hereby granted without fee, provided
	that the above copyright notice appear in all copies and that both that
	copyright notice and this permission notice appear in supporting
	documentation, and that the name of the copyright holder not be used
	in advertising or publicity pertaining to distribution of the software
	without specific, written prior permission.  The copyright holder makes no
	representations about the suitability of this software for any purpose.
	It is provided "as is" without express or implied warranty.

	THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
	INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
	EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
	CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
	DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
	TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
	PERFORMANCE OF THIS SOFTWARE.
*/


#ifndef MEMORYACCESSINSPECTOR_H
#define MEMORYACCESSINSPECTOR_H

#include "MemoryInspector.h"
class QPushButton;
class MyScrollBar;
class SimpleTerminal;
class QComboBox;
class QBoxLayout;
class GWidgetRGB;
class QCheckBox;
#include "templates/Array.h"
#include "templates/SharedArray.h"
typedef	SharedArray<CoreByte> Mem;


class MemoryAccessInspector : public MemoryInspector
{
	Q_OBJECT

	GWidgetRGB*		graphics_view;
	QComboBox*		combobox_bytes_per_row;	enum { width32, width64, width128, width256, width512 };
	QComboBox*		combobox_pixelzoom;	enum { zoom2, zoom3, zoom4 };
	QComboBox*		combobox_decaymode;	enum { modeFlash, modeDecayFast, modeDecaySlow, modeAccumulate };

	Array<uint32>	rom_pixels;
	Array<uint32>	ram_pixels;

	int				mode;			// combobox_mode
	int				zoom;			// combobox_zoom
	int				pixel_size;		// gem. zoom & space

	bool			first_update;	// we need to redo layout on first update

	void			set_self_to_required_size(bool send_signal);
	void			decay_pixel(uint32* pixels, int cnt, int decay);
	void			copy_access_bits_to_pixels(Mem& mem, uint32* pixels);
	void			prepare_for_fast_decay(uint32* pixels, int cnt);
	void			update_tooltip();

protected:
	virtual void	resizeEvent(QResizeEvent*);
//	virtual void	wheelEvent(QWheelEvent*);
//	virtual void	paintEvent(QPaintEvent*);
//	virtual void	mousePressEvent(QMouseEvent*);
//	virtual void	mouseMoveEvent(QMouseEvent*);
//	virtual bool	event(QEvent*);
//	virtual void	keyPressEvent(QKeyEvent*);
//	virtual void	keyReleaseEvent(QKeyEvent*);
//	virtual void	showEvent(QShowEvent*);
//	virtual void	hideEvent(QHideEvent*);

public:
	MemoryAccessInspector (QWidget*parent, IsaObject*);
	~MemoryAccessInspector();

signals:

private slots:
	virtual void	setMemoryPage(int);				// combobox_memorypage
	virtual void	updateDisplayedData();			// timer
	virtual void	memoryConfigChanged();			// MachineController
//	virtual void	setScrollPosition(int);			// scrollbar
	virtual void	setDataSource(int);				// combobox_datasource
	void			setDecayMode(int);				// combobox_decaymode
	void			setPixelZoom(int);				// combobox_pixelzoom
	void			setBytesPerRow(int);			// combobox_bytes_per_row
};

#endif // MEMORYACCESSINSPECTOR_H
