2014-10-22 15:51:34 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009-2014 Jerry Jacobs
|
|
|
|
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
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 );
|
2019-07-30 01:57:41 +00:00
|
|
|
float Clamp_Text_PenSize( float aPenSize, int aSize, bool aBold = true );
|
2009-06-28 16:50:42 +00:00
|
|
|
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
|
|
|
/**
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
* Function GraphicTextWidth
|
2009-05-29 07:29:55 +00:00
|
|
|
* @return the X size of the graphic text
|
* KIWAY Milestone A): Make major modules into DLL/DSOs.
! The initial testing of this commit should be done using a Debug build so that
all the wxASSERT()s are enabled. Also, be sure and keep enabled the
USE_KIWAY_DLLs option. The tree won't likely build without it. Turning it
off is senseless anyways. If you want stable code, go back to a prior version,
the one tagged with "stable".
* Relocate all functionality out of the wxApp derivative into more finely
targeted purposes:
a) DLL/DSO specific
b) PROJECT specific
c) EXE or process specific
d) configuration file specific data
e) configuration file manipulations functions.
All of this functionality was blended into an extremely large wxApp derivative
and that was incompatible with the desire to support multiple concurrently
loaded DLL/DSO's ("KIFACE")s and multiple concurrently open projects.
An amazing amount of organization come from simply sorting each bit of
functionality into the proper box.
* Switch to wxConfigBase from wxConfig everywhere except instantiation.
* Add classes KIWAY, KIFACE, KIFACE_I, SEARCH_STACK, PGM_BASE, PGM_KICAD,
PGM_SINGLE_TOP,
* Remove "Return" prefix on many function names.
* Remove obvious comments from CMakeLists.txt files, and from else() and endif()s.
* Fix building boost for use in a DSO on linux.
* Remove some of the assumptions in the CMakeLists.txt files that windows had
to be the host platform when building windows binaries.
* Reduce the number of wxStrings being constructed at program load time via
static construction.
* Pass wxConfigBase* to all SaveSettings() and LoadSettings() functions so that
these functions are useful even when the wxConfigBase comes from another
source, as is the case in the KICAD_MANAGER_FRAME.
* Move the setting of the KIPRJMOD environment variable into class PROJECT,
so that it can be moved into a project variable soon, and out of FP_LIB_TABLE.
* Add the KIWAY_PLAYER which is associated with a particular PROJECT, and all
its child wxFrames and wxDialogs now have a Kiway() member function which
returns a KIWAY& that that window tree branch is in support of. This is like
wxWindows DNA in that child windows get this member with proper value at time
of construction.
* Anticipate some of the needs for milestones B) and C) and make code
adjustments now in an effort to reduce work in those milestones.
* No testing has been done for python scripting, since milestone C) has that
being largely reworked and re-thought-out.
2014-03-20 00:42:08 +00:00
|
|
|
* the full X size is GraphicTextWidth + the thickness of graphic lines
|
2009-05-29 07:29:55 +00:00
|
|
|
*/
|
2016-03-23 07:41:47 +00:00
|
|
|
int GraphicTextWidth( const wxString& aText, const wxSize& aSize, bool italic, bool bold );
|
2009-05-28 17:39:40 +00:00
|
|
|
|
2010-11-12 16:59:16 +00:00
|
|
|
/**
|
2019-05-31 12:15:25 +00:00
|
|
|
* Function GRText
|
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)
|
2017-02-20 16:57:41 +00:00
|
|
|
* @param aColor (COLOR4D) = 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
|
2018-04-06 13:30:52 +00:00
|
|
|
* @param aCallback( int x0, int y0, int xf, int yf, void* aData ) is a function called
|
|
|
|
* (if non null) to draw each segment. used to draw 3D texts or for plotting.
|
|
|
|
* NULL for normal drawings
|
|
|
|
* @param aCallbackData = is the auxiliary parameter aData for the callback function.
|
|
|
|
* can be nullptr if no auxiliary parameter is needed
|
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
|
|
|
*/
|
2019-05-31 12:15:25 +00:00
|
|
|
void GRText( wxDC * aDC, const wxPoint &aPos, const COLOR4D aColor, const wxString &aText,
|
|
|
|
double aOrient, 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, void* aData ) = nullptr,
|
|
|
|
void* aCallbackData = nullptr, PLOTTER * aPlotter = nullptr );
|
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
|
2019-05-31 12:15:25 +00:00
|
|
|
* backgrounds. See GRText for most of the parameters.
|
2013-04-09 17:16:53 +00:00
|
|
|
* If aBgColor is a dark color text is drawn in aColor2 with aColor1
|
|
|
|
* border; otherwise colors are swapped.
|
|
|
|
*/
|
2019-05-31 12:15:25 +00:00
|
|
|
void GRHaloText( wxDC * aDC, const wxPoint &aPos, const COLOR4D aBgColor, COLOR4D aColor1,
|
|
|
|
COLOR4D aColor2, const wxString &aText, double aOrient, 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, void* aData ) = nullptr,
|
|
|
|
void* aCallbackData = nullptr, PLOTTER * aPlotter = nullptr );
|
2013-04-09 17:16:53 +00:00
|
|
|
|
2009-01-19 19:08:42 +00:00
|
|
|
#endif /* __INCLUDE__DRAWTXT_H__ */
|