21 #include <wx/clipbrd.h>
35 if ( alignment & wxMINX )
36 alignstring += wxT(
"wxMINX|" );
37 if ( alignment & wxMAXY )
38 alignstring += wxT(
"wxMAXY|" );
39 if ( alignment & wxMAXX )
40 alignstring += wxT(
"wxMAXX|" );
41 if ( alignment & wxMINY )
42 alignstring += wxT(
"wxMINY|" );
43 if ( alignment & wxMIDX )
44 alignstring += wxT(
"wxMIDX|" );
45 if ( alignment & wxMIDY )
46 alignstring += wxT(
"wxMIDY|" );
47 if ( alignment & wxBASELINE )
48 alignstring += wxT(
"wxBASELINE|" );
49 if ( alignment & wxBASELINE_CONTRA )
50 alignstring += wxT(
"wxBASELINE_CONTRA|" );
51 if ( alignstring.Last() == wxChar(
'|' ) )
52 alignstring.RemoveLast();
61 if ( alignstring.Find( wxT(
"wxMINX" ) ) != -1 )
63 if ( alignstring.Find( wxT(
"wxMAXX" ) ) != -1 )
65 if ( alignstring.Find( wxT(
"wxMINY" ) ) != -1 )
67 if ( alignstring.Find( wxT(
"wxMAXY" ) ) != -1 )
69 if ( alignstring.Find( wxT(
"wxMIDX" ) ) != -1 )
71 if ( alignstring.Find( wxT(
"wxMIDY" ) ) != -1 )
73 if ( alignstring.Find( wxT(
"wxBASELINE_CONTRA" ) ) != -1 )
74 alignment |= wxBASELINE_CONTRA;
75 else if ( alignstring.Find( wxT(
"wxBASELINE" ) ) != -1 )
76 alignment |= wxBASELINE;
85 #define DRAGRECTWIDTH 5
95 static_cast < a2dPropertyIdFont::ConstGet >( &a2dText::MX_GetFont ),
96 static_cast < a2dPropertyIdFont::ConstSet >( &a2dText::MX_SetFont ) );
97 AddPropertyId( PROPID_Font );
100 AddPropertyId( PROPID_PreEditText );
115 m_alignment = a2dDEFAULT_ALIGNMENT;
116 m_linespace = 1.0 / 10.0;
118 m_selection_start_pos = m_selection_end_pos = 0;
120 m_textflags = a2dCANVASTEXT_DEFAULTFLAGS;
121 m_utbbox_changed =
true;
126 const a2dFont& font,
double angle,
bool up,
int alignment )
151 m_wrongLoad = other.m_wrongLoad;
152 m_fontinfo = other.m_fontinfo;
171 return new a2dText( *
this, options, refs );
180 snappathlist->push_back( snappath );
195 ( snapToWhat & a2dRestrictionEngine::snapToPinsUnconnected && !pin->
IsConnectedTo() )
199 segments->
Add( seg );
205 if ( snapToWhat & a2dRestrictionEngine::snapToObjectPos )
208 segments->
Add( seg );
260 size_t lineend = ( size_t ) 0;
261 size_t textlength =
m_text.Length();
264 while ( lineend < textlength )
267 while ( lineend < textlength &&
m_text[lineend] != wxChar(
'\n' ) )
269 linetext =
m_text.Mid( linestart, lineend - linestart );
277 canpath->
SetFill( this->GetFill() );
279 if (
m_font.GetType() == a2dFONT_STROKED )
284 canpathlist->push_back( canpath );
300 while ( i <
m_text.Length() )
312 if ( !line.IsEmpty() )
332 while ( i <
m_text.Length() )
348 while ( i <
m_text.Length() && newlines < n )
354 if ( i <
m_text.Length() )
398 wxString a2dText::GetSelectedText()
const
403 void a2dText::InsertTextAtCarret(
const wxString& text )
405 size_t textlength =
m_text.Length();
445 size_t lineend = ( size_t ) 0;
446 size_t textlength =
m_text.Length();
449 while ( lineend <= textlength )
452 while ( lineend < textlength &&
m_text[lineend] != wxChar(
'\n' ) )
454 text =
m_text.Mid( linestart, lineend - linestart );
462 if ( !text.IsEmpty() )
465 double kerning = 0.0;
466 oldx = newx = linebbox.
GetMinX();
468 for(
size_t i = 0; i < text.Length(); i++ )
473 newx += kerning / 2.0;
475 if ( ( oldx + newx ) / 2.0 > xh )
484 newx += kerning / 2.0;
535 #if wxART2D_USE_CVGIO
540 if ( xmlparts == a2dXmlSer_attrib )
544 m_text.Replace( wxT(
"\\n" ), wxT(
"\n" ) );
571 if ( xmlparts == a2dXmlSer_attrib )
573 out.WriteAttribute( wxT(
"linespace" ),
m_linespace );
577 str.Replace( wxT(
"\n" ), wxT(
"\\n" ) );
578 out.WriteAttributeEnt( wxT(
"text" ), str );
580 out.WriteAttribute( wxT(
"textflags" ),
m_textflags );
582 out.WriteAttribute( wxT(
"font" ), m_fontinfo.
CreateString() );
589 out.WriteAttribute( wxT(
"alignment" ), alignstring );
595 #endif //wxART2D_USE_CVGIO
607 hitEvent.
m_how = HitTestRectangle( hitEvent.
m_relx, hitEvent.
m_rely, xmin, ymin, xmax, ymax, pw + margin );
616 #define SIN100 0.9848077530
617 #define COS100 -0.1736481776
626 eng_affine.
Mirror(
true,
false );
628 mod_affine *= eng_affine;
634 if ( ic.
GetDrawer2D()->
GetYaxis() && ( mod_affine( 0, 0 ) * SIN100 < mod_affine( 0, 1 ) * COS100 )
635 || !ic.
GetDrawer2D()->
GetYaxis() && ( mod_affine( 0, 0 ) * SIN100 < -mod_affine( 0, 1 ) * COS100 ) )
645 #define BBOX2XYWH(bbox) (bbox).GetMinX(), (bbox).GetMinY(), (bbox).GetWidth(), (bbox).GetHeight()
680 size_t lineend = ( size_t ) 0;
681 size_t textlength =
m_text.Length();
684 while ( lineend < textlength )
687 while ( lineend < textlength &&
m_text[lineend] != wxChar(
'\n' ) )
689 linetext =
m_text.Mid( linestart, lineend - linestart );
705 wxColour col = currentstroke.
GetColour();
706 if ( col.Red() + col.Green() + col.Blue() > 3 * 192 )
722 wxString left, sel, right;
739 wxColour col = currentstroke.
GetColour();
740 if ( col.Red() + col.Green() + col.Blue() > 3 * 192 )
744 if ( !left.IsEmpty() && ! sel.IsEmpty() )
754 if ( !sel.IsEmpty() && !right.IsEmpty() )
802 strokearound.
SetWidth( DRAGRECTWIDTH );
830 if (
m_text.Length() == 0 )
840 size_t lineend = ( size_t ) 0;
841 size_t textlength =
m_text.Length();
844 while ( lineend <= textlength )
847 while ( lineend < textlength &&
m_text[lineend] != wxChar(
'\n' ) )
853 text =
m_text.Mid( linestart, lineend - linestart );
860 if (
m_caret - linestart > 1 && (
size_t ) (
m_caret - linestart ) <= text.Length() )
863 text[(
size_t ) (
m_caret - linestart - 1 )] ) / 2;
877 if (
m_text.Length() == 0 )
904 if (
m_text.Length() == 0 )
914 size_t lineend = ( size_t ) 0;
915 size_t textlength =
m_text.Length();
918 while ( lineend <= textlength )
921 while ( lineend < textlength &&
m_text[lineend] != wxChar(
'\n' ) )
923 text =
m_text.Mid( linestart, lineend - linestart );
962 if (
m_font.GetType() != a2dFONT_WXDC )
995 rotline =
new a2dSLine( 0, 0, -w / 4, 0 );
997 rotline =
new a2dSLine( 0, 0, w / 4, 0 );
1006 Append( handle =
new a2dHandle(
this, -w / 4, 0, wxT(
"__text_rotate__" ) ) );
1008 Append( handle =
new a2dHandle(
this, w / 4, 0, wxT(
"__text_rotate__" ) ) );
1039 void a2dText::OnChar( wxKeyEvent& event )
1045 bool extend_selection;
1047 bool changed =
true;
1050 extend_selection =
event.ShiftDown();
1051 extend_start = FALSE;
1053 if ( extend_selection )
1063 size_t textlength =
m_text.Length();
1064 switch ( event.GetKeyCode() )
1067 if( event.ControlDown() )
1078 if( event.ControlDown() )
1106 if( event.ControlDown() )
1124 if( event.ControlDown() )
1143 extend_selection = FALSE;
1148 else if( event.ControlDown() )
1183 if( event.ShiftDown() )
1186 extend_selection =
false;
1188 if ( wxTheClipboard->Open() )
1190 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) )
1192 wxTextDataObject data;
1193 wxTheClipboard->GetData( data );
1196 m_caret += data.GetText().Length();
1199 wxTheClipboard->Close();
1202 else if( event.ControlDown() )
1208 if ( wxTheClipboard->Open() )
1211 wxTheClipboard->Close();
1225 extend_selection = FALSE;
1226 if( event.ShiftDown() )
1229 if ( wxTheClipboard->Open() )
1232 wxTheClipboard->Close();
1240 else if( event.ControlDown() )
1254 else if (
m_caret < textlength )
1269 if ( ( *editmode ) > 1 ) ( *editmode ) = 0;
1292 if( event.ControlDown() )
1294 switch( event.GetKeyCode() )
1311 if ( wxTheClipboard->Open() )
1314 wxTheClipboard->Close();
1323 extend_selection = FALSE;
1328 else if (
m_caret < textlength )
1349 extend_selection = FALSE;
1366 extend_selection = FALSE;
1402 extend_selection = FALSE;
1423 extend_selection =
false;
1425 if ( wxTheClipboard->Open() )
1427 if ( wxTheClipboard->IsSupported( wxDF_TEXT ) )
1429 wxTextDataObject data;
1430 wxTheClipboard->GetData( data );
1433 m_caret += data.GetText().Length();
1436 wxTheClipboard->Close();
1443 extend_selection = FALSE;
1464 extend_selection = FALSE;
1467 if ( wxTheClipboard->Open() )
1470 wxTheClipboard->Close();
1514 if( event.AltDown() )
1516 switch( event.GetKeyCode() )
1530 extend_selection = FALSE;
1531 if( event.ShiftDown() )
1534 if ( wxTheClipboard->Open() )
1537 wxTheClipboard->Close();
1576 extend_selection =
false;
1582 textlength =
m_text.Length();
1584 wxChar h =
event.GetKeyCode();
1591 if ( changed && (
m_caret != initial_pos ) )
1593 if ( extend_selection )
1627 static bool busydrag =
false;
1632 wxMouseEvent mouseevent =
event.GetMouseEvent();
1639 if ( mouseevent.LeftDown() )
1644 if (
GetBbox().PointOnBox( xw, yw, dragwidthworld ) )
1649 else if ( !mouseevent.ControlDown() )
1669 if (
GetBbox().PointOnBox( xw, yw, dragwidthworld ) )
1676 if ( mouseevent.Dragging() )
1680 else if ( mouseevent.LeftIsDown() && !mouseevent.ControlDown() )
1706 if ( mouseevent.LeftUp() && busydrag )
1724 a2dHandle* draghandle =
event.GetCanvasHandle();
1729 if ( editmode == 0 &&
m_font.GetType() == a2dFONT_WXDC )
1746 double xmin, ymin, xmax, ymax, w, h;
1747 xmin = untrans.GetMinX();
1748 ymin = untrans.GetMinY();
1749 xmax = untrans.GetMaxX();
1750 ymax = untrans.GetMaxY();
1751 w = untrans.GetWidth();
1752 h = untrans.GetHeight();
1759 if ( draghandle->
GetName() == wxT(
"__text_fontsize__" ) )
1767 if ( draghandle->
GetName() == wxT(
"__text_fontsize__" ) )
1773 else if ( draghandle->
GetName() == wxT(
"__text_rotate__" ) )
1776 restrict->
RestrictPoint( xw, yw, a2dRestrictionEngine::snapToPointAngle );
1817 if (
GetGeneratePins() && ( toCreate = toConnectTo->GetPinClassForTask( task,
this ) ) )
1874 if ( ( pin =
HasPinNamed( wxT(
"pinc*" ),
false ) ) != NULL )
1876 if ( ( pin =
HasPinNamed( wxT(
"pin1" ),
false ) ) != NULL )
1878 if ( ( pin =
HasPinNamed( wxT(
"pin2" ),
false ) ) != NULL )
1880 if ( ( pin =
HasPinNamed( wxT(
"pin3" ),
false ) ) != NULL )
1882 if ( ( pin =
HasPinNamed( wxT(
"pin4" ),
false ) ) != NULL )
1884 if ( ( pin =
HasPinNamed( wxT(
"pin5" ),
false ) ) != NULL )
1886 if ( ( pin =
HasPinNamed( wxT(
"pin6" ),
false ) ) != NULL )
1888 if ( ( pin =
HasPinNamed( wxT(
"pin7" ),
false ) ) != NULL )
1890 if ( ( pin =
HasPinNamed( wxT(
"pin8" ),
false ) ) != NULL )
1908 m_presentationflags.total = presentation;
1909 SetHorizontal( m_presentationflags.bits.m_horizontal );
1910 SetVertical( m_presentationflags.bits.m_vertical );
1912 m_fontType = fontType;
1913 if ( m_fontType == a2dFONT_STROKED )
1917 switch( m_presentationflags.bits.m_font )
1920 case 0 : weight = 2;
1922 case 1 : weight = 4;
1924 case 2 : weight = 8;
1926 case 3 : weight = 12;
1931 if ( m_fontType == a2dFONT_WXDC )
1933 int FontFamily = wxMODERN;
1934 switch( m_presentationflags.bits.m_font )
1936 case 0 : FontFamily = wxDEFAULT;
break;
1937 case 1 : FontFamily = wxROMAN;
break;
1938 case 2 : FontFamily = wxSWISS;
break;
1939 case 3 : FontFamily = wxDECORATIVE;
break;
1940 default: FontFamily = wxMODERN;
break;
1951 m_pathtype = TEXT_PATH_END_SQAURE;
1953 m_monoSpaced =
true;
1954 SetBackGround(
false );
1958 :
a2dText( other, options, refs )
1962 m_pathtype = other.m_pathtype;
1963 m_monoSpaced = other.m_monoSpaced;
1964 m_width = other.m_width;
1969 return new a2dTextGDS( *
this, options, refs );
1972 void a2dTextGDS::SetFontGDS(
char nw_font )
1975 if ( m_fontType == a2dFONT_STROKED )
1994 if ( m_fontType == a2dFONT_WXDC )
1996 int FontFamily = wxMODERN;
1999 case 0 : FontFamily = wxDEFAULT;
break;
2000 case 1 : FontFamily = wxROMAN;
break;
2001 case 2 : FontFamily = wxSWISS;
break;
2002 case 3 : FontFamily = wxDECORATIVE;
break;
2003 default: FontFamily = wxMODERN;
break;
2010 void a2dTextGDS::SetVertical(
char nw_vertical )
2029 void a2dTextGDS::SetHorizontal(
char nw_horizontal )
2048 short int a2dTextGDS::GetFontGDS()
2054 short int a2dTextGDS::GetVertical()
2060 short int a2dTextGDS::GetHorizontal()
2065 void a2dTextGDS::SetPresentationFlags(
short int the_total )
2073 short int a2dTextGDS::GetPresentationFlags( )
2078 #if wxART2D_USE_CVGIO
2083 if ( xmlparts == a2dXmlSer_attrib )
2100 if ( xmlparts == a2dXmlSer_attrib )
2102 out.WriteAttribute( wxT(
"texttype" ),
m_texttype );
2103 out.WriteAttribute( wxT(
"pathtype" ), m_pathtype );
2104 if ( GetPresentationFlags() )
2107 if ( GetHorizontal() != DEFAULT_PRESENTATION_HORIZONTAL )
2109 out.WriteAttribute( wxT(
"horizontal" ), GetHorizontal() );
2112 if ( GetVertical() != DEFAULT_PRESENTATION_VERTICAL )
2114 out.WriteAttribute( wxT(
"vertical" ), GetVertical() );
2117 if ( GetFontGDS() != DEFAULT_PRESENTATION_FONT )
2119 out.WriteAttribute( wxT(
"fontgds" ), GetFontGDS() );
2128 #endif //wxART2D_USE_CVGIO
2139 a2dTextChanges::a2dTextChanges()
2146 m_textflags(
a2dText::a2dCANVASTEXT_DEFAULTFLAGS ),
2147 m_btextflags( false ),
2148 m_alignment( a2dDEFAULT_ALIGNMENT ),
2149 m_balignment( false )
2151 m_alreadyusedfonts.Clear();
2154 a2dTextChanges::a2dTextChanges(
const a2dFont& font,
unsigned int textflags,
int alignment )
2156 Set( font, textflags, alignment );
2161 void a2dTextChanges::InitialiseFontList(
const wxArrayString &filterlist,
const wxString filtertype)
2163 if(m_fontlist.GetCount()==0)
2165 m_fontlist.DeleteContents(
true );
2169 if( filterlist.GetCount() > 0 && filtertype != wxT(
"" ) )
2172 for (
size_t i = 0; i < m_fontlist.GetCount(); i++ )
2174 wxString fontname = m_fontlist.Item( i )->GetData()->GetName();
2175 wxString fonttype = m_fontlist.Item( i )->GetData()->GetType();
2177 for(
int u = 0; u < filterlist.GetCount(); u++)
2179 if ( ( fonttype == filtertype ) && fontname == filterlist[u] )
2181 reduced_list.Append(
new a2dFontInfo( *m_fontlist.Item( i )->GetData() ) );
2186 m_fontlist.insert( m_fontlist.end(), reduced_list.begin(), reduced_list.end() );
2192 void a2dTextChanges::Set(
const a2dFont& font,
unsigned int textflags,
int alignment,
bool wrongloadflag )
2200 m_textflags = textflags;
2201 m_btextflags =
true;
2202 m_alignment = alignment;
2203 m_balignment =
true;
2205 if( wrongloadflag ==
false )
2207 m_commonstyle.Clear();
2210 for (
size_t i = 0; i < m_fontlist.GetCount(); i++ )
2212 wxString fontname = m_fontlist.Item( i )->GetData()->GetName();
2213 wxString fonttype = m_fontlist.Item( i )->GetData()->GetType();
2217 wxString fontstyle = m_fontlist.Item( i )->GetData()->GetStyle();
2219 for ( j = 0; j < m_commonstyle.GetCount(); j++ )
2221 if ( m_commonstyle.Item( j ) == fontstyle )
2224 if ( j == m_commonstyle.GetCount() )
2225 m_commonstyle.Add( fontstyle );
2232 void a2dTextChanges::Mix(
const a2dFont& font,
unsigned int textflags,
int alignment )
2240 wxArrayString fonts1;
2243 for (
size_t i = 0; i < m_alreadyusedfonts.GetCount(); i++ )
2245 wxString fontname = m_alreadyusedfonts.Item( i )->GetData()->GetName();
2246 wxString fonttype = m_alreadyusedfonts.Item( i )->GetData()->GetType();
2250 wxString fontstyle = m_alreadyusedfonts.Item( i )->GetData()->GetStyle();
2252 for ( j = 0; j < fonts1.GetCount(); j++ )
2254 if ( fonts1.Item( j ) == fontstyle )
2257 if ( j == fonts1.GetCount() )
2258 fonts1.Add( fontstyle );
2262 if( fonts1.GetCount() == 0 )
2264 for (
size_t i = 0; i < m_fontlist.GetCount(); i++ )
2266 wxString fontname = m_fontlist.Item( i )->GetData()->GetName();
2267 wxString fonttype = m_fontlist.Item( i )->GetData()->GetType();
2271 wxString fontstyle = m_fontlist.Item( i )->GetData()->GetStyle();
2273 for ( j = 0; j < fonts1.GetCount(); j++ )
2275 if ( fonts1.Item( j ) == fontstyle )
2278 if ( j == fonts1.GetCount() )
2280 fonts1.Add( fontstyle );
2281 m_alreadyusedfonts.push_back( m_fontlist.Item( i )->GetData() );
2286 wxArrayString commonstyle_temp;
2287 for(
int i = 0; i < fonts1.GetCount(); i++ )
2289 for(
int u = 0; u < m_commonstyle.GetCount(); u++ )
2291 if( fonts1[i] == m_commonstyle[u])
2293 commonstyle_temp.Add(fonts1[i]);
2298 m_commonstyle=commonstyle_temp;
2305 if( m_balignment && (m_alignment != alignment) ) m_balignment =
false;
2306 if( m_btextflags && (m_textflags != textflags) ) m_btextflags =
false;
2309 a2dFont a2dTextChanges::GetFont(
const a2dFont& font, wxArrayString valid_styles, wxArrayString valid_extras )
const
2314 wxString valid_style=
"", valid_extra;
2326 for(
int i = 0; i < valid_styles.GetCount() ; i++ )
2328 if( ( valid_style ==
"" && valid_styles[i] == wxT(
"Regular" ) ) || fontinfo.
GetStyle() == valid_styles[i] )
2330 valid_style = valid_styles[i];
2331 valid_extra = valid_extras[i];
2348 for (
size_t i = 0; i < m_alreadyusedfonts.GetCount(); i++ )
2350 wxString fonttype = m_alreadyusedfonts.Item( i )->GetData()->GetType();
2351 wxString fontname = m_alreadyusedfonts.Item( i )->GetData()->GetName();
2352 wxString fontstyle = m_alreadyusedfonts.Item( i )->GetData()->GetStyle();
2354 if ( ( fonttype == fontinfo.
GetType() || fontinfo.
GetType() == _(
"* (All types)" ) )
2357 fontinfo.
SetExtra( m_alreadyusedfonts.Item( i )->GetData()->GetExtra() );
2364 for (
size_t i = 0; i < m_fontlist.GetCount(); i++ )
2366 wxString fonttype = m_fontlist.Item( i )->GetData()->GetType();
2367 wxString fontname = m_fontlist.Item( i )->GetData()->GetName();
2368 wxString fontstyle = m_fontlist.Item( i )->GetData()->GetStyle();
2370 if ( ( fonttype == fontinfo.
GetType() || fontinfo.
GetType() == _(
"* (All types)" ) )
2373 fontinfo.
SetExtra( m_fontlist.Item( i )->GetData()->GetExtra() );
2374 m_alreadyusedfonts.push_back( m_fontlist.Item( i )->GetData() );
2392 if(m_balignment)
return m_alignment;
2398 if(m_btextflags)
return m_textflags;
2414 obj->SetBin2(
true );
a2dHit m_how
return in which way the object was hit (stroke, fill, ...)
void PushCursor(const wxCursor &cursor)
push a cursor on the cursor stack, and set display cursor to new back being cursor.
bool DoUpdate(UpdateMode mode, const a2dBoundingBox &childbox, const a2dBoundingBox &clipbox, const a2dBoundingBox &propbox)
Update derived Object specific things ( mainly boundingbox)
perform snapping to boundingbox of objects
int GetAlignment() const
Get the position of the anchor point w.r.t the text.
double m_relx
(world coordinates) hit point x relative to the canvas object its parent object(s) ...
a2dAffineMatrix & Mirror(bool y=true, bool x=false)
mirror a matrix in x, y
double GetHeight() const
returns height of the boundingbox
a2dText derived from a2dCanvasObject, holds multiline text
virtual void Render(a2dIterC &ic, OVERLAP clipparent)
Render this object to the active a2dDrawingPart.
double GetAbsY() const
get absolute Y position of the pin ( after applying the parent's matrix and its own matrix ) ...
double GetSize() const
Get the font size.
bool SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which, const wxString &classname=wxT(""), a2dCanvasObjectFlagsMask whichobjects=a2dCanvasOFlags::ALL, const a2dBoundingBox &bbox=wxNonValidBbox, const a2dAffineMatrix &tworld=a2dIDENTITY_MATRIX)
set all given bit flags at once recursive for all objects in given boundingbox
double GetStrokeWidth() const
Get stroke width.
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Base class for all types of strokes, understood by a2dDrawer2D classes.
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
bool GetGeneratePins() const
get the GeneratePins flag
wxString TextAlignment2String(int alignment)
convert alignment enum to a string
const wxString & GetName() const
Get name of font, e.g. Arial.
a2dHandle is used inside editing versions of a certain objects.
mouse event sent from a2dCanvasObject to itself
Text is always readible from the bottom right.
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
void SetAlignment(int alignment)
Set the position of the anchor point w.r.t the text.
void SetDrawStyle(a2dDrawStyle drawstyle)
set drawstyle to use for drawing,
const a2dStroke * a2dBLACK_STROKE
global a2dStroke stock object for BLACK stroking
Font info class, used as a single element for enumerating fonts.
virtual void PopTransform(void)
Recall the previously saved user-to-world transform off the matrix stack.
a2dTextGDS text based on wxDC text drawing.
disable background drawing
void ParseString(wxString string)
Fill this class from a string.
class to map references to objects stored in XML, in order to make the connection later on...
a2dDrawing * m_root
root group for rendering and accessing the canvas's also contains layer settings
int m_alignment
Alignment.
next line is higher in Y if set
a2dPropertyIdTyped< wxString, a2dStringProperty > a2dPropertyIdString
property of this type
transfer this property via a command processor
a2dCanvasOFlags m_flags
holds flags for objects
const wxString & GetExtra() const
Get the extra information ( e.g. the filename of the font )
const a2dAffineMatrix & GetInverseTransform() const
Inverse of GetTransform()
static const a2dCanvasObjectFlagsMask BIN2
void SetPixelStroke(bool pixelstroke)
set pixelstoke flag, stroke width is defined in pixels else in worldcoordinates
double m_linespace
space between the lines
a2dPin is used in a2dCanvasObject to add pins to it.
This is a class/type description for a2dPin's.
double GetSize() const
Get size of the font.
bool Rotate(double angle)
Rotate clockwise by the given number of degrees:
allow draw a frame rect around a text
bool GetMultiLine() const
True if multiple lines of text are allowed.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
void SetNextLineDirection(bool up)
next line is higher in Y if true or lower if false
When cloning, and this flag is set, the property is cloned deep, else not.
basetype * GetPropertyValuePtr(a2dObject *obj) const
Get a pointer to the property value in obj.
bool GetBackGround() const
bool IsHit() const
true if this is a hit
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
wxString CreateString()
Create a string description of the font.
unsigned int GetTextFlags() const
Get the text flags.
int GetAttributeValueInt(const wxString &attrib, int defaultv=0)
Returns the integer value of an attribute.
int m_caret
position of caret within text string
bool AdjustPinLocation()
Allow change in pin location when wiring things up.
#define EVT_CANVASHANDLE_MOUSE_EVENT(func)
static event table macro for a2dHandle mouse event
void SetDrawerStroke(const a2dStroke &stroke)
Used to set the current stroke.
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Input and output handler for the XmlSer format.
UpdateMode
Various mode flags for Update.
snap to pins in other objects when not connected
int GetLines() const
get the number of lines in the text
virtual void SetPending(bool pending)
set this object pending for update
void SetNormalizedFont(bool forceNormalizedFont)
Use a fixed device height for drawing text.
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
int AlignmentString2TextAlignment(const wxString &alignstring)
convert a string to alignment enum
bool m_visiblechilds
child objects are visible or not
bool GetYaxis() const
get y axis orientation
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
a2dPin * IsConnectedTo(a2dPin *pin=a2dAnyPin) const
Return the pin to which this pin is connected.
bool m_hasPins
true if this object does have a2dPin's as children
double GetTransformedHitMargin()
transformed to object its coordinate system
void SetFont(const a2dFont &font)
set font to use for drawing text
wxUint16 m_layer
layer of object, default wxLAYER_DEFAULT
a2dTextGDS(a2dFontType fontType=a2dFONT_STROKED, const wxString &text=wxT("not specified"), double height=1.0, short int presentation=0)
constructor
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
void ReStoreFixedStyle()
when fixed drawing style is set, it can be overruled.
a2dCanvasObject is the base class for Canvas Objects.
wxColour GetColour() const
return colour 1
void SetSize(double size)
Set the font size.
void SetBackGround(bool background=true)
Set if a background will be drawn.
bool GetCaretShow() const
return true if caret is visible
bool GetVpath(wxChar c, a2dVpath &glyph, const a2dAffineMatrix &affine=a2dIDENTITY_MATRIX)
Get the glyph of a single character as a vpath.
void ReStartEdit(wxUint16 editmode)
to restart editing in a different mode
void TransformPoint(double x, double y, double &tx, double &ty) const
Transform a point.
double GetRotation() const
return rotation
wxString GetName() const
get the name given to the handle.
static a2dPropertyIdString * PROPID_PreEditText
old Text property, to return text as it was before editing (use in Undo)
double TransformDistance(double distance) const
Transform a distance.
return to contain edit bbox, suitable for editing matrix of object
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.
union a2dTextGDS::@5 m_presentationflags
presentation flags
double m_YcaretinLine
Y position of caret in world coordinate in line.
a2dDrawStyle GetDrawStyle() const
get drawstyle used for drawing.
a2dFont GetFont() const
get font for text
void SetStyle(const wxString &style)
Set style of font, e.g. Bold.
a2dAffineMatrix m_lworld
used for positioning the object (x,y,ang,scale etc.)
size_t m_firsteditable
The first editable character, usually 0, but may be different for a2dVisibleProperty.
void SetCaretShow(bool visible=true)
set caret on or off
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
void SetInternal(bool internal)
set when pin is within the border of its parent
void SetDrawerFill(const a2dFill &fill)
Used to set the current fill.
bool Ok() const
Check font validity.
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load object specific CVG data.
void SetDrawFrame(bool frame=true)
Set if a frame rect will be drawn.
wxMouseEvent & GetMouseEvent()
return the original mouse event that was redirected to the a2dHandle
snap to other objects its vertexes, which are decided in a2dCanvasObject::RestrictToObject() ...
void SetWidth(float width)
Set width of stroke in world coordinates.
void WriteNewLine()
Writes a new line and takes care of indentation.
virtual void PushTransform()
Save the current user-to-world transform on the affine stack.
double GetWidth(wxChar c)
Get width of a single character.
a2dText is an abstract base class.
a2dCanvasObjectList * wxNullCanvasObjectList
define a NON a2dCanvasObjectList
bool GetValid() const
returns true if boundingbox is calculated properly and therefore its valid flag is set...
const wxString & GetType() const
Get type of font, e.g. Freetype or Stroke.
void Expand(const a2dPoint2D &, const a2dPoint2D &)
expand boundingbox width two points
const a2dBoundingBox & Translate(a2dPoint2D &)
translate with given vector
virtual a2dBoundingBox GetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_CHILDREN) const
Get boundingbox without the affine matrix transform included.
double GetMinX() const
get minimum X of the boundingbox
virtual void DrawRoundedRectangle(double x, double y, double width, double height, double radius, bool pixelsize=false)
Draw RoundedRectangle in world coordinates.
a2dCanvasObjectList * m_childobjects
holds child objects
void SetFont(const a2dFont &font, double lineSpaceFactor=0.1)
set font for text
#define forEachIn(listtype, list)
easy iteration for a2dlist
static void GetInfoList(a2dFontInfoList &list)
Append fonts of this type to the list.
const a2dFont * a2dNullFONT
global a2dFont stock object for NO font
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
void SetWeight(double weight)
Set the weight of the font.
double GetPosX() const
get x position from affine matrix
a2dDrawer2D * GetDrawer2D() const
get current a2dDrawer2D
Normal straight line segment in a2dVpath.
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
bool m_editable
object can be edited
double wxRadToDeg(double rad)
conversion from radians to degrees
void SetSpecificFlags(bool setOrClear, a2dCanvasObjectFlagsMask which)
set all bit flags in object that or true in mask to true or false
#define EVT_CANVASOBJECT_MOUSE_EVENT(func)
static event table macro for a2dCanvasObject mouse event
void SetContourWidth(double width)
static a2dFont CreateFont(const a2dFontInfo &info, bool force=false)
Create the font from a fontinfo description.
void SetTextHeight(double height)
set text height in world coordinates
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
const a2dAffineMatrix & GetUserToDeviceTransform() const
get matrix which transforms directly from relative world coordinates to device
general event sent from a2dHandle to its parent a2dCanvasObject
a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
return text as a vector path, where text outline is converted to polyline or polygons.
double GetLineHeight() const
Height in world coordinates of one line.
void Add(a2dVpathSegment *seg)
add a segment
Restriction engine for editing restrictions like snapping.
bool m_childrenOnSameLayer
bool GetNextLineDirection() const
next line is higher in Y if true or lower if false
bool HasPins(bool realcheck=false)
are there a2dPin derived children
virtual void DrawLine(double x1, double y1, double x2, double y2)
Draw line in world coordinates.
Input and output handler for the XmlSer format.
bool CheckMask(a2dCanvasObjectFlagsMask mask) const
Compares all flags in object to the given mask and return true is the same.
a2dPin * AddPin(const wxString name, double x, double y, wxUint32 a2dpinFlags, a2dPinClass *pinClass, bool undo=false)
add a a2dPin as child
size_t m_selection_start_pos
Selection starting position.
double GetTextHeight() const
get text height in world coordinates
void SetPathType(a2dPATH_END_TYPE pathtype)
Set when m_contourwidth != 0 what is the end of the lines should be.
bool GetDrawFrame() const
int GetAsArray(wxArrayString &array)
get lines into array, return number of lines
wxString RequireAttributeValue(const wxString &attrib)
Forces an attribute and returns its string value.
virtual bool DoIsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
Does hit test on the object (exclusif child objects)
the property is temporary and never saved
Contains a2dDrawing Class to hold a drawing.
Allows multiple lines of text.
virtual a2dBoundingBox DoGetUnTransformedBbox(a2dBboxFlags flags=a2dCANOBJ_BBOX_NON) const
Get boundingbox without the affine matrix transform included.
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
bool PointInBox(const a2dPoint2D &, double Marge=0) const
is the point within the boundingbox
virtual bool Submit(a2dCommand *command, bool storeIt=true)
next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
bool GetEngineeringText() const
Is text always readible from the bottom right.
virtual void DrawText(const wxString &text, double x, double y, int alignment=wxMINX|wxMINY, bool Background=true)
Draw text in user coordinates.
void SetVisible(bool visible)
set if this object will visible (be rendered or not)
virtual bool DoStartEdit(wxUint16 editmode, wxEditStyle editstyle)
only used for editable objects and under control of a editing tool.
unsigned int GetTextFlags() const
Get the text flags.
A 2x3 affine matrix class for 2D transformations.
wxMouseEvent & GetMouseEvent()
return the original mouse event that was redirected to the a2dCanvasObject
a2dStroke GetDrawerStroke() const
get the current stroke
wxUint16 m_pixelExtend
Pixel extend.
double GetMaxX() const
get maximum X of the boundingbox
a2dPin * HasPinNamed(const wxString pinName, bool NotConnected=false)
are there a2dPin derived children which matches the given pin name?
bool GetFixedStyle() const
Get object fixed style setting.
double GetPosY() const
get y position from affine matrix
double GetWorldStrokeExtend()
void SetName(const wxString &name)
Set name of font, e.g. Arial.
const a2dStroke * a2dWHITE_STROKE
global a2dStroke stock object for WHITE stroking
a2dBoundingBox m_untransbbox
Untransformed bounding box.
while iterating a a2dCanvasDocument, this holds the context.
void SetExtra(const wxString &extra)
Set the extra information ( e.g. the filename of the font )
void SetMultiLine(bool multiline=true)
Set if multiple lines of text are allowed.
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
void MapBbox(const a2dAffineMatrix &matrix)
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
virtual void DoRender(a2dIterC &ic, OVERLAP clipparent)
Render derived object.
void SetSize(double size)
Set size of the font.
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
a2dRestrictionEngine * GetRestrictionEngine()
Get restriction engine (grid snapping)
void SetCaretUntransformed(double xh, double yh)
Set caret to the character closest to the position.
a2dAffineMatrix GetEngineeringTransform(a2dIterC &ic)
Calculate a new affine, so text is always readible from the bottom right.
bool GetRelease() const
get release flag
double GetMaxY() const
get maximum Y of the boundingbox
double GetWidth() const
returns width of the boundingbox
An object of this class will update a a2dIterC with the required information.
const wxString & GetStyle() const
Get style of font, e.g. Bold.
wxUint16 m_texttype
GDSII compatible to sub identify types of text.
return to contain children bbox
size_t m_selection_end_pos
Selection end position.
void SetPosXY(double x, double y, bool restrict=false)
set position to x,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 SetEngineeringText(bool engineering=true)
Keep text readible from the bottom right.
wxString CreateString() const
Assemble a string containing this class in a readable format.
bool m_editingCopy
true if the object needs to be rendered in edit mode.
bool m_utbbox_changed
Untransformed bounding box changed.
a2dFill GetDrawerFill() const
get the current fill
wxString GetLine(int line) const
get the number of lines in the text
double m_XcaretinLine
X position of caret in world coordinate in line.
a2dCanvasObject * IsHitWorld(a2dIterC &ic, a2dHitEvent &hitEvent)
If the position (x,y) is within the object return this.
A list used for enumerating fonts.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
bool Invert(void)
Invert matrix.
void Rotate(double rotation)
Rotates this object clockwise.
double GetDeterminant() const
Calculate the determinat of the linear transformation.
unsigned int m_textflags
contains several text flags.
void SetType(const wxString &type)
Set type of font, e.g. Freetype or Stroke.
double GetMinY() const
get minimum Y of the boundingbox
virtual a2dCanvasObjectList * GetSnapVpath(a2dSnapToWhatMask snapToWhat)
return a vectorpath indicating on which point/segments the object likes to be snapped.
the a2dDrawingPart is a a2dView specially designed for displaying parts of a a2dDrawing. It uses a a2dDrawer2D to actually redraw things from the document, by giving that a2dDrawer2D as drawing context to the document, and telling the document to redraw a certain rectangular area. At that last is what this class is for. It optimizes the areas to be redrawn after object in the document were changed. To do that it combines redraw areas to a minimal set of redrawing areas. All the administration for this and the way things will be redrawn is from this view.
void SetCaret(int position)
set position of caret (-1 means off)
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
a2dCanvasObject for a Vector Path
bool GeneratePins(a2dPinClass *toConnectTo, a2dConnectTask task, double x, double y, double margin=0)
create pins in derived objects.
a2dDrawingPart * GetDrawingPart() const
get current a2dDrawingPart
int GetAlignment() const
Get the position of the anchor point w.r.t the text.
This template class is for property ids with a known data type.
double GetScale()
See GetScale()
a2dBoundingBox m_bbox
boundingbox in world coordinates
double RequireAttributeValueDouble(const wxString &attrib)
Forces an attribute and returns its double value.
Todo: The text will not be user-editable, but is selectable.
const a2dFontInfo & GetFontInfo() const
Get fontinfo of the font.
double GetAbsX() const
get absolute X position of the pin ( after applying the parent's matrix and its own matrix ) ...
a2dText(const wxString &text=wxT("not specified"))
constructor
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
wxString m_text
the text to display
void SetReadOnly(bool readonly=true)
Set if text is readonly.
const a2dAffineMatrix & GetTransform() const
Get the accumulated transform up to and including m_lworld of the current object. ...
virtual a2dObject * DoClone(CloneOptions options, a2dRefMap *refs) const
Clone this object and return a pointer to the new object.
virtual void SetLayer(wxUint16 layer)
set layer index where this object is drawn upon.
used to change text and caret of canvas text objects in a a2dCanvasDocument
double m_rely
(world coordinates) hit point y relative to the canvas object its parent object(s) ...
#define BBOX2XYWH(bbox)
expand a2dBoundingBox to x,y,w,h
A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.
edit a copy of the original object
CloneOptions
options for cloning
void SetHitFlags(a2dCanvasObjectHitFlags mask)
set hit flags
virtual void DoEndEdit()
only used for editable objects and under control of a editing tool.
void SetPreRenderAsChild(bool prerender)
If set, this object has a higher priority in rendering than other children objects.
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
structure to give as parameter to member functions of a2dCanvasObject
virtual bool RestrictPoint(double &x, double &y, wxUint32 sourceRequired=snapToAll, bool ignoreEngine=false)
Restrict a single point of a line or polyline.
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Write object specific CVG data.
snap to pins in other objects
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
static const a2dCanvasObjectFlagsMask PRERENDERASCHILD
general canvas module declarations and classes
void OverRuleFixedStyle()
id style is FIXED, saves current style and sets style to a2dFILLED