2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: richtext/richtextsymboldlg.h
|
2008-03-09 17:09:29 +00:00
|
|
|
// Purpose: interface of wxSymbolPickerDialog
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxSymbolPickerDialog
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Although this dialog is contained in the rich text library, the dialog
|
|
|
|
is generic and can be used in other contexts.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
To use the dialog, pass a default symbol specified as a string, an initial font
|
2008-10-09 16:30:57 +00:00
|
|
|
name, and a current font name. The difference between the initial font and
|
2008-03-08 13:52:38 +00:00
|
|
|
current font is that the initial font determines what the font control will be
|
2008-10-09 16:30:57 +00:00
|
|
|
set to when the dialog shows - an empty string will show the selection
|
|
|
|
@e normal text.
|
2008-03-08 13:52:38 +00:00
|
|
|
The current font, on the other hand, is used by the dialog to determine what
|
2008-10-09 16:30:57 +00:00
|
|
|
font to display the characters in, even when no initial font is selected.
|
2008-03-08 13:52:38 +00:00
|
|
|
This allows the user (and application) to distinguish between inserting a
|
|
|
|
symbol in the current font, and inserting it with a specified font.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
When the dialog is dismissed, the application can get the selected symbol
|
2008-10-09 16:30:57 +00:00
|
|
|
with wxSymbolPickerDialog::GetSymbol and test whether a font was specified
|
|
|
|
with wxSymbolPickerDialog::UseNormalFont,fetching the specified font with
|
|
|
|
wxSymbolPickerDialog::GetFontName.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Here's a realistic example, inserting the supplied symbol into a
|
|
|
|
rich text control in either the current font or specified font.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
2008-10-09 16:30:57 +00:00
|
|
|
wxRichTextCtrl* ctrl = (wxRichTextCtrl*) FindWindow(ID_RICHTEXT_CTRL);
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxTextAttr attr;
|
|
|
|
attr.SetFlags(wxTEXT_ATTR_FONT);
|
2008-10-09 16:30:57 +00:00
|
|
|
ctrl-GetStyle(ctrl->GetInsertionPoint(), attr);
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxString currentFontName;
|
2009-01-10 18:00:53 +00:00
|
|
|
if (attr.HasFont() && attr.GetFont().IsOk())
|
2008-03-08 13:52:38 +00:00
|
|
|
currentFontName = attr.GetFont().GetFaceName();
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
// 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.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2009-01-18 21:46:46 +00:00
|
|
|
wxSymbolPickerDialog dlg("*", wxEmptyString, currentFontName, this);
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
if (dlg.ShowModal() == wxID_OK)
|
|
|
|
{
|
|
|
|
if (dlg.HasSelection())
|
|
|
|
{
|
|
|
|
long insertionPoint = ctrl-GetInsertionPoint();
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-10-09 16:30:57 +00:00
|
|
|
ctrl->WriteText(dlg.GetSymbol());
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
if (!dlg.UseNormalFont())
|
|
|
|
{
|
|
|
|
wxFont font(attr.GetFont());
|
|
|
|
font.SetFaceName(dlg.GetFontName());
|
|
|
|
attr.SetFont(font);
|
|
|
|
ctrl-SetStyle(insertionPoint, insertionPoint+1, attr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxrichtext}
|
|
|
|
@category{cmndlg}
|
|
|
|
*/
|
|
|
|
class wxSymbolPickerDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-09 16:30:57 +00:00
|
|
|
Default ctor.
|
|
|
|
*/
|
|
|
|
wxSymbolPickerDialog();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param symbol
|
2008-10-09 16:30:57 +00:00
|
|
|
The initial symbol to show.
|
|
|
|
Specify a single character in a string, or an empty string.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param initialFont
|
2008-10-09 16:30:57 +00:00
|
|
|
The initial font to be displayed in the font list.
|
|
|
|
If empty, the item normal text will be selected.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param normalTextFont
|
2008-10-09 16:30:57 +00:00
|
|
|
The font the dialog will use to display the symbols if the
|
|
|
|
initial font is empty.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param parent
|
2008-03-09 12:33:59 +00:00
|
|
|
The dialog's parent.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
The dialog's identifier.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param title
|
2008-03-09 12:33:59 +00:00
|
|
|
The dialog's caption.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param pos
|
2008-03-09 12:33:59 +00:00
|
|
|
The dialog's position.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param size
|
2008-03-09 12:33:59 +00:00
|
|
|
The dialog's size.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param style
|
2008-03-09 12:33:59 +00:00
|
|
|
The dialog's window style.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxSymbolPickerDialog(const wxString& symbol,
|
|
|
|
const wxString& initialFont,
|
|
|
|
const wxString& normalTextFont,
|
|
|
|
wxWindow* parent,
|
2008-10-09 16:30:57 +00:00
|
|
|
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);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-10-09 16:30:57 +00:00
|
|
|
Creation: see @ref wxSymbolPickerDialog() "the constructor" for details about
|
2008-03-08 13:52:38 +00:00
|
|
|
the parameters.
|
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
bool Create(const wxString& symbol, const wxString& initialFont,
|
|
|
|
const wxString& normalTextFont, wxWindow* parent,
|
2008-10-09 16:30:57 +00:00
|
|
|
wxWindowID id = wxID_ANY,
|
2008-10-29 15:34:31 +00:00
|
|
|
const wxString& caption = wxGetTranslation("Symbols"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(400, 300), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the font name (the font reflected in the font list).
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetFontName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the dialog is showing the full range of Unicode characters.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool GetFromUnicode() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-10-09 16:30:57 +00:00
|
|
|
Gets the font name used for displaying symbols in the absence of a selected font.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetNormalTextFontName() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the current or initial symbol as a string.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
wxString GetSymbol() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the selected symbol character as an integer.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
int GetSymbolChar() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if a symbol is selected.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool HasSelection() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the initial/selected font name.
|
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
void SetFontName(wxString value);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the internal flag indicating that the full Unicode range should be
|
|
|
|
displayed.
|
|
|
|
*/
|
|
|
|
void SetFromUnicode(bool value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the name of the font to be used in the absence of a selected font.
|
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
void SetNormalTextFontName(wxString value);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the symbol as a one or zero character string.
|
|
|
|
*/
|
2008-10-29 15:34:31 +00:00
|
|
|
void SetSymbol(wxString value);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets Unicode display mode.
|
|
|
|
*/
|
|
|
|
void SetUnicodeMode(bool unicodeMode);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 16:30:57 +00:00
|
|
|
Returns @true if the has specified normal text - that is, there is no selected font.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool UseNormalFont() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|