2009-01-19 19:08:42 +00:00
|
|
|
/**
|
|
|
|
* This file is part of the common libary
|
|
|
|
* @file drawtxt.h
|
|
|
|
* @see common.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __INCLUDE__DRAWTXT_H__
|
|
|
|
#define __INCLUDE__DRAWTXT_H__ 1
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <base_struct.h>
|
2012-04-12 21:31:31 +00:00
|
|
|
#include <eda_text.h> // EDA_TEXT_HJUSTIFY_T and EDA_TEXT_VJUSTIFY_T
|
2009-06-28 16:50:42 +00:00
|
|
|
|
2013-04-11 17:40:20 +00:00
|
|
|
/* Minimum dimension in pixel for drawing/no drawing a text
|
|
|
|
* used in Pcbnew to decide to draw (or not) some texts
|
|
|
|
* ( like net names on pads/tracks )
|
|
|
|
* When a text height is smaller than MIN_TEXT_SIZE,
|
|
|
|
* it is not drawn by Pcbnew
|
|
|
|
*/
|
2013-04-09 16:00:46 +00:00
|
|
|
#define MIN_TEXT_SIZE 5
|
|
|
|
|
2013-04-11 17:40:20 +00:00
|
|
|
/* Absolute minimum dimension in pixel to draw a text as text or a line
|
|
|
|
* When a text height is smaller than MIN_DRAWABLE_TEXT_SIZE,
|
|
|
|
* it is drawn, but like a line by the draw text function
|
|
|
|
*/
|
|
|
|
#define MIN_DRAWABLE_TEXT_SIZE 3
|
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
class EDA_DRAW_PANEL;
|
2009-08-29 10:20:48 +00:00
|
|
|
class PLOTTER;
|
2009-01-19 19:08:42 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function Clamp_Text_PenSize
|
2009-05-30 16:06:01 +00:00
|
|
|
*As a rule, pen width should not be >1/4em, otherwise the character
|
2009-06-28 16:50:42 +00:00
|
|
|
* will be cluttered up in its own fatness
|
|
|
|
* The pen width max is aSize/4 for bold texts, and aSize/6 for normal texts
|
|
|
|
* The "best" pen width is aSize/5 for bold texts,
|
|
|
|
* so the clamp is consistant with bold option.
|
|
|
|
* @param aPenSize = the pen size to clamp
|
|
|
|
* @param aSize the char size (height or width, od its wxSize)
|
|
|
|
* @param aBold = true if text accept bold pen size
|
|
|
|
* @return the max pen size allowed
|
|
|
|
*/
|
|
|
|
int Clamp_Text_PenSize( int aPenSize, int aSize, bool aBold = true );
|
|
|
|
int Clamp_Text_PenSize( int aPenSize, wxSize aSize, bool aBold = true );
|
2009-05-30 16:06:01 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function GetPensizeForBold
|
2009-05-30 16:06:01 +00:00
|
|
|
* @return the "best" value for a pen size to draw/plot a bold text
|
|
|
|
* @param aTextSize = the char size (height or width)
|
|
|
|
*/
|
|
|
|
int GetPenSizeForBold( int aTextSize );
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function ReturnGraphicTextWidth
|
2009-05-29 07:29:55 +00:00
|
|
|
* @return the X size of the graphic text
|
|
|
|
* the full X size is ReturnGraphicTextWidth + the thickness of graphic lines
|
|
|
|
*/
|
2009-06-28 16:50:42 +00:00
|
|
|
int ReturnGraphicTextWidth( const wxString& aText, int size_h, bool italic, bool bold );
|
2009-05-28 17:39:40 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function NegableTextLength
|
2009-04-06 10:56:17 +00:00
|
|
|
* Return the text length of a negable string, excluding the ~ markers */
|
|
|
|
int NegableTextLength( const wxString& aText );
|
|
|
|
|
2013-04-10 19:09:59 +00:00
|
|
|
/**
|
|
|
|
* Helper function for texts with over bar, can be used as strut value
|
|
|
|
* for multiline text (add interline spacing)
|
|
|
|
*/
|
|
|
|
int OverbarPositionY( int size_v );
|
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
|
|
|
* Function DrawGraphicText
|
2009-01-19 19:08:42 +00:00
|
|
|
* Draw a graphic text (like module texts)
|
2013-06-29 09:52:22 +00:00
|
|
|
* @param aClipBox = the clipping rect, or NULL if no clipping
|
2009-04-06 10:56:17 +00:00
|
|
|
* @param aDC = the current Device Context. NULL if draw within a 3D GL Canvas
|
2009-01-19 19:08:42 +00:00
|
|
|
* @param aPos = text position (according to h_justify, v_justify)
|
2012-03-26 23:47:08 +00:00
|
|
|
* @param aColor (enum EDA_COLOR_T) = text color
|
2009-01-19 19:08:42 +00:00
|
|
|
* @param aText = text to draw
|
|
|
|
* @param aOrient = angle in 0.1 degree
|
|
|
|
* @param aSize = text size (size.x or size.y can be < 0 for mirrored texts)
|
|
|
|
* @param aH_justify = horizontal justification (Left, center, right)
|
|
|
|
* @param aV_justify = vertical justification (bottom, center, top)
|
|
|
|
* @param aWidth = line width (pen width) (default = 0)
|
|
|
|
* if width < 0 : draw segments in sketch mode, width = abs(width)
|
2009-05-30 16:06:01 +00:00
|
|
|
* Use a value min(aSize.x, aSize.y) / 5 for a bold text
|
2009-01-19 19:08:42 +00:00
|
|
|
* @param aItalic = true to simulate an italic font
|
2009-05-28 17:39:40 +00:00
|
|
|
* @param aBold = true to use a bold font
|
2009-01-19 19:08:42 +00:00
|
|
|
* @param aCallback() = function called (if non null) to draw each segment.
|
2009-01-30 14:11:36 +00:00
|
|
|
* used to draw 3D texts or for plotting, NULL for normal drawings
|
2010-12-28 11:24:42 +00:00
|
|
|
* @param aPlotter = a pointer to a PLOTTER instance, when this function is used to plot
|
|
|
|
* the text. NULL to draw this text.
|
2009-01-19 19:08:42 +00:00
|
|
|
*/
|
2013-06-29 09:52:22 +00:00
|
|
|
void DrawGraphicText( EDA_RECT* aClipBox,
|
2009-04-06 10:56:17 +00:00
|
|
|
wxDC * aDC,
|
|
|
|
const wxPoint &aPos,
|
2012-03-26 23:47:08 +00:00
|
|
|
enum EDA_COLOR_T aColor,
|
2009-04-06 10:56:17 +00:00
|
|
|
const wxString &aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2009-04-06 10:56:17 +00:00
|
|
|
const wxSize &aSize,
|
2012-01-03 17:14:17 +00:00
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
2009-05-28 17:39:40 +00:00
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
2009-05-30 16:06:01 +00:00
|
|
|
bool aBold,
|
2009-06-28 16:50:42 +00:00
|
|
|
void (*aCallback)( int x0, int y0, int xf, int yf ) = NULL,
|
2010-12-28 11:24:42 +00:00
|
|
|
PLOTTER * aPlotter = NULL );
|
2009-01-19 19:08:42 +00:00
|
|
|
|
|
|
|
|
2013-04-09 17:16:53 +00:00
|
|
|
/**
|
|
|
|
* Draw graphic text with a border, so that it can be read on different
|
|
|
|
* backgrounds. See DrawGraphicText for most of the parameters.
|
|
|
|
* If aBgColor is a dark color text is drawn in aColor2 with aColor1
|
|
|
|
* border; otherwise colors are swapped.
|
|
|
|
*/
|
2013-06-29 09:52:22 +00:00
|
|
|
void DrawGraphicHaloText( EDA_RECT* aClipBox,
|
2013-04-09 17:16:53 +00:00
|
|
|
wxDC * aDC,
|
|
|
|
const wxPoint &aPos,
|
|
|
|
enum EDA_COLOR_T aBgColor,
|
|
|
|
enum EDA_COLOR_T aColor1,
|
|
|
|
enum EDA_COLOR_T aColor2,
|
|
|
|
const wxString &aText,
|
2013-05-05 07:17:48 +00:00
|
|
|
double aOrient,
|
2013-04-09 17:16:53 +00:00
|
|
|
const wxSize &aSize,
|
|
|
|
enum EDA_TEXT_HJUSTIFY_T aH_justify,
|
|
|
|
enum EDA_TEXT_VJUSTIFY_T aV_justify,
|
|
|
|
int aWidth,
|
|
|
|
bool aItalic,
|
|
|
|
bool aBold,
|
|
|
|
void (*aCallback)( int x0, int y0, int xf, int yf ) = NULL,
|
|
|
|
PLOTTER * aPlotter = NULL );
|
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
#endif /* __INCLUDE__DRAWTXT_H__ */
|