Added a list style editor page to the formatting dialog.

Added a style organiser dialog, which can be used to browse
for and apply styles and can be limited to show one of
the three style types, or all three.
Added a font name cache since it's an expensive operation
that's used frequently by the rich text dialogs.
Added ability to switch off tooltips for new dialogs
(off by default). Improved the previews. Pressing tab or shift-tab
at the start of a list item now demotes or promotes the item.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42116 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-10-19 14:04:13 +00:00
parent 0c7e0a8771
commit dadd4f5523
20 changed files with 2892 additions and 259 deletions

View File

@@ -389,7 +389,6 @@ bool wxRichTextStyleSheet::operator==(const wxRichTextStyleSheet& WXUNUSED(sheet
IMPLEMENT_CLASS(wxRichTextStyleListBox, wxHtmlListBox)
BEGIN_EVENT_TABLE(wxRichTextStyleListBox, wxHtmlListBox)
EVT_LISTBOX(wxID_ANY, wxRichTextStyleListBox::OnSelect)
EVT_LEFT_DOWN(wxRichTextStyleListBox::OnLeftDown)
EVT_LEFT_DCLICK(wxRichTextStyleListBox::OnLeftDoubleClick)
EVT_IDLE(wxRichTextStyleListBox::OnIdle)
@@ -464,6 +463,8 @@ void wxRichTextStyleListBox::UpdateStyles()
{
if (GetStyleSheet())
{
SetSelection(wxNOT_FOUND);
if (GetStyleType() == wxRICHTEXT_STYLE_ALL)
SetItemCount(GetStyleSheet()->GetParagraphStyleCount()+GetStyleSheet()->GetCharacterStyleCount()+GetStyleSheet()->GetListStyleCount());
else if (GetStyleType() == wxRICHTEXT_STYLE_PARAGRAPH)
@@ -472,7 +473,14 @@ void wxRichTextStyleListBox::UpdateStyles()
SetItemCount(GetStyleSheet()->GetCharacterStyleCount());
else if (GetStyleType() == wxRICHTEXT_STYLE_LIST)
SetItemCount(GetStyleSheet()->GetListStyleCount());
Refresh();
if (GetItemCount() > 0)
{
SetSelection(0);
SendSelectedEvent();
}
}
}
@@ -531,10 +539,19 @@ wxString wxRichTextStyleListBox::CreateHTML(wxRichTextStyleDefinition* def) cons
str << wxT("<td nowrap>");
#ifdef __WXMSW__
int size = 3;
#else
int size = 4;
#endif
// Standard size is 12, say
size += (def->GetStyle().HasFont() ? def->GetStyle().GetFontSize() : 12) - 12;
int stdFontSize = 12;
int thisFontSize = ((def->GetStyle().GetFlags() & wxTEXT_ATTR_FONT_SIZE) != 0) ? def->GetStyle().GetFontSize() : stdFontSize;
if (thisFontSize < stdFontSize)
size ++;
else if (thisFontSize > stdFontSize)
size --;
str += wxT("<font");
@@ -593,18 +610,6 @@ int wxRichTextStyleListBox::ConvertTenthsMMToPixels(wxDC& dc, int units) const
return (int) pixels;
}
/// React to selection
void wxRichTextStyleListBox::OnSelect(wxCommandEvent& WXUNUSED(event))
{
#if 0
wxRichTextStyleDefinition* def = GetStyle(event.GetSelection());
if (def)
{
wxMessageBox(def->GetName());
}
#endif
}
void wxRichTextStyleListBox::OnLeftDown(wxMouseEvent& event)
{
wxVListBox::OnLeftDown(event);
@@ -726,27 +731,43 @@ bool wxRichTextStyleListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPo
wxControl::Create(parent, id, pos, size, style);
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
if (size != wxDefaultSize)
SetBestFittingSize(size);
m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER);
wxArrayString choices;
choices.Add(_("All styles"));
choices.Add(_("Paragraph styles"));
choices.Add(_("Character styles"));
choices.Add(_("List styles"));
m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
bool showSelector = ((style & wxRICHTEXTSTYLELIST_HIDE_TYPE_SELECTOR) == 0);
m_styleListBox = new wxRichTextStyleListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, showSelector ? wxSIMPLE_BORDER : wxNO_BORDER);
wxBoxSizer* boxSizer = new wxBoxSizer(wxVERTICAL);
boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5);
boxSizer->Add(m_styleChoice, 0, wxALL|wxEXPAND, 5);
SetSizer(boxSizer);
if (showSelector)
{
wxArrayString choices;
choices.Add(_("All styles"));
choices.Add(_("Paragraph styles"));
choices.Add(_("Character styles"));
choices.Add(_("List styles"));
m_styleChoice = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices);
boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 5);
boxSizer->Add(m_styleChoice, 0, wxALL|wxEXPAND, 5);
}
else
{
boxSizer->Add(m_styleListBox, 1, wxALL|wxEXPAND, 0);
}
SetSizer(boxSizer);
Layout();
m_dontUpdate = true;
int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
m_styleChoice->SetSelection(i);
if (m_styleChoice)
{
int i = StyleTypeToIndex(m_styleListBox->GetStyleType());
m_styleChoice->SetSelection(i);
}
m_dontUpdate = false;
@@ -755,6 +776,7 @@ bool wxRichTextStyleListCtrl::Create(wxWindow* parent, wxWindowID id, const wxPo
wxRichTextStyleListCtrl::~wxRichTextStyleListCtrl()
{
}
/// React to style type choice