1/*
2 * Copyright 2001-2022 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Mark Hogben
7 *		DarkWyrm <bpmagic@columbus.rr.com>
8 *		Axel D��rfler, axeld@pinc-software.de
9 *		Philippe Saint-Pierre, stpere@gmail.com
10 */
11#ifndef FONT_SELECTION_VIEW_H
12#define FONT_SELECTION_VIEW_H
13
14
15#include <View.h>
16
17class BLayoutItem;
18class BBox;
19class BMenuField;
20class BPopUpMenu;
21class BSpinner;
22class BTextView;
23
24static const int32 kMsgSetFamily = 'fmly';
25static const int32 kMsgSetStyle = 'styl';
26static const int32 kMsgSetSize = 'size';
27
28
29class FontSelectionView : public BView {
30public:
31								FontSelectionView(const char* name,
32									const char* label,
33									const BFont* font = NULL);
34	virtual						~FontSelectionView();
35
36	virtual void				MessageReceived(BMessage* message);
37
38			void				SetTarget(BHandler* messageTarget);
39
40			void				SetDefaults();
41			void				Revert();
42			bool				IsDefaultable();
43			bool				IsRevertable();
44
45			void				UpdateFontsMenu();
46
47			BLayoutItem*		CreateFontsLabelLayoutItem() const;
48			BLayoutItem*		CreateFontsMenuBarLayoutItem() const;
49			BView*				GetFontSizeSpinner() const;
50			BView*				GetPreviewBox() const;
51
52private:
53			void				_SelectCurrentFont(bool select);
54			void				_SelectCurrentSize();
55			void				_UpdateFontPreview();
56			void				_UpdateSystemFont();
57			void				_BuildSizesMenu();
58
59protected:
60			BHandler*			fMessageTarget;
61
62			BMenuField*			fFontsMenuField;
63			BPopUpMenu*			fFontsMenu;
64
65			BSpinner*			fFontSizeSpinner;
66
67			BBox*				fPreviewBox;
68			BTextView*			fPreviewTextView;
69			float				fPreviewTextWidth;
70
71			BFont				fSavedFont;
72			BFont				fCurrentFont;
73};
74
75#endif	// FONT_SELECTION_VIEW_H
76