// Original Copyright (c) Iuri Apollonio 1998
// Use & modify as you want & need, and leave those 3 lines.
// http://www.codeguru.com
// NEW Feature version by krkim(c),gigasoft@korea.com
// krkim@otech.co.kr
#if !defined(AFX_OUTBARCTRL_H__28FA2CA4_11B7_11D2_8437_0000B43382FE__INCLUDED_)
#define AFX_OUTBARCTRL_H__28FA2CA4_11B7_11D2_8437_0000B43382FE__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// OutLookBarCtrl.h : header file 
// 
#define NSOUTBAR_CLASSNAME	"NSOutBarCtrl"
/////////////////////////////////////////////////////////////////////////////
// COutBarCtrl window

#include <afxcoll.h>

#define WM_OUTBAR_NOTIFY		WM_USER + 1
#define NM_OB_ITEMCLICK			1
#define NM_OB_FOLDERCLICK		2

struct OUTBARINFO 
{
	int				index;
	const char *	cText;
	int				iDragFrom;
	int				iDragTo;
};

class COutBarCtrl : public CWnd
{
// Construction
	DECLARE_DYNCREATE(COutBarCtrl)
public:
	COutBarCtrl();

	enum {  fSmallIcon = 1 << 0, fLargeIcon = 1 << 1,fAnimation = 1 << 2};

	enum { ircIcon = 1, ircLabel = 2, ircAll = 3 };

// Attributes
public:
	COLORREF	crBackGroundColor;
	COLORREF	crTextColor;
	COLORREF	cr3dFace, crLightBorder, crHilightBorder, crShadowBorder, crDkShadowBorder;
	int			iFolderHeight;

	int			xSmallIconLabelOffset, yLargeIconLabelOffset;
	int			ySmallIconSpacing, yLargeIconSpacing;

	int			xLeftMargin, yTopMargin;
	bool		bUpArrow, bDownArrow, bUpPressed, bDownPressed;
	CRect		rcUpArrow, rcDownArrow;
	bool		bLooping;

	int			iHitInternal1, iHitInternal2;

	long		lAnimationTickCount;


	DWORD		dwFlags;

	CPtrArray	arFolder;

	int			iLastFolderHighlighted;
	int			iLastSelectedFolder;
	int			iFirstItem;

	int			iLastItemHighlighted;
	bool		bPressedHighlight;
	class CBarItem
	{
	public:
		CBarItem(const char * name, const int image, DWORD exData);
		virtual  ~CBarItem();
		int				iImageIndex;
		char *			cItem;
		DWORD			dwData;
	};

	class CBarFolder
	{
	public:
		CBarFolder(const char * name, DWORD exData);
		virtual  ~CBarFolder();
		int GetItemCount();
		int InsertItem(int index, const char * text, const int image, const DWORD exData);
		char *			cName;
		DWORD			dwData;
		CImageList *	pLargeImageList;
		CImageList *	pSmallImageList;
		CPtrArray		arItems;
		CWnd *			pChild;
	};

	int iSelFolder;

	CImageList *	pLargeImageList;
	CImageList *	pSmallImageList;

	HCURSOR			hDragCursor;
	HCURSOR			hNoDragCursor;

	CPen *			pBlackPen;

// Operations
public:
	enum { htNothing = -1, htFolder, htItem, htUpScroll, htDownScroll};

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(COutBarCtrl)
	//}}AFX_VIRTUAL

// Implementation
public:
	void RemoveAllFolder();
	void DrawFocusMark(CDC *pDC,RECT rect);
	BOOL m_bIsFocused;
	int m_yBorderGap;
	int m_xBorderGap;
	void DrawBorder(CDC *pDC,CRect rect);
	void GetItemText(const int index,LPSTR lpItemText);
	void GetFolderName(int iFolder,LPSTR lpName);
	void SetRoundFolder(bool flag=true);
	void SetRoundItem(bool flag=true);
	bool m_bRoundFolder;
	bool m_bRoundItem;
	COLORREF GetDepthColor(COLORREF color, int depth);
	void SetBackgroundColor(COLORREF color);
	CFont m_Font;
	COLORREF crSelectedTextColor;
	COLORREF crSelectedBkColor;
	int GetSelectedItem();
	int m_nPrevItemIndex;
	int m_nCurItemIndex;
	BOOL RegisterWindowClass();
	void RemoveItem(const int index);
	DWORD GetFolderData(int iFolder = -1);
	CWnd * GetFolderChild(int iFolder = -1);
	int AddFolderBar(const char * pFolder, CWnd * pSon, const DWORD exData = 0);
	CString GetItemText(const int index);
	void SetAnimationTickCount(const long value) { lAnimationTickCount = value; };
	long GetAnimationTickCount() { return lAnimationTickCount; };

	void AnimateFolderScroll(const int iFrom, const int iTo);
	void SetItemImage(const int index, const int iImage);
	void SetItemData(const int index, const DWORD dwData);
	int  GetItemImage(const int index) const;
	DWORD GetItemData(const int index) const;
	DWORD GetItemData(const int nfolder,const int index) const;

	bool IsValidItem(const int index) const;
	bool IsValidItem(const int nfolder,const int index) const;
	void SetItemText(const int index, const char * text);
	void SetFolderText(const int index, const char * text);
	void GetLabelRect(const int iFolder, const int iIndex, CRect &rect);
	void GetIconRect(const int iFolder, const int iIndex, CRect &rect);
	void HighlightItem(const int index);
	void GetVisibleRange(const int iFolder, int &first, int &last);
	void DrawItem(CDC * pDC, const int iFolder, CRect rc, const int index,bool bselected= 0);
	CImageList * GetFolderImageList(const int index, const bool bSmall) const;
	CSize GetItemSize(const int iFolder, const int index, const int type);
	void PaintItems(CDC * pDC, const int iFolder, CRect rc);
	CImageList * GetImageList(CImageList * pImageList, int nImageList);
	CImageList * SetFolderImageList(const int folder, CImageList * pImageList, int nImageList);
	CImageList * SetImageList(CImageList * pImageList, int nImageList);
	int GetCountPerPage() const;
	void RemoveFolder(const int index);
	int GetSelFolder() const;
	int GetFolderCount() const;
	void SetSelFolder(const int FolderIndex,const int ItemIndex = -1);
	int GetItemCount() const;
	int InsertItem(const int folder, const int index, const char * text, const int image = -1, const DWORD exData = 0);
	void HighlightFolder(const int index);
	int HitTestEx(const CPoint &point, int &index);
	void GetInsideRect(CRect &rect) const;
	int AddFolder(const char * cFolderName, const DWORD exData);
	void GetItemRect(const int iFolder, const int iIndex, CRect &rect);
	bool GetFolderRect(const int iIndex, CRect &rect) const;
	void ModifyFlag(const DWORD &dwRemove, const DWORD &dwAdd, const UINT redraw = 0);
	DWORD GetFlag() const;
	void SetSmallIconView(const bool bSet);
	bool IsSmallIconView() const;
	BOOL Create(DWORD dwStyle, const RECT& rect, CWnd * pParentWnd, UINT nID, const DWORD dwFlag = fAnimation);
	virtual ~COutBarCtrl();

	// Generated message map functions
protected:
	void DrawFolder(CDC * pDC, const int iIdx, CRect rect, const bool bSelected);
	//{{AFX_MSG(COutBarCtrl)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnKillFocus(CWnd* pNewWnd);
	//}}AFX_MSG
	//Class Wizard 에는 지원안되는 메세지 수동추가
	afx_msg LRESULT OnSetFont(WPARAM hFont, LPARAM lParam);
	afx_msg LRESULT OnGetFont(WPARAM hFont, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_OUTBARCTRL_H__28FA2CA4_11B7_11D2_8437_0000B43382FE__INCLUDED_)
