1/*
2 * Copyright 2006 Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan A��mus, superstippi@gmx.de
7 */
8#ifndef EXPRESSION_TEXT_VIEW_H
9#define EXPRESSION_TEXT_VIEW_H
10
11
12#include <List.h>
13#include <String.h>
14
15#include "InputTextView.h"
16
17
18class CalcView;
19
20class ExpressionTextView : public InputTextView {
21 public:
22								ExpressionTextView(BRect frame,
23									CalcView* calcView);
24	virtual						~ExpressionTextView();
25
26	// BView
27	virtual	void				MakeFocus(bool focused = true);
28	virtual	void				KeyDown(const char* bytes, int32 numBytes);
29
30	virtual	void				MouseDown(BPoint where);
31
32	// TextView
33	virtual	void				GetDragParameters(BMessage* dragMessage,
34									BBitmap** bitmap, BPoint* point,
35									BHandler** handler);
36	virtual	void 				SetTextRect(BRect rect);
37
38	// InputTextView
39	virtual	void				RevertChanges();
40	virtual	void				ApplyChanges();
41
42	// ExpressionTextView
43			void				AddKeypadLabel(const char* label);
44
45			void				SetExpression(const char* expression);
46			void				SetValue(BString value, BString decimalSeparator = ".");
47
48			void				BackSpace();
49			void				Clear();
50
51			void				AddExpressionToHistory(const char* expression);
52			void				PreviousExpression();
53			void				NextExpression();
54
55			void				LoadSettings(const BMessage* archive);
56			status_t			SaveSettings(BMessage* archive) const;
57
58 private:
59			CalcView*			fCalcView;
60			BString				fKeypadLabels;
61
62			BList				fPreviousExpressions;
63			int32				fHistoryPos;
64			BString				fCurrentExpression;
65			BString				fCurrentValue;
66
67			bool				fChangesApplied;
68};
69
70#endif // EXPRESSION_TEXT_VIEW_H
71