Beispiel #1
0
bool wxRichTextStyleListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPoint& pos,
        const wxSize& size, long style)
{
    if ((style & wxBORDER_MASK) == wxBORDER_DEFAULT)
        style |= wxBORDER_THEME;

    wxControl::Create(parent, id, pos, size, style);

    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
    if (size != wxDefaultSize)
        SetInitialSize(size);

    bool showSelector = ((style & wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR) == 0);

    wxBorder listBoxStyle;
    if (showSelector)
        listBoxStyle = wxBORDER_THEME;
    else
        listBoxStyle = wxBORDER_NONE;

    m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, listBoxStyle);

    wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL);

    if (showSelector)
    {
        wxArrayString choices;
        choices.Add(_("All styles"));
        choices.Add(_("Paragraph styles"));
        choices.Add(_("Character styles"));
        choices.Add(_("List styles"));
        choices.Add(_("Box styles"));

        m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);

        boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5);
        boxSizer->Add(m_styleChoice, 0, wxLEFT|wxRIGHT|wxBOTTOM|wxEXPAND, 5);
    }
    else
    {
        boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 0);
    }

    SetSizer(boxSizer);
    Layout();

    m_dontUpdate = true;

    if (m_styleChoice)
    {
        int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
        m_styleChoice->SetSelection(i);
    }

    m_dontUpdate = false;

    return true;
}
Beispiel #2
0
/// Set/get the style type to display
void wxRichTextStyleListCtrl::SetStyleType(wxRichTextStyleListBox::wxRichTextStyleType styleType)
{
    if (m_styleListBox)
        m_styleListBox->SetStyleType(styleType);

    m_dontUpdate = true;

    if (m_styleChoice)
    {
        int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
        m_styleChoice->SetSelection(i);
    }

    m_dontUpdate = false;
}