MutView.cpp
gehe zur Dokumentation dieser Datei
00001 
00037 // availlable groups: GUI, route, kernel, muwx, debug
00038 
00039 
00040 // ---------------------------------------------------------------------------
00041 // headers
00042 // --------------------------------------------------------------------------
00043 
00044 
00045 // For compilers that support precompilation, includes "wx/wx.h".
00046 #include "Defs.h"
00047 #include <wx/wxprec.h>
00048 
00049 #include "MutView.h"
00050 #include "MutFrame.h"
00051 #include "MutApp.h"
00052 #include "MutDocument.h"
00053 #include <wx/wx.h>
00054 
00055 #ifdef __BORLANDC__
00056     #pragma hdrstop
00057 #endif
00058 
00059 using mutaborGUI::MutView;
00060 IMPLEMENT_DYNAMIC_CLASS(MutView, wxView)
00061 
00062 BEGIN_EVENT_TABLE(MutView, wxView)
00063 END_EVENT_TABLE()
00064 
00065 namespace mutaborGUI {
00066 
00067         MutView::MutView()
00068         {
00069                 DEBUGLOG(docview,_T(""));
00070                 textsw = (MutEditFile *) NULL;
00071                 SetFrame(NULL);
00072         }
00073 
00074         MutView::~MutView()
00075         {
00076                 DEBUGLOG(docview,_T(""));
00077                 if (textsw) textsw->SetView(NULL);
00078                 MutFrame * f = GetMutFrame();
00079                 if (f) {
00080                         f->SetView(NULL);
00081                         f->Destroy();
00082                 }
00083         }
00084 
00090         bool MutView::OnCreate(wxDocument* doc, long flags)
00091         {
00092                 DEBUGLOG(docview,_T(""));
00093                 if (doc) {
00094                         wxASSERT(dynamic_cast<MutDocument *>(doc));
00095                 }
00096 
00097                 // create a new MutViewFrame for this view to draw into. The ChildFrame is
00098                 // told about the view, and the mainframe. It does not need to know about
00099                 // the document. The constructor of the Frame will call View::SetFrame(this)
00100                 MutFrame * frame  = new MutFrame((MutDocument *)doc, this, NULL, wxID_ANY, wxT(""));
00101                 if (!frame) return false;
00102                 wxGetApp().InitMainFrame(MutApp::EditorMenu,frame);
00103 
00104                 textsw = new MutEditFile(this,
00105                                          frame, 
00106                                          wxDefaultPosition, 
00107                                          wxDefaultSize);
00108         
00109 
00110                 if (!textsw) {
00111                         delete frame;
00112                         return false;
00113                 }
00114                 frame->SetClient(textsw,doc->GetTitle());
00115 #ifdef __X__
00116                 // X seems to require a forced resize
00117                 int x, y;
00118                 frame->GetSize(&x, &y);
00119                 frame->SetSize(wxDefaultCoord, wxDefaultCoord, x, y);
00120 #endif
00121 
00122                 frame->SetView(this);
00123                 SetFrame(frame);
00124                 frame->Show(true);      
00125                 // The doc manager maintains an active view, which is used to
00126                 // discern the active document which could be meaningful in MDI apps.
00127                 Activate(true);
00128 
00129                 //  return false to have this view deleted, supposedly.
00130                 return true;
00131         }
00132 
00133         bool MutView::OnClose(bool deleteWindow)
00134         {
00135                 if (!GetDocument()->Close())
00136                         return false;
00137     
00138                 Activate(false);
00139     
00140                 if (deleteWindow)
00141                 {
00142                         MutFrame * f = GetMutFrame();
00143                         SetFrame(NULL);
00144                         f->SetView(NULL);
00145                         f->Destroy();
00146                 }
00147                 return true;
00148         }
00149 
00150         void MutView::OnDraw(wxDC* WXUNUSED(dc))
00151         {
00152 #if 0
00153 // handled by MutEditWindow
00154                 MutDocument* pDoc = dynamic_cast<MutDocument*>(GetDocument());
00155                 // just a bit of doc-independent test code
00156                 wxSize s = GetFrame()->GetClientSize();
00157                 pdc->DrawCircle(0,0,s.GetWidth());
00158 #endif
00159         }
00160 
00161         void MutView::OnUpdate(wxView* WXUNUSED(sender), wxObject* WXUNUSED(hint))
00162         {
00163 #if 0
00164                 if(GetFrame())
00165                 {
00166                         GetFrame()->Refresh();
00167                 }
00168                 else
00169                 {
00170                         assert(false);
00171                 }
00172                 assert(dynamic_cast<MutFrame*>(GetFrame())->GetView()==this);
00173 
00174                 wxMessageBox(wxT("onupdate"), _T("onupdate"), wxOK | wxICON_INFORMATION);
00175 #endif
00176         }
00177 
00178         void MutView::OnActivateView(bool activate, 
00179                                      wxView *activeView, 
00180                                      wxView *deactiveView)
00181         {
00182                 // don't implement this function before looking at the debug output
00183                 DEBUGLOG(docview,_T("Activate: %d && %x == %x"),
00184                          activate, activeView, this);
00185         }
00186 
00187 
00188 }

Erzeugt am Sun Aug 21 2011 10:51:55 für Mutabor von doxygen 1.7.4