aboutsummaryrefslogtreecommitdiff
path: root/FolderView.h
blob: 5c5e9015ce3274a1f6812e9829b42293d60f790a (plain) (blame)
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
#ifndef FOLDERVIEW_H
#define FOLDERVIEW_H

#include "FolderTree.h"
#include "TipWnd.h"

struct CDisplayFolder {
	char *name;
	si32 depth;
	ui32 flags;				// 1=folder
	CFolder *source;
	ui32 index;
	si16 x, y, w, h;
	CDisplayFolder *next;
};

class CFolderView : public CFreeView {
public:
	CFolderView();
	DECLARE_DYNCREATE(CFolderView)
	virtual ~CFolderView();

	virtual void SetDocument(CFreeDoc *doc = NULL);
	virtual void SetPalette(void);

	void BuildTitleReverse(CFolder *folder, CString &string);
	CDisplayFolder *GetDisplayFolderFromPoint(const CPoint &point);
	CDisplayFolder *GetContainerDisplayFolderFromPoint(const CPoint &point);
	void HighlightPathAtPoint(const CPoint &point);

	void ZoomIn(CDisplayFolder *folder);
	void ZoomOut(void);
	void ZoomFull(void);
	void ShowFreeSpace(BOOL show);

	inline bool IsAnythingOpen(void)
		{ return rootfolder != NULL; }
	inline bool IsAnythingSelected(void)
		{ return selected != NULL; }
	inline bool IsSelectedAFolder(void)
		{ return selected != NULL && (selected->flags & 1) != 0; }
	inline bool IsZoomFull(void)
		{ return zoomlevel == 0; }

	void UpdateTitleBar(void);

	void SelectFolder(CDisplayFolder *cur);

	//{{AFX_VIRTUAL(CFolderView)
protected:
	virtual void OnDraw(CDC *pDC);
	//}}AFX_VIRTUAL

protected:
	//{{AFX_MSG(CFolderView)
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnLButtonDown(UINT flags, CPoint point);
	afx_msg void OnLButtonDblClk(UINT flags, CPoint point);
	afx_msg void OnRButtonUp(UINT flags, CPoint point);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDestroy();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	//}}AFX_MSG
	afx_msg void OnIgnoreUpdate(CCmdUI *ui);
	BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT *pResult);
	afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized);
	DECLARE_MESSAGE_MAP()

public:
	virtual void OnUpdate(CFreeDoc *doc);

protected:
	void BuildFolderLayout(int x, int y, int w, int h, CFolder *folder, int depth);
	void SizeFolders(int x, int y, int w, int h, CFolder *folder, int *index, int numindices, int depth);
	CDisplayFolder *AddDisplayFolder(CFolder *source, ui32 index,
		si32 depth, si16 x, si16 y, si16 w, si16 h, ui32 flags);
	void ClearDisplayFolders(void);
	void DrawDisplayFolder(CDC *pDC, CDisplayFolder *cur, BOOL selected);
	void MinimalDrawDisplayFolder(CDC *pDC, CDisplayFolder *cur, BOOL selected);
	void AnimateBox(const CRect &start, const CRect &end);
	void SetupInfoTip(CDisplayFolder *cur);
	void SetupNameTip(CDisplayFolder *cur);

protected:
	CPalette m_palette;
	CBrush black, white;
	CFont minifont;
	CFolder *rootfolder;
	CDisplayFolder *displayfolders, *displayend;
	int vmin, hmin;
	CTipWnd m_infotipwnd;
	CTipWnd m_nametipwnd;
	CDisplayFolder *lastcur;

public:
	int zoomlevel;
	CDisplayFolder *selected;
	BOOL showfreespace;
};

#endif