Debian Codegraph @

wxcrafter/controls/rich_text_ctrl_wrapper.cpp

raw
1 #include "rich_text_ctrl_wrapper.h"
2 #include "allocator_mgr.h"
3 #include "wxgui_defs.h"
4 #include <wx/richtext/richtextctrl.h>
5
6 RichTextCtrlWrapper::RichTextCtrlWrapper()
7 : wxcWidget(ID_WXRICHTEXT)
8 {
9 PREPEND_STYLE(wxTE_PROCESS_ENTER, true);
10 PREPEND_STYLE(wxTE_PROCESS_TAB, true);
11 PREPEND_STYLE(wxTE_MULTILINE, true);
12 PREPEND_STYLE(wxTE_READONLY, false);
13 PREPEND_STYLE(wxTE_AUTO_URL, false);
14
15 EnableStyle(wxT("wxWANTS_CHARS"), true);
16
17 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CHARACTER"), wxT("wxRichTextEvent"),
18 _("Process a wxEVT_COMMAND_RICHTEXT_CHARACTER event, generated when the user presses a character "
19 "key.\nValid event functions: GetFlags, GetPosition, GetCharacter."));
20 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_DELETE"), wxT("wxRichTextEvent"),
21 _("Process a wxEVT_COMMAND_RICHTEXT_DELETE event, generated when the user presses the backspace or "
22 "delete key.\nValid event functions: GetFlags, GetPosition"));
23 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_RETURN"), wxT("wxRichTextEvent"),
24 _("Process a wxEVT_COMMAND_RICHTEXT_RETURN event, generated when the user presses the return "
25 "key.\nValid event functions: GetFlags, GetPosition."));
26 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED"), wxT("wxRichTextEvent"),
27 _("Process a wxEVT_COMMAND_RICHTEXT_STYLE_CHANGED event, generated when styling has been applied "
28 "to the control.\nValid event functions: GetPosition, GetRange."));
29 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING"), wxT("wxRichTextEvent"),
30 _("Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_CHANGING event, generated when the control's "
31 "stylesheet has changed,\nfor example the user added, edited or deleted a style.\nValid event "
32 "functions: GetRange, GetPosition."));
33 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING"), wxT("wxRichTextEvent"),
34 _("Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACING event, generated when the control's "
35 "stylesheet is about to be replaced\nfor example when a file is loaded into the control.\nValid "
36 "event functions: Veto, GetOldStyleSheet, GetNewStyleSheet."));
37 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED"), wxT("wxRichTextEvent"),
38 _("Process a wxEVT_COMMAND_RICHTEXT_STYLESHEET_REPLACED event, generated when the control's "
39 "stylesheet has been replaced\nfor example when a file is loaded into the control\nValid event "
40 "functions: GetOldStyleSheet, GetNewStyleSheet."));
41 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED"), wxT("wxRichTextEvent"),
42 _("Process a wxEVT_COMMAND_RICHTEXT_CONTENT_INSERTED event generated when content has been "
43 "inserted into the control.\nValid event functions: GetPosition, GetRange."));
44 RegisterEvent(wxT("wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED"), wxT("wxRichTextEvent"),
45 _("Process a wxEVT_COMMAND_RICHTEXT_CONTENT_DELETED event, generated when content has been deleted "
46 "from the control\nValid event functions: GetPosition, GetRange."));
47 RegisterEvent(
48 wxT("wxEVT_COMMAND_RICHTEXT_BUFFER_RESET"), wxT("wxRichTextEvent"),
49 _("Process a wxEVT_COMMAND_RICHTEXT_BUFFER_RESET event, generated when the buffer has been reset by deleting "
50 "all content.\nYou can use this to set a default style for the first new paragraph."));
51 RegisterEventCommand(wxT("wxEVT_COMMAND_TEXT_UPDATED"),
52 _("Respond to a wxEVT_COMMAND_TEXT_UPDATED event, generated when the text changes.\nNotice "
53 "that this event will be sent when the text controls contents changes\n - whether this is "
54 "due to user input or comes from the program itself\n(for example, if SetValue() is "
55 "called); see ChangeValue() for a function which does not send this event."));
56 RegisterEventCommand(wxT("wxEVT_COMMAND_TEXT_ENTER"),
57 _("Respond to a wxEVT_COMMAND_TEXT_ENTER event, generated when enter is pressed in a text "
58 "control\n(which must have wxTE_PROCESS_ENTER style for this event to be generated)."));
59
60 SetPropertyString(_("Common Settings"), "wxRichTextCtrl");
61 AddProperty(new StringProperty(PROP_VALUE, wxT("wxRichTextCtrl!"), _("Value")));
62
63 m_namePattern = wxT("m_richTextCtrl");
64 SetName(GenerateName());
65 }
66
67 RichTextCtrlWrapper::~RichTextCtrlWrapper() {}
68
69 wxcWidget* RichTextCtrlWrapper::Clone() const { return new RichTextCtrlWrapper(); }
70
71 wxString RichTextCtrlWrapper::CppCtorCode() const
72 {
73 wxString code;
74 code << CPPStandardWxCtorWithValue(wxT("wxTE_MULTILINE|wxTE_PROCESS_ENTER|wxWANTS_CHARS"));
75 return code;
76 }
77
78 void RichTextCtrlWrapper::GetIncludeFile(wxArrayString& headers) const
79 {
80 headers.Add(wxT("#include <wx/richtext/richtextctrl.h>"));
81 }
82
83 wxString RichTextCtrlWrapper::GetWxClassName() const { return wxT("wxRichTextCtrl"); }
84
85 void RichTextCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const
86 {
87 if(type == XRC_LIVE) {
88 text << XRCUnknown();
89
90 } else {
91 text << XRCPrefix() << XRCStyle() << XRCCommonAttributes() << XRCValue() << XRCSize() << XRCSuffix();
92 }
93 }