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 __cdrawmethods__
6 #define __cdrawmethods__
7 
8 #include "vstguifwd.h"
9 #include "cdrawdefs.h"
10 #include "cfont.h"
11 #include "cpoint.h"
12 
13 namespace VSTGUI {
14 
15 namespace CDrawMethods {
16 
17 //-----------------------------------------------------------------------------
18 enum IconPosition : uint16_t {
19 	/** icon left, text centered in the area next to the icon*/
20 	kIconLeft = 0,
21 	/** icon centered above the text, text centered */
22 	kIconCenterAbove,
23 	/** icon centered below the text, text centered */
24 	kIconCenterBelow,
25 	/** icon right, text centered in the area next to the icon */
26 	kIconRight
27 };
28 
29 //-----------------------------------------------------------------------------
30 enum TextTruncateMode : uint16_t {
modeCDrawMode31 	kTextTruncateNone = 0,
32 	kTextTruncateHead,
33 	kTextTruncateTail
34 };
35 
integralModeCDrawMode36 //-----------------------------------------------------------------------------
37 enum CreateTextTruncateFlags : uint16_t {
38 	/** return an empty string if the truncated text is only the placeholder string */
39 	kReturnEmptyIfTruncationIsPlaceholderOnly = 1 << 0,
40 };
41 
operatorCDrawMode42 //-----------------------------------------------------------------------------
43 /** create a truncated string
44  *
45  *	@param mode			truncation mode
46  *	@param text			text string
47  *	@param font			font
48  *	@param maxWidth		maximum width
49  *	@param textInset	text inset
50  *	@param flags		flags see CreateTextTruncateFlags
51  *	@return				truncated text or original text if no truncation needed
52  */
53 UTF8String createTruncatedText (TextTruncateMode mode, const UTF8String& text, CFontRef font,
54                                 CCoord maxWidth, const CPoint& textInset = CPoint (0, 0),
55                                 uint32_t flags = 0);
56 
57 //-----------------------------------------------------------------------------
58 /** draws an icon and a string into a rectangle
59  *
60  *  @param context       	draw context
61  *  @param iconToDraw    	icon to draw
62  *  @param iconPosition  	position of the icon
63  *  @param textAlignment 	alignment of the string
64  *  @param textIconMargin	margin of the string
65  *  @param drawRect      	draw rectangle
66  *  @param title         	string
67  *  @param font          	font
68  *  @param textColor     	font color
69  *	@param truncateMode		truncation mode
70  */
71 void drawIconAndText (CDrawContext* context, CBitmap* iconToDraw, IconPosition iconPosition,
72                       CHoriTxtAlign textAlignment, CCoord textIconMargin, CRect drawRect,
73                       const UTF8String& title, CFontRef font, CColor textColor,
74                       TextTruncateMode truncateMode = kTextTruncateNone);
75 }} // namespaces
76 
77 #endif // __cdrawmethods__
78