summaryrefslogtreecommitdiff
path: root/plugins/MirandaG15/src/LCDFramework/CLCDTextLog.h
blob: 312ec8a992565931d0a516442843f1458e088259 (plain)
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
#ifndef _CLCDTEXTLOG_H_
#define _CLCDTEXTLOG_H_

#include "CLCDTextObject.h"
#include "CLCDBar.h"


enum EScrollMode {SCROLL_NONE, SCROLL_MESSAGE,SCROLL_LINE };
enum EExpandMode { EXPAND_SCROLL, EXPAND_UP,EXPAND_DOWN };

class CLCDTextLog : public CLCDTextObject
{
public:
	

	// Constructor
	CLCDTextLog();
	// Destructor
	~CLCDTextLog();

	// Initializes the log
	bool Initialize();
	// Deinitializes the log
	bool Shutdown();

	// updates the log
	bool Update();
	// draws the log
	bool Draw(CLCDGfx *pGfx);

	// sets the logs text
	void SetText(tstring strText);
	// adds some text to the log
	void AddText(tstring strText,bool bForceAutoscroll=false);
	// sets the maximum number of log entrys
	void SetLogSize(int iSize);
	// clears the log
	void ClearLog();

	// scrolls one line up
	bool ScrollUp();
	// scrolls one line down
	bool ScrollDown();
	// scrolls to the specified line
	bool ScrollTo(int iIndex);

	// associates a scrollbar with the log
	void SetScrollbar(CLCDBar *pScrollbar);

	// sets the autoscrolling mode
	void SetAutoscrollMode(EScrollMode eMode);
	// sets the expand mode
	void SetExpandMode(EExpandMode eMode);

protected:
	// called when the logs font has changed
	void OnFontChanged();
	// called when the logs size has changed
	void OnSizeChanged(SIZE OldSize);

	// rewraps all textlines
	void RefreshLines();
private:
	// the log entry class
	class CLogEntry
	{
	public:
		tstring strString;
		int iLines;
		vector<tstring> vLines;
	};

	// wraps the specified log entry
	void WrapMessage(CLogEntry *pEntry);

	EScrollMode m_eAutoScroll;
	EExpandMode m_eExpandMode;

	int		m_iLogSize;
	int		m_iPosition;
	int		m_iTextLines;
	int		m_iLastScrollDirection;
	
	DWORD	m_dwLastScroll;

	list<CLogEntry*> m_Entrys;
	CLCDBar			*m_pScrollbar;
};

#endif