X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b68603d5359cdfa4a79fc1798d87959d5a578f51..af4d748440f97aa6e37ab44dfc3fd14b7f42868e:/src/richtext/richtextstylepage.cpp diff --git a/src/richtext/richtextstylepage.cpp b/src/richtext/richtextstylepage.cpp index ab55e26708..19fbea008b 100644 --- a/src/richtext/richtextstylepage.cpp +++ b/src/richtext/richtextstylepage.cpp @@ -1,28 +1,18 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/richtext/richtextstylepage.cpp -// Purpose: +// Purpose: // Author: Julian Smart -// Modified by: +// Modified by: // Created: 10/5/2006 11:34:55 AM // RCS-ID: $Id$ // Copyright: (c) Julian Smart // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - #if wxUSE_RICHTEXT #include "wx/richtext/richtextstylepage.h" -#ifndef WX_PRECOMP -#endif - /*! * wxRichTextStylePage type definition */ @@ -60,7 +50,7 @@ wxRichTextStylePage::wxRichTextStylePage( wxWindow* parent, wxWindowID id, const /*! * Initialise members */ - + void wxRichTextStylePage::Init() { ////@begin wxRichTextStylePage member initialisation @@ -94,7 +84,7 @@ bool wxRichTextStylePage::Create( wxWindow* parent, wxWindowID id, const wxPoint */ void wxRichTextStylePage::CreateControls() -{ +{ ////@begin wxRichTextStylePage content construction wxRichTextStylePage* itemPanel1 = this; @@ -111,42 +101,32 @@ void wxRichTextStylePage::CreateControls() itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW, 5); wxStaticText* itemStaticText6 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Style:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); - - m_styleName = new wxTextCtrl( itemPanel1, - ID_RICHTEXTSTYLEPAGE_STYLE_NAME, - wxEmptyString, - wxDefaultPosition, - wxSize(300, wxDefaultCoord), - 0 ); + itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); + + m_styleName = new wxTextCtrl( itemPanel1, ID_RICHTEXTSTYLEPAGE_STYLE_NAME, wxEmptyString, wxDefaultPosition, wxSize(300, -1), wxTE_READONLY ); + m_styleName->SetHelpText(_("The style name.")); + if (ShowToolTips()) + m_styleName->SetToolTip(_("The style name.")); itemBoxSizer5->Add(m_styleName, 0, wxGROW|wxALL, 5); wxStaticText* itemStaticText8 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Based on:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText8, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer5->Add(itemStaticText8, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); wxString* m_basedOnStrings = NULL; - m_basedOn = new wxComboBox( itemPanel1, - ID_RICHTEXTSTYLEPAGE_BASED_ON, - wxEmptyString, - wxDefaultPosition, - wxDefaultSize, - 0, - m_basedOnStrings, - wxCB_DROPDOWN ); + m_basedOn = new wxComboBox( itemPanel1, ID_RICHTEXTSTYLEPAGE_BASED_ON, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, m_basedOnStrings, wxCB_DROPDOWN ); + m_basedOn->SetHelpText(_("The style on which this style is based.")); + if (ShowToolTips()) + m_basedOn->SetToolTip(_("The style on which this style is based.")); itemBoxSizer5->Add(m_basedOn, 0, wxGROW|wxALL, 5); wxStaticText* itemStaticText10 = new wxStaticText( itemPanel1, wxID_STATIC, _("&Next style:"), wxDefaultPosition, wxDefaultSize, 0 ); - itemBoxSizer5->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); + itemBoxSizer5->Add(itemStaticText10, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5); wxString* m_nextStyleStrings = NULL; - m_nextStyle = new wxComboBox( itemPanel1, - ID_RICHTEXTSTYLEPAGE_NEXT_STYLE, - wxEmptyString, - wxDefaultPosition, - wxDefaultSize, - 0, - m_nextStyleStrings, - wxCB_DROPDOWN ); + m_nextStyle = new wxComboBox( itemPanel1, ID_RICHTEXTSTYLEPAGE_NEXT_STYLE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, m_nextStyleStrings, wxCB_DROPDOWN ); + m_nextStyle->SetHelpText(_("The default style for the next paragraph.")); + if (ShowToolTips()) + m_nextStyle->SetToolTip(_("The default style for the next paragraph.")); itemBoxSizer5->Add(m_nextStyle, 0, wxGROW|wxALL, 5); itemBoxSizer3->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); @@ -160,12 +140,15 @@ bool wxRichTextStylePage::TransferDataFromWindow() wxPanel::TransferDataFromWindow(); wxRichTextStyleDefinition* def = wxRichTextFormattingDialog::GetDialogStyleDefinition(this); - wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition); - if (paraDef) - paraDef->SetNextStyle(m_nextStyle->GetValue()); + if (def) + { + wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition); + if (paraDef) + paraDef->SetNextStyle(m_nextStyle->GetValue()); - def->SetName(m_styleName->GetValue()); - def->SetBaseStyle(m_basedOn->GetValue()); + def->SetName(m_styleName->GetValue()); + def->SetBaseStyle(m_basedOn->GetValue()); + } return true; } @@ -175,62 +158,94 @@ bool wxRichTextStylePage::TransferDataToWindow() wxPanel::TransferDataToWindow(); wxRichTextStyleDefinition* def = wxRichTextFormattingDialog::GetDialogStyleDefinition(this); - wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition); - wxRichTextStyleSheet* sheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet(); + if (def) + { + wxRichTextParagraphStyleDefinition* paraDef = wxDynamicCast(def, wxRichTextParagraphStyleDefinition); + wxRichTextListStyleDefinition* listDef = wxDynamicCast(def, wxRichTextListStyleDefinition); + // wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition); + wxRichTextStyleSheet* sheet = wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet(); - m_styleName->SetValue(def->GetName()); + m_styleName->SetValue(def->GetName()); - if (paraDef) - { - if (m_nextStyle->GetCount() == 0) + if (listDef) { - if (sheet) + if (m_nextStyle->GetCount() == 0) { - size_t i; - for (i = 0; i < sheet->GetParagraphStyleCount(); i++) + if (sheet) { - wxRichTextParagraphStyleDefinition* p = wxDynamicCast(sheet->GetParagraphStyle(i), wxRichTextParagraphStyleDefinition); - if (p) - m_nextStyle->Append(p->GetName()); + size_t i; + for (i = 0; i < sheet->GetListStyleCount(); i++) + { + wxRichTextListStyleDefinition* p = wxDynamicCast(sheet->GetListStyle(i), wxRichTextListStyleDefinition); + if (p) + m_nextStyle->Append(p->GetName()); + } } } + m_nextStyle->SetValue(listDef->GetNextStyle()); } - m_nextStyle->SetValue(paraDef->GetNextStyle()); - } - - if (m_basedOn->GetCount() == 0) - { - if (sheet) + else if (paraDef) { - if (paraDef) + if (m_nextStyle->GetCount() == 0) { - size_t i; - for (i = 0; i < sheet->GetParagraphStyleCount(); i++) + if (sheet) { - wxRichTextParagraphStyleDefinition* p = wxDynamicCast(sheet->GetParagraphStyle(i), wxRichTextParagraphStyleDefinition); - if (p) - m_basedOn->Append(p->GetName()); + size_t i; + for (i = 0; i < sheet->GetParagraphStyleCount(); i++) + { + wxRichTextParagraphStyleDefinition* p = wxDynamicCast(sheet->GetParagraphStyle(i), wxRichTextParagraphStyleDefinition); + if (p) + m_nextStyle->Append(p->GetName()); + } } } - else + m_nextStyle->SetValue(paraDef->GetNextStyle()); + } + + if (m_basedOn->GetCount() == 0) + { + if (sheet) { - size_t i; - for (i = 0; i < sheet->GetCharacterStyleCount(); i++) + if (listDef) { - wxRichTextCharacterStyleDefinition* p = wxDynamicCast(sheet->GetCharacterStyle(i), wxRichTextCharacterStyleDefinition); - if (p) - m_basedOn->Append(p->GetName()); + size_t i; + for (i = 0; i < sheet->GetListStyleCount(); i++) + { + wxRichTextListStyleDefinition* p = wxDynamicCast(sheet->GetListStyle(i), wxRichTextListStyleDefinition); + if (p) + m_basedOn->Append(p->GetName()); + } + } + else if (paraDef) + { + size_t i; + for (i = 0; i < sheet->GetParagraphStyleCount(); i++) + { + wxRichTextParagraphStyleDefinition* p = wxDynamicCast(sheet->GetParagraphStyle(i), wxRichTextParagraphStyleDefinition); + if (p) + m_basedOn->Append(p->GetName()); + } + } + else + { + size_t i; + for (i = 0; i < sheet->GetCharacterStyleCount(); i++) + { + wxRichTextCharacterStyleDefinition* p = wxDynamicCast(sheet->GetCharacterStyle(i), wxRichTextCharacterStyleDefinition); + if (p) + m_basedOn->Append(p->GetName()); + } } } } + + m_basedOn->SetValue(def->GetBaseStyle()); } - - m_basedOn->SetValue(def->GetBaseStyle()); return true; } -wxTextAttrEx* wxRichTextStylePage::GetAttributes() +wxTextAttr* wxRichTextStylePage::GetAttributes() { return wxRichTextFormattingDialog::GetDialogAttributes(this); } @@ -241,7 +256,7 @@ wxTextAttrEx* wxRichTextStylePage::GetAttributes() bool wxRichTextStylePage::ShowToolTips() { - return true; + return wxRichTextFormattingDialog::ShowToolTips(); } /*!