Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef T_THUMBNAILVIEWE_INCLUDED
Toshihiro Shimizu 890ddd
#define T_THUMBNAILVIEWE_INCLUDED
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tw/scrollview.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//forward declaration
Toshihiro Shimizu 890ddd
class Thumbnail;
Toshihiro Shimizu 890ddd
class TTextField;
Toshihiro Shimizu 890ddd
class TFilePath;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class ThumbnailViewer : public TScrollView
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	vector<thumbnail *=""> m_items;</thumbnail>
Toshihiro Shimizu 890ddd
	int m_selectedItemIndex;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const TDimension m_itemSize;
Toshihiro Shimizu 890ddd
	const TDimension m_itemSpace;
Toshihiro Shimizu 890ddd
	const TDimension m_margins;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	const TRect m_playButtonBox;
Toshihiro Shimizu 890ddd
	const TRect m_iconBox;
Toshihiro Shimizu 890ddd
	const TRect m_textBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TPoint m_oldPos;
Toshihiro Shimizu 890ddd
	bool m_dragDropArmed;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_flag;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	bool m_playing, m_loading;
Toshihiro Shimizu 890ddd
	bool m_timerActive;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	class NameField;
Toshihiro Shimizu 890ddd
	NameField *m_nameField;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	ThumbnailViewer(TWidget *parent, string name = "thumbnailViewer");
Toshihiro Shimizu 890ddd
	~ThumbnailViewer();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void addItem(Thumbnail *item);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! removes the item from the ThumbnailViewer. It doesn't destroy the item
Toshihiro Shimizu 890ddd
	void removeItem(Thumbnail *item);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	TDimension getIconSize() const { return m_iconBox.getSize(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getItemCount() const;
Toshihiro Shimizu 890ddd
	Thumbnail *getItem(int index) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! find the max number of thumbnails which fit the current widget width
Toshihiro Shimizu 890ddd
	int getColumnCount() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! find the bottom-left corner coordinate of the index-th thumbnail (icon+controls)
Toshihiro Shimizu 890ddd
	TPoint getItemPos(int index);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// ! find the region covered by the index-th thumbnail (icon+controls)
Toshihiro Shimizu 890ddd
	TRect getItemBounds(int index);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	// ! coordinate --> thumbnail index; returns -1 if not found
Toshihiro Shimizu 890ddd
	int findItem(const TPoint &pos);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void configureNotify(const TDimension &d);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! draw the index-th thumbnail current frame
Toshihiro Shimizu 890ddd
	void drawFrame(int index);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! draw the index-th thumbnail
Toshihiro Shimizu 890ddd
	void drawItem(int index);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	//! draw the empty space around and between thumbnails
Toshihiro Shimizu 890ddd
	void drawBackground();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void repaint();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void leftButtonDown(const TMouseEvent &e);
Toshihiro Shimizu 890ddd
	void leftButtonDrag(const TMouseEvent &e);
Toshihiro Shimizu 890ddd
	void leftButtonUp(const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void leftButtonDoubleClick(const TMouseEvent &e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onTimer(int);
Toshihiro Shimizu 890ddd
	void startPlaying();
Toshihiro Shimizu 890ddd
	void stopPlaying();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void select(int);
Toshihiro Shimizu 890ddd
	int getSelectedItemIndex() { return m_selectedItemIndex; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void clearItems();
Toshihiro Shimizu 890ddd
	void loadDirectory(const TFilePath &dirPath, const vector<string> &fileTypes);</string>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void updateContentSize();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void middleButtonDown(const TMouseEvent &e) {}
Toshihiro Shimizu 890ddd
	void middleButtonDrag(const TMouseEvent &e) {}
Toshihiro Shimizu 890ddd
	void middleButtonUp(const TMouseEvent &e) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void scrollPage(int y);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	virtual void onDoubleClick(int index) {}
Toshihiro Shimizu 890ddd
	virtual void onSelect(int index) {}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif