1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtextstylepage.cpp
4 // Author: Julian Smart
6 // Created: 10/5/2006 11:34:55 AM
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
15 #include "../../include/wx/richtext/richtextstylepage.h"
21 * wxRichTextStylePage type definition
24 IMPLEMENT_DYNAMIC_CLASS( wxRichTextStylePage
, wxPanel
)
27 * wxRichTextStylePage event table definition
30 BEGIN_EVENT_TABLE( wxRichTextStylePage
, wxPanel
)
32 ////@begin wxRichTextStylePage event table entries
33 EVT_UPDATE_UI( ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
, wxRichTextStylePage::OnNextStyleUpdate
)
35 ////@end wxRichTextStylePage event table entries
40 * wxRichTextStylePage constructors
43 wxRichTextStylePage::wxRichTextStylePage( )
48 wxRichTextStylePage::wxRichTextStylePage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
51 Create(parent
, id
, pos
, size
, style
);
58 void wxRichTextStylePage::Init()
60 ////@begin wxRichTextStylePage member initialisation
64 ////@end wxRichTextStylePage member initialisation
68 * wxRichTextStylePage creator
71 bool wxRichTextStylePage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
73 ////@begin wxRichTextStylePage creation
74 wxPanel::Create( parent
, id
, pos
, size
, style
);
79 GetSizer()->SetSizeHints(this);
82 ////@end wxRichTextStylePage creation
87 * Control creation for wxRichTextStylePage
90 void wxRichTextStylePage::CreateControls()
92 ////@begin wxRichTextStylePage content construction
93 wxRichTextStylePage
* itemPanel1
= this;
95 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
96 itemPanel1
->SetSizer(itemBoxSizer2
);
98 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
99 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
101 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
102 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
104 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
105 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
107 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
108 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
110 m_styleName
= new wxTextCtrl( itemPanel1
, ID_RICHTEXTSTYLEPAGE_STYLE_NAME
, _T(""), wxDefaultPosition
, wxSize(300, -1), 0 );
111 itemBoxSizer5
->Add(m_styleName
, 0, wxGROW
|wxALL
, 5);
113 wxStaticText
* itemStaticText8
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Based on:"), wxDefaultPosition
, wxDefaultSize
, 0 );
114 itemBoxSizer5
->Add(itemStaticText8
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
116 wxString
* m_basedOnStrings
= NULL
;
117 m_basedOn
= new wxComboBox( itemPanel1
, ID_RICHTEXTSTYLEPAGE_BASED_ON
, _T(""), wxDefaultPosition
, wxDefaultSize
, 0, m_basedOnStrings
, wxCB_DROPDOWN
);
118 itemBoxSizer5
->Add(m_basedOn
, 0, wxGROW
|wxALL
, 5);
120 wxStaticText
* itemStaticText10
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Next style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
121 itemBoxSizer5
->Add(itemStaticText10
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
123 wxString
* m_nextStyleStrings
= NULL
;
124 m_nextStyle
= new wxComboBox( itemPanel1
, ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
, _T(""), wxDefaultPosition
, wxDefaultSize
, 0, m_nextStyleStrings
, wxCB_DROPDOWN
);
125 itemBoxSizer5
->Add(m_nextStyle
, 0, wxGROW
|wxALL
, 5);
127 itemBoxSizer3
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
129 ////@end wxRichTextStylePage content construction
132 /// Transfer data from/to window
133 bool wxRichTextStylePage::TransferDataFromWindow()
135 wxPanel::TransferDataFromWindow();
137 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
138 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
140 paraDef
->SetNextStyle(m_nextStyle
->GetValue());
142 def
->SetName(m_styleName
->GetValue());
143 def
->SetBaseStyle(m_basedOn
->GetValue());
148 bool wxRichTextStylePage::TransferDataToWindow()
150 wxPanel::TransferDataToWindow();
152 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
153 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
154 wxRichTextStyleSheet
* sheet
= wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
156 m_styleName
->SetValue(def
->GetName());
160 if (m_nextStyle
->GetCount() == 0)
165 for (i
= 0; i
< sheet
->GetParagraphStyleCount(); i
++)
167 wxRichTextParagraphStyleDefinition
* p
= wxDynamicCast(sheet
->GetParagraphStyle(i
), wxRichTextParagraphStyleDefinition
);
169 m_nextStyle
->Append(p
->GetName());
173 m_nextStyle
->SetValue(paraDef
->GetNextStyle());
176 if (m_basedOn
->GetCount() == 0)
183 for (i
= 0; i
< sheet
->GetParagraphStyleCount(); i
++)
185 wxRichTextParagraphStyleDefinition
* p
= wxDynamicCast(sheet
->GetParagraphStyle(i
), wxRichTextParagraphStyleDefinition
);
187 m_basedOn
->Append(p
->GetName());
193 for (i
= 0; i
< sheet
->GetCharacterStyleCount(); i
++)
195 wxRichTextCharacterStyleDefinition
* p
= wxDynamicCast(sheet
->GetCharacterStyle(i
), wxRichTextCharacterStyleDefinition
);
197 m_basedOn
->Append(p
->GetName());
203 m_basedOn
->SetValue(def
->GetBaseStyle());
208 wxTextAttrEx
* wxRichTextStylePage::GetAttributes()
210 return wxRichTextFormattingDialog::GetDialogAttributes(this);
214 * Should we show tooltips?
217 bool wxRichTextStylePage::ShowToolTips()
223 * Get bitmap resources
226 wxBitmap
wxRichTextStylePage::GetBitmapResource( const wxString
& name
)
229 ////@begin wxRichTextStylePage bitmap retrieval
232 ////@end wxRichTextStylePage bitmap retrieval
239 wxIcon
wxRichTextStylePage::GetIconResource( const wxString
& name
)
242 ////@begin wxRichTextStylePage icon retrieval
245 ////@end wxRichTextStylePage icon retrieval
248 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
251 void wxRichTextStylePage::OnNextStyleUpdate( wxUpdateUIEvent
& event
)
253 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
254 event
.Enable(def
->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition
)));