wxArt2D
cantext.h
Go to the documentation of this file.
1 /*! \file cantext.h
2  \brief a2dText derived from a2dCanvasObject, holds multiline text
3  \author Klaas Holwerda, Erik van der Wal
4 
5  Copyright: 2000-2004 (c) Klaas Holwerda
6 
7  Licence: wxWidgets Licence
8 
9  RCS-ID: $Id: cantext.h,v 1.29 2009/07/16 20:06:33 titato Exp $
10 */
11 
12 #ifndef __WXCANTEXT_H__
13 #define __WXCANTEXT_H__
14 
15 #include "wx/canvas/canobj.h"
16 
17 extern wxString TextAlignment2String( int alignment );
18 extern int AlignmentString2TextAlignment( const wxString& alignstring );
19 
20 /*! \defgroup textrelated Text related classes
21 */
22 
23 //! a2dText is an abstract base class.
24 /*!
25  The text is filled with a background if a2dFill != *a2dTRANSPARENT_FILL
26  The fill colour is the Colour of the a2dFill.
27  The a2dStroke colour is the colour used for the text itself.
28 
29  The text can be aligned, see SetAlignment() for info.
30  \par User editing keys:
31 
32 <TABLE border=0 cellpadding=0 cellspacing=0>
33 <tr><td colspan=2><br><b>Cursor movement</b></td></tr><br>
34 <tr><td colspan=2>Text selection can be done by pressing the Shift key, simultaneously with one of the following keys.<br></td></tr><br>
35 
36 <TR><TD class="memItemLeft" nowrap>Cursor up/down</TD><TD class="memItemRight"> Move cursor one line up/down.</TD></TR>
37 <TR><TD class="memItemLeft" nowrap>Cursor Left / Ctrl + B</TD><TD class="memItemRight"> Move cursor one character to the left.</TD></TR>
38 <TR><TD class="memItemLeft" nowrap>Cursor Right / Ctrl + F</TD><TD class="memItemRight"> Move cursor one character to the right.</TD></TR>
39 <TR><TD class="memItemLeft" nowrap>Ctrl + Left / Alt + B</TD><TD class="memItemRight"> Move cursor to start of (previous) word.</TD></TR>
40 <TR><TD class="memItemLeft" nowrap>Ctrl + Right / Alt + F</TD><TD class="memItemRight"> Move cursor to start of next word.</TD></TR>
41 <TR><TD class="memItemLeft" nowrap>Home / Ctrl + A</TD><TD class="memItemRight"> Move to start of line</TD></TR>
42 <TR><TD class="memItemLeft" nowrap>End / Ctrl + E</TD><TD class="memItemRight"> Move to end of line</TD></TR>
43 <TR><TD class="memItemLeft" nowrap>Ctrl + N</TD><TD class="memItemRight"> Move to start of next line.</TD></TR>
44 <TR><TD class="memItemLeft" nowrap>Ctrl + P</TD><TD class="memItemRight"> Move to start of previous line.</TD></TR>
45 <TR><TD class="memItemLeft" nowrap>Ctrl + Home</TD><TD class="memItemRight"> Move to start of text.</TD></TR>
46 <TR><TD class="memItemLeft" nowrap>Ctrl + End</TD><TD class="memItemRight"> Move to end of text.</TD></TR>
47 
48 <TR><TD colspan=2><br><b>Deletion</b></TD></TR><br>
49 <TR><TD colspan=2>If part of the text is selected, deleting it will take precedence over the following keys.<br></TD></TR><br>
50 
51 <TR><TD class="memItemLeft" nowrap>Backspace / Ctrl + H</TD><TD class="memItemRight"> Delete previous character.</TD></TR><br>
52 <TR><TD class="memItemLeft" nowrap>Delete / Ctrl + D</TD><TD class="memItemRight"> Delete next character.</TD></TR><br>
53 <TR><TD class="memItemLeft" nowrap>Ctrl + Backspace / Ctrl + W</TD><TD class="memItemRight"> Delete to start of (previous) word.</TD></TR><br>
54 <TR><TD class="memItemLeft" nowrap>Ctrl + Delete / Alt + D</TD><TD class="memItemRight"> Delete to start of next word.</TD></TR><br>
55 <TR><TD class="memItemLeft" nowrap>Ctrl + K</TD><TD class="memItemRight"> Delete to end of line.</TD></TR><br>
56 <TR><TD class="memItemLeft" nowrap>Ctrl + U</TD><TD class="memItemRight"> Delete current line</TD></TR><br>
57 
58 <TR><TD colspan=2><br><b>Clipboard<br></b></TD></TR><br>
59 
60 <TR><TD class="memItemLeft" nowrap>Ctrl + C / Ctrl + Insert</TD><TD class="memItemRight"> Copy text to clipboard.</TD></TR><br>
61 <TR><TD class="memItemLeft" nowrap>Ctrl + V / Shift + Insert</TD><TD class="memItemRight"> Paste text from clipboard.</TD></TR><br>
62 <TR><TD class="memItemLeft" nowrap>Ctrl + X / Shift + Delete</TD><TD class="memItemRight"> Cut text to clipboard.</TD></TR><br>
63 
64 <TR><TD colspan=2><br><b>Text alignment</b></TD></TR><br>
65 <TR><TD colspan=2>Num lock should be on to use these keys.<br></TD></TR><br>
66 
67 <TR><TD class="memItemLeft" nowrap>Ctrl + Keypad 1..9</TD><TD class="memItemRight"> Align the text to a different direction.</TD></TR><br>
68 <TR><TD class="memItemLeft" nowrap>Ctrl + Keypad 0</TD><TD class="memItemRight"> Toggle between bounding box and text alignment.</TD></TR><br>
69 
70 </TABLE>
71 
72  \bug EW: Solve behaviour when having a stretched affine matrix. Actually this bug is caused by
73  the drawing of the text (which cannot be stretched). Maybe even prevent stretching.
74 
75  Proper constructors for several cases.
76  \code
77  a2dText( text, x, y, a2dFont( fontfile, size ) );
78 
79  a2dText( text, x, y, a2dFont( wxfont, size, alignment), angle, up );
80 
81 
82  a2dText( text, x, y, a2dFont( wxfont, size, alignment), 0.0, up );
83 
84  text->SetFont( a2dFont( wxfont, text->GetTextHeight(), text->GetAlignment() ) );
85 
86  text->SetFont( a2dFont( wxfont, size, text->GetAlignment() ) );
87  \endcode
88 
89  \ingroup canvasobject
90  \ingroup textrelated
91 */
92 
93 class A2DCANVASDLLEXP a2dText: public a2dCanvasObject
94 {
95 public:
97  {
98  //! Allows multiple lines of text
99  a2dCANOBJTEXT_MULTILINE = 1 << 1,
100  //! Todo: The text will not be user-editable, but is selectable
101  a2dCANOBJTEXT_READONLY = 1 << 2,
102  //! show the caret
103  a2dCANOBJTEXT_CARETVISIBLE = 1 << 3,
104  //! next line is higher in Y if set
105  a2dCANOBJTEXT_NEXTLINEUP = 1 << 4,
106  //! Text is always readible from the bottom right.
107  a2dCANOBJTEXT_ENGINEERING = 1 << 5,
108  //! disable background drawing
109  a2dCANOBJTEXT_BACKGROUND = 1 << 6,
110  //! allow draw a frame rect around a text
111  a2dCANOBJTEXT_FRAME = 1 << 7,
112  a2dCANVASTEXT_DEFAULTFLAGS = a2dCANOBJTEXT_MULTILINE
113  | a2dCANOBJTEXT_CARETVISIBLE
114  | a2dCANOBJTEXT_NEXTLINEUP
115  };
116 
117 public:
118  DECLARE_EVENT_TABLE()
119  DECLARE_DYNAMIC_CLASS( a2dText )
120 
121  //! constructor
122  /*!
123  create text object at (0,0) text is set to "not specified" if not given
124  */
125  a2dText( const wxString& text = wxT( "not specified" ) );
126 
127  //! constructor
128  /*!
129  \param text text to display
130  \param x x start
131  \param y y start
132  \param font a2dFont to use
133  \param angle angle in degrees
134  \param up if true next line is higher in Y else lower
135  \param alignment Alignment of the text. (See SetAlignment)
136  */
137  a2dText( const wxString& text, double x, double y,
138  const a2dFont& font = *a2dDEFAULT_CANVASFONT, double angle = 0.0,
139  bool up = false, int alignment = a2dDEFAULT_ALIGNMENT );
140 
141 protected:
142  //! copy constructor
143  a2dText( const a2dText& other, CloneOptions options, a2dRefMap* refs );
144 
145 public:
146  //! Destructor
147  ~a2dText();
148 
149  inline a2dText* TClone( CloneOptions options, a2dRefMap* refs = NULL ) { return ( a2dText* ) Clone( options, refs ); }
150 
151 public:
152 
153  //! get the number of lines in the text
154  int GetLines() const;
155 
156  //! get lines into array, return number of lines
157  int GetAsArray( wxArrayString& array );
158 
159  //! get the number of lines in the text
160  wxString GetLine( int line ) const;
161 
162  wxString GetSelectedText() const;
163 
164  //! set the text for the object '\n' in string means new line
165  inline void SetText( const wxString& text )
166  { m_text = text; m_utbbox_changed = true; SetPending( true ); }
167  //! get the text of the object '\n' in string means new line
168  inline wxString GetText() const { return m_text; }
169 
170  void InsertTextAtCarret( const wxString& text );
171 
172  //! set text height in world coordinates
173  inline void SetTextHeight( double height )
174  { m_font.SetSize( height ); m_utbbox_changed = true; SetPending( true ); }
175  //! get text height in world coordinates
176  inline double GetTextHeight() const { return m_font.GetSize(); }
177 
178  //! Height in world coordinates of one line
179  inline double GetLineHeight() const { return m_font.GetLineHeight(); }
180 
181  //! Set the flag if text couldn't be loadad from file
182  inline void SetWrongLoad( bool wrongLoad ) { m_wrongLoad = wrongLoad; }
183  //! Get flag if text couldn't be loadad from file
184  inline bool GetWrongLoad() const { return m_wrongLoad; }
185 
186  //! Set Space in world coordinates between two lines
187  inline void SetLineSpacing( double linespace )
188  { m_linespace = linespace; m_utbbox_changed = true; SetPending( true ); }
189  //! Get Space in world coordinates between two lines
190  inline double GetLineSpacing() const { return m_linespace; }
191 
192  //! Set the text flags
193  inline void SetTextFlags( unsigned int textflags ) { m_textflags = textflags; m_utbbox_changed = true; }
194  //! Get the text flags
195  inline unsigned int GetTextFlags() const { return m_textflags; }
196 
197  //! Set if multiple lines of text are allowed.
198  void SetMultiLine( bool multiline = true );
199  //! True if multiple lines of text are allowed.
200  inline bool GetMultiLine() const
201  { return ( m_textflags & a2dCANOBJTEXT_MULTILINE ) != 0; }
202 
203  //! Set if text is readonly
204  void SetReadOnly( bool readonly = true );
205  //! True if text is readonly.
206  inline bool GetReadOnly()
207  { return ( m_textflags & a2dCANOBJTEXT_READONLY ) != 0; }
208 
209  //! next line is higher in Y if true or lower if false
210  void SetNextLineDirection( bool up );
211  //! next line is higher in Y if true or lower if false
212  inline bool GetNextLineDirection() const
213  { return ( m_textflags & a2dCANOBJTEXT_NEXTLINEUP ) != 0; }
214 
215  //! Keep text readible from the bottom right.
216  void SetEngineeringText( bool engineering = true );
217  //! Is text always readible from the bottom right.
218  inline bool GetEngineeringText() const
219  { return ( m_textflags & a2dCANOBJTEXT_ENGINEERING ) != 0; }
220 
221  //! Set if a background will be drawn.
222  /*!
223  When a layer style is used with a non transparent fill,
224  overlapping text is disturbing in case background overlaps other text.
225  By setting this flag false the background is set transparent, even if a private fill style is used.
226  Of course one can set the object to use a transparent fill, but this takes memory.
227  */
228  void SetBackGround( bool background = true );
229  //! \see SetBackGround()
230  inline bool GetBackGround() const
231  { return ( m_textflags & a2dCANOBJTEXT_BACKGROUND ) != 0; }
232 
233  //! Set if a frame rect will be drawn.
234  /*!
235 
236  */
237  void SetDrawFrame( bool frame = true );
238  //! \see SetDrawFrame()
239  inline bool GetDrawFrame() const
240  { return ( m_textflags & a2dCANOBJTEXT_FRAME ) != 0; }
241 
242  //! set font for text
243  /*! This class takes care of deleting the font
244  \param font The font to set
245  \param lineSpaceFactor The m_linespace will be set to font.GetSize() * lineSpaceFactor
246  */
247  void SetFont( const a2dFont& font, double lineSpaceFactor = 0.1 );
248  //! get font for text
249  /*! Returns a pointer to the current font. If you need a copy, use (a2dFont) GetFont()->Clone(flat_copy).
250  */
251  inline a2dFont GetFont() const { return m_font; }
252 
253  //! set position of caret (-1 means off)
254  inline void SetCaret( int position )
255  { m_caret = position; SetPending( true ); }
256  //! Get position of caret (-1 means off)
257  inline int GetCaret() const { return m_caret; }
258 
259  //! Set caret to the character closest to the position
260  /*! \param ic iterative context
261  \param x (mouse pointer) x-coordinate in absolute world coordinates
262  \param y (mouse pointer) y-coordinate in absolute world coordinates
263  \return True if mouse-position was within this object
264  */
265  bool SetCaret( a2dIterC& ic, double x, double y );
266 
267  //! set caret on or off
268  void SetCaretShow( bool visible = true );
269  //! return true if caret is visible
270  inline bool GetCaretShow() const
271  { return ( m_textflags & a2dCANOBJTEXT_CARETVISIBLE ) != 0; }
272 
273  //! Set the position of the anchor point w.r.t the text.
274  /*! \param alignment sets the direction of the anchor point. The direction can be set like e.g.
275  wxMINX | wxMINY, meaning a specific corner of the boundingbox.
276  Not specifying either a horizontal or vertical position will default to the centre. So only
277  specifying wxMINX corresponds to the left and middle Y of bbox position.
278  If Yaxis is up in a view, use wxBASELINE to have text origin start at (x,y).
279  If Yaxis is down in a view, use wxBASELINE_CONTRA to have text origin start at (x,y).
280  <!-- view picture using monospaced font -->
281  \code
282  +-----^-----+ wxMAXY
283  | # |
284  | # |
285  | #### #### |
286  |# # # #|
287  +-####-#---#+ wxBASELINE
288  | # |
289  | ### |
290  +-----v-----+ wxMINY
291  wxMINX wxMAXX
292  \endcode
293  */
294  inline void SetAlignment( int alignment )
295  {
296  if( m_alignment != alignment )
297  {
298  m_alignment = alignment; m_utbbox_changed = true; SetPending( true );
299  }
300  }
301  //! Get the position of the anchor point w.r.t the text
302  /*! \return The alignment setting.
303  */
304  inline int GetAlignment() const
305  { return m_alignment; }
306 
307  bool GeneratePins( a2dPinClass* toConnectTo, a2dConnectTask task, double x, double y, double margin = 0 );
308 
309  bool AdjustPinLocation();
310 
311  virtual a2dCanvasObjectList* GetSnapVpath( a2dSnapToWhatMask snapToWhat );
312 
313  //! return text as a vector path, where text outline is converted to polyline or polygons.
314  a2dCanvasObjectList* GetAsCanvasVpaths( bool transform = true ) const;
315 
316 #if wxART2D_USE_CVGIO
317  //! Write object specific CVG data
318  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
319 
320  //! Load object specific CVG data
321  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
322 #endif //wxART2D_USE_CVGIO
323 
324  static a2dPropertyIdFont* PROPID_Font;
325  //! old Text property, to return text as it was before editing (use in Undo)
327 
329 
330 protected:
331 
332  //! Clone this object and return a pointer to the new object.
333  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
334 
335  bool DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox );
336 
337  //! Render derived object
338  virtual void DoRender( a2dIterC& ic, OVERLAP clipparent );
339 
340  virtual bool DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent );
341 
342  //! Get boundingbox without the affine matrix transform included.
343  /*! \return The boundingbox.
344  */
345  virtual a2dBoundingBox DoGetUnTransformedBbox( a2dBboxFlags flags = a2dCANOBJ_BBOX_NON ) const;
346 
347  //! Set caret to the character closest to the position
348  /*!
349  \param xh (mouse pointer) x-coordinate in world coordinates
350  \param yh (mouse pointer) y-coordinate in world coordinates
351  */
352  void SetCaretUntransformed( double xh, double yh );
353 
354  //! Calculate a new affine, so text is always readible from the bottom right.
355  a2dAffineMatrix GetEngineeringTransform( a2dIterC& ic );
356 
357  virtual bool DoStartEdit( wxUint16 editmode, wxEditStyle editstyle );
358 
359  virtual void DoEndEdit();
360 
361  void OnChar( wxKeyEvent& event );
362 
363  void OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event );
364 
365  void OnHandleEvent( a2dHandleMouseEvent& event );
366 
367  const a2dFont& MX_GetFont() const { return m_font; }
368  void MX_SetFont( const a2dFont& value ) { m_font = value; }
369 
370  //! font
372 
373  a2dFontInfo m_fontinfo;
374 
375  bool m_wrongLoad;
376 
377  //! space between the lines
378  double m_linespace;
379 
380  //! the text to display
381  wxString m_text;
382 
383  //! contains several text flags.
384  unsigned int m_textflags;
385 
386  //! position of caret within text string
387  int m_caret;
388 
389  //! X position of caret in world coordinate in line
391 
392  //! Y position of caret in world coordinate in line
394 
395  //! Untransformed bounding box.
397 
398  //! Untransformed bounding box changed
399  mutable bool m_utbbox_changed;
400 
401  //! Selection starting position
403  //! Selection end position
405 
406  //! The first editable character, usually 0, but may be different for a2dVisibleProperty
408 
409  //! Alignment.
411 
412 private:
413  //!this is a not implemented copy constructor that avoids automatic creation of one
414  a2dText( const a2dText& other );
415 };
416 
417 #if defined(WXART2D_USINGDLL)
418 template class A2DCANVASDLLEXP a2dSmrtPtr<a2dText>;
419 #endif
420 
421 //
422 // enumerates used by the GDS text class
423 //
424 enum TEXT_PATHTYPE {TEXT_PATH_END_SQAURE, TEXT_PATH_END_ROUND, TEXT_PATH_END_SQAURE_EXT};
425 
426 //
427 // enumerates used by the Presentation class
428 //
429 enum {FONT0, FONT1, FONT2, FONT3};
430 enum {TOP, MIDDLE, BOTTOM};
431 enum {LEFT, CENTER, RIGTH};
432 
433 //! how a GDS-II object is placed relative to its XY position.
434 typedef struct pres_bitflags
435 {
436 
437 #if wxBYTE_ORDER == wxBIG_ENDIAN
438  unsigned m_reserved : 10;
439  unsigned m_font: 2;
440  unsigned m_vertical: 2;
441  unsigned m_horizontal: 2;
442 #else
443  unsigned m_horizontal: 2;
444  unsigned m_vertical: 2;
445  unsigned m_font: 2;
446  unsigned m_reserved : 10;
447 #endif
448 } pres_bitflags;
449 
450 //
451 // defaults for Presentation
452 //
453 #define DEFAULT_PRESENTATION_FONT FONT0
454 #define DEFAULT_PRESENTATION_VERTICAL TOP
455 #define DEFAULT_PRESENTATION_HORIZONTAL LEFT
456 #define DEFAULT_FONT_HEIGHT 1
457 
458 
459 //! a2dTextGDS text based on wxDC text drawing.
460 /*!
461  The text is filled with a background if a2dFill != *a2dTRANSPARENT_FILL
462  The fill colour is the Colour of the a2dFill.
463  The a2dStroke colour is the colour used for the text itself.
464 
465  \ingroup canvasobject
466 */
467 class A2DCANVASDLLEXP a2dTextGDS: public a2dText
468 {
469 
470 public:
471 
472  //! constructor
473  /*!
474  create text object at (0,0) text is set to "not specified" if not given
475  */
476  a2dTextGDS( a2dFontType fontType = a2dFONT_STROKED, const wxString& text = wxT( "not specified" ), double height = 1.0, short int presentation = 0 );
477 
478  //! constructor
479  a2dTextGDS( const a2dTextGDS& ori, CloneOptions options, a2dRefMap* refs );
480 
481  void SetFontGDS( char nw_font = DEFAULT_PRESENTATION_FONT );
482  void SetVertical( char nw_vertical = DEFAULT_PRESENTATION_VERTICAL );
483  void SetHorizontal( char nw_horizontal = DEFAULT_PRESENTATION_HORIZONTAL );
484  short int GetFontGDS();
485  short int GetVertical();
486  short int GetHorizontal();
487 
488  void SetRotation( double rotation );
489  double GetRotation();
490 
491  //! GDSII compatible to sub identify types of rectangles.
492  /*! you can use it as a special tagged text */
493  void SetTextType( wxUint16 type ) { m_texttype = type; }
494 
495  //! GDSII compatible to sub identify types of rectangles.
496  /*! you can use it as a special tagged text */
497  wxUint16 GetTextType() { return m_texttype; }
498 
499  void SetPresentationFlags( short int total );
500 
501  short int GetPresentationFlags( );
502 
503  void SetPathtype( TEXT_PATHTYPE type ) { m_pathtype = type; }
504 
505  TEXT_PATHTYPE GetPathtype() { return m_pathtype; }
506 
507  //! a factor to modify the internal text height, compared to the GDSII file height.
508  static void SetFontScaleFactor( double fontScaleFactor ) { m_fontScaleFactor = fontScaleFactor; }
509 
510  //! a factor to modify the internal text height, compared to the GDSII file height.
511  static double GetFontScaleFactor() { return m_fontScaleFactor; }
512 
513 protected:
514 
515 #if wxART2D_USE_CVGIO
516  //! Write object specific CVG data
517  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite );
518 
519  //! Load object specific CVG data
520  void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
521 #endif //wxART2D_USE_CVGIO
522 
523  //! Clone this object and return a pointer to the new object.
524  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
525 
526  //! GDSII compatible to sub identify types of text.
527  wxUint16 m_texttype;
528 
529  a2dFontType m_fontType;
530 
531  TEXT_PATHTYPE m_pathtype;
532 
533  float m_width;
534 
535  bool m_monoSpaced;
536 
537  static double m_fontScaleFactor;
538 
539  //! presentation flags \see pres_bitflags
540  union
541  {
542  short int total;
543  pres_bitflags bits;
544  } m_presentationflags;
545 
546  DECLARE_DYNAMIC_CLASS( a2dTextGDS )
547 };
548 
549 
550 /*! a2dTextChanges - register a2dFont and other text properties
551 on a group of a2dText objects.
552 The class is used to set only certain properties on a2dText objects, and leaf the rest as is.
553 For example to change the alignment of a group of selected a2dText objects, but leaf the font settings for the rest as is.
554 
555 */
557 {
558 public:
559  a2dTextChanges();
560  a2dTextChanges(const a2dFont& font, unsigned int textflags, int alignment );
561 
562  // Creates the list of available fonts once
563  // Optional: filter fonts, if a filled filterlist and filtertype is passed
564  static void InitialiseFontList(const wxArrayString &filterlist = wxArrayString(), const wxString filtertype = wxT( "" ));
565 
566  // Initialises with <font>.
567  void Set(const a2dFont& font, unsigned int textflags, int alignment, bool wrongloadflag = false );
568 
569  // Compares with <font> and sets to invalid if unequal.
570  void Mix(const a2dFont& font, unsigned int textflags, int alignment );
571 
572  // Returns the a2dFont member object if valid, or <font> instead.
573  a2dFont GetFont(const a2dFont& font, wxArrayString valid_styles = wxArrayString(), wxArrayString valid_extras = wxArrayString() ) const;
574  int GetAlignment( int Alignment ) const;
575  unsigned int GetTextFlags( unsigned int textflags ) const;
576 
577 
578  bool IsValid() const { return m_bFont; }
579  // Returns the a2dFill member object.
580  a2dFont GetFont() const { return m_Font; }
581  void SetFont(a2dFont font)
582  {
583  m_Font = font;
584  m_bFont = true;
585  }
586 
587  //! Set the font style
588  inline void SetStyle(wxString style)
589  {
590  a2dFontInfo fontinfo=m_Font.GetFontInfo();
591  fontinfo.SetStyle( style );
592  m_Font = a2dFont::CreateFont( fontinfo );
593 
594  m_bStyle=true;
595  }
596 
597  //! Set the font name
598  inline void SetName(wxString name)
599  {
600  a2dFontInfo fontinfo=m_Font.GetFontInfo();
601  fontinfo.SetName( name );
602  m_Font = a2dFont::CreateFont( fontinfo );
603 
604  m_bName=true;
605  }
606 
607  //! Set the size
608  inline void SetSize(double size)
609  {
610  a2dFontInfo fontinfo=m_Font.GetFontInfo();
611  fontinfo.SetSize( size );
612  m_Font = a2dFont::CreateFont( fontinfo );
613 
614  m_bSize=true;
615  }
616 
617  //! Set the text flags
618  inline void SetTextFlags( unsigned int textflags )
619  {
620  m_textflags = textflags;
621  m_btextflags = true;
622  }
623 
624  //! Set the position of the anchor point w.r.t the text.
625  inline void SetAlignment( int alignment )
626  {
627  m_alignment = alignment;
628  m_balignment = true;
629  }
630 
631  bool IsTypeValid() const { return m_bType; }
632  bool IsNameValid() const { return m_bName; }
633  bool IsStyleValid() const { return m_bStyle; }
634  bool IsSizeValid() const { return m_bSize; }
635  bool IsAlignmentValid() const { return m_balignment; }
636  bool IsTextflagsValid() const { return m_btextflags; }
637 
638  void SetStyleValidity( bool valid ) { m_bStyle = valid; }
639  void SetNameValidity( bool valid ) { m_bName = valid; }
640 
641  //! Get the text flags
642  inline unsigned int GetTextFlags() const { return m_textflags; }
643 
644  //! Get the position of the anchor point w.r.t the text
645  /*! \return The alignment setting.
646  */
647  inline int GetAlignment() const
648  { return m_alignment; }
649 
650  a2dFontInfoList *GetFontInfoList()
651  { return &m_fontlist; }
652 
653  wxArrayString GetCommonStyle()
654  { return m_commonstyle; }
655 
656 private:
657  a2dFont m_Font;
658  bool m_bFont;
659 
660  //! Font flags
661  bool m_bName;
662  bool m_bType;
663  bool m_bStyle;
664  bool m_bSize;
665 
666  //! Font alignment
667  int m_alignment;
668  bool m_balignment;
669 
670  //! contains several text flags.
671  unsigned int m_textflags;
672  bool m_btextflags;
673 
674  //! contains the comlete font list
675  static a2dFontInfoList m_fontlist;
676 
677  //! contains the common styles when objects are mixed
678  wxArrayString m_commonstyle;
679 
680  //! for speed optimization, hold a list of already used fonts
681  static a2dFontInfoList m_alreadyusedfonts;
682 };
683 
684 extern wxUint32 SetTextChanges( a2dTextChanges& returned, a2dCanvasObjectList* objects, a2dCanvasObjectFlagsMask mask = a2dCanvasOFlags::SELECTED, a2dLayers* layersetup = NULL );
685 
686 
687 #endif /* __WXCANTEXT_H__ */
virtual bool GeneratePins(a2dPinClass *toConnectTo, a2dConnectTask task, double x, double y, double margin=0)
create pins in derived objects.
Definition: canobj.h:2054
int GetAlignment() const
Get the position of the anchor point w.r.t the text.
Definition: cantext.h:647
wxString TextAlignment2String(int alignment)
convert alignment enum to a string
Definition: cantext.cpp:32
bool GetWrongLoad() const
Get flag if text couldn&#39;t be loadad from file.
Definition: cantext.h:184
mouse event sent from a2dCanvasObject to itself
Definition: canglob.h:223
a2dConnectTask
flags for searching a connecting a2dpinClass, for the connecting task at hand.
Definition: connectgen.h:40
void SetAlignment(int alignment)
Set the position of the anchor point w.r.t the text.
Definition: cantext.h:294
Font info class, used as a single element for enumerating fonts.
Definition: stylebase.h:686
a2dTextGDS text based on wxDC text drawing.
Definition: cantext.h:467
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
int m_alignment
Alignment.
Definition: cantext.h:410
virtual bool AdjustPinLocation()
Allow change in pin location when wiring things up.
Definition: canobj.h:2058
static double GetFontScaleFactor()
a factor to modify the internal text height, compared to the GDSII file height.
Definition: cantext.h:511
double m_linespace
space between the lines
Definition: cantext.h:378
This is a class/type description for a2dPin&#39;s.
Definition: canpin.h:628
Ref Counted base object.
Definition: gen.h:1045
bool GetMultiLine() const
True if multiple lines of text are allowed.
Definition: cantext.h:200
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
bool GetBackGround() const
Definition: cantext.h:230
unsigned int GetTextFlags() const
Get the text flags.
Definition: cantext.h:642
int m_caret
position of caret within text string
Definition: cantext.h:387
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
UpdateMode
Various mode flags for Update.
Definition: canobj.h:1091
virtual void SetPending(bool pending)
set this object pending for update
Definition: canobj.cpp:2585
OVERLAP
Result of a a2dBoundingBox intersection or hittest.
Definition: bbox.h:24
int AlignmentString2TextAlignment(const wxString &alignstring)
convert a string to alignment enum
Definition: cantext.cpp:58
static void SetFontScaleFactor(double fontScaleFactor)
a factor to modify the internal text height, compared to the GDSII file height.
Definition: cantext.h:508
The base class for all drawable objects in a a2dCanvasDocument.
#define DECLARE_PROPERTIES()
check if class has the given id as a valid id for this object
Definition: gen.h:835
void SetSize(double size)
Set the size.
Definition: cantext.h:608
bool GetReadOnly()
True if text is readonly.
Definition: cantext.h:206
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
load object specific CVG data
Definition: canobj.cpp:5728
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
bool GetCaretShow() const
return true if caret is visible
Definition: cantext.h:270
static a2dPropertyIdString * PROPID_PreEditText
old Text property, to return text as it was before editing (use in Undo)
Definition: cantext.h:326
double m_YcaretinLine
Y position of caret in world coordinate in line.
Definition: cantext.h:393
a2dFont GetFont() const
get font for text
Definition: cantext.h:251
void SetStyle(const wxString &style)
Set style of font, e.g. Bold.
Definition: stylebase.h:724
size_t m_firsteditable
The first editable character, usually 0, but may be different for a2dVisibleProperty.
Definition: cantext.h:407
wxUint64 a2dCanvasObjectFlagsMask
mask flags for a2dCanvasObject
Definition: candefs.h:152
a2dText is an abstract base class.
Definition: cantext.h:93
wxUint16 GetTextType()
GDSII compatible to sub identify types of rectangles.
Definition: cantext.h:497
void SetName(wxString name)
Set the font name.
Definition: cantext.h:598
virtual a2dCanvasObjectList * GetAsCanvasVpaths(bool transform=true) const
when implemented the object without its children, is converted to
Definition: canobj.cpp:1505
void SetTextType(wxUint16 type)
GDSII compatible to sub identify types of rectangles.
Definition: cantext.h:493
void SetStyle(wxString style)
Set the font style.
Definition: cantext.h:588
static a2dFont CreateFont(const a2dFontInfo &info, bool force=false)
Create the font from a fontinfo description.
Definition: stylebase.cpp:3163
void SetTextHeight(double height)
set text height in world coordinates
Definition: cantext.h:173
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
write object specific CVGL data
Definition: canobj.cpp:5569
general event sent from a2dHandle to its parent a2dCanvasObject
Definition: canglob.h:273
double GetLineHeight() const
Height in world coordinates of one line.
Definition: cantext.h:179
double GetLineSpacing() const
Get Space in world coordinates between two lines.
Definition: cantext.h:190
bool GetNextLineDirection() const
next line is higher in Y if true or lower if false
Definition: cantext.h:212
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
static const a2dCanvasObjectFlagsMask SELECTED
Definition: candefs.h:180
size_t m_selection_start_pos
Selection starting position.
Definition: cantext.h:402
double GetTextHeight() const
get text height in world coordinates
Definition: cantext.h:176
bool GetDrawFrame() const
Definition: cantext.h:239
wxUint32 a2dSnapToWhatMask
mask for a2dSnapToWhat flags
Definition: restrict.h:26
bool GetEngineeringText() const
Is text always readible from the bottom right.
Definition: cantext.h:218
virtual a2dCanvasObjectList * GetSnapVpath(a2dSnapToWhatMask snapToWhat)
return a vectorpath indicating on which point/segments the object likes to be snapped.
Definition: canobj.cpp:4308
unsigned int GetTextFlags() const
Get the text flags.
Definition: cantext.h:195
A 2x3 affine matrix class for 2D transformations.
Definition: afmatrix.h:53
void SetName(const wxString &name)
Set name of font, e.g. Arial.
Definition: stylebase.h:719
a2dBoundingBox m_untransbbox
Untransformed bounding box.
Definition: cantext.h:396
while iterating a a2dCanvasDocument, this holds the context.
Definition: canobj.h:3212
const a2dFont * a2dDEFAULT_CANVASFONT
global a2dFont stock object for default font
void SetSize(double size)
Set size of the font.
Definition: stylebase.h:735
void SetText(const wxString &text)
set the text for the object &#39; &#39; in string means new line
Definition: cantext.h:165
void SetTextFlags(unsigned int textflags)
Set the text flags.
Definition: cantext.h:618
void SetTextFlags(unsigned int textflags)
Set the text flags.
Definition: cantext.h:193
int GetCaret() const
Get position of caret (-1 means off)
Definition: cantext.h:257
wxUint16 m_texttype
GDSII compatible to sub identify types of text.
Definition: cantext.h:527
size_t m_selection_end_pos
Selection end position.
Definition: cantext.h:404
void SetWrongLoad(bool wrongLoad)
Set the flag if text couldn&#39;t be loadad from file.
Definition: cantext.h:182
bool m_utbbox_changed
Untransformed bounding box changed.
Definition: cantext.h:399
a2dTextFlags
Definition: cantext.h:96
struct pres_bitflags pres_bitflags
how a GDS-II object is placed relative to its XY position.
double m_XcaretinLine
X position of caret in world coordinate in line.
Definition: cantext.h:390
A list used for enumerating fonts.
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
unsigned int m_textflags
contains several text flags.
Definition: cantext.h:384
void SetCaret(int position)
set position of caret (-1 means off)
Definition: cantext.h:254
int GetAlignment() const
Get the position of the anchor point w.r.t the text.
Definition: cantext.h:304
This template class is for property ids with a known data type.
Definition: id.h:477
void SetLineSpacing(double linespace)
Set Space in world coordinates between two lines.
Definition: cantext.h:187
void SetAlignment(int alignment)
Set the position of the anchor point w.r.t the text.
Definition: cantext.h:625
wxString m_text
the text to display
Definition: cantext.h:381
wxString GetText() const
get the text of the object &#39; &#39; in string means new line
Definition: cantext.h:168
list of a2dObject&#39;s
Definition: gen.h:3157
CloneOptions
options for cloning
Definition: gen.h:1200
how a GDS-II object is placed relative to its XY position.
Definition: cantext.h:434
structure to give as parameter to member functions of a2dCanvasObject
Definition: canobj.h:252
a2dFont m_font
font
Definition: cantext.h:371
wxEditStyle
Definition: canobj.h:109
cantext.h Source File -- Sun Oct 12 2014 17:04:14 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation