Debian Codegraph @

wxcrafter/controls/media_ctrl_wrapper.cpp

raw
1 #include "media_ctrl_wrapper.h"
2
3 #include "allocator_mgr.h"
4 #include "choice_property.h"
5 #include "wxgui_defs.h"
6 #include "wxgui_helpers.h"
7
8 #include <wx/mediactrl.h>
9
10 MediaCtrlWrapper::MediaCtrlWrapper()
11 : wxcWidget(ID_WXMEDIACTRL)
12 {
13 wxArrayString backendList;
14 backendList.Add(""); // Default empty
15 backendList.Add("wxMEDIABACKEND_DIRECTSHOW");
16 backendList.Add("wxMEDIABACKEND_MCI");
17 backendList.Add("wxMEDIABACKEND_QUICKTIME");
18 backendList.Add("wxMEDIABACKEND_GSTREAMER");
19 backendList.Add("wxMEDIABACKEND_REALPLAYER");
20 backendList.Add("wxMEDIABACKEND_WMP10");
21
22 SetPropertyString(_("Common Settings"), "wxMediaCtrl");
23 AddProperty(new ChoiceProperty(PROP_MC_BACKENDNAME, backendList, 0,
24 _("Select the media control backend, leave empty for the default")));
25 wxArrayString controls;
26 controls.Add(PROP_MC_NO_CONTROLS);
27 controls.Add(PROP_MC_DEFAULT_CONTROLS);
28 AddProperty(new ChoiceProperty(PROP_MC_CONTROLS, controls, 0, _("Show the player controls")));
29
30 RegisterEvent("wxEVT_MEDIA_LOADED", "wxMediaEvent",
31 _("Sent when a media has loaded enough data that it can start playing"));
32 RegisterEvent("wxEVT_MEDIA_STOP", "wxMediaEvent",
33 _("Sent when a media has switched to the wxMEDIASTATE_STOPPED state. You may be able to Veto this "
34 "event to prevent it from stopping, causing it to continue playing - even if it has reached that "
35 "end of the media (note that this may not have the desired effect - if you want to loop the media, "
36 "for example, catch the EVT_MEDIA_FINISHED and play there instead)."));
37 RegisterEvent("wxEVT_MEDIA_FINISHED", "wxMediaEvent",
38 _("Sent when a media has finished playing in a wxMediaCtrl."));
39 RegisterEvent("wxEVT_MEDIA_STATECHANGED", "wxMediaEvent",
40 _("Sent when a media has switched its state (from any media state)"));
41 RegisterEvent("wxEVT_MEDIA_PLAY", "wxMediaEvent",
42 _("Sent when a media has switched to the wxMEDIASTATE_PLAYING state"));
43 RegisterEvent("wxEVT_MEDIA_PAUSE", "wxMediaEvent",
44 _("Sent when a media has switched to the wxMEDIASTATE_PAUSED state"));
45
46 m_namePattern = "m_mediaCtrl";
47 SetName(GenerateName());
48 }
49
50 MediaCtrlWrapper::~MediaCtrlWrapper() {}
51
52 wxcWidget* MediaCtrlWrapper::Clone() const { return new MediaCtrlWrapper(); }
53
54 wxString MediaCtrlWrapper::CppCtorCode() const
55 {
56 wxString cppCode;
57 cppCode << GetName() << " = new " << GetRealClassName() << "();\n";
58 cppCode << GetName() << "->Create(" << GetWindowParent() << ", " << GetId() << ", "
59 << wxCrafter::WXT(PropertyString(PROP_MC_BACKENDNAME)) << ", "
60 << "wxDefaultPosition, " << SizeAsString() << ", " << StyleFlags("0") << ");\n";
61 cppCode << GetName() << "->ShowPlayerControls(" << PropertyString(PROP_MC_CONTROLS) << ");\n";
62
63 cppCode << CPPCommonAttributes();
64 return cppCode;
65 }
66
67 void MediaCtrlWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add("#include <wx/mediactrl.h>"); }
68
69 wxString MediaCtrlWrapper::GetWxClassName() const { return "wxMediaCtrl"; }
70
71 void MediaCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const
72 {
73 if(type == XRC_LIVE) {
74 text << XRCUnknown();
75
76 } else {
77 text << XRCPrefix() << XRCSize() << XRCCommonAttributes() << XRCStyle() << "<controlstyle>"
78 << PropertyString(PROP_MC_CONTROLS) << "</controlstyle>" << XRCSuffix();
79 }
80 }