1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtextbackgroundpage.cpp
4 // Author: Julian Smart
6 // Created: 13/11/2010 11:17:25
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/richtext/richtextbackgroundpage.h"
13 #include "wx/richtext/richtextformatdlg.h"
20 * wxRichTextBackgroundPage type definition
23 IMPLEMENT_DYNAMIC_CLASS( wxRichTextBackgroundPage
, wxRichTextDialogPage
)
27 * wxRichTextBackgroundPage event table definition
30 BEGIN_EVENT_TABLE( wxRichTextBackgroundPage
, wxRichTextDialogPage
)
31 EVT_BUTTON(ID_RICHTEXT_BACKGROUND_COLOUR_SWATCH
, wxRichTextBackgroundPage::OnColourSwatch
)
33 ////@begin wxRichTextBackgroundPage event table entries
34 ////@end wxRichTextBackgroundPage event table entries
38 IMPLEMENT_HELP_PROVISION(wxRichTextBackgroundPage
)
41 * wxRichTextBackgroundPage constructors
44 wxRichTextBackgroundPage::wxRichTextBackgroundPage()
49 wxRichTextBackgroundPage::wxRichTextBackgroundPage( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
52 Create(parent
, id
, pos
, size
, style
);
57 * wxRichTextBackgroundPage creator
60 bool wxRichTextBackgroundPage::Create( wxWindow
* parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
)
62 ////@begin wxRichTextBackgroundPage creation
63 SetExtraStyle(wxWS_EX_VALIDATE_RECURSIVELY
);
64 wxRichTextDialogPage::Create( parent
, id
, pos
, size
, style
);
69 GetSizer()->SetSizeHints(this);
72 ////@end wxRichTextBackgroundPage creation
78 * wxRichTextBackgroundPage destructor
81 wxRichTextBackgroundPage::~wxRichTextBackgroundPage()
83 ////@begin wxRichTextBackgroundPage destruction
84 ////@end wxRichTextBackgroundPage destruction
89 * Member initialisation
92 void wxRichTextBackgroundPage::Init()
94 ////@begin wxRichTextBackgroundPage member initialisation
95 m_backgroundColourCheckBox
= NULL
;
96 m_backgroundColourSwatch
= NULL
;
97 ////@end wxRichTextBackgroundPage member initialisation
102 * Control creation for wxRichTextBackgroundPage
105 void wxRichTextBackgroundPage::CreateControls()
107 ////@begin wxRichTextBackgroundPage content construction
108 wxRichTextBackgroundPage
* itemRichTextDialogPage1
= this;
110 wxBoxSizer
* itemBoxSizer2
= new wxBoxSizer(wxVERTICAL
);
111 itemRichTextDialogPage1
->SetSizer(itemBoxSizer2
);
113 wxBoxSizer
* itemBoxSizer3
= new wxBoxSizer(wxVERTICAL
);
114 itemBoxSizer2
->Add(itemBoxSizer3
, 1, wxGROW
, 5);
116 wxBoxSizer
* itemBoxSizer4
= new wxBoxSizer(wxHORIZONTAL
);
117 itemBoxSizer3
->Add(itemBoxSizer4
, 0, wxGROW
, 5);
119 wxStaticText
* itemStaticText5
= new wxStaticText( itemRichTextDialogPage1
, wxID_STATIC
, _("Background"), wxDefaultPosition
, wxDefaultSize
, 0 );
120 itemStaticText5
->SetFont(wxFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
).GetPointSize(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
).GetFamily(), wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
).GetStyle(), wxBOLD
, false, wxT("")));
121 itemBoxSizer4
->Add(itemStaticText5
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
123 wxStaticLine
* itemStaticLine6
= new wxStaticLine( itemRichTextDialogPage1
, wxID_STATIC
, wxDefaultPosition
, wxDefaultSize
, wxLI_HORIZONTAL
);
124 itemBoxSizer4
->Add(itemStaticLine6
, 1, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
126 wxBoxSizer
* itemBoxSizer7
= new wxBoxSizer(wxHORIZONTAL
);
127 itemBoxSizer3
->Add(itemBoxSizer7
, 0, wxGROW
, 5);
129 itemBoxSizer7
->Add(5, 5, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
131 m_backgroundColourCheckBox
= new wxCheckBox( itemRichTextDialogPage1
, ID_RICHTEXT_BACKGROUND_COLOUR_CHECKBOX
, _("Background &colour:"), wxDefaultPosition
, wxDefaultSize
, 0 );
132 m_backgroundColourCheckBox
->SetValue(false);
133 m_backgroundColourCheckBox
->SetHelpText(_("Enables a background colour."));
134 if (wxRichTextBackgroundPage::ShowToolTips())
135 m_backgroundColourCheckBox
->SetToolTip(_("Enables a background colour."));
136 itemBoxSizer7
->Add(m_backgroundColourCheckBox
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
138 m_backgroundColourSwatch
= new wxRichTextColourSwatchCtrl( itemRichTextDialogPage1
, ID_RICHTEXT_BACKGROUND_COLOUR_SWATCH
, wxDefaultPosition
, wxSize(80, 20), wxBORDER_THEME
);
139 m_backgroundColourSwatch
->SetHelpText(_("The background colour."));
140 if (wxRichTextBackgroundPage::ShowToolTips())
141 m_backgroundColourSwatch
->SetToolTip(_("The background colour."));
142 itemBoxSizer7
->Add(m_backgroundColourSwatch
, 0, wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
144 ////@end wxRichTextBackgroundPage content construction
149 * Should we show tooltips?
152 wxRichTextAttr
* wxRichTextBackgroundPage::GetAttributes()
154 return wxRichTextFormattingDialog::GetDialogAttributes(this);
157 bool wxRichTextBackgroundPage::TransferDataToWindow()
159 wxRichTextAttr
* attr
= GetAttributes();
160 if (!attr
->HasBackgroundColour())
162 m_backgroundColourCheckBox
->SetValue(false);
163 m_backgroundColourSwatch
->SetColour(*wxWHITE
);
167 m_backgroundColourCheckBox
->SetValue(true);
168 m_backgroundColourSwatch
->SetColour(attr
->GetBackgroundColour());
174 bool wxRichTextBackgroundPage::TransferDataFromWindow()
176 wxRichTextAttr
* attr
= GetAttributes();
177 if (m_backgroundColourCheckBox
->GetValue())
179 attr
->SetBackgroundColour(m_backgroundColourSwatch
->GetColour());
183 attr
->SetFlags(attr
->GetFlags() & ~wxTEXT_ATTR_BACKGROUND_COLOUR
);
189 // Respond to colour swatch click
190 void wxRichTextBackgroundPage::OnColourSwatch(wxCommandEvent
& event
)
192 m_backgroundColourCheckBox
->SetValue(true);
196 bool wxRichTextBackgroundPage::ShowToolTips()
202 * Get bitmap resources
205 wxBitmap
wxRichTextBackgroundPage::GetBitmapResource( const wxString
& name
)
208 ////@begin wxRichTextBackgroundPage bitmap retrieval
211 ////@end wxRichTextBackgroundPage bitmap retrieval
218 wxIcon
wxRichTextBackgroundPage::GetIconResource( const wxString
& name
)
221 ////@begin wxRichTextBackgroundPage icon retrieval
224 ////@end wxRichTextBackgroundPage icon retrieval