19 #include <wx/filename.h>
20 #include <wx/fontenum.h>
21 #include <wx/module.h>
32 #if defined(__USE_WINAPI__)
33 #include "wx/msw/dc.h"
37 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
38 #include <wx/msw/msvcrt.h>
41 #define newline wxString("\n")
43 #if wxART2D_USE_FREETYPE
44 FT_Library g_freetypeLibrary;
47 #define wxART2D_USE_DC2FREETYPE 1
50 IMPLEMENT_DYNAMIC_CLASS(
a2dStroke, wxObject )
51 IMPLEMENT_DYNAMIC_CLASS(
a2dFill, wxObject )
57 #include <wx/listimpl.cpp>
65 const wxString& style,
double size,
const wxString& extra )
75 const wxString& style,
const wxString& extra )
111 size.Printf( wxT(
"%f" ),
m_size );
113 + wxT(
"-" ) + size + wxT(
"-" );
115 description += wxT(
"-" ) +
m_extra;
122 size_t stringlength =
string.Length();
125 while ( idx < stringlength &&
string[idx] != wxChar(
'-' ) )
127 m_type =
string.Mid( last, idx - last );
128 if ( idx < stringlength )
131 while ( idx < stringlength &&
string[idx] != wxChar(
'-' ) )
133 m_name =
string.Mid( last, idx - last );
134 if ( idx < stringlength )
137 while ( idx < stringlength &&
string[idx] != wxChar(
'-' ) )
139 m_style =
string.Mid( last, idx - last );
140 if ( idx < stringlength )
143 while ( idx < stringlength &&
string[idx] != wxChar(
'-' ) )
145 string.Mid( last, idx - last ).ToDouble( &
m_size );
146 if ( idx < stringlength )
149 while ( idx < stringlength &&
string[idx] != wxChar(
'-' ) )
151 if ( idx < stringlength )
172 virtual a2dFontType GetType(
void )
const {
return a2dFONT_NULL; }
176 m_fontinfo.SetSize( size );
198 bool Ok() {
return m_ok; }
199 virtual void SetSize(
double size ) { m_fontinfo.SetSize( size ); }
200 inline double GetSize()
const {
return m_fontinfo.GetSize(); }
205 return m_fontinfo.GetSize() * m_desc;
213 return m_fontinfo.GetSize() * m_height;
224 virtual double GetKerning( wxChar WXUNUSED( c1 ), wxChar WXUNUSED( c2 ) )
const {
return 0.0; }
227 virtual double GetWidth( wxChar c )
const = 0;
231 virtual void GetTextExtent(
const wxString&
string,
double& w,
double& h,
double& descent,
double& externalLeading )
const;
251 #if wxART2D_USE_CVGIO
256 #endif //wxART2D_USE_CVGIO
260 void a2dFontRefData::GetTextExtent(
const wxString&
string,
double& w,
261 double& h,
double& descent,
double& externalLeading )
const
266 int len(
string.Length());
269 wxChar ch_n_1, ch_n(
string[(
size_t)0]);
271 for (
size_t n = 1; n < len; n++ )
285 w = h = descent = externalLeading = 0.0;
310 virtual a2dFontType GetType(
void )
const {
return a2dFONT_WXDC; }
316 a2dFontDcData(
const wxFont& font = wxNullFont,
double size = 0.0 );
349 a2dFontDcData(
double size,
int family,
int style = wxNORMAL,
int weight = wxNORMAL,
350 const bool underline =
false,
const wxString& faceName = wxT(
"" ),
351 wxFontEncoding encoding = wxFONTENCODING_DEFAULT );
361 void SetFont(
const wxFont& font );
373 wxString FindFileName()
const;
379 double GetKerning( wxChar c1, wxChar c2 )
const;
382 void SetDeviceHeight(
double sizeInPixels );
384 double GetDeviceHeight() {
return m_sizeInPixels; }
386 void GetTextExtent(
const wxString&
string,
double& w,
double& h,
double& descent,
double& externalLeading )
const;
396 #if wxART2D_USE_FREETYPE
418 #if defined(__USE_WINAPI__)
420 mutable KERNINGPAIR* m_kerningcache;
421 mutable map<int, int> m_kerningmap;
423 mutable int m_nkerningpairs;
429 #if wxART2D_USE_FREETYPE
436 #define CHAR_CACHE_START wxChar(' ')
437 #define CHAR_CACHE_END wxChar('~')
445 #if defined(__USE_WINAPI__)
452 const bool underline,
const wxString& faceName, wxFontEncoding encoding )
458 #if defined(__USE_WINAPI__)
461 SetFont( wxFont( 1, family, style, weight, underline, faceName, encoding ) );
469 #if defined(__USE_WINAPI__)
479 #if defined(__USE_WINAPI__)
496 #if wxART2D_USE_FREETYPE
518 m_widthcache =
new double[CHAR_CACHE_END - CHAR_CACHE_START + 1];
526 wxCoord width, height, desc, lead;
527 width = height = desc = lead = 0;
529 #if defined(__USE_WINAPI__)
530 #if wxCHECK_VERSION(2,9,0)
531 wxMSWDCImpl* dcimpl =
wxStaticCast( dc.GetImpl(), wxMSWDCImpl );
532 WXHDC hdc = dcimpl->GetHDC();
534 WXHDC hdc = dc.GetHDC();
539 #if defined(__USE_WINAPI__)
540 string = CHAR_CACHE_START;
541 dc.GetTextExtent(
string, &width, &height, &descmax, &lead );
543 ABCFLOAT* ABCarray =
new ABCFLOAT[CHAR_CACHE_END - CHAR_CACHE_START + 1];
544 GetCharABCWidthsFloat( ( HDC ) hdc, CHAR_CACHE_START, CHAR_CACHE_END, ( LPABCFLOAT ) ABCarray );
546 for ( c = CHAR_CACHE_START; c <= CHAR_CACHE_END; c++ )
548 ABCFLOAT a = ABCarray[c - CHAR_CACHE_START];
549 float widthf = a.abcfA + a.abcfB + a.abcfC;
555 for ( c = CHAR_CACHE_START; c <= CHAR_CACHE_END; c++ )
558 dc.GetTextExtent(
string, &width, &height, &desc, &lead );
559 descmax = wxMax( descmax, desc );
560 float widthf = ( float ) width / m_sizeInPixels;
565 m_height = ( double ) height / m_sizeInPixels;
566 m_desc = ( double ) descmax / m_sizeInPixels;
567 m_lead = ( double ) lead / m_sizeInPixels;
569 if (
m_font.GetFaceName().IsEmpty() )
573 wxString style = wxEmptyString;
574 switch (
m_font.GetWeight() )
577 if (
m_font.GetStyle() == wxNORMAL )
578 style = wxT(
"Regular" );
581 style = wxT(
"Bold " );
584 style = wxT(
"Light " );
587 switch (
m_font.GetStyle() )
593 style += wxT(
"Italic" );
598 #if wxART2D_USE_FREETYPE
601 #if wxART2D_USE_DC2FREETYPE
603 if ( !filename.IsEmpty() )
611 #if defined(__USE_WINAPI__)
619 m_nkerningpairs = ::GetKerningPairs( ( HDC ) hdc, 0, NULL );
621 m_nkerningpairs = ::GetKerningPairs( ( HDC ) hdc, m_nkerningpairs,
m_kerningcache );
625 int i = m_nkerningpairs;
628 m_kerningmap[(ptr->wFirst << 16) + ptr->wSecond] = ptr->iKernAmount;
633 #endif //defined(__USE_WINAPI__)
634 dc.SetFont( wxNullFont );
638 void a2dFontDcData::GetTextExtent(
const wxString&
string,
double& w,
639 double& h,
double& descent,
double& externalLeading )
const
641 a2dFontRefData::GetTextExtent(
string, w, h, descent, externalLeading );
646 w = h = descent = externalLeading = 0.0;
652 wxCoord width, height, desc, lead;
653 width = height = desc = lead = 0;
655 dc.GetTextExtent(
string, &width, &height, &desc, &lead );
665 #if defined(__USE_WINAPI__)
666 wxString facename =
m_font.GetFaceName();
667 if (
m_font.GetWeight() == wxBOLD )
668 facename += wxT(
" Bold" );
669 if (
m_font.GetStyle() == wxITALIC )
670 facename += wxT(
" Italic" );
672 TCHAR displayname[_MAX_PATH];
673 TCHAR fontfilename[_MAX_PATH];
674 if(
GetFontFile( facename.c_str(), displayname, _MAX_PATH - 1,
675 fontfilename, _MAX_PATH - 1 ) )
677 filename = fontfilename;
679 #endif // defined( __USE_WINAPI__ )
684 #if wxART2D_USE_FREETYPE
685 void a2dFontDcData::SetSize(
double size )
687 a2dFontRefData::SetSize( size );
699 if ( c >= CHAR_CACHE_START && c <= CHAR_CACHE_END )
710 wxCoord width, height, desc, lead;
712 dc.GetTextExtent(
string, &width, &height, &desc, &lead );
713 dc.SetFont( wxNullFont );
724 #if defined( __USE_WINAPI__ )
725 map<int,int>::iterator it(m_kerningmap.find((c1 << 16) + c2));
726 if (it != m_kerningmap.end())
730 #else // defined( __USE_WINAPI__ )
740 wxCoord width, height, desc, lead;
741 dc.GetTextExtent( ab, &width, &height, &desc, &lead );
742 dc.SetFont( wxNullFont );
749 #endif // defined( __USE_WINAPI__ )
754 #if wxART2D_USE_FREETYPE
755 #if defined( __USE_WINAPI__ )
825 #else // defined( __USE_WINAPI__ )
828 #endif // defined( __USE_WINAPI__ )
839 virtual bool OnFacename(
const wxString& facename )
841 m_facenames.Add( facename );
844 wxArrayString m_facenames;
850 enumerator.EnumerateFacenames();
851 for (
unsigned int i = 0; i < enumerator.m_facenames.GetCount(); i++ )
853 wxString fontname = enumerator.m_facenames.Item( i );
854 list.Append(
new a2dFontInfo( wxT(
"Device font" ), fontname, wxT(
"Regular" ), 1.0 ) );
855 list.Append(
new a2dFontInfo( wxT(
"Device font" ), fontname, wxT(
"Italic" ), 1.0 ) );
856 list.Append(
new a2dFontInfo( wxT(
"Device font" ), fontname, wxT(
"Bold" ), 1.0 ) );
857 list.Append(
new a2dFontInfo( wxT(
"Device font" ), fontname, wxT(
"Bold Italic" ), 1.0 ) );
858 list.Append(
new a2dFontInfo( wxT(
"Device font" ), fontname, wxT(
"Light" ), 1.0 ) );
859 list.Append(
new a2dFontInfo( wxT(
"Device font" ), fontname, wxT(
"Light Italic" ), 1.0 ) );
865 int slant = wxNORMAL;
866 int weight = wxNORMAL;
867 if ( force || info.
GetType().Upper() == wxT(
"DEVICE FONT" ) )
869 if ( info.
GetStyle().Upper().Find( wxT(
"ITALIC" ) ) != -1 )
871 if ( info.
GetStyle().Upper().Find( wxT(
"BOLD" ) ) != -1 )
873 if ( info.
GetStyle().Upper().Find( wxT(
"LIGHT" ) ) != -1 )
885 #if wxART2D_USE_FREETYPE
896 class a2dFreetypeFace;
906 bool a2dFreetypeModule::OnInit()
908 #if wxART2D_USE_FREETYPE
909 int error = FT_Init_FreeType( &g_freetypeLibrary );
910 if ( error )
return false;
915 void a2dFreetypeModule::OnExit()
917 a2dFont::ClearFontCache();
919 #if wxART2D_USE_FREETYPE
920 FT_Done_FreeType( g_freetypeLibrary );
923 g_freetypeLibrary = NULL;
927 #if wxART2D_USE_FREETYPE
946 virtual a2dFontType GetType(
void )
const {
return a2dFONT_FREETYPE; }
953 a2dFontFreetypeData(
const wxString& filename = wxT(
"" ),
double size = 0.0, wxFontEncoding encoding = wxFONTENCODING_DEFAULT,
int faceindex = 0 );
954 #if defined(__USE_WINAPI__)
962 a2dFontFreetypeData(
const wxFont& font,
double size = 0.0, wxFontEncoding encoding = wxFONTENCODING_DEFAULT );
963 #endif // defined( __USE_WINAPI__ )
981 wxString
GetFilename(
bool filenameonly =
false )
const;
983 void SetEncodingConverter( wxEncodingConverter* converter );
988 const a2dGlyph* GetGlyph( wxChar c )
const;
991 void SetDeviceHeight(
double sizeInPixels );
993 double GetDeviceHeight() {
return m_sizeInPixels; }
995 void GetTextExtent(
const wxString&
string,
double& w,
double& h,
double& descent,
double& externalLeading )
const;
1000 double GetGlyphHeight( wxChar c )
const;
1003 double GetKerning( wxChar c1, wxChar c2 )
const;
1018 static void SetLoadFlags( wxInt32 loadMethodMask ) { m_loadMethodMask = loadMethodMask; }
1022 static wxInt32 m_loadMethodMask;
1035 #if wxART2D_USE_FREETYPE
1040 #endif // wxART2D_USE_FREETYPE
1057 void ClearCacheLinkes(
void );
1060 wxInt32 a2dFontFreetypeData::m_loadMethodMask = a2dFont::a2d_LOAD_DEFAULT;
1070 #if wxART2D_USE_FREETYPE
1090 #if defined(__USE_WINAPI__)
1099 #if wxART2D_USE_FREETYPE
1117 wxString facename = font.GetFaceName();
1118 if ( font.GetWeight() == wxBOLD )
1119 facename += wxT(
" Bold" );
1120 if ( font.GetStyle() == wxITALIC )
1121 facename += wxT(
" Italic" );
1125 TCHAR displayname[10];
1126 TCHAR fontfilename[_MAX_PATH];
1128 if(
GetFontFile( facename.c_str(), displayname,
sizeof( displayname ),
1129 fontfilename,
sizeof( fontfilename ) ) )
1134 #endif // defined( __USE_WINAPI__ )
1144 #if wxART2D_USE_FREETYPE
1165 #if wxART2D_USE_FREETYPE
1170 if (
m_face && g_freetypeLibrary )
1173 #endif // wxART2D_USE_FREETYPE
1188 #if wxART2D_USE_FREETYPE
1195 wxASSERT_MSG( error == 0 , _(
"a2dText problem setting character size" ) );
1201 const FT_Size_Metrics& size =
m_face->size->metrics;
1202 m_height = ( size.ascender - size.descender ) / ( m_sizeInPixels * 64.0 );
1203 m_desc = -size.descender / ( m_sizeInPixels * 64.0 );
1204 m_lead = ( size.height - ( size.ascender - size.descender ) ) / ( m_sizeInPixels * 64.0 );
1206 #else //wxART2D_USE_FREETYPE
1211 #endif // wxART2D_USE_FREETYPE
1214 if ( m_glyphcache.empty() )
1216 m_glyphcache.reserve( CHAR_CACHE_END - CHAR_CACHE_START + 1 );
1217 for (
size_t i = CHAR_CACHE_START; i <= CHAR_CACHE_END; i++ )
1218 m_glyphcache.push_back(
a2dGlyph() );
1222 for (
size_t i = CHAR_CACHE_START; i <= CHAR_CACHE_END; i++ )
1223 if( m_glyphcache[i - CHAR_CACHE_START].m_glyph != NULL )
1224 FT_Done_Glyph( m_glyphcache[i - CHAR_CACHE_START].m_glyph );
1226 for (
size_t j = CHAR_CACHE_START; j <= CHAR_CACHE_END; j++ )
1227 m_glyphcache[j - CHAR_CACHE_START].m_glyph = NULL;
1238 return filename.GetFullName();
1244 void a2dFontFreetypeData::ClearCacheLinkes(
void )
1246 #if wxART2D_USE_FREETYPE
1250 int qpos = wxChar(
'?' ) - CHAR_CACHE_START;
1251 if( m_glyphcache[qpos].m_glyph != NULL && m_glyphcache[qpos].m_glyph != ( FT_Glyph ) - 1 )
1253 size_t index = m_glyphcache[qpos].m_index;
1254 for (
size_t i = CHAR_CACHE_START; i <= CHAR_CACHE_END; i++ )
1255 if( m_glyphcache[i - CHAR_CACHE_START].m_index == index )
1256 m_glyphcache[i - CHAR_CACHE_START].m_glyph = NULL;
1261 if( it->second.m_index == index )
1262 it->second.m_glyph = NULL;
1276 #if wxART2D_USE_FREETYPE
1285 if ( m_glyphcache.empty() )
1287 m_glyphcache.reserve( CHAR_CACHE_END - CHAR_CACHE_START + 1 );
1288 for (
size_t i = CHAR_CACHE_START; i <= CHAR_CACHE_END; i++ )
1289 m_glyphcache.push_back(
a2dGlyph() );
1293 for (
size_t i = CHAR_CACHE_START; i <= CHAR_CACHE_END; i++ )
1294 if( m_glyphcache[i - CHAR_CACHE_START].m_glyph != NULL )
1295 FT_Done_Glyph( m_glyphcache[i - CHAR_CACHE_START].m_glyph );
1297 for (
size_t j = CHAR_CACHE_START; j <= CHAR_CACHE_END; j++ )
1298 m_glyphcache[j - CHAR_CACHE_START].m_glyph = NULL;
1302 if ( filename.IsEmpty() )
1309 if ( !::wxFileExists( fname ) )
1323 else if ( !(
m_face->face_flags & FT_FACE_FLAG_SCALABLE ) )
1335 wxASSERT_MSG( error == 0 , _(
"a2dText problem setting character size" ) );
1342 const FT_Size_Metrics& size =
m_face->size->metrics;
1343 m_height = ( size.ascender - size.descender ) / ( m_sizeInPixels * 64.0 );
1344 m_desc = -size.descender / ( m_sizeInPixels * 64.0 );
1345 m_lead = ( size.height - ( size.ascender - size.descender ) ) / ( m_sizeInPixels * 64.0 );
1350 #else //wxART2D_USE_FREETYPE
1355 #endif // wxART2D_USE_FREETYPE
1361 #if wxART2D_USE_FREETYPE
1369 if ( cinput >= CHAR_CACHE_START && cinput <= CHAR_CACHE_END )
1371 a2dGlyph* a2dglyph = &m_glyphcache[cinput - CHAR_CACHE_START];
1372 FT_Glyph glyph = a2dglyph->m_glyph;
1375 wchar_t wc = ( wchar_t )cinput;
1380 wxChar cinputstr[2];
1382 cinputstr[0] = cinput;
1387 wc =
m_converter->Convert( wxString( cinput ) ).Last();
1391 FT_ULong c = ( FT_ULong ) wc;
1393 FT_UInt index = FT_Get_Char_Index(
m_face, ( FT_ULong ) c );
1396 error = FT_Load_Glyph(
m_face, index, m_loadMethodMask );
1397 wxASSERT_MSG( error == 0 , _(
"Glyph could not be loaded" ) );
1400 error = FT_Get_Glyph(
m_face->glyph, &glyph );
1401 wxASSERT_MSG( error == 0 , _(
"Glyph could not be get" ) );
1406 glyph->advance =
m_face->glyph->advance;
1409 glyph = ( FT_Glyph ) - 1;
1410 if ( c != wxChar(
'?' ) )
1415 index = a2dglyph->m_index;
1416 glyph = glyphErr->m_glyph;
1420 a2dglyph->m_index = index;
1421 a2dglyph->m_glyph = glyph;
1422 a2dglyph->m_lsb =
m_face->glyph->lsb_delta;
1423 a2dglyph->m_rsb =
m_face->glyph->rsb_delta;
1424 a2dglyph->m_face =
m_face;
1426 if ( glyph == ( FT_Glyph ) - 1 )
1437 FT_Glyph glyph = a2dglyph->m_glyph;
1440 wchar_t wc = ( wchar_t )cinput;
1445 wxChar cinputstr[2];
1447 cinputstr[0] = cinput;
1452 wc =
m_converter->Convert( wxString( cinput ) ).Last();
1455 FT_ULong c = ( FT_ULong ) wc;
1457 FT_UInt index = FT_Get_Char_Index(
m_face, ( FT_ULong ) c );
1459 error = FT_Load_Glyph(
m_face, index, m_loadMethodMask );
1460 wxASSERT_MSG( error == 0 , _(
"Glyph could not be loaded" ) );
1463 error = FT_Get_Glyph(
m_face->glyph, &glyph );
1464 wxASSERT_MSG( error == 0 , _(
"Glyph could not be get" ) );
1469 glyph->advance =
m_face->glyph->advance;
1473 glyph = ( FT_Glyph ) - 1;
1474 if ( c != wxChar(
'?' ) )
1479 index = glyphErr->m_index;
1480 glyph = glyphErr->m_glyph;
1484 a2dglyph->m_index = index;
1485 a2dglyph->m_glyph = glyph;
1486 a2dglyph->m_lsb =
m_face->glyph->lsb_delta;
1487 a2dglyph->m_rsb =
m_face->glyph->rsb_delta;
1488 a2dglyph->m_face =
m_face;
1490 if ( glyph == ( FT_Glyph ) - 1 )
1498 #else // wxART2D_USE_FREETYPE
1500 #endif // wxART2D_USE_FREETYPE
1503 void a2dFontFreetypeData::GetTextExtent(
const wxString&
string,
double& w,
1504 double& h,
double& descent,
double& externalLeading )
const
1508 const a2dGlyph* a2dglyphprev = NULL;
1511 const wxStringCharType *cp(
string.wx_str());
1513 const wxChar* cp(
string.c_str());
1514 #endif // wxUSE_UNICODE
1515 for (
size_t n = 0; n <
string.Length(); n++ )
1525 FT_Face face = a2dglyph->m_face;
1527 FT_Get_Kerning( a2dglyph->m_face, a2dglyphprev->m_index, a2dglyph->m_index, FT_KERNING_DEFAULT, &kern );
1530 if ( a2dglyphprev->m_rsb - a2dglyph->m_lsb >= 32 )
1532 else if ( a2dglyphprev->m_rsb - a2dglyph->m_lsb < -32 )
1536 a2dglyphprev = a2dglyph;
1537 FT_Glyph glyphimage = a2dglyph->m_glyph;
1538 x += glyphimage->advance.x / 64.0;
1551 w = h = descent = externalLeading = 0.0;
1578 #if wxART2D_USE_FREETYPE
1584 FT_Glyph glyphimage = a2dglyph->m_glyph;
1589 #else //wxART2D_USE_FREETYPE
1592 #endif //wxART2D_USE_FREETYPE
1595 double a2dFontFreetypeData::GetGlyphHeight( wxChar c )
const
1597 #if wxART2D_USE_FREETYPE
1603 FT_Glyph glyphimage = a2dglyph->m_glyph;
1608 #else //wxART2D_USE_FREETYPE
1611 #endif //wxART2D_USE_FREETYPE
1616 #if wxART2D_USE_FREETYPE
1629 if ( FT_Get_Kerning(
m_face, a2dglyph1->m_index, a2dglyph2->m_index, FT_KERNING_DEFAULT, &kern ) )
1633 double rsblsbshift = 0;
1635 if ( a2dglyph1->m_rsb - a2dglyph2->m_lsb >= 32 )
1637 else if ( a2dglyph1->m_rsb - a2dglyph2->m_lsb < -32 )
1642 #else //wxART2D_USE_FREETYPE
1644 #endif //wxART2D_USE_FREETYPE
1647 static double fscale = 0;
1648 static double fx = 0;
1649 static double fy = 0;
1651 int MoveToFunc(
const FT_Vector* to,
void* user )
1654 if ( vpath->size() )
1656 vpath->
MoveTo( fx + fscale * to->x , fy + fscale * to->y );
1660 int LineToFunc(
const FT_Vector* to,
void* user )
1663 vpath->
LineTo( fx + fscale * to->x , fy + fscale * to->y );
1668 int ConicToFunc(
const FT_Vector* control,
1669 const FT_Vector* to,
1673 vpath->
QBCurveTo( fx + fscale * to->x, fy + fscale * to->y, fx + fscale * control->x, fy + fscale * control->y );
1678 int CubicToFunc(
const FT_Vector* control1,
1679 const FT_Vector* control2,
1680 const FT_Vector* to,
1685 vpath->
CBCurveTo( fx + fscale * to->x, fy + fscale * to->y, fx + fscale * control2->x, fy + fscale * control2->y,
1686 fx + fscale * control2->x, fy + fscale * control2->y );
1694 #if wxART2D_USE_FREETYPE
1695 double x = affine.
GetValue( 2, 0 );
1696 double y = affine.
GetValue( 2, 1 );
1704 FT_Glyph glyph = a2dglyph->m_glyph;
1705 if ( glyph->format != FT_GLYPH_FORMAT_OUTLINE )
1707 FT_Outline& outline = ( ( FT_OutlineGlyph ) glyph )->outline;
1710 FT_Vector v_control;
1741 for( n = 0; n < outline.n_contours; n++ )
1745 last = outline.contours[n];
1746 limit = outline.points + last;
1748 v_start = outline.points[first];
1749 v_last = outline.points[last];
1751 v_control = v_start;
1753 point = outline.points + first;
1754 tags = outline.tags + first;
1755 tag = FT_CURVE_TAG( tags[0] );
1758 if( tag == FT_CURVE_TAG_CUBIC )
return false;
1761 if( tag == FT_CURVE_TAG_CONIC )
1764 if( FT_CURVE_TAG( outline.tags[last] ) == FT_CURVE_TAG_ON )
1775 v_start.x = ( v_start.x + v_last.x ) / 2;
1776 v_start.y = ( v_start.y + v_last.y ) / 2;
1784 vpath.
MoveTo( x + scale * v_start.x, y + scale * v_start.y );
1786 while( point < limit )
1791 tag = FT_CURVE_TAG( tags[0] );
1794 case FT_CURVE_TAG_ON:
1796 vpath.
LineTo( x + scale * point->x, y + scale * point->y );
1800 case FT_CURVE_TAG_CONIC:
1802 v_control.x = point->x;
1803 v_control.y = point->y;
1813 tag = FT_CURVE_TAG( tags[0] );
1818 if( tag == FT_CURVE_TAG_ON )
1821 vpath.
QBCurveTo( x + scale * vec.x, y + scale * vec.y, x + scale * v_control.x, y + scale * v_control.y );
1825 if( tag != FT_CURVE_TAG_CONIC )
return false;
1827 v_middle.x = ( v_control.x + vec.x ) / 2;
1828 v_middle.y = ( v_control.y + vec.y ) / 2;
1830 vpath.
QBCurveTo( x + scale * v_middle.x, y + scale * v_middle.y, x + scale * v_control.x, y + scale * v_control.y );
1835 vpath.
QBCurveTo( x + scale * v_start.x, y + scale * v_start.y, x + scale * v_control.x, y + scale * v_control.y );
1842 FT_Vector vec1, vec2;
1844 if( point + 1 > limit || FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
1849 vec1.x = point[0].x;
1850 vec1.y = point[0].y;
1851 vec2.x = point[1].x;
1852 vec2.y = point[1].y;
1857 if( point <= limit )
1864 vpath.
CBCurveTo( x + scale * vec1.x, y + scale * vec1.y,
1865 x + scale * vec2.x, y + scale * vec2.y,
1866 x + scale * vec.x, y + scale * vec.y );
1870 vpath.
CBCurveTo( x + scale * vec1.x, y + scale * vec1.y,
1871 x + scale * vec2.x, y + scale * vec2.y,
1872 x + scale * v_start.x, y + scale * v_start.y );
1879 vpath.
LineTo( x + scale * v_start.x, y + scale * v_start.y,
true );
1886 #else //wxART2D_USE_FREETYPE
1888 #endif //wxART2D_USE_FREETYPE
1893 #if wxART2D_USE_FREETYPE
1895 #if wxCHECK_VERSION(2,7,0)
1896 for ( wxPathList::iterator node = pathlist.begin(); node != pathlist.end(); node++ )
1898 for ( wxPathList::compatibility_iterator node = pathlist.GetFirst(); node; node = node->GetNext() )
1901 wxString path( node->GetData() );
1902 if ( !wxDir::Exists( path ) )
1904 wxArrayString files;
1905 wxDir::GetAllFiles( path, &files, wxT(
"*.ttf" ), wxDIR_FILES );
1906 for (
unsigned int i = 0; i < files.GetCount(); i++ )
1910 error = FT_New_Face( g_freetypeLibrary, files.Item( i ).mb_str(), 0, &face );
1913 list.Append(
new a2dFontInfo( wxT(
"Freetype font" ),
1914 wxString::FromAscii( face->family_name ),
1915 wxString::FromAscii( face->style_name ),
1916 1.0, files.Item( i ) ) );
1917 FT_Done_Face( face );
1921 wxUnusedVar( list );
1927 #if wxART2D_USE_FREETYPE
1928 if ( force || info.
GetType().Upper() == wxT(
"FREETYPE FONT" ) )
1931 if ( !force && !info.
GetExtra().IsEmpty() )
1947 list.DeleteContents(
true );
1951 for ( i = 0; i < list.GetCount(); i++ )
1970 for ( i = 0; i < list.GetCount(); i++ )
1979 else if ( ( fi->
GetName().Upper().Find( info.
GetName().Upper() ) != -1 )
1980 || ( info.
GetName().Upper().Find( fi->
GetName().Upper() ) != -1 ) )
1985 if ( ( info.
GetStyle().Upper() == wxT(
"BOLD" ) )
1986 || ( info.
GetStyle().Upper().Find( wxT(
"BOLD" ) ) != -1 ) )
1988 if ( ( info.
GetStyle().Upper() == wxT(
"ITALIC" ) )
1989 || ( info.
GetStyle().Upper().Find( wxT(
"ITALIC" ) ) != -1 ) )
1991 if ( ( info.
GetStyle().Upper() == wxT(
"REGULAR" ) )
1992 || ( info.
GetStyle().Upper().Find( wxT(
"REGULAR" ) ) != -1 ) )
2044 virtual a2dFontType GetType(
void )
const {
return a2dFONT_STROKED; }
2051 a2dFontStrokeData(
const wxString& filename = wxT(
"" ),
double size = 0.0,
bool monoSpaced =
false,
double weight = 0.0 );
2068 wxString
GetFilename(
bool filenameonly =
false )
const;
2084 void SetWeight(
const wxString& weight );
2090 double GetKerning( wxChar c1, wxChar c2 )
const;
2134 #define BGI_FONT_MAGIC "PK\b\bBGI "
2145 unsigned short headersize;
2147 unsigned short datasize;
2148 unsigned char majorversion, minorversion;
2149 unsigned char minmajorversion, minminorversion;
2157 unsigned short nchar;
2159 unsigned char firstchar;
2160 unsigned short stroke_offset;
2162 signed char org_top;
2163 signed char org_base;
2164 signed char org_desc;
2174 m_monoSpaced = monoSpaced;
2189 m_monoSpaced = other.m_monoSpaced;
2199 for (
unsigned char i = 0; i <
m_count; i++ )
2218 return filename.GetFullName();
2236 for (
unsigned char i = 0; i <
m_count; i++ )
2256 if ( fname.IsEmpty() )
2259 wxFile file( fname );
2260 if ( !file.IsOpened() )
2263 BGI_FONT_HEADER bgifontheader;
2264 file.Read( &bgifontheader.magic,
sizeof( bgifontheader.magic ) );
2268 while( !file.Eof() && idx <
sizeof( bgifontheader.descr ) - 1 && c != 0x1a )
2270 bgifontheader.descr[idx++] = c;
2273 while( !file.Eof() && c != 0x1a )
2275 bgifontheader.descr[idx] =
'\0';
2276 file.Read( &bgifontheader.headersize,
sizeof( bgifontheader.headersize ) );
2278 bgifontheader.headersize = wxINT16_SWAP_ON_BE( bgifontheader.headersize );
2279 file.Read( &bgifontheader.fname, 4 );
2280 bgifontheader.fname[4] =
'\0';
2281 file.Read( &bgifontheader.datasize,
sizeof( bgifontheader.datasize ) );
2283 bgifontheader.datasize = wxINT16_SWAP_ON_BE( bgifontheader.datasize );
2284 file.Read( &bgifontheader.majorversion, 4 *
sizeof( bgifontheader.majorversion ) );
2286 if ( memcmp( bgifontheader.magic, BGI_FONT_MAGIC,
sizeof( bgifontheader.magic ) ) )
2291 file.Seek( bgifontheader.headersize, wxFromStart );
2293 BGI_FONT_DATA bgifontdata;
2294 file.Read( &bgifontdata,
sizeof( BGI_FONT_DATA ) );
2296 bgifontdata.nchar = wxUINT16_SWAP_ON_BE( bgifontdata.nchar );
2297 bgifontdata.stroke_offset = wxUINT16_SWAP_ON_BE( bgifontdata.stroke_offset );
2299 if ( bgifontdata.signature !=
'+' )
2308 m_intsize = bgifontdata.org_top - bgifontdata.org_base;
2313 m_desc = ( bgifontdata.org_base - bgifontdata.org_desc + 1.5 ) / size;
2319 file.Seek( bgifontheader.headersize +
sizeof( BGI_FONT_DATA ) +
sizeof(
unsigned short ) * ( bgifontdata.nchar ), wxFromStart );
2322 for ( i = 0; i <
m_count; i++ )
2324 file.Read( &w,
sizeof(
unsigned char ) );
2330 for ( i = 0; i <
m_count; i++ )
2333 file.Seek( bgifontheader.headersize +
sizeof( BGI_FONT_DATA ) +
sizeof(
unsigned short ) * i, wxFromStart );
2334 unsigned short char_offset;
2335 file.Read( &char_offset,
sizeof( char_offset ) );
2337 char_offset = wxUINT16_SWAP_ON_BE( char_offset );
2339 file.Seek( bgifontheader.headersize + bgifontdata.stroke_offset + char_offset, wxFromStart );
2342 unsigned char opcode = 1;
2347 signed char penupx = 0;
2348 signed char penupy = 0;
2349 while ( opcode != 0 )
2352 file.Read( &x,
sizeof( x ) );
2353 file.Read( &y,
sizeof( y ) );
2354 if ( x & 0x80 ) opcode |= 0x2;
else opcode &= ~0x2;
2355 if ( y & 0x80 ) opcode |= 0x1;
else opcode &= ~0x1;
2356 if ( x & 0x40 ) x |= 0x80;
else x &= ~0x80;
2357 if ( y & 0x40 ) y |= 0x80;
else y &= ~0x80;
2363 list->push_back(
new a2dLineSegment( penupx / size, ( penupy - bgifontdata.org_base ) / size +
m_desc ) );
2366 list->push_back(
new a2dLineSegment( x / size, ( y - bgifontdata.org_base ) / size +
m_desc ) );
2377 penup =
true; penupx = x; penupy = y;
2393 wxString fontname = wxString::FromAscii( bgifontheader.fname );
2394 if ( fontname == wxT(
"EURO" ) )
2395 fontname = wxT(
"EuroStyle" );
2396 else if ( fontname == wxT(
"GOTH" ) )
2397 fontname = wxT(
"Gothic" );
2398 else if ( fontname == wxT(
"LCOM" ) )
2399 fontname = wxT(
"Complex" );
2400 else if ( fontname == wxT(
"LITT" ) )
2401 fontname = wxT(
"Small" );
2402 else if ( fontname == wxT(
"SANS" ) )
2403 fontname = wxT(
"Sans serif" );
2404 else if ( fontname == wxT(
"SCRI" ) )
2405 fontname = wxT(
"Script" );
2406 else if ( fontname == wxT(
"SIMP" ) )
2407 fontname = wxT(
"Simple" );
2408 else if ( fontname == wxT(
"TRIP" ) )
2409 fontname = wxT(
"Triplex" );
2410 else if ( fontname == wxT(
"TSCR" ) )
2411 fontname = wxT(
"Triplex Script" );
2412 else if ( fontname == wxT(
"NEN " ) )
2413 fontname = wxT(
"NEN 3094" );
2430 style.Printf( wxT(
"%.1f\x25 of height" ),
m_weight );
2438 if ( weight.Upper() == wxT(
"PIXEL PEN" ) )
2442 else if ( weight.Upper() == wxT(
"NORMALIZED PEN" ) )
2448 int idxend = weight.Find( wxChar(
'%' ) );
2453 size_t idxstart = idxend;
2454 while ( idxstart > 0 && weight[idxstart - 1] == wxChar(
' ' ) )
2456 while ( idxstart > 0 && weight[idxstart - 1] != wxChar(
' ' ) )
2458 weight.Mid( idxstart, idxend - idxstart ).ToDouble( &
m_weight );
2468 unsigned char c2 = c;
2479 return width * 0.83;
2509 unsigned char c2 = c;
2542 vpath.
Add( trans,
true,
false );
2552 #if wxCHECK_VERSION(2,7,0)
2553 for ( wxPathList::iterator node = pathlist.begin(); node != pathlist.end(); node++ )
2555 for ( wxPathList::compatibility_iterator node = pathlist.GetFirst(); node; node = node->GetNext() )
2558 wxString path( node->GetData() );
2559 if ( !wxDir::Exists( path ) )
2562 wxArrayString files;
2563 wxDir::GetAllFiles( path, &files, wxT(
"*.chr" ), wxDIR_FILES );
2564 for (
unsigned int i = 0; i < files.GetCount(); i++ )
2567 wxFile file( files.Item( i ) );
2568 if ( !file.IsOpened() )
2571 BGI_FONT_HEADER bgifontheader;
2572 file.Read( &bgifontheader.magic,
sizeof( bgifontheader.magic ) );
2576 while( !file.Eof() && idx <
sizeof( bgifontheader.descr ) - 1 && c != 0x1a )
2578 bgifontheader.descr[idx++] = c;
2581 while( !file.Eof() && c != 0x1a )
2583 bgifontheader.descr[idx] =
'\0';
2584 file.Read( &bgifontheader.headersize,
sizeof( bgifontheader.headersize ) );
2586 bgifontheader.headersize = wxINT16_SWAP_ON_BE( bgifontheader.headersize );
2587 file.Read( &bgifontheader.fname, 4 );
2588 bgifontheader.fname[4] =
'\0';
2589 file.Read( &bgifontheader.datasize,
sizeof( bgifontheader.datasize ) );
2591 bgifontheader.datasize = wxINT16_SWAP_ON_BE( bgifontheader.datasize );
2592 file.Read( &bgifontheader.majorversion, 4 *
sizeof( bgifontheader.majorversion ) );
2594 if ( memcmp( bgifontheader.magic, BGI_FONT_MAGIC,
sizeof( bgifontheader.magic ) ) )
2599 file.Seek( bgifontheader.headersize, wxFromStart );
2601 BGI_FONT_DATA bgifontdata;
2602 file.Read( &bgifontdata,
sizeof( BGI_FONT_DATA ) );
2604 bgifontdata.nchar = wxUINT16_SWAP_ON_BE( bgifontdata.nchar );
2605 bgifontdata.stroke_offset = wxUINT16_SWAP_ON_BE( bgifontdata.stroke_offset );
2607 if ( bgifontdata.signature !=
'+' )
2614 wxString fontname = wxString::FromAscii( bgifontheader.fname );
2615 if ( fontname == wxT(
"EURO" ) )
2616 fontname = wxT(
"EuroStyle" );
2617 else if ( fontname == wxT(
"GOTH" ) )
2618 fontname = wxT(
"Gothic" );
2619 else if ( fontname == wxT(
"LCOM" ) )
2620 fontname = wxT(
"Complex" );
2621 else if ( fontname == wxT(
"LITT" ) )
2622 fontname = wxT(
"Small" );
2623 else if ( fontname == wxT(
"SANS" ) )
2624 fontname = wxT(
"Sans serif" );
2625 else if ( fontname == wxT(
"SCRI" ) )
2626 fontname = wxT(
"Script" );
2627 else if ( fontname == wxT(
"SIMP" ) )
2628 fontname = wxT(
"Simple" );
2629 else if ( fontname == wxT(
"TRIP" ) )
2630 fontname = wxT(
"Triplex" );
2631 else if ( fontname == wxT(
"TSCR" ) )
2632 fontname = wxT(
"Triplex Script" );
2633 else if ( fontname == wxT(
"NEN " ) )
2634 fontname = wxT(
"NEN 3094" );
2636 wxFileName filename( files.Item( i ) );
2637 wxString weightstring;
2638 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
"Pixel Pen" ), 1.0, filename.GetFullName() ) );
2639 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
"Normalized Pen" ), 1.0, filename.GetFullName() ) );
2640 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
" 2% of height" ), 1.0, filename.GetFullName() ) );
2641 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
" 5% of height" ), 1.0, filename.GetFullName() ) );
2642 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
" 7% of height" ), 1.0, filename.GetFullName() ) );
2643 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
"10% of height" ), 1.0, filename.GetFullName() ) );
2644 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
"15% of height" ), 1.0, filename.GetFullName() ) );
2645 list.Append(
new a2dFontInfo( wxT(
"Stroke font" ), fontname, wxT(
"20% of height" ), 1.0, filename.GetFullName() ) );
2652 if ( force || info.
GetType().Upper() == wxT(
"STROKE FONT" ) )
2655 if ( !force && !info.
GetExtra().IsEmpty() )
2669 list.DeleteContents(
true );
2673 for ( i = 0; i < list.GetCount(); i++ )
2691 for ( i = 0; i < list.GetCount(); i++ )
2695 if ( ( fi->
GetName().Upper().Find( info.
GetName().Upper() ) != -1 )
2696 || ( info.
GetName().Upper().Find( fi->
GetName().Upper() ) != -1 ) )
2717 map< wxString, a2dFont > a2dFont::ms_fontCache;
2719 IMPLEMENT_ABSTRACT_CLASS(
a2dFont, wxObject )
2732 wxString typestr = wxT(
"Freetype font" );
2734 sizestr.Printf( wxT(
"%f" ), size );
2736 weightstr.Printf( wxT(
"%d" ), weight );
2737 wxString description = typestr + wxT(
"-" ) + filename + wxT(
"-" ) + weightstr
2738 + wxT(
"-" ) + sizestr;
2744 wxString typestr = wxT(
"Stroke font" );
2747 if ( weight == 0.0 )
2748 weightstr = wxT(
"Pixel Pen" );
2749 if ( weight == -1.0 )
2750 weightstr = wxT(
"Normalized Pen" );
2752 weightstr.Printf( wxT(
"%.1f\x25 of height" ), weight );
2755 if ( monoSpaced ) monostr = wxT(
"monoSpaced" );
2757 sizestr.Printf( wxT(
"%f" ), size );
2758 wxString description = typestr + wxT(
"-" ) + filename + wxT(
"-" ) + weightstr
2759 + wxT(
"-" ) + sizestr + wxT(
"-" ) + monostr ;
2765 wxString name = font.GetFaceName();
2766 wxString style = wxEmptyString;
2772 typestr = wxT(
"Device font" );
2774 case a2dFONT_FREETYPE:
2775 typestr = wxT(
"Freetype font" );
2778 wxFAIL_MSG( _(
"wrong font to set a wxFont to" ) );
2782 switch ( font.GetWeight() )
2785 if ( font.GetStyle() == wxNORMAL )
2786 style = wxT(
"Regular" );
2789 style = wxT(
"Bold " );
2792 style = wxT(
"Light " );
2795 switch ( font.GetStyle() )
2801 style += wxT(
"Italic" );
2807 sizestr.Printf( wxT(
"%f" ), size );
2808 wxString description = typestr + wxT(
"-" ) + name + wxT(
"-" ) + style.Trim()
2809 + wxT(
"-" ) + sizestr;
2816 wxString fontstr =
CreateString( type, font, size, encoding );
2817 if ( ms_fontCache.find( fontstr ) == ms_fontCache.end() )
2824 #if wxART2D_USE_FREETYPE
2825 case a2dFONT_FREETYPE:
2826 #if defined(__USE_WINAPI__)
2829 wxFAIL_MSG( _(
"freetype based on wxFont not enabled" ) );
2830 #endif // defined( __USE_WINAPI__ )
2834 wxFAIL_MSG( _(
"wrong font to set a wxFont to" ) );
2837 ms_fontCache[fontstr] = *
this;
2841 Ref( ms_fontCache[fontstr] );
2845 const bool underline,
const wxString& faceName,
2846 wxFontEncoding encoding )
2848 wxString fontstr =
CreateString( a2dFONT_WXDC, wxFont( 1, family, style, weight, underline, faceName, encoding ), size, encoding );
2849 if ( ms_fontCache.find( fontstr ) == ms_fontCache.end() )
2851 m_refData =
new a2dFontDcData( size, family, style, weight, underline, faceName, encoding );
2852 ms_fontCache[fontstr] = *
this;
2856 Ref( ms_fontCache[fontstr] );
2860 #if wxART2D_USE_FREETYPE
2861 a2dFont::a2dFont(
const wxString& filename,
double size, wxFontEncoding encoding,
int faceindex )
2869 wxString fontstr =
CreateString( filename, size, monoSpaced, weight );
2870 if ( ms_fontCache.find( fontstr ) == ms_fontCache.end() )
2873 ms_fontCache[fontstr] = *
this;
2877 a2dFont cached = ms_fontCache[fontstr];
2890 return ( (
a2dFontRefData* )GetRefData() )->m_fontinfo.CreateString();
2891 return wxEmptyString;
2927 return ( (
a2dFontRefData* )GetRefData() )->GetKerning( c1, c2 );
2933 switch ( GetType() )
2935 case a2dFONT_STROKED:
2946 switch ( GetType() )
2948 case a2dFONT_STROKED:
2951 wxFAIL_MSG( _(
"need stroked font a2dFontStrokeData" ) );
2957 const a2dGlyph* a2dFont::GetGlyphFreetype( wxChar c )
const
2959 switch ( GetType() )
2961 #if wxART2D_USE_FREETYPE && defined(__USE_WINAPI__)
2969 case a2dFONT_FREETYPE:
2972 wxFAIL_MSG( _(
"need stroked font a2dFontFreetypeData" ) );
2978 void a2dFont::SetDeviceHeight(
double sizeInPixels )
2980 switch ( GetType() )
2984 ( (
a2dFontDcData* )GetRefData() )->SetDeviceHeight( sizeInPixels );
2987 case a2dFONT_FREETYPE:
2995 double a2dFont::GetDeviceHeight()
2997 switch ( GetType() )
2999 #if wxART2D_USE_FREETYPE && defined(__USE_WINAPI__)
3002 return ( (
a2dFontDcData* )GetRefData() )->GetDeviceHeight();
3006 case a2dFONT_FREETYPE:
3014 #if wxART2D_USE_FREETYPE && defined(__USE_WINAPI__)
3015 a2dFont a2dFont::GetFreetypeFont()
3017 switch ( GetType() )
3020 return ( (
a2dFontDcData* )GetRefData() )->GetFreetypeFont();
3023 wxFAIL_MSG( _(
"need wxDc font a2dFontDcData" ) );
3032 switch ( GetType() )
3038 wxFAIL_MSG( _(
"need wxDc font a2dFontDcData" ) );
3045 int alignment,
double* w,
double* h,
3046 double* descent,
double* externalLeading )
const
3048 double gte_x, gte_y, gte_w, gte_h, gte_desc, gte_lead;
3052 if ( alignment & wxMINY )
3054 else if ( alignment & wxMAXY )
3056 else if ( alignment & wxBASELINE )
3058 else if ( alignment & wxBASELINE_CONTRA )
3059 gte_y = gte_desc - gte_h;
3061 gte_y = -gte_h / 2.0;
3064 gte_x = -gte_w / 2.0;
3065 if ( alignment & wxMINX )
3066 gte_x += gte_w / 2.0;
3067 if ( alignment & wxMAXX )
3068 gte_x -= gte_w / 2.0;
3071 if ( w ) * w = gte_w;
3072 if ( h ) * h = gte_h;
3073 if ( descent ) * descent = gte_desc;
3074 if ( externalLeading ) * externalLeading = gte_lead;
3076 return a2dBoundingBox( gte_x, gte_y, gte_x + gte_w, gte_y + gte_h );
3080 double& h,
double& descent,
double& externalLeading )
const
3082 return ( (
a2dFontRefData* )GetRefData() )->GetTextExtent(
string, w, h, descent, externalLeading );
3087 double descent, externalLeading;
3088 return ( (
a2dFontRefData* )GetRefData() )->GetTextExtent(
string, w, h, descent, externalLeading );
3091 bool a2dFont::GetPartialTextExtents (
const wxString& text, wxArrayInt& widths )
const
3113 return ( (
a2dFontRefData* )GetRefData() )->GetVpath( c, vpath, affine );
3133 affine2.
Mirror(
true,
false );
3143 const size_t n = text.Length();
3144 for (
size_t i = 0; i < n; i++ )
3146 const wxChar oldc = c;
3158 a2dFontFreetypeData::GetInfoList( list );
3159 a2dFontStrokeData::GetInfoList( list );
3160 a2dFontDcData::GetInfoList( list );
3169 fontdata = (
a2dFontRefData* ) a2dFontFreetypeData::CreateFont( info );
3171 fontdata = (
a2dFontRefData* ) a2dFontStrokeData::CreateFont( info );
3173 fontdata = (
a2dFontRefData* ) a2dFontDcData::CreateFont( info );
3175 if ( !fontdata && !force )
3178 font.m_refData = fontdata;
3184 fontdata = (
a2dFontRefData* ) a2dFontFreetypeData::CreateFont( info, force );
3186 fontdata = (
a2dFontRefData* ) a2dFontStrokeData::CreateFont( info, force );
3188 fontdata = (
a2dFontRefData* ) a2dFontDcData::CreateFont( info, force );
3199 font.m_refData = fontdata;
3204 a2dFontType a2dFont::GetType(
void )
const
3207 return a2dFONT_NULL;
3211 wxObjectRefData* a2dFont::CreateRefData()
const
3213 switch ( GetType() )
3219 case a2dFONT_FREETYPE:
3221 case a2dFONT_STROKED:
3229 wxObjectRefData* a2dFont::CloneRefData(
const wxObjectRefData* data )
const
3237 case a2dFONT_FREETYPE:
3239 case a2dFONT_STROKED:
3257 case a2dFONT_FREETYPE:
3260 case a2dFONT_STROKED:
3264 wxFAIL_MSG( _(
"wrong font to set a filename" ) );
3273 case a2dFONT_FREETYPE:
3275 case a2dFONT_STROKED:
3287 case a2dFONT_STROKED:
3304 case a2dFONT_STROKED:
3317 case a2dFONT_STROKED:
3325 A2DARTBASEDLLEXP a2dDECLARE_GLOBAL_VAR(
const a2dFill*,
a2dBLACK_FILL );
3326 A2DARTBASEDLLEXP a2dDECLARE_GLOBAL_VAR(
const a2dFill*,
a2dWHITE_FILL );
3330 A2DARTBASEDLLEXP a2dDECLARE_GLOBAL_VAR(
const a2dFill*,
a2dNullFILL );
3332 A2DARTBASEDLLEXP a2dDECLARE_GLOBAL_VAR(
const a2dFill*,
a2dINHERIT_FILL );
3333 A2DARTBASEDLLEXP a2dDECLARE_GLOBAL_VAR(
const a2dFill*,
a2dSELECT_FILL );
3451 return wxT(
"a2dFILL_NULLFILL" );
3457 if ( stylestr == wxT(
"a2dFILL_SOLID" ) )
3459 if ( stylestr == wxT(
"a2dFILL_TRANSPARENT" ) )
3461 if ( stylestr == wxT(
"a2dFILL_BDIAGONAL_HATCH" ) )
3463 if ( stylestr == wxT(
"a2dFILL_CROSSDIAG_HATCH" ) )
3465 if ( stylestr == wxT(
"a2dFILL_FDIAGONAL_HATCH" ) )
3467 if ( stylestr == wxT(
"a2dFILL_CROSS_HATCH" ) )
3469 if ( stylestr == wxT(
"a2dFILL_HORIZONTAL_HATCH" ) )
3471 if ( stylestr == wxT(
"a2dFILL_VERTICAL_HATCH" ) )
3473 if ( stylestr == wxT(
"a2dFILL_STIPPLE" ) )
3475 if ( stylestr == wxT(
"a2dFILL_STIPPLE_MASK_OPAQUE" ) )
3477 if ( stylestr == wxT(
"a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT" ) )
3479 if ( stylestr == wxT(
"a2dFILL_GRADIENT_FILL_XY_LINEAR" ) )
3481 if ( stylestr == wxT(
"a2dFILL_GRADIENT_FILL_XY_RADIAL" ) )
3483 if ( stylestr == wxT(
"a2dFILL_GRADIENT_FILL_XY_DROP" ) )
3485 if ( stylestr == wxT(
"a2dFILL_INHERIT" ) )
3487 if ( stylestr == wxT(
"a2dFILL_LAYER" ) )
3489 if ( stylestr == wxT(
"a2dFILL_NULLFILL" ) )
3492 if ( stylestr == wxT(
"a2dFILL_TWOCOL_BDIAGONAL_HATCH" ) )
3494 if ( stylestr == wxT(
"a2dFILL_TWOCOL_CROSSDIAG_HATCH" ) )
3496 if ( stylestr == wxT(
"a2dFILL_TWOCOL_FDIAGONAL_HATCH" ) )
3498 if ( stylestr == wxT(
"a2dFILL_TWOCOL_CROSS_HATCH" ) )
3500 if ( stylestr == wxT(
"a2dFILL_TWOCOL_HORIZONTAL_HATCH" ) )
3502 if ( stylestr == wxT(
"a2dFILL_TWOCOL_VERTICAL_HATCH" ) )
3505 if ( !stylestr.IsEmpty() )
3508 stylestr.ToLong( &num );
3544 #if wxART2D_USE_CVGIO
3548 virtual void DoLoad( wxObject* parent,
a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts ) = 0;
3549 #endif //wxART2D_USE_CVGIO
3569 friend class a2dFill;
3590 void SetColour(
const wxColour& col ) { m_colour1 = col; }
3595 a2dFillStyle GetStyle(
void )
const {
return m_style; }
3597 void SetStyle(
a2dFillStyle style ) { m_style = style; }
3601 #if wxART2D_USE_CVGIO
3604 #endif //wxART2D_USE_CVGIO
3621 m_colour1 = *wxBLACK;
3640 wxFAIL_MSG( _(
"invalid style for a2dOneColourFillData" ) );
3646 if ( brush.GetStyle() == wxSOLID )
3648 m_colour1 = wxColour( brush.GetColour() );
3651 else if ( brush.IsHatch() )
3653 m_colour1 = wxColour( brush.GetColour() );
3655 switch( brush.GetStyle() )
3657 case wxBDIAGONAL_HATCH :
3660 case wxCROSSDIAG_HATCH :
3663 case wxFDIAGONAL_HATCH :
3666 case wxCROSS_HATCH :
3669 case wxHORIZONTAL_HATCH :
3672 case wxVERTICAL_HATCH :
3677 else if ( brush.GetStyle() == wxTRANSPARENT )
3685 m_colour1 = other.m_colour1;
3688 #if wxART2D_USE_CVGIO
3691 if ( xmlparts == a2dXmlSer_attrib )
3697 if ( !fillColour.IsEmpty() )
3699 if ( fillColour.GetChar( 0 ) == wxT(
'#' ) )
3700 m_colour1 =
HexToColour( fillColour.After( wxT(
'#' ) ) );
3703 m_colour1 = wxTheColourDatabase->Find( fillColour );
3704 if ( !m_colour1.Ok() )
3705 m_colour1 = *wxBLACK;
3709 m_colour1 = *wxBLACK;
3717 if ( xmlparts == a2dXmlSer_attrib )
3723 wxString brushColour = wxTheColourDatabase->FindName(
GetColour() );
3725 if ( brushColour.IsEmpty() )
3728 out.WriteAttribute( wxT(
"colour" ), brushColour );
3734 #endif //wxART2D_USE_CVGIO
3752 friend class a2dFill;
3767 a2dFillStyle GetStyle(
void )
const {
return m_style; }
3769 void SetStyle(
a2dFillStyle style ) { m_style = style; }
3783 #if wxART2D_USE_CVGIO
3786 #endif //wxART2D_USE_CVGIO
3821 #if wxART2D_USE_CVGIO
3824 if ( xmlparts == a2dXmlSer_attrib )
3827 if ( fillColour.GetChar( 0 ) == wxT(
'#' ) )
3831 m_colour1 = wxTheColourDatabase->Find( fillColour );
3836 if ( !fillColour.IsEmpty() )
3838 if ( fillColour.GetChar( 0 ) == wxT(
'#' ) )
3842 m_colour2 = wxTheColourDatabase->Find( fillColour );
3854 if ( xmlparts == a2dXmlSer_attrib )
3858 wxString brushColour = wxTheColourDatabase->FindName(
GetColour() );
3860 if ( brushColour.IsEmpty() )
3863 out.WriteAttribute( wxT(
"colour" ), brushColour );
3865 brushColour = wxTheColourDatabase->FindName(
GetColour2() );
3866 if ( brushColour.IsEmpty() )
3869 out.WriteAttribute( wxT(
"colour2" ), brushColour );
3875 #endif //wxART2D_USE_CVGIO
3892 friend class a2dFill;
3918 #if wxART2D_USE_CVGIO
3921 #endif //wxART2D_USE_CVGIO
3954 wxFAIL_MSG( _(
"invalid style for a2dHatchFillData" ) );
3957 #if wxART2D_USE_CVGIO
3961 if ( xmlparts == a2dXmlSer_attrib )
3973 if ( xmlparts == a2dXmlSer_attrib )
3980 #endif //wxART2D_USE_CVGIO
3999 friend class a2dFill;
4019 const wxColour& col,
const wxColour& col2,
4020 double x1,
double y1,
double x2,
double y2 );
4026 void SetStart(
double x,
double y );
4029 void SetStop(
double x,
double y );
4037 void Init(
a2dAffineMatrix* cworld,
double minx,
double miny,
double maxx,
double maxy,
double centroidx,
double centroidy );
4039 void ColourXY(
a2dDrawer2D* drawer,
int x1,
int x2,
int y );
4041 wxUint32
GetStamp() {
return m_gradientstamp; }
4043 #if wxART2D_USE_CVGIO
4046 #endif //wxART2D_USE_CVGIO
4048 double m_x1, m_y1, m_x2, m_y2;
4050 wxUint32 m_gradientstamp;
4063 const wxColour& col,
const wxColour& col2,
4064 double x1,
double y1,
double x2,
double y2 )
4094 #if wxART2D_USE_CVGIO
4098 if ( xmlparts == a2dXmlSer_attrib )
4102 out.WriteAttribute( wxT(
"x1" ), m_x1 );
4103 out.WriteAttribute( wxT(
"y1" ), m_y1 );
4104 out.WriteAttribute( wxT(
"x2" ), m_x2 );
4105 out.WriteAttribute( wxT(
"y2" ), m_y2 );
4114 if ( xmlparts == a2dXmlSer_attrib )
4127 #endif //wxART2D_USE_CVGIO
4145 friend class a2dFill;
4165 const wxColour& col,
const wxColour& col2,
4166 double xfc,
double yfc,
double xe,
double ye,
double radius );
4172 void SetCenter(
double x,
double y );
4175 void SetRadius(
double radius );
4178 void SetFocal(
double x,
double y );
4189 void Init(
a2dAffineMatrix* cworld,
double minx,
double miny,
double maxx,
double maxy,
double centroidx,
double centroidy );
4191 void ColourXY(
a2dDrawer2D* drawer,
int x1,
int x2,
int y );
4193 wxUint32
GetStamp() {
return m_gradientstamp; }
4195 #if wxART2D_USE_CVGIO
4198 #endif //wxART2D_USE_CVGIO
4216 wxUint32 m_gradientstamp;
4230 const wxColour& col,
const wxColour& col2,
4231 double xfc,
double yfc,
double xe,
double ye,
double radius )
4248 m_radius = other.m_radius;
4269 #if wxART2D_USE_CVGIO
4273 if ( xmlparts == a2dXmlSer_attrib )
4277 out.WriteAttribute( wxT(
"cx" ),
m_xe );
4278 out.WriteAttribute( wxT(
"cy" ),
m_ye );
4279 out.WriteAttribute( wxT(
"r" ), m_radius );
4280 out.WriteAttribute( wxT(
"fx" ),
m_xfc );
4281 out.WriteAttribute( wxT(
"fy" ),
m_yfc );
4290 if ( xmlparts == a2dXmlSer_attrib )
4304 #endif //wxART2D_USE_CVGIO
4325 friend class a2dFill;
4353 void SetStipple(
const wxBitmap& stipple );
4355 const wxBitmap& GetStipple()
const {
return m_stipple; }
4367 #if wxART2D_USE_CVGIO
4370 #endif //wxART2D_USE_CVGIO
4382 m_stipple = wxNullBitmap;
4389 m_stipple = stipple;
4393 wxASSERT_MSG( m_stipple.GetMask(), wxT(
"require a mask for a2dFILL_STIPPLE_MASK_OPAQUE or a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT" ) );
4405 wxLogError( _(
"CVG : bitmap file for a2dPatternFill not specified or empty" ) );
4406 image = wxImage( 32, 32 );
4411 if ( filename.IsEmpty() )
4414 image = wxImage( 32, 32 );
4416 else if ( ! image.LoadFile( filename, wxBITMAP_TYPE_BMP ) )
4418 wxLogError( _(
"CVG : Could not load bitmap %s for a2dPatternFill" ), filename.c_str() );
4419 image = wxImage( 32, 32 );
4422 m_stipple = wxBitmap( image );
4426 wxColour white( wxT(
"WHITE" ) );
4427 wxColour black( wxT(
"BLACK" ) );
4429 wxMask* monochrome_mask =
new wxMask( m_stipple, black );
4430 m_stipple.SetMask( monochrome_mask );
4437 m_stipple = stipple;
4442 m_stipple = other.m_stipple;
4450 void a2dPatternFillData::SetStyle(
a2dFillStyle style )
4458 if ( !m_stipple.GetMask() )
4460 wxMask* mask =
new wxMask( m_stipple,
GetColour() );
4461 m_stipple.SetMask( mask );
4468 wxFAIL_MSG( _(
"invalid style for a2dPatternFillData" ) );
4471 #if wxART2D_USE_CVGIO
4475 if ( xmlparts == a2dXmlSer_attrib )
4479 if ( filename.IsEmpty() )
4481 wxLogError( _(
"CVG : bitmap file for a2dPatternFillData not specified or empty" ) );
4482 image = wxImage( 32, 32 );
4490 image = wxImage( 32, 32 );
4492 else if ( ! image.LoadFile(
m_filename, wxBITMAP_TYPE_BMP ) )
4494 wxLogError( _(
"CVG : Could not load bitmap %s for a2dPatternFillData" ),
m_filename.c_str() );
4495 image = wxImage( 32, 32 );
4498 m_stipple = wxBitmap( image );
4505 wxColour white( wxT(
"WHITE" ) );
4506 wxColour black( wxT(
"BLACK" ) );
4508 wxMask* monochrome_mask =
new wxMask( m_stipple, black );
4509 m_stipple.SetMask( monochrome_mask );
4519 if ( xmlparts == a2dXmlSer_attrib )
4525 if ( filename.IsEmpty() )
4529 wxString fileTosave;
4531 wxString* layerfile =
a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT(
"wxart2dlayers" ) );
4532 wxString* layerfiledir =
a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT(
"layerFileSavePath" ) );
4534 if ( layerfile && !layerfile->IsEmpty() )
4536 if ( !wxDirExists( *layerfiledir ) )
4537 wxMkdir( *layerfiledir );
4538 wxString mess = *layerfiledir + *layerfile + wxT(
" directory does not exist, and could not be created" );
4539 wxASSERT_MSG( wxDirExists( *layerfiledir ) , mess );
4541 fileTosave = *layerfiledir + wxFILE_SEP_PATH;
4550 fileTosave += wxFileNameFromPath(
m_filename );
4551 bool isOke = m_stipple.SaveFile( fileTosave, wxBITMAP_TYPE_BMP );
4553 wxLogError( _(
"Could not save bitmap %s for a2dPatternFillData" ), fileTosave.c_str() );
4554 out.WriteAttribute( wxT(
"filename" ), wxFileNameFromPath(
m_filename ) );
4557 out.WriteAttribute( wxT(
"filename" ), wxFileNameFromPath(
m_filename ) );
4563 #endif //wxART2D_USE_CVGIO
4588 else if ( style >= a2dFIRST_TWOCOL_HATCH && style <= a2dLAST_TWOCOL_HATCH )
4601 wxFAIL_MSG( _(
"invalid style for in a2dFill for two colours" ) );
4606 double x1,
double y1,
double x2,
double y2 )
4612 double xfc,
double yfc,
double xe,
double ye,
double radius )
4648 if ( brush == wxNullBrush )
4651 else if ( brush.GetStyle() == wxTRANSPARENT || brush.GetStyle() == wxSOLID || brush.IsHatch() )
4653 else if ( brush.GetStyle() == wxSTIPPLE )
4658 else if ( brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE )
4677 a2dFill& a2dFill::UnShare()
4679 wxObject::UnShare();
4683 wxObjectRefData* a2dFill::CreateRefData()
const
4685 switch ( GetType() )
4705 wxObjectRefData* a2dFill::CloneRefData(
const wxObjectRefData* data )
const
4741 switch ( GetType() )
4748 wxFAIL_MSG( _T(
"Not a gradient fill" ) );
4771 void a2dFill::SetAlpha( wxUint8 val )
4775 switch ( GetType() )
4782 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4784 newcol.Set( newcol.Red(), newcol.Green(), newcol.Blue(), val );
4793 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4795 newcol.Set( newcol.Red(), newcol.Green(), newcol.Blue(), val );
4804 wxUint8 a2dFill::GetAlpha()
const
4806 switch ( GetType() )
4811 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4818 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4830 switch ( GetType() )
4835 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4842 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4854 if ( cur_style == style )
4861 if ( type == GetType() )
4863 switch ( GetType() )
4869 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4873 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4877 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4881 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4885 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4918 m_refData = newrefdata;
4930 else if ( style >= a2dFIRST_TWOCOL_HATCH && style <= a2dLAST_TWOCOL_HATCH )
4932 else if ( style >= a2dFIRST_HATCH && style <= a2dLAST_HATCH )
4944 wxFAIL_MSG( _(
"invalid style for in a2dFill" ) );
4952 switch ( GetType() )
4961 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4971 switch ( GetType() )
4979 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
4985 return wxColour( 0, 0, 0, 0 );
4991 switch ( GetType() )
4997 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
5004 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
5014 switch ( GetType() )
5019 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
5026 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
5035 void a2dFill::SetStipple(
const wxBitmap& stipple )
5047 const wxBitmap& a2dFill::GetStipple()
const
5051 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
5056 return wxNullBitmap;
5071 switch ( GetType() )
5079 #if wxART2D_USE_CVGIO
5087 if ( classname == wxT(
"a2dOneColourFill" ) )
5089 else if ( classname == wxT(
"a2dLinearGradientFill" ) )
5091 else if ( classname == wxT(
"a2dRadialGradientFill" ) )
5093 else if ( classname == wxT(
"a2dPatternFill" ) )
5097 wxString stype = parser.
GetAttributeValue( wxT(
"type" ), wxT(
"a2dFILL_NULL" ) );
5098 if ( stype == wxT(
"a2dFILL_NULL" ) )
5100 else if ( stype == wxT(
"a2dFILL_ONE_COLOUR" ) )
5102 else if ( stype == wxT(
"a2dFILL_HATCH_TWO_COLOUR" ) )
5104 else if ( stype == wxT(
"a2dFILL_GRADIENT_FILL_LINEAR" ) )
5106 else if ( stype == wxT(
"a2dFILL_GRADIENT_FILL_RADIAL" ) )
5108 else if ( stype == wxT(
"a2dFILL_BITMAP" ) )
5137 ( (
a2dFillRefData* )GetRefData() )->DoLoad( parent, parser, a2dXmlSer_attrib );
5140 ( (
a2dFillRefData* )GetRefData() )->DoLoad( parent, parser, a2dXmlSer_Content );
5152 out.WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
5154 switch ( GetType() )
5159 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dFILL_ONE_COLOUR" ) );
5162 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dFILL_HATCH_TWO_COLOUR" ) );
5165 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dFILL_GRADIENT_FILL_LINEAR" ) );
5168 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dFILL_GRADIENT_FILL_RADIAL" ) );
5171 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dFILL_BITMAP" ) );
5178 ( (
a2dFillRefData* )GetRefData() )->DoSave( parent, out, a2dXmlSer_attrib, towrite );
5181 ( (
a2dFillRefData* )GetRefData() )->DoSave( parent, out, a2dXmlSer_Content, towrite );
5184 #endif //wxART2D_USE_CVGIO
5198 virtual a2dStrokeType GetType(
void )
const {
return a2dSTROKE_NULL; }
5210 #if wxART2D_USE_CVGIO
5214 virtual void DoLoad( wxObject* parent,
a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts ) = 0;
5215 #endif //wxART2D_USE_CVGIO
5254 return wxT(
"a2dSTROKE_NULLFILL" );
5260 if ( stylestr == wxT(
"a2dSTROKE_SOLID" ) )
5262 if ( stylestr == wxT(
"a2dSTROKE_TRANSPARENT" ) )
5264 if ( stylestr == wxT(
"a2dSTROKE_DOT" ) )
5266 if ( stylestr == wxT(
"a2dSTROKE_LONG_DASH" ) )
5268 if ( stylestr == wxT(
"a2dSTROKE_SHORT_DASH" ) )
5270 if ( stylestr == wxT(
"a2dSTROKE_DOT_DASH" ) )
5272 if ( stylestr == wxT(
"a2dSTROKE_USER_DASH" ) )
5274 if ( stylestr == wxT(
"a2dSTROKE_BDIAGONAL_HATCH" ) )
5276 if ( stylestr == wxT(
"a2dSTROKE_CROSSDIAG_HATCH" ) )
5278 if ( stylestr == wxT(
"a2dSTROKE_FDIAGONAL_HATCH" ) )
5280 if ( stylestr == wxT(
"a2dSTROKE_CROSS_HATCH" ) )
5282 if ( stylestr == wxT(
"a2dSTROKE_HORIZONTAL_HATCH" ) )
5284 if ( stylestr == wxT(
"a2dSTROKE_VERTICAL_HATCH" ) )
5286 if ( stylestr == wxT(
"a2dSTROKE_STIPPLE" ) )
5288 if ( stylestr == wxT(
"a2dSTROKE_STIPPLE_MASK_OPAQUE" ) )
5290 if ( stylestr == wxT(
"a2dSTROKE_STIPPLE_MASK_OPAQUE_TRANSPARENT" ) )
5300 if ( stylestr == wxT(
"a2dSTROKE_INHERIT" ) )
5302 if ( stylestr == wxT(
"a2dSTROKE_LAYER" ) )
5304 if ( stylestr == wxT(
"a2dSTROKE_NULLSTROKE" ) )
5307 if ( !stylestr.IsEmpty() )
5310 stylestr.ToLong( &num );
5354 void SetColour(
const wxColour& col ) { m_colour1 = col; }
5359 void SetJoin( wxPenJoin join_style ) { m_join = join_style; }
5361 void SetCap( wxPenCap cap_style ) { m_cap = cap_style; }
5363 wxPenCap GetCap() {
return m_cap; }
5365 wxPenJoin GetJoin() {
return m_join; }
5374 virtual float GetExtend()
const {
return m_width; }
5386 #if wxART2D_USE_CVGIO
5389 #endif //wxART2D_USE_CVGIO
5420 m_colour1 = *wxBLACK;
5422 m_cap = wxCAP_ROUND;
5434 m_cap = wxCAP_ROUND;
5465 wxFAIL_MSG( _(
"invalid style for a2dStroke" ) );
5472 m_join = stroke.GetJoin();
5473 m_cap = stroke.GetCap();
5475 m_colour1 = stroke.GetColour();
5478 if ( stroke != wxNullPen )
5480 m_width = ( float ) stroke.GetWidth();
5481 switch( stroke.GetStyle() )
5508 wxFAIL_MSG( _(
"invalid style for a2dOneColourStroke" ) );
5520 m_colour1 = other.m_colour1;
5521 m_style = other.m_style;
5526 m_dash = other.m_dash;
5562 wxFAIL_MSG( _(
"invalid style for a2dStroke" ) );
5567 #if wxART2D_USE_CVGIO
5570 if ( xmlparts == a2dXmlSer_attrib )
5583 case wxCAP_PROJECTING:
5584 out.WriteAttribute( wxT(
"cap" ),
"projecting" );
5587 out.WriteAttribute( wxT(
"cap" ),
"butt" );
5595 out.WriteAttribute( wxT(
"join" ),
"bevel" );
5598 out.WriteAttribute( wxT(
"join" ),
"miter" );
5607 wxString strokeColour = wxTheColourDatabase->FindName( m_colour1 );
5608 if ( strokeColour.IsEmpty() )
5610 out.WriteAttribute( wxT(
"colour" ), wxT(
"#" ) +
ColourToHex( m_colour1 ) );
5614 out.WriteAttribute( wxT(
"colour" ), strokeColour );
5624 out.WriteAttribute( wxT(
"width" ),
m_width );
5634 if ( xmlparts == a2dXmlSer_attrib )
5637 SetStyle( m_style );
5639 if ( cap ==
"round")
5640 m_cap = wxCAP_ROUND;
5641 else if ( cap ==
"projecting")
5642 m_cap = wxCAP_PROJECTING;
5643 else if ( cap ==
"butt")
5647 if ( join ==
"bevel")
5649 else if ( join ==
"miter")
5651 else if ( join ==
"round")
5655 if ( !strokeColour.IsEmpty() )
5657 if ( strokeColour.GetChar( 0 ) == wxT(
'#' ) )
5659 m_colour1 =
HexToColour( strokeColour.After( wxT(
'#' ) ) );
5663 m_colour1 = wxTheColourDatabase->Find( strokeColour );
5664 if ( !m_colour1.Ok() )
5665 m_colour1 = *wxBLACK;
5669 m_colour1 = *wxBLACK;
5678 #endif //wxART2D_USE_CVGIO
5728 void SetStipple(
const wxBitmap& stipple ) { m_stipple = stipple; }
5730 const wxBitmap& GetStipple()
const {
return m_stipple; }
5742 #if wxART2D_USE_CVGIO
5745 #endif //wxART2D_USE_CVGIO
5756 m_stipple = wxNullBitmap;
5758 SetStyle( m_style );
5763 m_stipple = stipple;
5765 wxASSERT_MSG( m_stipple.Ok(), wxT(
"Stipple Bitmap not oke" ) );
5768 wxASSERT_MSG( m_stipple.GetMask(), wxT(
"require a mask for a2dSTROKE_STIPPLE_MASK_OPAQUE or a2dSTROKE_STIPPLE_MASK_OPAQUE_TRANSPARENT" ) );
5780 wxLogError( _(
"CVG : bitmap file for a2dPatternFill not specified or empty" ) );
5781 image = wxImage( 32, 32 );
5786 if ( filename.IsEmpty() )
5789 image = wxImage( 32, 32 );
5791 else if ( ! image.LoadFile( filename, wxBITMAP_TYPE_BMP ) )
5793 wxLogError( _(
"CVG : Could not load bitmap %s for a2dPatternStroke" ), filename.c_str() );
5794 image = wxImage( 32, 32 );
5797 m_stipple = wxBitmap( image );
5801 wxColour white( wxT(
"WHITE" ) );
5802 wxColour black( wxT(
"BLACK" ) );
5804 wxMask* monochrome_mask =
new wxMask( m_stipple, black );
5805 m_stipple.SetMask( monochrome_mask );
5812 m_stipple = other.m_stipple;
5828 if ( !m_stipple.GetMask() )
5830 wxMask* mask =
new wxMask( m_stipple,
GetColour() );
5831 m_stipple.SetMask( mask );
5838 wxFAIL_MSG( _(
"invalid style for a2dPatternStrokeData" ) );
5841 #if wxART2D_USE_CVGIO
5845 if ( xmlparts == a2dXmlSer_attrib )
5849 if ( filename.IsEmpty() )
5851 wxLogError( _(
"CVG : bitmap file for a2dPatternStrokeData not specified or empty" ) );
5852 image = wxImage( 32, 32 );
5860 image = wxImage( 32, 32 );
5862 else if ( ! image.LoadFile(
m_filename, wxBITMAP_TYPE_BMP ) )
5864 wxLogError( _(
"CVG : Could not load bitmap %s for a2dPatternStrokeData" ),
m_filename.c_str() );
5865 image = wxImage( 32, 32 );
5868 m_stipple = wxBitmap( image );
5871 SetStyle( m_style );
5875 wxColour white( wxT(
"WHITE" ) );
5876 wxColour black( wxT(
"BLACK" ) );
5878 wxMask* monochrome_mask =
new wxMask( m_stipple, black );
5879 m_stipple.SetMask( monochrome_mask );
5890 if ( xmlparts == a2dXmlSer_attrib )
5896 if ( filename.IsEmpty() )
5900 wxString fileTosave;
5902 wxString* layerfile =
a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT(
"wxart2dlayers" ) );
5903 wxString* layerfiledir =
a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT(
"layerFileSavePath" ) );
5905 if ( layerfile && !layerfile->IsEmpty() )
5907 if ( !wxDirExists( *layerfiledir ) )
5908 wxMkdir( *layerfiledir );
5909 wxString mess = *layerfiledir + *layerfile + wxT(
" directory does not exist, and could not be created" );
5910 wxASSERT_MSG( wxDirExists( *layerfiledir ) , mess );
5912 fileTosave = *layerfiledir + wxFILE_SEP_PATH;
5921 fileTosave += wxFileNameFromPath(
m_filename );
5922 bool isOke = m_stipple.SaveFile( fileTosave, wxBITMAP_TYPE_BMP );
5924 wxLogError( _(
"Could not save bitmap %s for a2dPatternStrokeData" ), fileTosave.c_str() );
5925 out.WriteAttribute( wxT(
"filename" ), wxFileNameFromPath(
m_filename ) );
5928 out.WriteAttribute( wxT(
"filename" ), wxFileNameFromPath(
m_filename ) );
5933 #endif //wxART2D_USE_CVGIO
5991 : wxObject( Stroke )
6002 wxObject::UnShare();
6009 return a2dSTROKE_NULL;
6013 wxObjectRefData* a2dStroke::CreateRefData()
const
6018 wxObjectRefData* a2dStroke::CloneRefData(
const wxObjectRefData* data )
const
6022 case a2dSTROKE_NULL:
6036 void a2dStroke::SetStipple(
const wxBitmap& stipple )
6048 const wxBitmap& a2dStroke::GetStipple()
const
6052 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6057 return wxNullBitmap;
6061 void a2dStroke::SetAlpha( wxUint8 val )
6065 switch ( GetType() )
6067 case a2dSTROKE_NULL:
6072 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6074 newcol.Set( newcol.Red(), newcol.Green(), newcol.Blue(), val );
6080 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6082 newcol.Set( newcol.Red(), newcol.Green(), newcol.Blue(), val );
6091 wxUint8 a2dStroke::GetAlpha()
const
6093 switch ( GetType() )
6095 case a2dSTROKE_NULL:
6098 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6102 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6115 switch ( GetType() )
6117 case a2dSTROKE_NULL:
6133 switch ( GetType() )
6135 case a2dSTROKE_NULL:
6152 switch ( GetType() )
6154 case a2dSTROKE_NULL:
6158 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6161 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6172 switch ( GetType() )
6174 case a2dSTROKE_NULL:
6188 void a2dStroke::SetJoin( wxPenJoin join_style )
6191 switch ( GetType() )
6193 case a2dSTROKE_NULL:
6207 void a2dStroke::SetCap( wxPenCap cap_style )
6210 switch ( GetType() )
6212 case a2dSTROKE_NULL:
6226 wxPenCap a2dStroke::GetCap()
const
6228 switch ( GetType() )
6230 case a2dSTROKE_NULL:
6244 wxPenJoin a2dStroke::GetJoin()
const
6246 switch ( GetType() )
6248 case a2dSTROKE_NULL:
6259 return wxJOIN_ROUND;
6265 switch ( GetType() )
6267 case a2dSTROKE_NULL:
6283 switch ( GetType() )
6285 case a2dSTROKE_NULL:
6298 float a2dStroke::GetExtend()
const
6300 switch ( GetType() )
6302 case a2dSTROKE_NULL:
6319 switch ( GetType() )
6321 case a2dSTROKE_NULL:
6337 switch ( GetType() )
6339 case a2dSTROKE_NULL:
6355 switch ( GetType() )
6357 case a2dSTROKE_NULL:
6375 if ( cur_style == style )
6381 if ( type == GetType() )
6385 case a2dSTROKE_NULL:
6389 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6403 wxASSERT_MSG( m_refData, _T(
"No ref data" ) );
6415 case a2dSTROKE_NULL:
6420 newrefdata = onenewrefdata;
6421 onenewrefdata->SetColour(
GetColour() );
6423 onenewrefdata->SetJoin( GetJoin() );
6424 onenewrefdata->SetCap( GetCap() );
6439 newrefdata = patnewrefdata;
6440 patnewrefdata->SetColour(
GetColour() );
6442 patnewrefdata->SetJoin( GetJoin() );
6443 patnewrefdata->SetCap( GetCap() );
6452 m_refData = newrefdata;
6459 return a2dSTROKE_NULL;
6490 wxFAIL_MSG( _(
"invalid style for in a2dStroke" ) );
6492 return a2dSTROKE_NULL;
6496 #if wxART2D_USE_CVGIO
6504 if ( classname == wxT(
"a2dOneColourStroke" ) )
6506 else if ( classname == wxT(
"a2dPatternFill" ) )
6510 wxString stype = parser.
GetAttributeValue( wxT(
"type" ), wxT(
"a2dSTROKE_NULL" ) );
6511 if ( stype == wxT(
"a2dSTROKE_NULL" ) )
6512 type = a2dSTROKE_NULL;
6513 if ( stype == wxT(
"a2dSTROKE_ONE_COLOUR" ) )
6515 else if ( stype == wxT(
"a2dSTROKE_BITMAP" ) )
6521 case a2dSTROKE_NULL:
6535 ( (
a2dStrokeRefData* )GetRefData() )->DoLoad( parent, parser, a2dXmlSer_attrib );
6537 ( (
a2dStrokeRefData* )GetRefData() )->DoLoad( parent, parser, a2dXmlSer_Content );
6549 out.WriteAttribute( wxT(
"classname" ), GetClassInfo()->GetClassName() );
6551 switch ( GetType() )
6553 case a2dSTROKE_NULL:
6556 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dSTROKE_ONE_COLOUR" ) );
6559 out.WriteAttribute( wxT(
"type" ), wxT(
"a2dSTROKE_BITMAP" ) );
6565 ( (
a2dStrokeRefData* )GetRefData() )->DoSave( parent, out, a2dXmlSer_attrib, towrite );
6569 ( (
a2dStrokeRefData* )GetRefData() )->DoSave( parent, out, a2dXmlSer_Content, towrite );
6573 #endif //wxART2D_USE_CVGIO
6591 a2dExtStroke::a2dExtStroke()
6592 : m_Default(), m_Style(), m_Color(), m_Width(), m_Cap(), m_Join(), m_bStyle(false), m_bInitialised(false),
6593 m_bEditable(false), m_bColor(false), m_bWidth(false), m_bCap(false), m_bJoin(false)
6597 a2dExtStroke::a2dExtStroke(
const a2dStroke& stroke)
6598 : m_Default(), m_Style(), m_Color(), m_Width(), m_Cap(), m_Join(), m_bStyle(false), m_bInitialised(false),
6599 m_bEditable(false), m_bColor(false), m_bWidth(false), m_bCap(false), m_bJoin(false)
6605 void a2dExtStroke::Set(
const a2dStroke& stroke)
6607 m_Style = stroke.GetStyle();
6610 if(HasIndividualAttributes(stroke.GetStyle()))
6611 SetAttributes(stroke);
6614 void a2dExtStroke::SetAttributes(
const a2dStroke& stroke)
6618 m_Cap = stroke.GetCap();
6619 m_Join = stroke.GetJoin();
6621 m_bInitialised =
true;
6631 void a2dExtStroke::Mix(
const a2dStroke& stroke)
6633 if( m_bStyle && (stroke.GetStyle() != m_Style) ) m_bStyle =
false;
6635 if(!HasIndividualAttributes(stroke.GetStyle()))
6640 SetAttributes(stroke);
6644 if( m_bColor && (stroke.
GetColour() != m_Color) ) m_bColor =
false;
6645 if( m_bWidth && (stroke.
GetWidth() != m_Width) ) m_bWidth =
false;
6646 if( m_bCap && (stroke.GetCap() != m_Cap) ) m_bCap =
false;
6647 if( m_bJoin && (stroke.GetJoin() != m_Join) ) m_bJoin =
false;
6667 if(!HasIndividualAttributes(stroke.GetStyle()))
6675 if( m_bColor && (mixed.
GetColour() != m_Color) )
6677 if( m_bWidth && (mixed.
GetWidth() != m_Width) )
6679 if( m_bCap && (mixed.GetCap() != m_Cap) )
6680 mixed.SetCap(m_Cap);
6681 if( m_bJoin && (mixed.GetJoin() != m_Join) )
6682 mixed.SetJoin(m_Join);
6683 if( m_bStyle && (mixed.GetStyle() != m_Style) )
6684 mixed.SetStyle(m_Style);
6692 m_bEditable = HasIndividualAttributes(m_Style);
6695 void a2dExtStroke::SetColor(
const wxColour& color)
6701 void a2dExtStroke::SetWidth(
const float& width)
6707 void a2dExtStroke::SetCap(wxPenCap cap)
6713 void a2dExtStroke::SetJoin(wxPenJoin join)
6724 a2dExtFill::a2dExtFill()
6725 : m_Fill(), m_bFill(false)
6729 a2dExtFill::a2dExtFill(
const a2dFill& fill)
6730 : m_Fill(), m_bFill(false)
6736 void a2dExtFill::Set(
const a2dFill& fill)
6744 else m_bFill =
false;
6748 void a2dExtFill::Mix(
const a2dFill& fill)
6750 if(!m_bFill)
return;
6751 switch(m_Fill.GetStyle())
6768 a2dFill a2dExtFill::Get(
const a2dFill& fill)
const
6770 if(m_bFill)
return m_Fill;
wxString GetFilename(bool filenameonly=false) const
Get the font filename.
bool GetAttributeValueBool(const wxString &attrib, bool defaultv=false)
Returns the boolean value of an attribute.
wxEncodingConverter * m_converter
encoding converter
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
a2dStrokeGlyph * m_characters
Glyph storage.
a2dAffineMatrix & Mirror(bool y=true, bool x=false)
mirror a matrix in x, y
a2dFillStyle FillString2Style(const wxString &stylestr)
convert a string to a style enum
a2dOneColourStrokeData(void)
constructor
wxUint16 * m_width
Width storage.
a2dTwoColourFillData(void)
constructor
double GetSize() const
Get the font size.
A2DGENERALDLLEXP long wxGenNewId()
This function is like wxNewId, but it has its own ID set.
const a2dFill * a2dSELECT_FILL
global a2dFill stock object for drawing fill of selected objects
double GetStrokeWidth() const
Get stroke width.
Base class for all types of strokes, understood by a2dDrawer2D classes.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)=0
Load settings.
a2dPatternFillData()
constructor
void SetFont(const wxFont &font)
Set font format.
void SetDeviceHeight(double sizeInPixels)
to set for load glyph from face, to do proper hinting
const wxString & GetName() const
Get name of font, e.g. Arial.
a2dGlyph * m_a2dLastGlyph
Glyph cache one last character.
wxColour A2DGENERALDLLEXP HexToColour(const wxString &hex)
3-digit hex to wxColour
To set a two colour fill.
bool m_fillOn
if true filling is done, else transparent fill
a2dFont CreateFont(double size)
Create this enumerated font.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
wxColour GetColour() const
return colour
void SetWeight(double weight)
Set the weight of the font.
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
Stroke and fill base classes.
Font info class, used as a single element for enumerating fonts.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
wxString FindValidPath(const wxString &filename, bool reportError=true)
Find the first full path for which the file exists.
XMLeventType Next()
Walks to next element and returns event type.
bool GetPixelStroke() const
if the width is pixels or not.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
void SetColour(const wxColour &col)
set colour used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
a2dPoint2D GetStop() const
Get stop for gradient fill colour change.
const a2dFill * a2dINHERIT_FILL
global a2dFill stock object for INHERTED from parent object filling
void ParseString(wxString string)
Fill this class from a string.
a2dVertexList ** a2dStrokeGlyph
A list of pointers to vertexlists. Ends with NULL.
wxColour GetColour2() const
return colour 2
double m_height
Font height cache normalized to a font height of 1.
a2dFontDcData auxiliry class to aid in enumerating fonts.
void SetWidth(float width)
Set width of stroke in world coordinates.
a2dRadialGradientFillData(void)
constructor
const wxString & GetExtra() const
Get the extra information ( e.g. the filename of the font )
a2dPoint2D GetCenter()
Get start for gradient fill colour change.
void SetFilename(const wxString &filename)
Set the font filename and load the font.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)=0
Save settings.
void SetColour2(const wxColour &col)
set colour 2 used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
void SetPixelStroke(bool pixelstroke)
set pixelstoke flag, stroke width is defined in pixels else in worldcoordinates
const a2dFill * a2dBLACK_FILL
global a2dFill stock object for BLACK filling
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
wxFont & GetFont(void)
wxFont in case of a2dFONT_WXDC
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
double GetSize() const
Get size of the font.
void CBCurveTo(double x1, double y1, double x2, double y2, double x3, double y3, bool withStroke=true)
add a quadratic bezier segment to the path
wxString m_type
Font type.
a2dOneColourFillData(void)
constructor
wxString CreateString()
Create a string description of the font.
DcKerningHash m_kerningcache
Kerning cache normalized to a font height of 1.
~a2dPatternStrokeData(void)
destructor
wxChar m_lastChar
last character for glyph cache one character
double GetDescent() const
Get descent.
const a2dError a2dError_FileCouldNotOpen
bool operator==(const a2dFontInfo &other) const
Comparison operator.
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
double GetRadius() const
Get stop for gradient fill colour change.
Input and output handler for the XmlSer format.
bool GetPixelStroke() const
if the width is pixels or not.
wxString A2DGENERALDLLEXP ColourToHex(const wxColour &colour)
RGB to 3-digit hex.
double GetValue(int col, int row) const
get the value in the matrix at col,row
double GetKerning(wxChar c1, wxChar c2) const
Get kerning space between two characters.
wxUint32 GetStamp() const
time stamp gradient fill
a2dFont m_freetypefont
freetype equivalent of the font, used in AggDrawer.
const a2dFill * a2dWHITE_FILL
global a2dFill stock object for WHITE filling
a2dGlobal * a2dGlobals
global a2dCanvasGlobal to have easy access to global settings
const a2dGlyph * GetGlyph(wxChar c) const
Get the glyph of a single character.
void Close(bool withStroke=true)
Closing the path as a filled area.
void a2dCanvasInitializeStockObjects()
to initialize stock style ( a2dStroke a2dFill ) objects.
void SetCenter(double x, double y)
center end for gradient fill colour change
double m_sizeInPixels
current text drawn its size in pixels to do proper hinting.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
double GetKerning(wxChar c1, wxChar c2) const
Get kerning space between two characters.
wxFont & GetFont(void)
Get the font format.
wxColour GetColour() const
return colour 1
void SetSize(double size)
Set the font size.
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
a2dFontFreetypeData(const wxString &filename=wxT(""), double size=0.0, wxFontEncoding encoding=wxFONTENCODING_DEFAULT, int faceindex=0)
Constructor.
bool GetVpath(wxChar c, a2dVpath &glyph, const a2dAffineMatrix &affine=a2dIDENTITY_MATRIX)
Get the glyph of a single character as a vpath.
vector< a2dGlyph > a2dGlyphCache
Glyph Cache. This stores the 'normal' part of the alphabet.
vertex list of line and arc segments.
wxString FillStyle2String(a2dFillStyle style)
convert a style enum to a string
~a2dOneColourStrokeData(void)
destructor
a2dStrokeGlyph GetGlyphStroke(wxChar c) const
Get the glyph of a single character.
virtual ~a2dFontStrokeData()
Destructor.
wxColour GetColour2() const
return colour 2
#define NORMFONT
Normalization font size used for bigger size drawing of text.
a2dBoundingBox GetTextExtent(const wxString &string, int alignment=wxMINX|wxMINY, double *w=NULL, double *h=NULL, double *descent=NULL, double *externalLeading=NULL) const
Get the dimensions in world coordinates of the string.
FT_Face m_face
freetypelib face struct.
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
virtual ~a2dFill(void)
destructor
wxString GetFileName()
can contain the filename if pattern was read froma file
general vertexlist and array and vector path functions and classes.
double GetWeight() const
Get the weight of the font.
void SetStipple(const wxBitmap &stipple)
set stipple style
wxString GetFileName()
can contain the filename if pattern was read froma file
void Transform(const a2dAffineMatrix &world)
transform all segments with given matrix
double GetKerning(wxChar c1, wxChar c2) const
Get kerning space between two characters.
void SetStyle(const wxString &style)
Set style of font, e.g. Bold.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)=0
Save settings.
a2dFillRefData()
constructor
bool Ok() const
Check font validity.
Filling using a wxbitmap.
a2dFillStyle
Filling styles for a2dFill.
wxUint16 m_beginchar
First character in font.
void SetWidth(float width)
Set width of stroke in world coordinates.
a2dStrokeStyle StrokeString2Style(const wxString &stylestr)
convert a string to a style enum
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
double GetWidth(wxChar c)
Get width of a single character.
void GetTextExtentWH(const wxString &string, double &w, double &h) const
Get the dimensions in world coordinates of the string.
const wxString & GetType() const
Get type of font, e.g. Freetype or Stroke.
const a2dBoundingBox & Translate(a2dPoint2D &)
translate with given vector
double GetMinX() const
get minimum X of the boundingbox
a2dPathList & GetFontPathList()
Path for Fonts.
void SetStart(double x, double y)
start for gradient fill colour change
a2dFont GetFreetypeFont()
Get the freetype equivalent of the font.
double GetLineHeight() const
Get the line height.
a2dStrokeGlyph GetGlyph(wxChar c) const
Get the glyph of a single character.
void SetColour(const wxColour &col)
set colour used for gradient and wxSTROKE_MASK_OPAQUE filling.
wxColour m_colour1
used for gradient fill or text background or opaque filling
A hash map, used for storage of kerning between characters of a font.
static void GetInfoList(a2dFontInfoList &list)
Append fonts of this type to the list.
static void SetLoadFlags(wxInt32 loadMethodMask)
const a2dFont * a2dNullFONT
global a2dFont stock object for NO font
virtual ~a2dFont()
Destructor.
static void SetLoadFlags(wxInt32 loadMethodMask)
a2dFontStrokeData(const wxString &filename=wxT(""), double size=0.0, bool monoSpaced=false, double weight=0.0)
Constructor.
void SetWeight(double weight)
Set the weight of the font.
wxPenCap m_cap
Sets the pen cap style, which may be one of wxCAP_ROUND (default), wxCAP_PROJECTING and wxCAP_BUTT...
a2dPoint2D GetStart()
Get start for gradient fill colour change.
wxString m_extra
Extra information (e.g. the filename of the font).
Filling using a wxbitmap.
const a2dError a2dError_XMLparse
a2dPoint2D GetStart() const
Get start for gradient fill colour change.
bounding class for optimizing drawing speed.
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
a2dPoint2D GetCenter() const
Get start for gradient fill colour change.
Drawing context abstraction.
a2dFillStyle m_style
style of Fill
a2dFontDcData(const wxFont &font=wxNullFont, double size=0.0)
Constructor.
Normal straight line segment in a2dVertexList and a2dVertexArray.
static a2dFont CreateFont(const a2dFontInfo &info, bool force=false)
Create the font from a fontinfo description.
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
a2dFontInfo m_fontinfo
Font info.
bool m_ok
True if a valid font is set.
void SetRadius(double radius)
radius for gradient fill colour change
void Add(a2dVpathSegment *seg)
add a segment
wxString GetFilename(bool filenameonly=false) const
Get the font filename.
virtual ~a2dFontDcData()
Destructor.
void SetColour(const wxColour &col)
set colour used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
wxColour GetColour() const
return colour
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
double GetStrokeWidth() const
Get stroke width.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
const a2dStroke * a2dINHERIT_STROKE
global a2dStroke stock object for INHERTED from parent object stroking
Input and output handler for the XmlSer format.
~a2dLinearGradientFillData(void)
destructor
Internal to a2dStroke for refcounting in wxObject style.
a2dPoint2D GetFocal() const
Get start for gradient fill colour change.
void QBCurveTo(double x1, double y1, double x2, double y2, bool withStroke=true)
add a quadratic bezier segment to the path
const a2dFill * a2dNullFILL
global a2dFill stock object for defining NO filling
wxString GetFilename(bool filenameonly=false) const
Get the font filename.
double m_lead
Font external leading normalized to a font height of 1.
A hash map, used for storage of character widths of a font.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
void WriteEndAttributes(bool close=false)
"Closes" the start tag after writing all attributes (writes the ">" or "/>" bracket).
a2dPathList & GetImagePathList()
Path for Images.
a2dFontInfo & operator=(const a2dFontInfo &other)
Assignment operator.
double m_xfc
relative start and focal point x
~a2dPatternFillData(void)
destructor
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
double GetRadius()
Get stop for gradient fill colour change.
a2dStrokeRefData()
constructor
A 2x3 affine matrix class for 2D transformations.
wxString m_name
Font name.
double GetAttributeValueDouble(const wxString &attrib, double defaultv=0)
Returns the double value of an attribute.
wxPenJoin m_join
Sets the pen join style, which may be one of wxJOIN_BEVEL, wxJOIN_ROUND (default) and wxJOIN_MITER...
const a2dStroke * a2dNullSTROKE
global a2dStroke stock object for NO stroking
virtual ~a2dFontFreetypeData()
Destructor.
bool GetFilling() const
if true, filling is on else filling is transparent.
void SetName(const wxString &name)
Set name of font, e.g. Arial.
void SetStipple(const wxBitmap &stipple)
set stipple style
const a2dStroke * a2dWHITE_STROKE
global a2dStroke stock object for WHITE stroking
void SetFilename(const wxString &filename)
Set the font filename and load the font.
Contains graphical drawing context specific classes. a2dDrawer2D and derived classes are used for dra...
holes one glyph from a freetype font.
void SetExtra(const wxString &extra)
Set the extra information ( e.g. the filename of the font )
void SetColour2(const wxColour &col)
set colour 2 used for gradient and wxSTROKE_MASK_OPAQUE filling.
long m_faceindex
what font with index to load from file
virtual ~a2dStroke(void)
destructor
double * m_widthcache
Width cache normalized to a font height of 1. This stores the 'normal' part of the alphabet...
double GetWidth(wxChar c) const
Get width of a single character.
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
general modules header files all together.
wxUint16 m_intsize
Font size in internal coordinates.
a2dPoint2D GetStop()
Get stop for gradient fill colour change.
void SetDeviceHeight(double sizeInPixels)
to set for load glyph from face, to do proper hinting
double GetWidth(wxChar c) const
Get width of a single character.
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
wxString FindFileName() const
Find the filename of the current font.
virtual double GetKerning(wxChar c1, wxChar c2) const
Get kerning space between two characters.
a2dFontInfo()
Constructor.
double m_desc
Font descender cache normalized to a font height of 1.
wxString StrokeStyle2String(a2dStrokeStyle style)
convert a style enum to a string
a2dFillType
for a2dFill to define the type of filling.
wxString m_style
Font style.
const wxString & GetStyle() const
Get style of font, e.g. Bold.
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
~a2dTwoColourFillData(void)
destructor
void MoveTo(double x, double y)
add a MoveTo command to the path
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
double GetWidth(wxChar c) const
Get width of a single character.
double m_weight
Font weight.
a2dStroke(void)
constructor
double m_yfc
relative start and focal point y
wxColour GetColour() const
return colour
a2dLinearGradientFillData(void)
constructor
bool Scale(double scale)
Scale by scale (isotropic scaling i.e. the same in x and y):
bool Translate(double x, double y)
Translate by dx, dy:
double GetKerning(wxChar c1, wxChar c2) const
Get kerning space between two characters.
void LineTo(double x, double y, bool withStroke=true)
add a LineTo command to the path
const a2dStroke * a2dTRANSPARENT_STROKE
global a2dStroke stock object for TRANSPARENT stroking
a2dPatternStrokeData()
constructor
a2dPoint2D GetFocal()
Get start for gradient fill colour change.
~a2dRadialGradientFillData(void)
destructor
a2dHatchFillData(void)
constructor
wxString CreateString() const
Assemble a string containing this class in a readable format.
double m_ye
relative y as end for gradient fill
wxString m_filename
Filename of the font.
A list used for enumerating fonts.
initiates Freetype library
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
void SetFilename(const wxString &filename)
Set the font filename and load the font.
void SetType(const wxString &type)
Set type of font, e.g. Freetype or Stroke.
double GetMinY() const
get minimum Y of the boundingbox
DcWidthHash m_extwidthcache
Width cache normalized to a font height of 1. This stores the extended characters.
BOOL GetFontFile(LPCTSTR lpszFontName, LPTSTR lpszDisplayName, int nDisplayNameSize, LPTSTR lpszFontFile, int nFontFileSize)
find a font that is close to a wxDC font.
wxString GetAsString()
Get all search paths as one string.
void SetFilling(bool OnOff)
wxColour m_colour2
used for gradient fill or text background or opaque filling
wxUint16 m_count
Number of characters in font.
void SetFocal(double x, double y)
focal point, startpoint for gradient fill
initializes the general module
const a2dFontInfo & GetFontInfo() const
Get fontinfo of the font.
bool m_pixelstroke
set if stroke is in pixels
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
~a2dOneColourFillData(void)
destructor
float m_width
width of stroke in world coordinates
a2dFillStyle m_style
style of Fill
a2dStrokeStyle
stroke styles for a2dStroke
virtual float GetWidth() const
double m_xe
relative x as end for gradient fill
Internal to a2dFill for refcounting in wxObject style.
wxString m_filename
Filename of the vector font.
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)=0
Load settings.
void a2dCanvasDeleteStockObjects()
to delete stock style ( a2dStroke a2dFill ) objects.
wxColour GetColour() const
return colour
void SetColour2(const wxColour &col)
set colour 2 used for gradient and wxSTIPPLE_MASK_OPAQUE filling.
double m_sizeInPixels
current text drawn its size in pixels to do proper hinting.
wxColour GetColour2() const
return colour 2
a2dGlyphHash m_extglyphcache
Glyph cache. This stores the extended characters.
virtual double GetWidth(wxChar c) const =0
Get width of a single character.
const a2dStroke * a2dLAYER_SELECT_STROKE
global a2dStroke stock object for SELECTED object stroking
void SetPixelStroke(bool pixelstroke)
set pixelstoke flag, stroke width is defined in pixels else in worldcoordinates
void SetStop(double x, double y)
stop for gradient fill colour change
a2dFontRefData()
constructor
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
~a2dHatchFillData(void)
destructor
wxFontEncoding m_encoding
encoding setting
double GetWeight() const
Get the weight of the font.