1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/richtext/richtextstylepage.cpp
4 // Author: Julian Smart
6 // Created: 10/5/2006 11:34:55 AM
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/richtext/richtextstylepage.h"
17 * wxRichTextStylePage type definition
20 IMPLEMENT_DYNAMIC_CLASS( wxRichTextStylePage
, wxPanel
)
23 * wxRichTextStylePage event table definition
26 BEGIN_EVENT_TABLE( wxRichTextStylePage
, wxPanel
)
28 ////@begin wxRichTextStylePage event table entries
29 EVT_UPDATE_UI( ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
, wxRichTextStylePage::OnNextStyleUpdate
)
31 ////@end wxRichTextStylePage event table entries
36 * wxRichTextStylePage constructors
39 wxRichTextStylePage::wxRichTextStylePage( )
44 wxRichTextStylePage::wxRichTextStylePage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
47 Create(parent
, id
, pos
, size
, style
);
54 void wxRichTextStylePage::Init()
56 ////@begin wxRichTextStylePage member initialisation
60 ////@end wxRichTextStylePage member initialisation
64 * wxRichTextStylePage creator
67 bool wxRichTextStylePage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
69 ////@begin wxRichTextStylePage creation
70 wxPanel::Create( parent
, id
, pos
, size
, style
);
75 GetSizer()->SetSizeHints(this);
78 ////@end wxRichTextStylePage creation
83 * Control creation for wxRichTextStylePage
86 void wxRichTextStylePage::CreateControls()
88 ////@begin wxRichTextStylePage content construction
89 wxRichTextStylePage
* itemPanel1
= this;
91 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
92 itemPanel1
->SetSizer(itemBoxSizer2
);
94 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
95 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
|wxALL
, 5);
97 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
98 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxALIGN_CENTER_HORIZONTAL
, 5);
100 wxBoxSizer
* itemBoxSizer5
= new wxBoxSizer(wxVERTICAL
);
101 itemBoxSizer4
->Add(itemBoxSizer5
, 0, wxGROW
, 5);
103 wxStaticText
* itemStaticText6
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
104 itemBoxSizer5
->Add(itemStaticText6
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
106 m_styleName
= new wxTextCtrl( itemPanel1
,
107 ID_RICHTEXTSTYLEPAGE_STYLE_NAME
,
110 wxSize(300, wxDefaultCoord
),
112 itemBoxSizer5
->Add(m_styleName
, 0, wxGROW
|wxALL
, 5);
114 wxStaticText
* itemStaticText8
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Based on:"), wxDefaultPosition
, wxDefaultSize
, 0 );
115 itemBoxSizer5
->Add(itemStaticText8
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
117 wxString
* m_basedOnStrings
= NULL
;
118 m_basedOn
= new wxComboBox( itemPanel1
,
119 ID_RICHTEXTSTYLEPAGE_BASED_ON
,
126 itemBoxSizer5
->Add(m_basedOn
, 0, wxGROW
|wxALL
, 5);
128 wxStaticText
* itemStaticText10
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Next style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
129 itemBoxSizer5
->Add(itemStaticText10
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
131 wxString
* m_nextStyleStrings
= NULL
;
132 m_nextStyle
= new wxComboBox( itemPanel1
,
133 ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
,
140 itemBoxSizer5
->Add(m_nextStyle
, 0, wxGROW
|wxALL
, 5);
142 itemBoxSizer3
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
144 ////@end wxRichTextStylePage content construction
147 /// Transfer data from/to window
148 bool wxRichTextStylePage::TransferDataFromWindow()
150 wxPanel::TransferDataFromWindow();
152 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
153 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
155 paraDef
->SetNextStyle(m_nextStyle
->GetValue());
157 def
->SetName(m_styleName
->GetValue());
158 def
->SetBaseStyle(m_basedOn
->GetValue());
163 bool wxRichTextStylePage::TransferDataToWindow()
165 wxPanel::TransferDataToWindow();
167 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
168 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
169 wxRichTextStyleSheet
* sheet
= wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
171 m_styleName
->SetValue(def
->GetName());
175 if (m_nextStyle
->GetCount() == 0)
180 for (i
= 0; i
< sheet
->GetParagraphStyleCount(); i
++)
182 wxRichTextParagraphStyleDefinition
* p
= wxDynamicCast(sheet
->GetParagraphStyle(i
), wxRichTextParagraphStyleDefinition
);
184 m_nextStyle
->Append(p
->GetName());
188 m_nextStyle
->SetValue(paraDef
->GetNextStyle());
191 if (m_basedOn
->GetCount() == 0)
198 for (i
= 0; i
< sheet
->GetParagraphStyleCount(); i
++)
200 wxRichTextParagraphStyleDefinition
* p
= wxDynamicCast(sheet
->GetParagraphStyle(i
), wxRichTextParagraphStyleDefinition
);
202 m_basedOn
->Append(p
->GetName());
208 for (i
= 0; i
< sheet
->GetCharacterStyleCount(); i
++)
210 wxRichTextCharacterStyleDefinition
* p
= wxDynamicCast(sheet
->GetCharacterStyle(i
), wxRichTextCharacterStyleDefinition
);
212 m_basedOn
->Append(p
->GetName());
218 m_basedOn
->SetValue(def
->GetBaseStyle());
223 wxTextAttrEx
* wxRichTextStylePage::GetAttributes()
225 return wxRichTextFormattingDialog::GetDialogAttributes(this);
229 * Should we show tooltips?
232 bool wxRichTextStylePage::ShowToolTips()
238 * Get bitmap resources
241 wxBitmap
wxRichTextStylePage::GetBitmapResource( const wxString
& name
)
244 ////@begin wxRichTextStylePage bitmap retrieval
247 ////@end wxRichTextStylePage bitmap retrieval
254 wxIcon
wxRichTextStylePage::GetIconResource( const wxString
& name
)
257 ////@begin wxRichTextStylePage icon retrieval
260 ////@end wxRichTextStylePage icon retrieval
263 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
266 void wxRichTextStylePage::OnNextStyleUpdate( wxUpdateUIEvent
& event
)
268 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
269 event
.Enable(def
->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition
)));
272 #endif // wxUSE_RICHTEXT