From b2c36cf7478e5c8091b5a1c31954557861df6793 Mon Sep 17 00:00:00 2001 From: Perry Rapp Date: Sun, 20 Apr 2003 20:07:11 +0000 Subject: [PATCH] Add files that should have gone in with patch 724309 --- Src/WaitStatusCursor.cpp | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ Src/WaitStatusCursor.h | 50 +++++++++++++++++++++++++++++++++ Src/readme.txt | 2 ++ 3 files changed, 124 insertions(+) create mode 100644 Src/WaitStatusCursor.cpp create mode 100644 Src/WaitStatusCursor.h diff --git a/Src/WaitStatusCursor.cpp b/Src/WaitStatusCursor.cpp new file mode 100644 index 000000000..1b4468192 --- /dev/null +++ b/Src/WaitStatusCursor.cpp @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////// +// WaitStatusCursur +// Copyright (C) 2003 Perry Rapp +// Author: Perry Rapp +// +// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. +// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +// You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// +///////////////////////////////////////////////////////////////////////////// +// WaitStatusCursur.cpp: implementation of the WaitStatusCursur class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "WaitStatusCursor.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +IStatusDisplay * WaitStatusCursor::c_piStatusDisplay = 0; + + +void WaitStatusCursor::SetStatusDisplay(IStatusDisplay * piStatusDisplay) +{ + c_piStatusDisplay = piStatusDisplay; +} + + +WaitStatusCursor::WaitStatusCursor(LPCTSTR fmt, ...) +: m_ended(false) +{ + va_list args; + va_start(args, fmt); + m_msg.FormatV(fmt, args); + va_end(args); + if (c_piStatusDisplay) + m_oldmsg = c_piStatusDisplay->BeginStatus(m_msg); +} + +WaitStatusCursor::~WaitStatusCursor() +{ + End(); +} + +void WaitStatusCursor::End() +{ + if (!m_ended) + { + m_ended = true; + if (c_piStatusDisplay) + c_piStatusDisplay->EndStatus(m_msg, m_oldmsg); + m_msg = _T(""); + m_oldmsg = _T(""); + } +} + +void WaitStatusCursor::ChangeMsg(LPCTSTR fmt, ...) +{ + va_list args; + va_start(args, fmt); + m_msg.FormatV(fmt, args); + va_end(args); + if (c_piStatusDisplay) + c_piStatusDisplay->ChangeStatus(m_msg); +} + + + diff --git a/Src/WaitStatusCursor.h b/Src/WaitStatusCursor.h new file mode 100644 index 000000000..b2537ae9f --- /dev/null +++ b/Src/WaitStatusCursor.h @@ -0,0 +1,50 @@ +#ifndef WaitStatusCursor_included_h +#define WaitStatusCursor_included_h + +class IStatusDisplay; + +// A WaitStatusCursor does what a CWaitCursor does, and also sets a status message. +// Clients create WaitStatusCursors instead of CWaitCursors, and are isolated from +// status message implementation. Whoever wants to implement the status messages +// should call SetStatusDisplay to begin (or end) doing so. +class WaitStatusCursor +{ + +// factor/class interface +public: + static void SetStatusDisplay(IStatusDisplay * piStatusDisplay); + +// public interface +public: + WaitStatusCursor(LPCTSTR fmt, ...); + void ChangeMsg(LPCTSTR fmt, ...); + void End(); + ~WaitStatusCursor(); + + +// implementation methods +protected: + +// implementation data +private: + CString m_msg; + CString m_oldmsg; + bool m_ended; + CWaitCursor m_wait; + +// factory/class data +private: + static IStatusDisplay * c_piStatusDisplay; +}; + + +// Something that implements status messages for WaitStatusCursors +class IStatusDisplay +{ +public: + virtual CString BeginStatus(LPCTSTR str) = 0; + virtual void ChangeStatus(LPCTSTR str) = 0; + virtual void EndStatus(LPCTSTR str, LPCTSTR oldstr) = 0; +}; + +#endif // WaitStatusCursor_included_h diff --git a/Src/readme.txt b/Src/readme.txt index 33c6d0172..20260a8cb 100644 --- a/Src/readme.txt +++ b/Src/readme.txt @@ -8,6 +8,8 @@ WinMerge: DirDoc.cpp DirView.cpp MainFrm.cpp MergeDoc.cpp MergeEditView.cpp resource.h StdAfx.cpp StdAfx.h PATCH: [ 724479 ] Fix Refresh crash in empty dir view WinMerge: DirDoc.cpp + bugfix: Add new files that were part of patch#724309 + WinMerge: WaitStatusCursor.cpp WaitStatusCursor.h 2003-04-19 Perry [ 724280 ] Could use wait cursors at OpenSelection calls -- 2.11.0