1 /* 2 * Copyright 2001-2009, Haiku. 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 BStringView; 22 23 static const int32 kMsgSetFamily = 'fmly'; 24 static const int32 kMsgSetStyle = 'styl'; 25 static const int32 kMsgSetSize = 'size'; 26 27 28 class FontSelectionView : public BView { 29 public: 30 FontSelectionView(const char* name, 31 const char* label, 32 const BFont* font = NULL); 33 virtual ~FontSelectionView(); 34 35 virtual void MessageReceived(BMessage* message); 36 37 void SetTarget(BHandler* messageTarget); 38 39 void SetDefaults(); 40 void Revert(); 41 bool IsDefaultable(); 42 bool IsRevertable(); 43 44 void UpdateFontsMenu(); 45 46 BLayoutItem* CreateSizesLabelLayoutItem(); 47 BLayoutItem* CreateSizesMenuBarLayoutItem(); 48 49 BLayoutItem* CreateFontsLabelLayoutItem(); 50 BLayoutItem* CreateFontsMenuBarLayoutItem(); 51 52 BView* GetPreviewBox(); 53 54 private: 55 void _SelectCurrentFont(bool select); 56 void _SelectCurrentSize(bool select); 57 void _UpdateFontPreview(); 58 void _UpdateSystemFont(); 59 void _BuildSizesMenu(); 60 61 protected: 62 BHandler* fMessageTarget; 63 64 BMenuField* fFontsMenuField; 65 BMenuField* fSizesMenuField; 66 BPopUpMenu* fFontsMenu; 67 BPopUpMenu* fSizesMenu; 68 69 BBox* fPreviewBox; 70 BStringView* fPreviewText; 71 72 BFont fSavedFont; 73 BFont fCurrentFont; 74 float fMaxFontNameWidth; 75 }; 76 77 #endif // FONT_SELECTION_VIEW_H 78