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 #pragma once 6 7 #include "../vstguifwd.h" 8 #include "../cviewcontainer.h" 9 #include "../cfont.h" 10 #include "../cdatabrowser.h" 11 #include "../genericstringlistdatabrowsersource.h" 12 #include "icontrollistener.h" 13 14 namespace VSTGUI { 15 16 /// @ingroup new_in_4_0 17 //----------------------------------------------------------------------------- 18 class IFontChooserDelegate 19 { 20 public: 21 virtual void fontChanged (CFontChooser* chooser, CFontRef newFont) = 0; 22 }; 23 24 /// @ingroup new_in_4_0 25 //----------------------------------------------------------------------------- 26 struct CFontChooserUIDefinition 27 { 28 CFontRef font; 29 int32_t rowHeight; 30 CColor fontColor; 31 CColor selectionColor; 32 CColor rowlineColor; 33 CColor rowBackColor; 34 CColor rowAlternateBackColor; 35 CColor previewTextColor; 36 CColor previewBackgroundColor; 37 CColor scrollbarScrollerColor; 38 CColor scrollbarFrameColor; 39 CColor scrollbarBackgroundColor; 40 CCoord scrollbarWidth; 41 42 CFontChooserUIDefinition (CFontRef font = kSystemFont, 43 const CColor& fontColor = kWhiteCColor, 44 const CColor& selectionColor = kBlueCColor, 45 const CColor& rowlineColor = kGreyCColor, 46 const CColor& rowBackColor = kTransparentCColor, 47 const CColor& rowAlternateBackColor = kTransparentCColor, 48 const CColor& previewTextColor = kBlackCColor, 49 const CColor& previewBackgroundColor = kWhiteCColor, 50 const CColor& scrollbarScrollerColor = kBlueCColor, 51 const CColor& scrollbarFrameColor = kBlackCColor, 52 const CColor& scrollbarBackgroundColor = kGreyCColor, 53 int32_t rowHeight = -1, 54 CCoord scrollbarWidth = 16) fontCFontChooserUIDefinition55 : font (font), rowHeight (rowHeight), fontColor (fontColor), selectionColor (selectionColor), rowlineColor (rowlineColor) 56 , rowBackColor (rowBackColor), rowAlternateBackColor (rowAlternateBackColor), previewTextColor (previewTextColor), previewBackgroundColor (previewBackgroundColor) 57 , scrollbarScrollerColor (scrollbarScrollerColor), scrollbarFrameColor (scrollbarFrameColor) 58 , scrollbarBackgroundColor (scrollbarBackgroundColor), scrollbarWidth (scrollbarWidth) 59 {} 60 }; 61 62 /// @ingroup new_in_4_0 63 //----------------------------------------------------------------------------- 64 class CFontChooser : public CViewContainer, public IControlListener, public GenericStringListDataBrowserSourceSelectionChanged 65 { 66 public: 67 CFontChooser (IFontChooserDelegate* delegate, CFontRef initialFont = nullptr, const CFontChooserUIDefinition& uiDef = CFontChooserUIDefinition ()); 68 ~CFontChooser () noexcept override; 69 70 void setFont (CFontRef font); 71 72 protected: 73 void dbSelectionChanged (int32_t selectedRow, GenericStringListDataBrowserSource* source) override; 74 void valueChanged (CControl* pControl) override; 75 bool attached (CView* parent) override; 76 int32_t onKeyDown (VstKeyCode& keyCode) override; 77 78 IFontChooserDelegate* delegate; 79 CDataBrowser* fontBrowser; 80 CTextEdit* sizeEdit; 81 CCheckBox* boldBox; 82 CCheckBox* italicBox; 83 CCheckBox* underlineBox; 84 CCheckBox* strikeoutBox; 85 CView* fontPreviewView; 86 GenericStringListDataBrowserSource::StringVector fontNames; 87 88 CFontRef selFont; 89 }; 90 91 } // VSTGUI 92 93