KiCad PCB EDA Suite
dialog_lib_edit_text.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2001 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 2004-2011 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <fctsys.h>
26 #include <sch_draw_panel.h>
27 #include <lib_edit_frame.h>
28 #include <class_libentry.h>
29 #include <lib_text.h>
30 
31 #include <dialog_lib_edit_text.h>
32 
33 
35  DIALOG_LIB_EDIT_TEXT_BASE( aParent ),
36  m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
37  m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
38  m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true, 0 )
39 {
40  m_parent = aParent;
41  m_graphicText = aText;
42 
43  // Disable options for fieldedit, not existing in graphic text
44  m_visible->Show( false );
46  m_PowerComponentValues->Show( false );
47 
48  wxFont infoFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
49  infoFont.SetSymbolicSize( wxFONTSIZE_SMALL );
50  m_PowerComponentValues->SetFont( infoFont );
51 
53 
54  m_sdbSizerButtonsOK->SetDefault();
55 
56  // Now all widgets have the size fixed, call FinishDialogSettings
58 }
59 
60 
62 {
63  if( m_graphicText )
64  {
68  m_TextValue->SetValue( m_graphicText->GetText() );
69 
70  m_italic->SetValue( m_graphicText->IsItalic() );
71  m_bold->SetValue( m_graphicText->IsBold() );
72  m_CommonUnit->SetValue( m_graphicText->GetUnit() == 0 );
73  m_CommonConvert->SetValue( m_graphicText->GetConvert() == 0 );
74  m_orientChoice->SetSelection( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ ? 0 : 1 );
75 
76  switch ( m_graphicText->GetHorizJustify() )
77  {
78  case GR_TEXT_HJUSTIFY_LEFT: m_hAlignChoice->SetSelection( 0 ); break;
79  case GR_TEXT_HJUSTIFY_CENTER: m_hAlignChoice->SetSelection( 1 ); break;
80  case GR_TEXT_HJUSTIFY_RIGHT: m_hAlignChoice->SetSelection( 2 ); break;
81  }
82 
83  switch ( m_graphicText->GetVertJustify() )
84  {
85  case GR_TEXT_VJUSTIFY_TOP: m_vAlignChoice->SetSelection( 0 ); break;
86  case GR_TEXT_VJUSTIFY_CENTER: m_vAlignChoice->SetSelection( 1 ); break;
87  case GR_TEXT_VJUSTIFY_BOTTOM: m_vAlignChoice->SetSelection( 2 ); break;
88  }
89  }
90  else
91  {
93 
96  m_orientChoice->SetSelection( m_graphicText->GetTextAngle() == TEXT_ANGLE_HORIZ ? 0 : 1 );
97  }
98 
99  return true;
100 }
101 
102 
104 {
109  m_parent->m_drawSpecificUnit = !m_CommonUnit->GetValue();
110 
111  if( m_graphicText )
112  {
113  if( m_TextValue->GetValue().IsEmpty() )
114  m_graphicText->SetText( wxT( "[null]" ) );
115  else
116  m_graphicText->SetText( m_TextValue->GetValue() );
117 
121 
124  else
125  m_graphicText->SetUnit( 0 );
126 
129  else
131 
132  m_graphicText->SetItalic( m_italic->GetValue() );
133  m_graphicText->SetBold( m_bold->GetValue() );
134 
135  switch( m_hAlignChoice->GetSelection() )
136  {
140  }
141 
142  switch( m_vAlignChoice->GetSelection() )
143  {
147  }
148  }
149 
150  if( m_parent->GetDrawItem() )
152 
153  return true;
154 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:169
#define TEXT_ANGLE_HORIZ
DIALOG_LIB_EDIT_TEXT(LIB_EDIT_FRAME *aParent, LIB_TEXT *aText)
static double m_current_text_angle
Current text angle setting.
bool IsItalic() const
Definition: eda_text.h:183
void SetPosition(const wxPoint &aPosition)
#define TEXT_ANGLE_VERT
int GetUnit() const
Define a symbol library graphical text item.
Definition: lib_text.h:44
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_text.h:117
bool TransferDataToWindow() override
void SetItalic(bool isItalic)
Definition: eda_text.h:182
int GetTextWidth() const
Definition: eda_text.h:231
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
bool TransferDataFromWindow() override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:115
double GetTextAngle() const
Definition: eda_text.h:177
bool IsBold() const
Definition: eda_text.h:186
virtual int GetValue()
Function GetValue Returns the current value in Internal Units.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
Class LIB_ITEM definition.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:207
LIB_EDIT_FRAME * m_parent
static int m_textSize
The current text size setting.
Class DIALOG_LIB_EDIT_TEXT_BASE.
void SetConvert(int aConvert)
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
void SetUnit(int aUnit)
The symbol library editor main window.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:206
virtual void SetValue(int aValue)
Function SetValue Sets new value (in Internal Units) for the text field, taking care of units convers...
void SetText(const wxString &aText) override
Sets the text item string to aText.
Definition: lib_text.cpp:350
LIB_ITEM * GetDrawItem() const
Definition of class LIB_EDIT_FRAME.
bool m_drawSpecificConvert
Convert of the item currently being drawn.
bool m_drawSpecificUnit
Specify which component parts the current draw item applies to.
void SetBold(bool aBold)
Definition: eda_text.h:185
int GetConvert() const