Fixed compilation support with wxWidgets 2.9.0 (seems to work correctly besides some minor gui issues)

Originally committed to SVN as r3049.
This commit is contained in:
harukalover 2009-06-11 23:30:33 +00:00
parent 1a44455205
commit 0ff5b0194e
14 changed files with 120 additions and 0 deletions

View file

@ -232,7 +232,11 @@ AudioProvider *AudioProviderFactoryManager::GetAudioProvider(wxString filename,
wxString error; wxString error;
for (unsigned int i=0;i<list.Count();i++) { for (unsigned int i=0;i<list.Count();i++) {
try { try {
#if wxCHECK_VERSION(2,9,0)
AudioProvider *prov = GetFactory(list[i])->CreateProvider(filename.wc_str());
#else
AudioProvider *prov = GetFactory(list[i])->CreateProvider(filename.c_str()); AudioProvider *prov = GetFactory(list[i])->CreateProvider(filename.c_str());
#endif
if (prov) { if (prov) {
provider = prov; provider = prov;
break; break;

View file

@ -991,7 +991,11 @@ void BaseGrid::OnKeyPress(wxKeyEvent &event) {
if (key == WXK_LEFT || key == WXK_RIGHT) { if (key == WXK_LEFT || key == WXK_RIGHT) {
if (VideoContext::Get()->IsLoaded()) { if (VideoContext::Get()->IsLoaded()) {
parentFrame->videoBox->videoSlider->SetFocus(); parentFrame->videoBox->videoSlider->SetFocus();
#if wxCHECK_VERSION(2,9,0)
parentFrame->videoBox->videoSlider->GetEventHandler()->ProcessEvent(event);
#else
parentFrame->videoBox->videoSlider->AddPendingEvent(event); parentFrame->videoBox->videoSlider->AddPendingEvent(event);
#endif
return; return;
} }
event.Skip(); event.Skip();
@ -1082,7 +1086,11 @@ void BaseGrid::OnKeyPress(wxKeyEvent &event) {
// Other events, send to audio display // Other events, send to audio display
if (VideoContext::Get()->audio->loaded) { if (VideoContext::Get()->audio->loaded) {
#if wxCHECK_VERSION(2,9,0)
VideoContext::Get()->audio->GetEventHandler()->ProcessEvent(event);
#else
VideoContext::Get()->audio->AddPendingEvent(event); VideoContext::Get()->audio->AddPendingEvent(event);
#endif
} }
else event.Skip(); else event.Skip();
} }

View file

@ -120,7 +120,11 @@ END_EVENT_TABLE()
void DialogDetachedVideo::OnKey(wxKeyEvent &event) { void DialogDetachedVideo::OnKey(wxKeyEvent &event) {
// Send to parent... except that it doesn't work // Send to parent... except that it doesn't work
event.Skip(); event.Skip();
#if wxCHECK_VERSION(2,9,0)
GetParent()->GetEventHandler()->ProcessEvent(event);
#else
GetParent()->AddPendingEvent(event); GetParent()->AddPendingEvent(event);
#endif
} }

View file

@ -177,5 +177,9 @@ wxThread::ExitCode DialogProgressThread::Entry() {
void DialogProgressThread::Close() { void DialogProgressThread::Close() {
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
dialog->canceled = NULL; dialog->canceled = NULL;
#if wxCHECK_VERSION(2,9,0)
dialog->GetEventHandler()->ProcessEvent(event);
#else
dialog->AddPendingEvent(event); dialog->AddPendingEvent(event);
#endif
} }

View file

@ -898,7 +898,11 @@ void DialogStyleManager::OnCurrentImport(wxCommandEvent &event) {
// Get selection // Get selection
wxArrayInt selections; wxArrayInt selections;
#if wxCHECK_VERSION(2,9,0)
int res = wxGetSelectedChoices(selections,_("Choose styles to import:"),_("Import Styles"),styles);
#else
int res = wxGetMultipleChoices(selections,_("Choose styles to import:"),_("Import Styles"),styles); int res = wxGetMultipleChoices(selections,_("Choose styles to import:"),_("Import Styles"),styles);
#endif
if (res == -1 || selections.Count() == 0) return; if (res == -1 || selections.Count() == 0) return;
bool modified = false; bool modified = false;

View file

@ -124,7 +124,11 @@ wxString FFmpegSourceProvider::GetCacheFilename(const wxString& filename)
md5_state_t state; md5_state_t state;
md5_byte_t digest[16]; md5_byte_t digest[16];
md5_init(&state); md5_init(&state);
#if wxCHECK_VERSION(2,9,0)
md5_append(&state,(md5_byte_t*)toHash.wc_str(),toHash.Length()*sizeof(wxChar));
#else
md5_append(&state,(md5_byte_t*)toHash.c_str(),toHash.Length()*sizeof(wxChar)); md5_append(&state,(md5_byte_t*)toHash.c_str(),toHash.Length()*sizeof(wxChar));
#endif
md5_finish(&state,digest); md5_finish(&state,digest);
// Generate the filename // Generate the filename

View file

@ -234,7 +234,11 @@ END_EVENT_TABLE()
//////////////////////////////// ////////////////////////////////
// Redirect grid events to grid // Redirect grid events to grid
void FrameMain::OnGridEvent (wxCommandEvent &event) { void FrameMain::OnGridEvent (wxCommandEvent &event) {
#if wxCHECK_VERSION(2,9,0)
SubsBox->GetEventHandler()->ProcessEvent(event);
#else
SubsBox->AddPendingEvent(event); SubsBox->AddPendingEvent(event);
#endif
} }

View file

@ -482,7 +482,11 @@ void AegisubApp::OnMouseWheel(wxMouseEvent &event) {
wxPoint pt; wxPoint pt;
wxWindow *target = wxFindWindowAtPointer(pt); wxWindow *target = wxFindWindowAtPointer(pt);
if (frame && (target == frame->audioBox->audioDisplay || target == frame->SubsBox)) { if (frame && (target == frame->audioBox->audioDisplay || target == frame->SubsBox)) {
#if wxCHECK_VERSION(2,9,0)
if (target->IsShownOnScreen()) target->GetEventHandler()->ProcessEvent(event);
#else
if (target->IsShownOnScreen()) target->AddPendingEvent(event); if (target->IsShownOnScreen()) target->AddPendingEvent(event);
#endif
else event.Skip(); else event.Skip();
} }
else event.Skip(); else event.Skip();

View file

@ -67,6 +67,7 @@
#pragma comment(lib, "wxmsw29ud_adv.lib") #pragma comment(lib, "wxmsw29ud_adv.lib")
#pragma comment(lib, "wxmsw29ud_gl.lib") #pragma comment(lib, "wxmsw29ud_gl.lib")
#pragma comment(lib, "wxmsw29ud_stc.lib") #pragma comment(lib, "wxmsw29ud_stc.lib")
#pragma comment(lib, "wxscintillad.lib")
#pragma comment(lib, "wxbase29ud_xml.lib") #pragma comment(lib, "wxbase29ud_xml.lib")
#pragma comment(lib, "wxexpatd.lib") #pragma comment(lib, "wxexpatd.lib")
#else #else
@ -78,6 +79,7 @@
#pragma comment(lib, "wxmsw29u_adv.lib") #pragma comment(lib, "wxmsw29u_adv.lib")
#pragma comment(lib, "wxmsw29u_gl.lib") #pragma comment(lib, "wxmsw29u_gl.lib")
#pragma comment(lib, "wxmsw29u_stc.lib") #pragma comment(lib, "wxmsw29u_stc.lib")
#pragma comment(lib, "wxscintilla.lib")
#pragma comment(lib, "wxbase29u_xml.lib") #pragma comment(lib, "wxbase29u_xml.lib")
#pragma comment(lib, "wxexpat.lib") #pragma comment(lib, "wxexpat.lib")
#endif #endif

View file

@ -756,7 +756,11 @@ void SubsTextEditCtrl::OnMouseEvent(wxMouseEvent &event) {
} }
event.Skip(); event.Skip();
#if wxCHECK_VERSION(2,9,0)
GetParent()->GetEventHandler()->ProcessEvent(event);
#else
GetParent()->AddPendingEvent(event); GetParent()->AddPendingEvent(event);
#endif
} }

View file

@ -97,7 +97,11 @@ void TTXTSubtitleFormat::ReadFile(wxString filename,wxString forceEncoding) {
if (doc.GetRoot()->GetName() != _T("TextStream")) throw _T("Invalid TTXT file."); if (doc.GetRoot()->GetName() != _T("TextStream")) throw _T("Invalid TTXT file.");
// Check version // Check version
#if wxCHECK_VERSION(2,9,0)
wxString verStr = doc.GetRoot()->GetAttribute(_T("version"),_T(""));
#else
wxString verStr = doc.GetRoot()->GetPropVal(_T("version"),_T("")); wxString verStr = doc.GetRoot()->GetPropVal(_T("version"),_T(""));
#endif
version = -1; version = -1;
if (verStr == _T("1.0")) version = 0; if (verStr == _T("1.0")) version = 0;
else if (verStr == _T("1.1")) version = 1; else if (verStr == _T("1.1")) version = 1;
@ -138,7 +142,11 @@ void TTXTSubtitleFormat::ReadFile(wxString filename,wxString forceEncoding) {
// Process a dialogue line // Process a dialogue line
bool TTXTSubtitleFormat::ProcessLine(wxXmlNode *node) { bool TTXTSubtitleFormat::ProcessLine(wxXmlNode *node) {
// Get time // Get time
#if wxCHECK_VERSION(2,9,0)
wxString sampleTime = node->GetAttribute(_T("sampleTime"),_T("00:00:00.000"));
#else
wxString sampleTime = node->GetPropVal(_T("sampleTime"),_T("00:00:00.000")); wxString sampleTime = node->GetPropVal(_T("sampleTime"),_T("00:00:00.000"));
#endif
AssTime time; AssTime time;
time.ParseASS(sampleTime); time.ParseASS(sampleTime);
@ -148,7 +156,11 @@ bool TTXTSubtitleFormat::ProcessLine(wxXmlNode *node) {
// Get text // Get text
wxString text; wxString text;
#if wxCHECK_VERSION(2,9,0)
if (version == 0) text = node->GetAttribute(_T("text"),_T(""));
#else
if (version == 0) text = node->GetPropVal(_T("text"),_T("")); if (version == 0) text = node->GetPropVal(_T("text"),_T(""));
#endif
else text = node->GetNodeContent(); else text = node->GetNodeContent();
// Create line // Create line
@ -211,7 +223,11 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
// Create XML structure // Create XML structure
wxXmlDocument doc; wxXmlDocument doc;
wxXmlNode *root = new wxXmlNode(NULL,wxXML_ELEMENT_NODE,_T("TextStream")); wxXmlNode *root = new wxXmlNode(NULL,wxXML_ELEMENT_NODE,_T("TextStream"));
#if wxCHECK_VERSION(2,9,0)
root->AddAttribute(_T("version"),_T("1.1"));
#else
root->AddProperty(_T("version"),_T("1.1")); root->AddProperty(_T("version"),_T("1.1"));
#endif
doc.SetRoot(root); doc.SetRoot(root);
// Create header // Create header
@ -244,16 +260,33 @@ void TTXTSubtitleFormat::WriteFile(wxString filename,wxString encoding) {
void TTXTSubtitleFormat::WriteHeader(wxXmlNode *root) { void TTXTSubtitleFormat::WriteHeader(wxXmlNode *root) {
// Write stream header // Write stream header
wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextStreamHeader")); wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextStreamHeader"));
#if wxCHECK_VERSION(2,9,0)
node->AddAttribute(_T("width"),_T("400"));
node->AddAttribute(_T("height"),_T("60"));
node->AddAttribute(_T("layer"),_T("0"));
node->AddAttribute(_T("translation_x"),_T("0"));
node->AddAttribute(_T("translation_y"),_T("0"));
#else
node->AddProperty(_T("width"),_T("400")); node->AddProperty(_T("width"),_T("400"));
node->AddProperty(_T("height"),_T("60")); node->AddProperty(_T("height"),_T("60"));
node->AddProperty(_T("layer"),_T("0")); node->AddProperty(_T("layer"),_T("0"));
node->AddProperty(_T("translation_x"),_T("0")); node->AddProperty(_T("translation_x"),_T("0"));
node->AddProperty(_T("translation_y"),_T("0")); node->AddProperty(_T("translation_y"),_T("0"));
#endif
root->AddChild(node); root->AddChild(node);
root = node; root = node;
// Write sample description // Write sample description
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSampleDescription")); node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSampleDescription"));
#if wxCHECK_VERSION(2,9,0)
node->AddAttribute(_T("horizontalJustification"),_T("center"));
node->AddAttribute(_T("verticalJustification"),_T("bottom"));
node->AddAttribute(_T("backColor"),_T("0 0 0 0"));
node->AddAttribute(_T("verticalText"),_T("no"));
node->AddAttribute(_T("fillTextRegion"),_T("no"));
node->AddAttribute(_T("continuousKaraoke"),_T("no"));
node->AddAttribute(_T("scroll"),_T("None"));
#else
node->AddProperty(_T("horizontalJustification"),_T("center")); node->AddProperty(_T("horizontalJustification"),_T("center"));
node->AddProperty(_T("verticalJustification"),_T("bottom")); node->AddProperty(_T("verticalJustification"),_T("bottom"));
node->AddProperty(_T("backColor"),_T("0 0 0 0")); node->AddProperty(_T("backColor"),_T("0 0 0 0"));
@ -261,31 +294,51 @@ void TTXTSubtitleFormat::WriteHeader(wxXmlNode *root) {
node->AddProperty(_T("fillTextRegion"),_T("no")); node->AddProperty(_T("fillTextRegion"),_T("no"));
node->AddProperty(_T("continuousKaraoke"),_T("no")); node->AddProperty(_T("continuousKaraoke"),_T("no"));
node->AddProperty(_T("scroll"),_T("None")); node->AddProperty(_T("scroll"),_T("None"));
#endif
root->AddChild(node); root->AddChild(node);
root = node; root = node;
// Write font table // Write font table
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("FontTable")); node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("FontTable"));
wxXmlNode *subNode = new wxXmlNode(wxXML_ELEMENT_NODE,_T("FontTableEntry")); wxXmlNode *subNode = new wxXmlNode(wxXML_ELEMENT_NODE,_T("FontTableEntry"));
#if wxCHECK_VERSION(2,9,0)
subNode->AddAttribute(_T("fontName"),_T("Sans"));
subNode->AddAttribute(_T("fontID"),_T("1"));
#else
subNode->AddProperty(_T("fontName"),_T("Sans")); subNode->AddProperty(_T("fontName"),_T("Sans"));
subNode->AddProperty(_T("fontID"),_T("1")); subNode->AddProperty(_T("fontID"),_T("1"));
#endif
node->AddChild(subNode); node->AddChild(subNode);
root->AddChild(node); root->AddChild(node);
// Write text box // Write text box
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextBox")); node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextBox"));
#if wxCHECK_VERSION(2,9,0)
node->AddAttribute(_T("top"),_T("0"));
node->AddAttribute(_T("left"),_T("0"));
node->AddAttribute(_T("bottom"),_T("60"));
node->AddAttribute(_T("right"),_T("400"));
#else
node->AddProperty(_T("top"),_T("0")); node->AddProperty(_T("top"),_T("0"));
node->AddProperty(_T("left"),_T("0")); node->AddProperty(_T("left"),_T("0"));
node->AddProperty(_T("bottom"),_T("60")); node->AddProperty(_T("bottom"),_T("60"));
node->AddProperty(_T("right"),_T("400")); node->AddProperty(_T("right"),_T("400"));
#endif
root->AddChild(node); root->AddChild(node);
// Write style // Write style
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("Style")); node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("Style"));
#if wxCHECK_VERSION(2,9,0)
node->AddAttribute(_T("styles"),_T("Normal"));
node->AddAttribute(_T("fontID"),_T("1"));
node->AddAttribute(_T("fontSize"),_T("18"));
node->AddAttribute(_T("color"),_T("ff ff ff ff"));
#else
node->AddProperty(_T("styles"),_T("Normal")); node->AddProperty(_T("styles"),_T("Normal"));
node->AddProperty(_T("fontID"),_T("1")); node->AddProperty(_T("fontID"),_T("1"));
node->AddProperty(_T("fontSize"),_T("18")); node->AddProperty(_T("fontSize"),_T("18"));
node->AddProperty(_T("color"),_T("ff ff ff ff")); node->AddProperty(_T("color"),_T("ff ff ff ff"));
#endif
root->AddChild(node); root->AddChild(node);
} }
@ -297,8 +350,13 @@ void TTXTSubtitleFormat::WriteLine(wxXmlNode *root, AssDialogue *line) {
wxXmlNode *node,*subNode; wxXmlNode *node,*subNode;
if (prev && prev->End != line->Start) { if (prev && prev->End != line->Start) {
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample")); node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample"));
#if wxCHECK_VERSION(2,9,0)
node->AddAttribute(_T("sampleTime"),_T("0") + prev->End.GetASSFormated(true));
node->AddAttribute(_T("xml:space"),_T("preserve"));
#else
node->AddProperty(_T("sampleTime"),_T("0") + prev->End.GetASSFormated(true)); node->AddProperty(_T("sampleTime"),_T("0") + prev->End.GetASSFormated(true));
node->AddProperty(_T("xml:space"),_T("preserve")); node->AddProperty(_T("xml:space"),_T("preserve"));
#endif
subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),_T("")); subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),_T(""));
node->AddChild(subNode); node->AddChild(subNode);
root->AddChild(node); root->AddChild(node);
@ -306,8 +364,13 @@ void TTXTSubtitleFormat::WriteLine(wxXmlNode *root, AssDialogue *line) {
// Generate and insert node // Generate and insert node
node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample")); node = new wxXmlNode(wxXML_ELEMENT_NODE,_T("TextSample"));
#if wxCHECK_VERSION(2,9,0)
node->AddAttribute(_T("sampleTime"),_T("0") + line->Start.GetASSFormated(true));
node->AddAttribute(_T("xml:space"),_T("preserve"));
#else
node->AddProperty(_T("sampleTime"),_T("0") + line->Start.GetASSFormated(true)); node->AddProperty(_T("sampleTime"),_T("0") + line->Start.GetASSFormated(true));
node->AddProperty(_T("xml:space"),_T("preserve")); node->AddProperty(_T("xml:space"),_T("preserve"));
#endif
subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),line->Text); subNode = new wxXmlNode(wxXML_TEXT_NODE,_T(""),line->Text);
node->AddChild(subNode); node->AddChild(subNode);
root->AddChild(node); root->AddChild(node);

View file

@ -478,7 +478,10 @@ wxGLContext *VideoContext::GetGLContext(wxGLCanvas *canvas) {
// Everywhere else, we can just create a wxGLContext using the documented interface // Everywhere else, we can just create a wxGLContext using the documented interface
// and be over with it after that. // and be over with it after that.
// Also see bug #850. // Also see bug #850.
#if wxCHECK_VERSION(2,9,0)
#else
if (!glContext) glContext = canvas->GetContext(); if (!glContext) glContext = canvas->GetContext();
#endif
#ifndef __WXMAC__ #ifndef __WXMAC__
if (!glContext) glContext = new wxGLContext(canvas); if (!glContext) glContext = new wxGLContext(canvas);
#endif #endif

View file

@ -63,7 +63,11 @@
VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video,double fps) { VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video,double fps) {
// First check special case of dummy video // First check special case of dummy video
if (video.StartsWith(_T("?dummy:"))) { if (video.StartsWith(_T("?dummy:"))) {
#if wxCHECK_VERSION(2,9,0)
return new DummyVideoProvider(video.wc_str(), fps);
#else
return new DummyVideoProvider(video.c_str(), fps); return new DummyVideoProvider(video.c_str(), fps);
#endif
} }
// List of providers // List of providers
@ -77,7 +81,11 @@ VideoProvider *VideoProviderFactoryManager::GetProvider(wxString video,double fp
for (unsigned int i=0;i<list.Count();i++) { for (unsigned int i=0;i<list.Count();i++) {
try { try {
// Create provider // Create provider
#if wxCHECK_VERSION(2,9,0)
VideoProvider *provider = GetFactory(list[i])->CreateProvider(video.wc_str(),fps);
#else
VideoProvider *provider = GetFactory(list[i])->CreateProvider(video.c_str(),fps); VideoProvider *provider = GetFactory(list[i])->CreateProvider(video.c_str(),fps);
#endif
if (provider) { if (provider) {
// Cache if necessary // Cache if necessary
if (provider->GetDesiredCacheSize()) { if (provider->GetDesiredCacheSize()) {

View file

@ -370,7 +370,11 @@ void VideoSlider::OnKeyDown(wxKeyEvent &event) {
// Forward up/down to grid // Forward up/down to grid
if (key == WXK_UP || key == WXK_DOWN) { if (key == WXK_UP || key == WXK_DOWN) {
#if wxCHECK_VERSION(2,9,0)
grid->GetEventHandler()->ProcessEvent(event);
#else
grid->AddPendingEvent(event); grid->AddPendingEvent(event);
#endif
grid->SetFocus(); grid->SetFocus();
return; return;
} }