From aed08178d4c156d9482b2f0d8ef38c56a18183cf Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Wed, 15 Jun 2011 12:50:17 +1000 Subject: [PATCH] Help->View Log and finally finished WGL (windows) pBuffer implementation --- Projects/CodeBlocks/SleepyHead.cbp | 2 + Projects/CodeBlocks/SleepyHead.depend | 16 ++++---- Projects/CodeBlocks/SleepyHead.layout | 58 +++++++++++++++------------ src/GUIFrame.cpp | 8 +++- src/GUIFrame.h | 1 + src/SleepyHeadApp.cpp | 2 +- src/SleepyHeadMain.cpp | 29 ++++++++++---- src/SleepyHeadMain.h | 5 ++- src/WxWizFrame.fbp | 17 +++++++- src/graphs/gl_pbuffer.cpp | 42 ++++++++++++++++--- src/graphs/graph.cpp | 16 ++++++-- src/version.h | 12 +++--- 12 files changed, 148 insertions(+), 60 deletions(-) diff --git a/Projects/CodeBlocks/SleepyHead.cbp b/Projects/CodeBlocks/SleepyHead.cbp index 5d838a35..26cfa240 100644 --- a/Projects/CodeBlocks/SleepyHead.cbp +++ b/Projects/CodeBlocks/SleepyHead.cbp @@ -119,6 +119,8 @@ + + diff --git a/Projects/CodeBlocks/SleepyHead.depend b/Projects/CodeBlocks/SleepyHead.depend index 83b196bd..42b4eadb 100644 --- a/Projects/CodeBlocks/SleepyHead.depend +++ b/Projects/CodeBlocks/SleepyHead.depend @@ -8210,12 +8210,12 @@ "wx/treebase.h" "wx/hashmap.h" -1307861037 source:/home/mark/projects/git/sleepyhead/src/GUIFrame.cpp +1308106038 source:/home/mark/projects/git/sleepyhead/src/GUIFrame.cpp "wx/wxprec.h" "GUIFrame.h" -1307995741 /home/mark/projects/git/sleepyhead/src/GUIFrame.h +1308105778 /home/mark/projects/git/sleepyhead/src/GUIFrame.h @@ -8240,7 +8240,7 @@ -1308095988 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadApp.cpp +1308099489 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadApp.cpp "wx_pch.h" @@ -8258,7 +8258,7 @@ 1307418393 /home/mark/projects/git/sleepyhead/src/SleepyHeadApp.h -1307862247 /home/mark/projects/git/sleepyhead/src/SleepyHeadMain.h +1308105875 /home/mark/projects/git/sleepyhead/src/SleepyHeadMain.h "SleepyHeadApp.h" @@ -8309,7 +8309,7 @@ 1308026543 D -1308097644 /home/mark/projects/git/sleepyhead/src/version.h +1308106147 /home/mark/projects/git/sleepyhead/src/version.h 1308003040 ent of cb2ab33... Linux wx2.8 & wx2.9 builds fixed @@ -8341,7 +8341,7 @@ "preferences.h" "tinyxml/tinyxml.h" -1308088585 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp +1308105937 source:/home/mark/projects/git/sleepyhead/src/SleepyHeadMain.cpp "wx_pch.h" "version.h" @@ -8361,7 +8361,7 @@ "sleeplib/profiles.h" "sleeplib/machine_loader.h" -1308097644 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp +1308104848 source:/home/mark/projects/git/sleepyhead/src/graphs/graph.cpp "freetype-gl/font-manager.h" "freetype-gl/texture-font.h" "graph.h" @@ -11067,7 +11067,7 @@ -1308097442 source:/home/mark/projects/git/sleepyhead/src/graphs/gl_pbuffer.cpp +1308100135 source:/home/mark/projects/git/sleepyhead/src/graphs/gl_pbuffer.cpp "gl_pbuffer.h" diff --git a/Projects/CodeBlocks/SleepyHead.layout b/Projects/CodeBlocks/SleepyHead.layout index bb3ad24a..39dfa023 100644 --- a/Projects/CodeBlocks/SleepyHead.layout +++ b/Projects/CodeBlocks/SleepyHead.layout @@ -1,17 +1,17 @@ - - + + - + - + @@ -19,47 +19,53 @@ - - + + - - + + - + - + + + + + + + - - + + - + - + - + - - + + - + - + - + - + - - + + @@ -73,10 +79,10 @@ - + - + @@ -88,7 +94,7 @@ - + diff --git a/src/GUIFrame.cpp b/src/GUIFrame.cpp index e68664f8..36c9cb35 100644 --- a/src/GUIFrame.cpp +++ b/src/GUIFrame.cpp @@ -88,9 +88,13 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons HelpMenu = new wxMenu(); wxMenuItem* HelpMenuAbout; - HelpMenuAbout = new wxMenuItem( HelpMenu, wxID_ABOUT, wxString( _("&About") ) , wxEmptyString, wxITEM_NORMAL ); + HelpMenuAbout = new wxMenuItem( HelpMenu, wxID_ABOUT, wxString( _("&About") ) + wxT('\t') + wxT("F1"), wxEmptyString, wxITEM_NORMAL ); HelpMenu->Append( HelpMenuAbout ); + wxMenuItem* HelpMenuLog; + HelpMenuLog = new wxMenuItem( HelpMenu, wxID_ANY, wxString( _("&View Log") ) + wxT('\t') + wxT("Ctrl+L"), wxEmptyString, wxITEM_NORMAL ); + HelpMenu->Append( HelpMenuLog ); + menubar->Append( HelpMenu, _("&Help") ); this->SetMenuBar( menubar ); @@ -117,6 +121,7 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons this->Connect( ViewMenuFullscreen->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnFullscreen ) ); this->Connect( ToolsMenuScreenshot->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnScreenshot ) ); this->Connect( HelpMenuAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) ); + this->Connect( HelpMenuLog->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewLog ) ); } GUIFrame::~GUIFrame() @@ -135,6 +140,7 @@ GUIFrame::~GUIFrame() this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnFullscreen ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnScreenshot ) ); this->Disconnect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) ); + this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewLog ) ); m_mgr.UnInit(); diff --git a/src/GUIFrame.h b/src/GUIFrame.h index e63c6249..6e96a7c8 100644 --- a/src/GUIFrame.h +++ b/src/GUIFrame.h @@ -70,6 +70,7 @@ class GUIFrame : public wxFrame virtual void OnFullscreen( wxCommandEvent& event ) { event.Skip(); } virtual void OnScreenshot( wxCommandEvent& event ) { event.Skip(); } virtual void OnAbout( wxCommandEvent& event ) { event.Skip(); } + virtual void OnViewLog( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/src/SleepyHeadApp.cpp b/src/SleepyHeadApp.cpp index 8d103d3f..ac00f1d1 100644 --- a/src/SleepyHeadApp.cpp +++ b/src/SleepyHeadApp.cpp @@ -41,7 +41,7 @@ bool SleepyHeadApp::OnInit() // It helps to allocate the logger on the heap.. This show work for all platforms now :) - wxLog *logger=new wxLogStderr(NULL); //new wxLogWindow(NULL,wxT("Debug"),true,false); //new wxLogStderr(NULL); // + wxLog *logger=new wxLogStderr(NULL); wxLog::SetActiveTarget(logger); //wxLog::SetLogLevel(wxLOG_Max); diff --git a/src/SleepyHeadMain.cpp b/src/SleepyHeadMain.cpp index aa0233ef..994e7535 100644 --- a/src/SleepyHeadMain.cpp +++ b/src/SleepyHeadMain.cpp @@ -81,6 +81,8 @@ SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame) wxString title=wxTheApp->GetAppName()+wxT(" v")+wxString(AutoVersion::_FULLVERSION_STRING,wxConvUTF8); SetTitle(title); + logwindow=new wxLogWindow(this,wxT("Debug"),false,false); //new wxLogStderr(NULL); // + profile=Profiles::Get(); if (!profile) { wxLogError(wxT("Couldn't get active profile")); @@ -127,7 +129,11 @@ SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame) SleepyHeadFrame::~SleepyHeadFrame() { GraphDone(); -} +} +void SleepyHeadFrame::OnViewLog(wxCommandEvent & event) +{ + logwindow->Show(); +} void SleepyHeadFrame::UpdateProfiles() { wxMenuItemList z=ProfileMenu->GetMenuItems(); @@ -322,8 +328,7 @@ void SleepyHeadFrame::OnImportSD(wxCommandEvent &event) int idx=main_auinotebook->GetPageIndex(daily); if (idx!=wxNOT_FOUND) { daily->ResetDate(); - daily->RefreshData(); - daily->Refresh(); + //daily->RefreshData(); } idx=main_auinotebook->GetPageIndex(summary); if (idx!=wxNOT_FOUND) { @@ -339,8 +344,8 @@ void SleepyHeadFrame::OnViewMenuDaily( wxCommandEvent& event ) if (idx==wxNOT_FOUND) { daily=new Daily(this,profile); main_auinotebook->AddPage(daily,_("Daily"),true,wxNullBitmap); - daily->RefreshData(); - daily->Refresh(); + //daily->ResetDate(); + //daily->RefreshData(); } else { main_auinotebook->SetSelection(idx); @@ -804,7 +809,9 @@ Daily::Daily(wxWindow *win,Profile *p) //fgSizer->Add(TAP_IAP,1,wxEXPAND); //fgSizer->Add(TAP_EAP,1,wxEXPAND); - + this->Connect(wxID_ANY, wxEVT_REFRESH_DAILY, wxCommandEventHandler(Daily::RefreshData)); + Refresh(); + Update(); ResetDate(); } Daily::~Daily() @@ -853,6 +860,8 @@ void Daily::ResetDate() { foobar_datehack=false; // this exists due to a wxGTK bug. // RefreshData(); + + Update(); wxDateTime date; if (profile->LastDay().IsValid()) { date=profile->LastDay()+wxTimeSpan::Day(); @@ -864,8 +873,14 @@ void Daily::ResetDate() wxCalendarEvent ev; ev.SetDate(date); OnCalendarMonth(ev); + RefreshData(); } void Daily::RefreshData() +{ + wxCommandEvent MyEvent( wxEVT_REFRESH_DAILY); + wxPostEvent(this, MyEvent); +} +void Daily::RefreshData(wxCommandEvent& event) { wxDateTime date=Calendar->GetDate(); date.ResetTime(); @@ -1204,7 +1219,7 @@ void Daily::RefreshData() } */ html+=wxT(""); HTMLInfo->SetPage(html); - + Refresh(); } void Daily::OnSelectSession( wxCommandEvent& event ) { diff --git a/src/SleepyHeadMain.h b/src/SleepyHeadMain.h index cd2fec52..411a09ab 100644 --- a/src/SleepyHeadMain.h +++ b/src/SleepyHeadMain.h @@ -50,6 +50,7 @@ protected: Day *dummyday; }; +const wxEventType wxEVT_REFRESH_DAILY = wxNewEventType(); class Daily:public DailyPanel { @@ -58,6 +59,7 @@ public: virtual ~Daily(); void ResetDate(); void RefreshData(); + void RefreshData(wxCommandEvent& event); // void SetProfile(Profile *p); protected: virtual void OnCalendarDay( wxCalendarEvent& event ); @@ -108,6 +110,7 @@ class SleepyHeadFrame: public GUIFrame virtual void OnAbout(wxCommandEvent& event); virtual void OnScreenshot(wxCommandEvent& event); virtual void OnFullscreen(wxCommandEvent& event); + virtual void OnViewLog(wxCommandEvent& event); virtual void DoScreenshot(wxCommandEvent& event); virtual void OnImportSD(wxCommandEvent& event); virtual void OnViewMenuDaily(wxCommandEvent& event); @@ -125,7 +128,7 @@ class SleepyHeadFrame: public GUIFrame Daily *daily; Machine *machine; Profile *profile; - + wxLogWindow *logwindow; vectorcpap_machines; int current_machine; diff --git a/src/WxWizFrame.fbp b/src/WxWizFrame.fbp index 730706ff..5af3c14b 100644 --- a/src/WxWizFrame.fbp +++ b/src/WxWizFrame.fbp @@ -409,11 +409,26 @@ &About HelpMenuAbout none - + F1 OnAbout + + + 0 + 1 + + wxID_ANY + wxITEM_NORMAL + &View Log + HelpMenuLog + none + Ctrl+L + + OnViewLog + + diff --git a/src/graphs/gl_pbuffer.cpp b/src/graphs/gl_pbuffer.cpp index f8c0e02d..98eabede 100644 --- a/src/graphs/gl_pbuffer.cpp +++ b/src/graphs/gl_pbuffer.cpp @@ -17,7 +17,7 @@ pBuffer::~pBuffer() #if defined(__WXMSW__) -/*#if !defined(wglGetExtensionsStringARB) +#if !defined(wglGetExtensionsStringARB) PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB = NULL; // WGL_ARB_pbuffer @@ -31,7 +31,7 @@ pBuffer::~pBuffer() PFNWGLGETPIXELFORMATATTRIBIVARBPROC wglGetPixelFormatAttribivARB = NULL; PFNWGLGETPIXELFORMATATTRIBFVARBPROC wglGetPixelFormatAttribfvARB = NULL; PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = NULL; -#endif */ +#endif pBufferWGL::pBufferWGL(int width, int height) @@ -61,7 +61,7 @@ pBufferWGL::pBufferWGL(int width, int height) m_width=j; m_height=j; - wxLogMessage(wxString::Format(wxT("Adjusting pBuffer width and height to %ix%i"),j,j)); + wxLogDebug(wxString::Format(wxT("Adjusting pBuffer width and height to %ix%i"),j,j)); // Create Texture glGenTextures(1, &m_texture); @@ -93,7 +93,6 @@ pBufferWGL::pBufferWGL(int width, int height) unsigned int numFormats = 0; - wxLogError(wxT("Foo2")); if (!wglChoosePixelFormatARB) { throw GLException(wxT("No wglChoosePixelFormatARB available")); } @@ -134,8 +133,6 @@ pBufferWGL::pBufferWGL(int width, int height) // compare w & h to m_width & m_height. - wxLogError(wxT("Foo7")); - wglMakeCurrent(hdc,hGlRc); glEnable(GL_TEXTURE_2D); // Enable Texture Mapping @@ -187,6 +184,39 @@ bool pBufferWGL::InitGLStuff() return false; } + if (strstr(ext, "WGL_ARB_pbuffer" ) == NULL) { + wxLogError(wxT("WGL_ARB_pbuffer extension was not found")); + return false; + } else { + wglCreatePbufferARB = (PFNWGLCREATEPBUFFERARBPROC)wglGetProcAddress("wglCreatePbufferARB"); + wglGetPbufferDCARB = (PFNWGLGETPBUFFERDCARBPROC)wglGetProcAddress("wglGetPbufferDCARB"); + wglReleasePbufferDCARB = (PFNWGLRELEASEPBUFFERDCARBPROC)wglGetProcAddress("wglReleasePbufferDCARB"); + wglDestroyPbufferARB = (PFNWGLDESTROYPBUFFERARBPROC)wglGetProcAddress("wglDestroyPbufferARB"); + wglQueryPbufferARB = (PFNWGLQUERYPBUFFERARBPROC)wglGetProcAddress("wglQueryPbufferARB"); + + if (!wglCreatePbufferARB || !wglGetPbufferDCARB || !wglReleasePbufferDCARB || + !wglDestroyPbufferARB || !wglQueryPbufferARB) { + wxLogError(wxT("One or more WGL_ARB_pbuffer functions were not found")); + return false; + } + } + + // WGL_ARB_pixel_format + if (strstr( ext, "WGL_ARB_pixel_format" ) == NULL) { + wxLogError(wxT("WGL_ARB_pixel_format extension was not found")); + return false; + } else { + wglGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribivARB"); + wglGetPixelFormatAttribfvARB = (PFNWGLGETPIXELFORMATATTRIBFVARBPROC)wglGetProcAddress("wglGetPixelFormatAttribfvARB"); + wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB"); + + if (!wglGetExtensionsStringARB || !wglCreatePbufferARB || !wglGetPbufferDCARB) { + wxLogError(wxT("One or more WGL_ARB_pixel_format functions were not found")); + return false; + } + } + + return true; } diff --git a/src/graphs/graph.cpp b/src/graphs/graph.cpp index 472802aa..fb82881c 100644 --- a/src/graphs/graph.cpp +++ b/src/graphs/graph.cpp @@ -358,6 +358,7 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl int *attribList = (int*) NULL; AGLPixelFormat aglpf=aglChoosePixelFormat(NULL,0,attribList); shared_context=new wxGLContext(aglpf,this,wxNullPalette,NULL); + // Mmmmm.. Platform incosistency with wx.. #else // Darwin joins the rest of the platforms as of wx2.9 @@ -366,6 +367,16 @@ gGraphWindow::gGraphWindow(wxWindow *parent, wxWindowID id,const wxString & titl } +#if defined(__DARWIN__) && !wxCHECK_VERSION(2,9,0) + shared_context->SetCurrent(); // It's just plain broken. :( +#else + shared_context->SetCurrent(*this); +#endif + +#if !defined(__WXMAC__) && defined (__UNIX__) + real_shared_context = glXGetCurrentContext(); +#endif + GraphInit(); // Font //texfont=::texfont; if (!title.IsEmpty()) { @@ -824,6 +835,7 @@ wxBitmap * gGraphWindow::RenderBitmap(int width,int height) #endif } catch(GLException e) { // Should log already if failed.. + pbuffer=NULL; return NULL; } } @@ -906,8 +918,6 @@ void gGraphWindow::OnPaint(wxPaintEvent& event) wxPaintDC dc(this); //#endif - - //#if wxCHECK_VERSION(2,9,0) //SetCurrent(*shared_context); //#else @@ -915,7 +925,7 @@ void gGraphWindow::OnPaint(wxPaintEvent& event) #if defined(__DARWIN__) && !wxCHECK_VERSION(2,9,0) shared_context->SetCurrent(); #else - shared_context->SetCurrent(*this); // A generic Context needs to be used.. Not one per graph window + shared_context->SetCurrent(*this); #endif //#endif diff --git a/src/version.h b/src/version.h index b645c966..607038e9 100644 --- a/src/version.h +++ b/src/version.h @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long _MAJOR = 0; static const long _MINOR = 7; - static const long _BUILD = 5861; - static const long _REVISION = 15371; + static const long _BUILD = 5910; + static const long _REVISION = 15610; //Miscellaneous Version Types - static const long _BUILDS_COUNT = 6256; - #define _RC_FILEVERSION 0,7,5861,15371 - #define _RC_FILEVERSION_STRING "0, 7, 5861, 15371\0" - static const char _FULLVERSION_STRING[] = "0.7.5861.15371"; + static const long _BUILDS_COUNT = 6353; + #define _RC_FILEVERSION 0,7,5910,15610 + #define _RC_FILEVERSION_STRING "0, 7, 5910, 15610\0" + static const char _FULLVERSION_STRING[] = "0.7.5910.15610"; //These values are to keep track of your versioning state, don't modify them. static const long _BUILD_HISTORY = 0;