1 // This file is part of VSTGUI. It is subject to the license terms 2 // in the LICENSE file found in the top-level directory of this 3 // distribution and at http://github.com/steinbergmedia/vstgui/LICENSE 4 5 #ifndef __cfontchooser__ 6 #define __cfontchooser__ 7 8 #include "../vstguifwd.h" 9 #include "../cviewcontainer.h" 10 #include "../cfont.h" 11 #include "../cdatabrowser.h" 12 #include "../genericstringlistdatabrowsersource.h" 13 #include "icontrollistener.h" 14 15 namespace VSTGUI { 16 17 /// @ingroup new_in_4_0 18 //----------------------------------------------------------------------------- 19 class IFontChooserDelegate 20 { 21 public: 22 virtual void fontChanged (CFontChooser* chooser, CFontRef newFont) = 0; 23 }; 24 25 /// @ingroup new_in_4_0 26 //----------------------------------------------------------------------------- 27 struct CFontChooserUIDefinition 28 { 29 CFontRef font; 30 int32_t rowHeight; 31 CColor fontColor; 32 CColor selectionColor; 33 CColor rowlineColor; 34 CColor rowBackColor; 35 CColor rowAlternateBackColor; 36 CColor previewTextColor; 37 CColor previewBackgroundColor; 38 CColor scrollbarScrollerColor; 39 CColor scrollbarFrameColor; 40 CColor scrollbarBackgroundColor; 41 CCoord scrollbarWidth; 42 43 CFontChooserUIDefinition (CFontRef font = kSystemFont, 44 const CColor& fontColor = kWhiteCColor, 45 const CColor& selectionColor = kBlueCColor, 46 const CColor& rowlineColor = kGreyCColor, 47 const CColor& rowBackColor = kTransparentCColor, 48 const CColor& rowAlternateBackColor = kTransparentCColor, 49 const CColor& previewTextColor = kBlackCColor, 50 const CColor& previewBackgroundColor = kWhiteCColor, 51 const CColor& scrollbarScrollerColor = kBlueCColor, 52 const CColor& scrollbarFrameColor = kBlackCColor, 53 const CColor& scrollbarBackgroundColor = kGreyCColor, 54 int32_t rowHeight = -1, 55 CCoord scrollbarWidth = 16) fontCFontChooserUIDefinition56 : font (font), rowHeight (rowHeight), fontColor (fontColor), selectionColor (selectionColor), rowlineColor (rowlineColor) 57 , rowBackColor (rowBackColor), rowAlternateBackColor (rowAlternateBackColor), previewTextColor (previewTextColor), previewBackgroundColor (previewBackgroundColor) 58 , scrollbarScrollerColor (scrollbarScrollerColor), scrollbarFrameColor (scrollbarFrameColor) 59 , scrollbarBackgroundColor (scrollbarBackgroundColor), scrollbarWidth (scrollbarWidth) 60 {} 61 }; 62 63 /// @ingroup new_in_4_0 64 //----------------------------------------------------------------------------- 65 class CFontChooser : public CViewContainer, public IControlListener, public GenericStringListDataBrowserSourceSelectionChanged 66 { 67 public: 68 CFontChooser (IFontChooserDelegate* delegate, CFontRef initialFont = nullptr, const CFontChooserUIDefinition& uiDef = CFontChooserUIDefinition ()); 69 ~CFontChooser () noexcept override; 70 71 void setFont (CFontRef font); 72 73 protected: 74 void dbSelectionChanged (int32_t selectedRow, GenericStringListDataBrowserSource* source) override; 75 void valueChanged (CControl* pControl) override; 76 bool attached (CView* parent) override; 77 int32_t onKeyDown (VstKeyCode& keyCode) override; 78 79 IFontChooserDelegate* delegate; 80 CDataBrowser* fontBrowser; 81 CTextEdit* sizeEdit; 82 CCheckBox* boldBox; 83 CCheckBox* italicBox; 84 CCheckBox* underlineBox; 85 CCheckBox* strikeoutBox; 86 CView* fontPreviewView; 87 GenericStringListDataBrowserSource::StringVector fontNames; 88 89 CFontRef selFont; 90 }; 91 92 } // namespace 93 94 #endif 95