]> git.saurik.com Git - wxWidgets.git/commitdiff
wxImage::Rotate corrections added; docview improvements (menus updated properly)
authorJulian Smart <julian@anthemion.co.uk>
Sun, 20 Feb 2000 12:40:08 +0000 (12:40 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sun, 20 Feb 2000 12:40:08 +0000 (12:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6159 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

distrib/msw/generic.rsp
include/wx/docview.h
src/common/docview.cpp
src/common/image.cpp
src/msw/dcmemory.cpp

index a22375a3a86d0af7b73d64e8ab878a2cdccbb2b5..cd6016310209d6a3d415c239bbac8a6bb6db761d 100644 (file)
@@ -255,6 +255,9 @@ utils/wxMMedia2/sample/makefile*
 utils/wxMMedia2/sample/*.xbm
 utils/wxMMedia2/sample/*.xpm
 utils/wxMMedia2/sample/*.txt
 utils/wxMMedia2/sample/*.xbm
 utils/wxMMedia2/sample/*.xpm
 utils/wxMMedia2/sample/*.txt
+utils/wxMMedia2/board/*.cpp
+utils/wxMMedia2/board/*.def
+utils/wxMMedia2/board/make*
 
 samples/*.txt
 samples/makefile*
 
 samples/*.txt
 samples/makefile*
index 39854b9847d52270ba4e8a9bf76b2617ffb3a623..b2c0b7dedf550d5b7a512942bfaa7b469d2ddaf8 100644 (file)
@@ -316,6 +316,20 @@ public:
     void OnUndo(wxCommandEvent& event);
     void OnRedo(wxCommandEvent& event);
 
     void OnUndo(wxCommandEvent& event);
     void OnRedo(wxCommandEvent& event);
 
+    // Handlers for UI update commands
+    void OnUpdateFileOpen(wxUpdateUIEvent& event);
+    void OnUpdateFileClose(wxUpdateUIEvent& event);
+    void OnUpdateFileRevert(wxUpdateUIEvent& event);
+    void OnUpdateFileNew(wxUpdateUIEvent& event);
+    void OnUpdateFileSave(wxUpdateUIEvent& event);
+    void OnUpdateFileSaveAs(wxUpdateUIEvent& event);
+    void OnUpdateUndo(wxUpdateUIEvent& event);
+    void OnUpdateRedo(wxUpdateUIEvent& event);
+
+    void OnUpdatePrint(wxUpdateUIEvent& event);
+    void OnUpdatePrintSetup(wxUpdateUIEvent& event);
+    void OnUpdatePreview(wxUpdateUIEvent& event);
+
     // Extend event processing to search the view's event table
     virtual bool ProcessEvent(wxEvent& event);
 
     // Extend event processing to search the view's event table
     virtual bool ProcessEvent(wxEvent& event);
 
@@ -357,6 +371,9 @@ public:
     // Make a default document name
     virtual bool MakeDefaultName(wxString& buf);
 
     // Make a default document name
     virtual bool MakeDefaultName(wxString& buf);
 
+    // Make a frame title (override this to do something different)
+    virtual wxString MakeFrameTitle(wxDocument* doc);
+
     virtual wxFileHistory *OnCreateFileHistory();
     virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
 
     virtual wxFileHistory *OnCreateFileHistory();
     virtual wxFileHistory *GetFileHistory() const { return m_fileHistory; }
 
@@ -378,6 +395,9 @@ public:
     inline wxString GetLastDirectory() const { return m_lastDirectory; }
     inline void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
 
     inline wxString GetLastDirectory() const { return m_lastDirectory; }
     inline void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; }
 
+    // Get the current document manager
+    static wxDocManager* GetDocumentManager() { return sm_docManager; }
+
 protected:
     long              m_flags;
     int               m_defaultDocumentNameCounter;
 protected:
     long              m_flags;
     int               m_defaultDocumentNameCounter;
@@ -387,6 +407,7 @@ protected:
     wxView*           m_currentView;
     wxFileHistory*    m_fileHistory;
     wxString          m_lastDirectory;
     wxView*           m_currentView;
     wxFileHistory*    m_fileHistory;
     wxString          m_lastDirectory;
+    static wxDocManager* sm_docManager;
 
     DECLARE_EVENT_TABLE()
 };
 
     DECLARE_EVENT_TABLE()
 };
index 5f8f8967915fe81ecfd6603ab825a7ad53e6ab82..bcd9d3de2fa0b8d7a393d43bc43044129ccbf1f2 100644 (file)
@@ -562,10 +562,11 @@ void wxView::OnChangeFilename()
 {
     if (GetFrame() && GetDocument())
     {
 {
     if (GetFrame() && GetDocument())
     {
-        wxString name;
-        GetDocument()->GetPrintableName(name);
+        wxString title;
+
+        GetDocument()->GetPrintableName(title);
 
 
-        GetFrame()->SetTitle(name);
+        GetFrame()->SetTitle(title);
     }
 }
 
     }
 }
 
@@ -696,13 +697,29 @@ BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler)
     EVT_MENU(wxID_SAVEAS, wxDocManager::OnFileSaveAs)
     EVT_MENU(wxID_UNDO, wxDocManager::OnUndo)
     EVT_MENU(wxID_REDO, wxDocManager::OnRedo)
     EVT_MENU(wxID_SAVEAS, wxDocManager::OnFileSaveAs)
     EVT_MENU(wxID_UNDO, wxDocManager::OnUndo)
     EVT_MENU(wxID_REDO, wxDocManager::OnRedo)
+
+    EVT_UPDATE_UI(wxID_OPEN, wxDocManager::OnUpdateFileOpen)
+    EVT_UPDATE_UI(wxID_CLOSE, wxDocManager::OnUpdateFileClose)
+    EVT_UPDATE_UI(wxID_REVERT, wxDocManager::OnUpdateFileRevert)
+    EVT_UPDATE_UI(wxID_NEW, wxDocManager::OnUpdateFileNew)
+    EVT_UPDATE_UI(wxID_SAVE, wxDocManager::OnUpdateFileSave)
+    EVT_UPDATE_UI(wxID_SAVEAS, wxDocManager::OnUpdateFileSaveAs)
+    EVT_UPDATE_UI(wxID_UNDO, wxDocManager::OnUpdateUndo)
+    EVT_UPDATE_UI(wxID_REDO, wxDocManager::OnUpdateRedo)
+
 #if wxUSE_PRINTING_ARCHITECTURE
     EVT_MENU(wxID_PRINT, wxDocManager::OnPrint)
     EVT_MENU(wxID_PRINT_SETUP, wxDocManager::OnPrintSetup)
     EVT_MENU(wxID_PREVIEW, wxDocManager::OnPreview)
 #if wxUSE_PRINTING_ARCHITECTURE
     EVT_MENU(wxID_PRINT, wxDocManager::OnPrint)
     EVT_MENU(wxID_PRINT_SETUP, wxDocManager::OnPrintSetup)
     EVT_MENU(wxID_PREVIEW, wxDocManager::OnPreview)
+
+    EVT_UPDATE_UI(wxID_PRINT, wxDocManager::OnUpdatePrint)
+    EVT_UPDATE_UI(wxID_PRINT_SETUP, wxDocManager::OnUpdatePrintSetup)
+    EVT_UPDATE_UI(wxID_PREVIEW, wxDocManager::OnUpdatePreview)
 #endif
 END_EVENT_TABLE()
 
 #endif
 END_EVENT_TABLE()
 
+wxDocManager* wxDocManager::sm_docManager = (wxDocManager*) NULL;
+
 wxDocManager::wxDocManager(long flags, bool initialize)
 {
     m_defaultDocumentNameCounter = 1;
 wxDocManager::wxDocManager(long flags, bool initialize)
 {
     m_defaultDocumentNameCounter = 1;
@@ -712,6 +729,7 @@ wxDocManager::wxDocManager(long flags, bool initialize)
     m_fileHistory = (wxFileHistory *) NULL;
     if (initialize)
         Initialize();
     m_fileHistory = (wxFileHistory *) NULL;
     if (initialize)
         Initialize();
+    sm_docManager = this;
 }
 
 wxDocManager::~wxDocManager()
 }
 
 wxDocManager::~wxDocManager()
@@ -719,6 +737,7 @@ wxDocManager::~wxDocManager()
     Clear();
     if (m_fileHistory)
         delete m_fileHistory;
     Clear();
     if (m_fileHistory)
         delete m_fileHistory;
+    sm_docManager = (wxDocManager*) NULL;
 }
 
 bool wxDocManager::Clear(bool force)
 }
 
 bool wxDocManager::Clear(bool force)
@@ -889,6 +908,71 @@ void wxDocManager::OnRedo(wxCommandEvent& WXUNUSED(event))
         doc->GetCommandProcessor()->Redo();
 }
 
         doc->GetCommandProcessor()->Redo();
 }
 
+// Handlers for UI update commands
+
+void wxDocManager::OnUpdateFileOpen(wxUpdateUIEvent& event)
+{
+    event.Enable( TRUE );
+}
+
+void wxDocManager::OnUpdateFileClose(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdateFileRevert(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdateFileNew(wxUpdateUIEvent& event)
+{
+    event.Enable( TRUE );
+}
+
+void wxDocManager::OnUpdateFileSave(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdateFileSaveAs(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdateUndo(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanUndo()) );
+}
+
+void wxDocManager::OnUpdateRedo(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc && doc->GetCommandProcessor() && doc->GetCommandProcessor()->CanRedo()) );
+}
+
+void wxDocManager::OnUpdatePrint(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc != (wxDocument*) NULL) );
+}
+
+void wxDocManager::OnUpdatePrintSetup(wxUpdateUIEvent& event)
+{
+    event.Enable( TRUE );
+}
+
+void wxDocManager::OnUpdatePreview(wxUpdateUIEvent& event)
+{
+    wxDocument *doc = GetCurrentDocument();
+    event.Enable( (doc != (wxDocument*) NULL) );
+}
+
 wxView *wxDocManager::GetCurrentView() const
 {
     if (m_currentView)
 wxView *wxDocManager::GetCurrentView() const
 {
     if (m_currentView)
@@ -1093,6 +1177,24 @@ bool wxDocManager::MakeDefaultName(wxString& name)
     return TRUE;
 }
 
     return TRUE;
 }
 
+// Make a frame title (override this to do something different)
+// If docName is empty, a document is not currently active.
+wxString wxDocManager::MakeFrameTitle(wxDocument* doc)
+{
+    wxString appName = wxTheApp->GetAppName();
+    wxString title;
+    if (!doc)
+        title = appName;
+    else
+    {
+        wxString docName;
+        doc->GetPrintableName(docName);
+        title = docName + wxString(_(" - ")) + appName;
+    }
+    return title;
+}
+
+
 // Not yet implemented
 wxDocTemplate *wxDocManager::MatchTemplate(const wxString& WXUNUSED(path))
 {
 // Not yet implemented
 wxDocTemplate *wxDocManager::MatchTemplate(const wxString& WXUNUSED(path))
 {
index d7a1ea7cd45ec2f40db93069049db0ebaec010b0..908e1f89a3e9d3171c714cd197b92bf40b03cfe5 100644 (file)
@@ -2789,17 +2789,35 @@ wxImage wxImage::Rotate(double angle, const wxPoint & centre_of_rotation, bool i
             {
                 wxRealPoint src = rotated_point (x + x1, y + y1, cos_angle, -sin_angle, p0);
 
             {
                 wxRealPoint src = rotated_point (x + x1, y + y1, cos_angle, -sin_angle, p0);
 
-                if (0 < src.x && src.x < GetWidth() - 1 &&
-                    0 < src.y && src.y < GetHeight() - 1)
+                if (-0.25 < src.x && src.x < GetWidth() - 0.75 &&
+                    -0.25 < src.y && src.y < GetHeight() - 0.75)
                 {
                     // interpolate using the 4 enclosing grid-points.  Those
                     // points can be obtained using floor and ceiling of the
                     // exact coordinates of the point
                 {
                     // interpolate using the 4 enclosing grid-points.  Those
                     // points can be obtained using floor and ceiling of the
                     // exact coordinates of the point
+                        // C.M. 2000-02-17:  when the point is near the border, special care is required.
 
 
-                    const int x1 = wxCint(floor(src.x));
-                    const int y1 = wxCint(floor(src.y));
-                    const int x2 = wxCint(ceil(src.x));
-                    const int y2 = wxCint(ceil(src.y));
+                    int x1, y1, x2, y2;
+
+                    if (0 < src.x && src.x < GetWidth() - 1)
+                    {
+                        x1 = wxCint(floor(src.x));
+                        x2 = wxCint(ceil(src.x));
+                    }
+                    else    // else means that x is near one of the borders (0 or width-1)
+                    {
+                        x1 = x2 = wxCint (src.x);
+                    }
+
+                    if (0 < src.y && src.y < GetHeight() - 1)
+                    {
+                        y1 = wxCint(floor(src.y));
+                        y2 = wxCint(ceil(src.y));
+                    }
+                    else
+                    {
+                        y1 = y2 = wxCint (src.y);
+                    }
 
                     // get four points and the distances (square of the distance,
                     // for efficiency reasons) for the interpolation formula
 
                     // get four points and the distances (square of the distance,
                     // for efficiency reasons) for the interpolation formula
index 64ff3c778f42183b6224a59a5f5f90d3564c0e29..f79d33b26eb8bc25392064b5aa6c78fd639c8b82 100644 (file)
@@ -169,11 +169,13 @@ static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoo
 
 void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 {
 
 void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 {
-// Set this to 0 to demonstrate strange rectangle behaviour in the Drawing sample.
+    // Set this to 1 to work around an apparent video driver bug
+    // (visible with e.g. 70x70 rectangle on a memory DC; see Drawing sample)
 #if 0
     if (m_brush.Ok() && m_pen.Ok() &&
         (m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) &&
 #if 0
     if (m_brush.Ok() && m_pen.Ok() &&
         (m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) &&
-        (m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT))
+        (m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT) &&
+        (GetLogicalFunction() == wxCOPY))
     {
         wxDrawRectangle(* this, x, y, width, height);
     }
     {
         wxDrawRectangle(* this, x, y, width, height);
     }