Public Member Functions

# wxSymbolPickerDialog Class Reference
[Common Dialogs]

`#include <wx/richtext/richtextsymboldlg.h>`

Inheritance diagram for wxSymbolPickerDialog:
[legend]

## Detailed Description

wxSymbolPickerDialog presents the user with a choice of fonts and a grid of available characters.

This modal dialog provides the application with a selected symbol and optional font selection.

Although this dialog is contained in the rich text library, the dialog is generic and can be used in other contexts.

To use the dialog, pass a default symbol specified as a string, an initial font name, and a current font name. The difference between the initial font and current font is that the initial font determines what the font control will be set to when the dialog shows - an empty string will show the selection normal text. The current font, on the other hand, is used by the dialog to determine what font to display the characters in, even when no initial font is selected. This allows the user (and application) to distinguish between inserting a symbol in the current font, and inserting it with a specified font.

When the dialog is dismissed, the application can get the selected symbol with wxSymbolPickerDialog::GetSymbol and test whether a font was specified with wxSymbolPickerDialog::UseNormalFont,fetching the specified font with wxSymbolPickerDialog::GetFontName.

Here's a realistic example, inserting the supplied symbol into a rich text control in either the current font or specified font.

            wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL);

            wxTextAttr attr;
            attr.SetFlags(wxTEXT_ATTR_FONT);
            ctrl-GetStyle(ctrl->GetInsertionPoint(), attr);

            wxString currentFontName;
            if (attr.HasFont() && attr.GetFont().IsOk())
                currentFontName = attr.GetFont().GetFaceName();

            // Don't set the initial font in the dialog (so the user is choosing
            // 'normal text', i.e. the current font) but do tell the dialog
            // what 'normal text' is.

            wxSymbolPickerDialog dlg("*", wxEmptyString, currentFontName, this);

            if (dlg.ShowModal() == wxID_OK)
            {
                if (dlg.HasSelection())
                {
                    long insertionPoint = ctrl-GetInsertionPoint();

                    ctrl->WriteText(dlg.GetSymbol());

                    if (!dlg.UseNormalFont())
                    {
                        wxFont font(attr.GetFont());
                        font.SetFaceName(dlg.GetFontName());
                        attr.SetFont(font);
                        ctrl-SetStyle(insertionPoint, insertionPoint+1, attr);
                    }
                }
            }

##

Library: wxRichText
Category: Common Dialogs

## Public Member Functions
| wxSymbolPickerDialog ()
| Default ctor.
| wxSymbolPickerDialog (const wxString &symbol, const wxString &initialFont, const wxString &normalTextFont, wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Symbols"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX)
| Constructor.
bool | Create (const wxString &symbol, const wxString &initialFont, const wxString &normalTextFont, wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &caption=wxGetTranslation("Symbols"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(400, 300), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX)
| Creation: see the constructor for details about the parameters.
wxString | GetFontName () const
| Returns the font name (the font reflected in the font list).
bool | GetFromUnicode () const
| Returns true if the dialog is showing the full range of Unicode characters.
wxString | GetNormalTextFontName () const
| Gets the font name used for displaying symbols in the absence of a selected font.
wxString | GetSymbol () const
| Gets the current or initial symbol as a string.
int | GetSymbolChar () const
| Gets the selected symbol character as an integer.
bool | HasSelection () const
| Returns true if a symbol is selected.
void | SetFontName (wxString value)
| Sets the initial/selected font name.
void | SetFromUnicode (bool value)
| Sets the internal flag indicating that the full Unicode range should be displayed.
void | SetNormalTextFontName (wxString value)
| Sets the name of the font to be used in the absence of a selected font.
void | SetSymbol (wxString value)
| Sets the symbol as a one or zero character string.
void | SetUnicodeMode (bool unicodeMode)
| Sets Unicode display mode.
bool | UseNormalFont () const
| Returns true if the has specified normal text - that is, there is no selected font.

List of all members.

## Constructor & Destructor Documentation

wxSymbolPickerDialog::wxSymbolPickerDialog | ( |  | ) |

Default ctor.

wxSymbolPickerDialog::wxSymbolPickerDialog | ( | const wxString & | symbol,
|  | const wxString & | initialFont,
|  | const wxString & | normalTextFont,
|  | wxWindow * | parent,
|  | wxWindowID | id = `wxID_ANY`,
|  | const wxString & | title = `_("Symbols")`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX` |
| ) |  |  |

Constructor.

Parameters:

  | symbol | The initial symbol to show. Specify a single character in a string, or an empty string.
  | initialFont | The initial font to be displayed in the font list. If empty, the item normal text will be selected.
  | normalTextFont | The font the dialog will use to display the symbols if the initial font is empty.
  | parent | The dialog's parent.
  | id | The dialog's identifier.
  | title | The dialog's caption.
  | pos | The dialog's position.
  | size | The dialog's size.
  | style | The dialog's window style.

## Member Function Documentation

bool wxSymbolPickerDialog::Create | ( | const wxString & | symbol,
|  | const wxString & | initialFont,
|  | const wxString & | normalTextFont,
|  | wxWindow * | parent,
|  | wxWindowID | id = `wxID_ANY`,
|  | const wxString & | caption = `wxGetTranslation("Symbols")`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxSize(400, 300)`,
|  | long | style = `wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX` |
| ) |  |  |

Creation: see the constructor for details about the parameters.

wxString wxSymbolPickerDialog::GetFontName | ( |  | ) | const

Returns the font name (the font reflected in the font list).

bool wxSymbolPickerDialog::GetFromUnicode | ( |  | ) | const

Returns true if the dialog is showing the full range of Unicode characters.

wxString wxSymbolPickerDialog::GetNormalTextFontName | ( |  | ) | const

Gets the font name used for displaying symbols in the absence of a selected font.

wxString wxSymbolPickerDialog::GetSymbol | ( |  | ) | const

Gets the current or initial symbol as a string.

int wxSymbolPickerDialog::GetSymbolChar | ( |  | ) | const

Gets the selected symbol character as an integer.

bool wxSymbolPickerDialog::HasSelection | ( |  | ) | const

Returns true if a symbol is selected.

void wxSymbolPickerDialog::SetFontName | ( | wxString | value | ) |

Sets the initial/selected font name.

void wxSymbolPickerDialog::SetFromUnicode | ( | bool | value | ) |

Sets the internal flag indicating that the full Unicode range should be displayed.

void wxSymbolPickerDialog::SetNormalTextFontName | ( | wxString | value | ) |

Sets the name of the font to be used in the absence of a selected font.

void wxSymbolPickerDialog::SetSymbol | ( | wxString | value | ) |

Sets the symbol as a one or zero character string.

void wxSymbolPickerDialog::SetUnicodeMode | ( | bool | unicodeMode | ) |

Sets Unicode display mode.

bool wxSymbolPickerDialog::UseNormalFont | ( |  | ) | const

Returns true if the has specified normal text - that is, there is no selected font.

|  | [ top ]