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
, ID_RICHTEXTSTYLEPAGE_STYLE_NAME
, wxEmptyString
, wxDefaultPosition
, wxSize(300, -1), wxTE_READONLY
);
107 m_styleName
->SetHelpText(_("The style name."));
109 m_styleName
->SetToolTip(_("The style name."));
110 itemBoxSizer5
->Add(m_styleName
, 0, wxGROW
|wxALL
, 5);
112 wxStaticText
* itemStaticText8
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Based on:"), wxDefaultPosition
, wxDefaultSize
, 0 );
113 itemBoxSizer5
->Add(itemStaticText8
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
115 wxString
* m_basedOnStrings
= NULL
;
116 m_basedOn
= new wxComboBox( itemPanel1
, ID_RICHTEXTSTYLEPAGE_BASED_ON
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, 0, m_basedOnStrings
, wxCB_DROPDOWN
);
117 m_basedOn
->SetHelpText(_("The style on which this style is based."));
119 m_basedOn
->SetToolTip(_("The style on which this style is based."));
120 itemBoxSizer5
->Add(m_basedOn
, 0, wxGROW
|wxALL
, 5);
122 wxStaticText
* itemStaticText10
= new wxStaticText( itemPanel1
, wxID_STATIC
, _("&Next style:"), wxDefaultPosition
, wxDefaultSize
, 0 );
123 itemBoxSizer5
->Add(itemStaticText10
, 0, wxALIGN_LEFT
|wxLEFT
|wxRIGHT
|wxTOP
|wxADJUST_MINSIZE
, 5);
125 wxString
* m_nextStyleStrings
= NULL
;
126 m_nextStyle
= new wxComboBox( itemPanel1
, ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, 0, m_nextStyleStrings
, wxCB_DROPDOWN
);
127 m_nextStyle
->SetHelpText(_("The default style for the next paragraph."));
129 m_nextStyle
->SetToolTip(_("The default style for the next paragraph."));
130 itemBoxSizer5
->Add(m_nextStyle
, 0, wxGROW
|wxALL
, 5);
132 itemBoxSizer3
->Add(5, 5, 1, wxALIGN_CENTER_HORIZONTAL
|wxALL
, 5);
134 ////@end wxRichTextStylePage content construction
137 /// Transfer data from/to window
138 bool wxRichTextStylePage::TransferDataFromWindow()
140 wxPanel::TransferDataFromWindow();
142 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
145 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
147 paraDef
->SetNextStyle(m_nextStyle
->GetValue());
149 def
->SetName(m_styleName
->GetValue());
150 def
->SetBaseStyle(m_basedOn
->GetValue());
156 bool wxRichTextStylePage::TransferDataToWindow()
158 wxPanel::TransferDataToWindow();
160 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
163 wxRichTextParagraphStyleDefinition
* paraDef
= wxDynamicCast(def
, wxRichTextParagraphStyleDefinition
);
164 wxRichTextListStyleDefinition
* listDef
= wxDynamicCast(def
, wxRichTextListStyleDefinition
);
165 // wxRichTextCharacterStyleDefinition* charDef = wxDynamicCast(def, wxRichTextCharacterStyleDefinition);
166 wxRichTextStyleSheet
* sheet
= wxRichTextFormattingDialog::GetDialog(this)->GetStyleSheet();
168 m_styleName
->SetValue(def
->GetName());
172 if (m_nextStyle
->GetCount() == 0)
177 for (i
= 0; i
< sheet
->GetListStyleCount(); i
++)
179 wxRichTextListStyleDefinition
* p
= wxDynamicCast(sheet
->GetListStyle(i
), wxRichTextListStyleDefinition
);
181 m_nextStyle
->Append(p
->GetName());
185 m_nextStyle
->SetValue(listDef
->GetNextStyle());
189 if (m_nextStyle
->GetCount() == 0)
194 for (i
= 0; i
< sheet
->GetParagraphStyleCount(); i
++)
196 wxRichTextParagraphStyleDefinition
* p
= wxDynamicCast(sheet
->GetParagraphStyle(i
), wxRichTextParagraphStyleDefinition
);
198 m_nextStyle
->Append(p
->GetName());
202 m_nextStyle
->SetValue(paraDef
->GetNextStyle());
205 if (m_basedOn
->GetCount() == 0)
212 for (i
= 0; i
< sheet
->GetListStyleCount(); i
++)
214 wxRichTextListStyleDefinition
* p
= wxDynamicCast(sheet
->GetListStyle(i
), wxRichTextListStyleDefinition
);
216 m_basedOn
->Append(p
->GetName());
222 for (i
= 0; i
< sheet
->GetParagraphStyleCount(); i
++)
224 wxRichTextParagraphStyleDefinition
* p
= wxDynamicCast(sheet
->GetParagraphStyle(i
), wxRichTextParagraphStyleDefinition
);
226 m_basedOn
->Append(p
->GetName());
232 for (i
= 0; i
< sheet
->GetCharacterStyleCount(); i
++)
234 wxRichTextCharacterStyleDefinition
* p
= wxDynamicCast(sheet
->GetCharacterStyle(i
), wxRichTextCharacterStyleDefinition
);
236 m_basedOn
->Append(p
->GetName());
242 m_basedOn
->SetValue(def
->GetBaseStyle());
248 wxTextAttrEx
* wxRichTextStylePage::GetAttributes()
250 return wxRichTextFormattingDialog::GetDialogAttributes(this);
254 * Should we show tooltips?
257 bool wxRichTextStylePage::ShowToolTips()
259 return wxRichTextFormattingDialog::ShowToolTips();
263 * Get bitmap resources
266 wxBitmap
wxRichTextStylePage::GetBitmapResource( const wxString
& name
)
269 ////@begin wxRichTextStylePage bitmap retrieval
272 ////@end wxRichTextStylePage bitmap retrieval
279 wxIcon
wxRichTextStylePage::GetIconResource( const wxString
& name
)
282 ////@begin wxRichTextStylePage icon retrieval
285 ////@end wxRichTextStylePage icon retrieval
288 * wxEVT_UPDATE_UI event handler for ID_RICHTEXTSTYLEPAGE_NEXT_STYLE
291 void wxRichTextStylePage::OnNextStyleUpdate( wxUpdateUIEvent
& event
)
293 wxRichTextStyleDefinition
* def
= wxRichTextFormattingDialog::GetDialogStyleDefinition(this);
294 event
.Enable(def
->IsKindOf(CLASSINFO(wxRichTextParagraphStyleDefinition
)));
297 #endif // wxUSE_RICHTEXT