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 17 class BLayoutItem; 18 class BBox; 19 class BMenuField; 20 class BPopUpMenu; 21 class BSpinner; 22 class BTextView; 23 24 static const int32 kMsgSetFamily = 'fmly'; 25 static const int32 kMsgSetStyle = 'styl'; 26 static const int32 kMsgSetSize = 'size'; 27 28 29 class FontSelectionView : public BView { 30 public: 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 52 private: 53 void _SelectCurrentFont(bool select); 54 void _SelectCurrentSize(); 55 void _UpdateFontPreview(); 56 void _UpdateSystemFont(); 57 void _BuildSizesMenu(); 58 59 protected: 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