ASPiK SDK
cparamdisplay.h
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 __cparamdisplay__
6 #define __cparamdisplay__
7 
8 #include "ccontrol.h"
9 #include "../cfont.h"
10 #include "../ccolor.h"
11 #include "../cdrawdefs.h"
12 #include <functional>
13 
14 namespace VSTGUI {
15 
16 //-----------------------------------------------------------------------------
17 using CParamDisplayValueToStringProc = bool (*) (float value, char utf8String[256], void* userData);
18 
19 //-----------------------------------------------------------------------------
20 // CParamDisplay Declaration
23 //-----------------------------------------------------------------------------
24 class CParamDisplay : public CControl
25 {
26 public:
27  CParamDisplay (const CRect& size, CBitmap* background = nullptr, const int32_t style = 0);
28  CParamDisplay (const CParamDisplay& paramDisplay);
29 
30  //-----------------------------------------------------------------------------
32  //-----------------------------------------------------------------------------
34  virtual void setFont (CFontRef fontID);
35  const CFontRef getFont () const { return fontID; }
36 
37  virtual void setFontColor (CColor color);
38  CColor getFontColor () const { return fontColor; }
39 
40  virtual void setBackColor (CColor color);
41  CColor getBackColor () const { return backColor; }
42 
43  virtual void setFrameColor (CColor color);
44  CColor getFrameColor () const { return frameColor; }
45 
46  virtual void setShadowColor (CColor color);
47  CColor getShadowColor () const { return shadowColor; }
48 
49  virtual void setShadowTextOffset (const CPoint& offset);
50  CPoint getShadowTextOffset () const { return shadowTextOffset; }
51 
52  virtual void setAntialias (bool state) { bAntialias = state; }
53  bool getAntialias () const { return bAntialias; }
54 
55  virtual void setHoriAlign (CHoriTxtAlign hAlign);
56  CHoriTxtAlign getHoriAlign () const { return horiTxtAlign; }
57 
58  virtual void setTextInset (const CPoint& p);
59  CPoint getTextInset () const { return textInset; }
60 
61  virtual void setTextRotation (double angle);
62  double getTextRotation () const { return textRotation; }
63 
64  virtual void setRoundRectRadius (const CCoord& radius);
65  CCoord getRoundRectRadius () const { return roundRectRadius; }
66 
67  virtual void setFrameWidth (const CCoord& width);
68  CCoord getFrameWidth () const { return frameWidth; }
69 
71  using ValueToStringFunction = std::function<bool(float value, char utf8String[256], CParamDisplay* display)>;
72 
73  void setValueToStringFunction (const ValueToStringFunction& valueToStringFunc);
74  void setValueToStringFunction (ValueToStringFunction&& valueToStringFunc);
75 
76  using ValueToStringFunction2 = std::function<bool (float value, std::string& result, CParamDisplay* display)>;
77 
78  void setValueToStringFunction2 (const ValueToStringFunction2& valueToStringFunc);
79  void setValueToStringFunction2 (ValueToStringFunction2&& valueToStringFunc);
80 
81  virtual void setStyle (int32_t val);
82  int32_t getStyle () const { return style; }
83 
84  virtual void setPrecision (uint8_t precision);
85  uint8_t getPrecision () const { return valuePrecision; }
86 
88 
89  void draw (CDrawContext* pContext) override;
90  bool getFocusPath (CGraphicsPath& outPath) override;
91  bool removed (CView* parent) override;
92 
93  CLASS_METHODS(CParamDisplay, CControl)
94 protected:
95  ~CParamDisplay () noexcept override;
96  virtual void drawBack (CDrawContext* pContext, CBitmap* newBack = nullptr);
97 
98  virtual void drawPlatformText (CDrawContext* pContext, IPlatformString* string);
99  virtual void drawPlatformText (CDrawContext* pContext, IPlatformString* string, const CRect& size);
100 
101  virtual void drawStyleChanged ();
102 
103  ValueToStringFunction2 valueToStringFunction;
104 
105  CHoriTxtAlign horiTxtAlign;
106  int32_t style;
107  uint8_t valuePrecision;
108 
109  CFontRef fontID;
110  CColor fontColor;
111  CColor backColor;
112  CColor frameColor;
113  CColor shadowColor;
114  CPoint textInset;
115  CPoint shadowTextOffset {1., 1.};
116  CCoord roundRectRadius;
117  CCoord frameWidth;
118  double textRotation;
119  bool bAntialias;
120 };
121 
122 } // namespace
123 
124 #endif
bool getFocusPath(CGraphicsPath &outPath) override
Definition: cparamdisplay.cpp:137
font class
Definition: cfont.h:31
Rect structure.
Definition: crect.h:17
A drawing context encapsulates the drawing context of the underlying OS.
Definition: cdrawcontext.h:29
RGBA Color structure.
Definition: ccolor.h:15
Graphics Path Object.
Definition: cgraphicspath.h:19
Encapsulates various platform depended kinds of bitmaps.
Definition: cbitmap.h:21
void draw(CDrawContext *pContext) override
called if the view should draw itself
Definition: cparamdisplay.cpp:166
Definition: customcontrols.cpp:8
base class of all VSTGUI controls
Definition: ccontrol.h:76
Base Class of all view objects.
Definition: cview.h:44
Point structure.
Definition: cpoint.h:17
a parameter display
Definition: cparamdisplay.h:24
bool removed(CView *parent) override
view is removed from parent view
Definition: cparamdisplay.cpp:73