KiCad PCB EDA Suite
FONT_CHOICE Class Reference

#include <font_choice.h>

Inheritance diagram for FONT_CHOICE:

Public Member Functions

 FONT_CHOICE (wxWindow *aParent, int aId, wxPoint aPosition, wxSize aSize, int nChoices, wxString *aChoices, int aStyle)
 
virtual ~FONT_CHOICE ()
 
void SetFontSelection (KIFONT::FONT *aFont)
 
bool HaveFontSelection () const
 
KIFONT::FONTGetFontSelection (bool aBold, bool aItalic) const
 

Private Attributes

int m_systemFontCount
 
wxString m_notFound
 

Detailed Description

Definition at line 28 of file font_choice.h.

Constructor & Destructor Documentation

◆ FONT_CHOICE()

FONT_CHOICE::FONT_CHOICE ( wxWindow *  aParent,
int  aId,
wxPoint  aPosition,
wxSize  aSize,
int  nChoices,
wxString *  aChoices,
int  aStyle 
)

Definition at line 28 of file font_choice.cpp.

29 :
30 wxChoice( aParent, aId, aPosition, aSize, nChoices, aChoices, aStyle )
31{
32 m_systemFontCount = wxChoice::GetCount();
33
34 std::vector<std::string> fontNames;
35 Fontconfig()->ListFonts( fontNames );
36
37 wxArrayString menuList;
38
39 // The initial list of fonts has on top 1 or 2 options
40 // only "KiCad Font" (KICAD_FONT_NAME)
41 // "Default Font" and "KiCad Font" (KICAD_FONT_NAME)
42 // "KiCad Font" is also a keyword, and cannot be translated.
43 // So rebuilt the starting list
44 wxChoice::Clear();
45
46 if( m_systemFontCount > 1 )
47 Append( _( "Default Font" ) );
48
49 Append( KICAD_FONT_NAME );
50 m_systemFontCount = wxChoice::GetCount();
51
52 for( const std::string& name : fontNames )
53 menuList.Add( wxString( name ) );
54
55 menuList.Sort();
56 Append( menuList );
57
58 m_notFound = wxS( " " ) + _( "<not found>" );
59}
const char * name
Definition: DXF_plotter.cpp:56
int m_systemFontCount
Definition: font_choice.h:43
wxString m_notFound
Definition: font_choice.h:44
#define _(s)
FONTCONFIG * Fontconfig()
Definition: fontconfig.cpp:52
#define KICAD_FONT_NAME

References _, Fontconfig(), KICAD_FONT_NAME, m_notFound, m_systemFontCount, and name.

◆ ~FONT_CHOICE()

FONT_CHOICE::~FONT_CHOICE ( )
virtual

Definition at line 62 of file font_choice.cpp.

63{
64}

Member Function Documentation

◆ GetFontSelection()

KIFONT::FONT * FONT_CHOICE::GetFontSelection ( bool  aBold,
bool  aItalic 
) const

◆ HaveFontSelection()

◆ SetFontSelection()

void FONT_CHOICE::SetFontSelection ( KIFONT::FONT aFont)

Definition at line 67 of file font_choice.cpp.

68{
69 if( !aFont )
70 {
71 SetSelection( 0 );
72 }
73 else
74 {
75 SetStringSelection( aFont->GetName() );
76
77 if( GetSelection() == wxNOT_FOUND )
78 {
79 Append( aFont->GetName() + m_notFound );
80 SetSelection( GetCount() );
81 }
82 }
83
84 SendSelectionChangedEvent( wxEVT_CHOICE );
85}
const wxString & GetName() const
Definition: font.h:121

References KIFONT::FONT::GetName(), and m_notFound.

Referenced by PROPERTIES_FRAME::CopyPrmsFromItemToPanel(), DIALOG_FIELD_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LIB_TEXTBOX_PROPERTIES::TransferDataToWindow(), DIALOG_SHEET_PIN_PROPERTIES::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataToWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataToWindow().

Member Data Documentation

◆ m_notFound

wxString FONT_CHOICE::m_notFound
private

Definition at line 44 of file font_choice.h.

Referenced by FONT_CHOICE(), HaveFontSelection(), and SetFontSelection().

◆ m_systemFontCount

int FONT_CHOICE::m_systemFontCount
private

Definition at line 43 of file font_choice.h.

Referenced by FONT_CHOICE(), and GetFontSelection().


The documentation for this class was generated from the following files: