wxImage::Rotate corrections added; docview improvements (menus updated properly)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6159 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart 2000-02-20 12:40:08 +00:00
parent 00cf120892
commit f250631042
5 changed files with 157 additions and 11 deletions

View File

@ -255,6 +255,9 @@ utils/wxMMedia2/sample/makefile*
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*

View File

@ -316,6 +316,20 @@ public:
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);
@ -357,6 +371,9 @@ public:
// 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; }
@ -378,6 +395,9 @@ public:
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;
@ -387,6 +407,7 @@ protected:
wxView* m_currentView;
wxFileHistory* m_fileHistory;
wxString m_lastDirectory;
static wxDocManager* sm_docManager;
DECLARE_EVENT_TABLE()
};

View File

@ -562,10 +562,11 @@ void wxView::OnChangeFilename()
{
if (GetFrame() && GetDocument())
{
wxString name;
GetDocument()->GetPrintableName(name);
wxString title;
GetFrame()->SetTitle(name);
GetDocument()->GetPrintableName(title);
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_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)
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()
wxDocManager* wxDocManager::sm_docManager = (wxDocManager*) NULL;
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();
sm_docManager = this;
}
wxDocManager::~wxDocManager()
@ -719,6 +737,7 @@ wxDocManager::~wxDocManager()
Clear();
if (m_fileHistory)
delete m_fileHistory;
sm_docManager = (wxDocManager*) NULL;
}
bool wxDocManager::Clear(bool force)
@ -889,6 +908,71 @@ void wxDocManager::OnRedo(wxCommandEvent& WXUNUSED(event))
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)
@ -1093,6 +1177,24 @@ bool wxDocManager::MakeDefaultName(wxString& name)
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))
{

View 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);
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
// 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

View 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)
{
// 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) &&
(m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT))
(m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT) &&
(GetLogicalFunction() == wxCOPY))
{
wxDrawRectangle(* this, x, y, width, height);
}